diff --git a/src/main/java/org/prebid/server/auction/BidsAdjuster.java b/src/main/java/org/prebid/server/auction/BidsAdjuster.java index ec6b1c9d2f3..8134662fcd9 100644 --- a/src/main/java/org/prebid/server/auction/BidsAdjuster.java +++ b/src/main/java/org/prebid/server/auction/BidsAdjuster.java @@ -95,8 +95,9 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar final List requestCurrencies = bidRequest.getCur(); if (requestCurrencies.size() > 1) { - errors.add(BidderError.badInput("Cur parameter contains more than one currency. %s will be used" - .formatted(requestCurrencies.getFirst()))); + warnings.add(BidderError.badInput( + "a single currency (" + requestCurrencies.getFirst() + ") has been chosen for the request. " + + "ORTB 2.6 requires that all responses are in the same currency.")); } final List bids = seatBid.getBids(); @@ -118,9 +119,7 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar } } - final BidderResponse resultBidderResponse = errors.size() == seatBid.getErrors().size() - ? bidderResponse - : bidderResponse.with( + final BidderResponse resultBidderResponse = bidderResponse.with( seatBid.toBuilder() .bids(validBids) .errors(errors) diff --git a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy index 568f202be55..df5bba70028 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy @@ -14,6 +14,7 @@ import static org.prebid.server.functional.model.Currency.CHF import static org.prebid.server.functional.model.Currency.EUR import static org.prebid.server.functional.model.Currency.JPY import static org.prebid.server.functional.model.Currency.USD +import static org.prebid.server.functional.model.response.auction.ErrorType.GENERIC import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer class CurrencySpec extends BaseSpec { @@ -146,6 +147,49 @@ class CurrencySpec extends BaseSpec { CHF || EUR } + def "PBS should emit warning when request contain more that one currency"() { + given: "Default BidRequest with currencies" + def currencies = [EUR, USD] + def bidRequest = BidRequest.defaultBidRequest.tap { + cur = currencies + } + + when: "PBS processes auction request" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Bid response should contain first requested currency" + assert bidResponse.cur == currencies[0] + + and: "Bidder request should contain requested currencies" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.cur == currencies + + and: "Bid response should contain warnings" + assert bidResponse.ext.warnings[GENERIC]?.message == ["a single currency (${currencies[0]}) has been chosen for the request. " + + "ORTB 2.6 requires that all responses are in the same currency." as String] + } + + def "PBS shouldn't emit warning when request contain one currency"() { + given: "Default BidRequest with currency" + def currency = [USD] + def bidRequest = BidRequest.defaultBidRequest.tap { + cur = currency + } + + when: "PBS processes auction request" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Bid response should contain first requested currency" + assert bidResponse.cur == currency[0] + + and: "Bidder request should contain requested currency" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.cur == currency + + and: "Bid response shouldn't contain warnings" + assert !bidResponse.ext.warnings + } + private static Map getExternalCurrencyConverterConfig() { ["auction.ad-server-currency" : DEFAULT_CURRENCY as String, "currency-converter.external-rates.enabled" : "true", diff --git a/src/test/java/org/prebid/server/auction/BidsAdjusterTest.java b/src/test/java/org/prebid/server/auction/BidsAdjusterTest.java index 2691b629544..8b7dd0589b0 100644 --- a/src/test/java/org/prebid/server/auction/BidsAdjusterTest.java +++ b/src/test/java/org/prebid/server/auction/BidsAdjusterTest.java @@ -332,7 +332,7 @@ public void shouldRespondWithOneBidAndErrorWhenBidResponseContainsOneUnsupported } @Test - public void shouldUpdateBidPriceWithCurrencyConversionAndAddErrorAboutMultipleCurrency() { + public void shouldUpdateBidPriceWithCurrencyConversionAndAddWarningAboutMultipleCurrency() { // given final BigDecimal bidderPrice = BigDecimal.valueOf(2.0); final BidderResponse bidderResponse = BidderResponse.of( @@ -363,14 +363,16 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndAddErrorAboutMultipleCu assertThat(result).hasSize(1); - final BidderError expectedError = BidderError.badInput("Cur parameter contains more than one currency." - + " CUR1 will be used"); final BidderSeatBid firstSeatBid = result.getFirst().getBidderResponse().getSeatBid(); assertThat(firstSeatBid.getBids()) .extracting(BidderBid::getBid) .flatExtracting(Bid::getPrice) .containsOnly(updatedPrice); - assertThat(firstSeatBid.getErrors()).containsOnly(expectedError); + + final BidderError expectedWarning = BidderError.badInput( + "a single currency (CUR1) has been chosen for the request. " + + "ORTB 2.6 requires that all responses are in the same currency."); + assertThat(firstSeatBid.getWarnings()).containsOnly(expectedWarning); } @Test