From 2fb02151cb82d85dedeeed9e0ccc93c8f4588f8d Mon Sep 17 00:00:00 2001 From: Andrii Braslavskyi Date: Wed, 21 Oct 2020 16:25:09 +0300 Subject: [PATCH] Update currencyService to accept bidRequest as parameter --- .../server/auction/ExchangeService.java | 18 +---- .../currency/CurrencyConversionService.java | 33 ++++++++- .../CurrencyConversionServiceTest.java | 70 ++++++++++++------- .../server/auction/ExchangeServiceTest.java | 38 +++++----- 4 files changed, 97 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index 40498876898..7b3426e4258 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -45,7 +45,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtBidderConfigFpd; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; -import org.prebid.server.proto.openrtb.ext.request.ExtRequestCurrency; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebidBidderConfig; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebidCache; @@ -189,18 +188,6 @@ private static ExtRequestTargeting targeting(BidRequest bidRequest) { return prebid != null ? prebid.getTargeting() : null; } - private static Map> currencyRates(BidRequest bidRequest) { - final ExtRequestPrebid prebid = extRequestPrebid(bidRequest); - final ExtRequestCurrency currency = prebid != null ? prebid.getCurrency() : null; - return currency != null ? currency.getRates() : null; - } - - private static Boolean usepbsrates(BidRequest bidRequest) { - final ExtRequestPrebid prebid = extRequestPrebid(bidRequest); - final ExtRequestCurrency currency = prebid != null ? prebid.getCurrency() : null; - return currency != null ? currency.getUsepbsrates() : null; - } - /** * Creates {@link BidRequestCacheInfo} based on {@link BidRequest} model. */ @@ -885,15 +872,14 @@ private BidderResponse applyBidPriceChanges(BidderResponse bidderResponse, BidRe final String adServerCurrency = bidRequest.getCur().get(0); final BigDecimal priceAdjustmentFactor = bidAdjustmentForBidder(bidRequest, bidderResponse.getBidder()); - final Boolean usepbsrates = usepbsrates(bidRequest); for (final BidderBid bidderBid : bidderBids) { final Bid bid = bidderBid.getBid(); final String bidCurrency = bidderBid.getBidCurrency(); final BigDecimal price = bid.getPrice(); try { - final BigDecimal priceInAdServerCurrency = currencyService.convertCurrency( - price, currencyRates(bidRequest), adServerCurrency, bidCurrency, usepbsrates); + final BigDecimal priceInAdServerCurrency = currencyService.convertCurrency(price, bidRequest, + adServerCurrency, bidCurrency); final BigDecimal adjustedPrice = adjustPrice(priceAdjustmentFactor, priceInAdServerCurrency); diff --git a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java index 34912e03d19..151b6d39d2c 100644 --- a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java +++ b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java @@ -1,5 +1,6 @@ package org.prebid.server.currency; +import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; import io.vertx.core.Vertx; import io.vertx.core.logging.Logger; @@ -10,6 +11,9 @@ import org.prebid.server.currency.proto.CurrencyConversionRates; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.request.ExtRequest; +import org.prebid.server.proto.openrtb.ext.request.ExtRequestCurrency; +import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.spring.config.model.ExternalConversionProperties; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; @@ -141,13 +145,23 @@ public Map> getExternalCurrencyRates() { return externalCurrencyRates; } + /** + * Converts price from fromCurrency to toCurrency using rates from {@link BidRequest} or external currency service. + * If bidrequest.prebid.currecy.usepbsrates is true it takes rates from prebid server, if false from request. + * Default value of usepbsrates is true. + * Throws {@link PreBidException} in case conversion is not possible. + */ + public BigDecimal convertCurrency(BigDecimal price, BidRequest bidRequest, String fromCurrency, String toCurrency) { + return convertCurrency(price, currencyRates(bidRequest), fromCurrency, toCurrency, usepbsrates(bidRequest)); + } + /** * Converts price from bidCurrency to adServerCurrency using rates and usepbsrates flag defined in request. * If usepbsrates is true it takes rates from prebid server, if false from request. Default value of usepbsrates * is true. * Throws {@link PreBidException} in case conversion is not possible. */ - public BigDecimal convertCurrency(BigDecimal price, Map> requestCurrencyRates, + private BigDecimal convertCurrency(BigDecimal price, Map> requestCurrencyRates, String adServerCurrency, String bidCurrency, Boolean usepbsrates) { // use Default USD currency if bidder left this field empty. After, when bidder will implement multi currency // support it will be changed to throwing PrebidException. @@ -178,6 +192,23 @@ public BigDecimal convertCurrency(BigDecimal price, Map> currencyRates(BidRequest bidRequest) { + final ExtRequestPrebid prebid = extRequestPrebid(bidRequest); + final ExtRequestCurrency currency = prebid != null ? prebid.getCurrency() : null; + return currency != null ? currency.getRates() : null; + } + + private static ExtRequestPrebid extRequestPrebid(BidRequest bidRequest) { + final ExtRequest requestExt = bidRequest.getExt(); + return requestExt != null ? requestExt.getPrebid() : null; + } + + private static Boolean usepbsrates(BidRequest bidRequest) { + final ExtRequestPrebid prebid = extRequestPrebid(bidRequest); + final ExtRequestCurrency currency = prebid != null ? prebid.getCurrency() : null; + return currency != null ? currency.getUsepbsrates() : null; + } + /** * Returns conversion rate from the given currency rates according to priority. */ diff --git a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java index 2fd4e688f21..b932370d47d 100644 --- a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java +++ b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java @@ -1,6 +1,7 @@ package org.prebid.server.auction; import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.Vertx; @@ -15,6 +16,9 @@ import org.prebid.server.currency.CurrencyConversionService; import org.prebid.server.currency.proto.CurrencyConversionRates; import org.prebid.server.exception.PreBidException; +import org.prebid.server.proto.openrtb.ext.request.ExtRequest; +import org.prebid.server.proto.openrtb.ext.request.ExtRequestCurrency; +import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.spring.config.model.ExternalConversionProperties; import org.prebid.server.vertx.http.HttpClient; import org.prebid.server.vertx.http.model.HttpClientResponse; @@ -85,7 +89,8 @@ public void convertCurrencyShouldReturnSamePriceIfBidAndServerCurrenciesEquals() final BigDecimal price = BigDecimal.valueOf(100); // when - final BigDecimal convertedPrice = currencyService.convertCurrency(price, null, USD, USD, false); + final BigDecimal convertedPrice = currencyService.convertCurrency(price, + givenBidRequestWithCurrencies(null, false), USD, USD); // then assertThat(convertedPrice).isSameAs(price); @@ -98,8 +103,8 @@ public void convertCurrencyShouldUseUSDByDefaultIfBidCurrencyIsNull() { singletonMap(GBP, singletonMap(USD, BigDecimal.valueOf(1.4306))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, GBP, null, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), GBP, null); // then assertThat(price.compareTo(BigDecimal.valueOf(0.699))).isEqualTo(0); @@ -112,8 +117,8 @@ public void convertCurrencyShouldReturnConvertedByStraightMultiplierPrice() { singletonMap(EUR, BigDecimal.valueOf(1.1565))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, GBP, EUR, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), GBP, EUR); // then assertThat(price.compareTo(BigDecimal.valueOf(0.865))).isEqualTo(0); @@ -126,8 +131,8 @@ public void convertCurrencyShouldReturnConvertedByInvertedMultiplierPrice() { BigDecimal.valueOf(1.1565))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, GBP, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, GBP); // then assertThat(price.compareTo(BigDecimal.valueOf(1.156))).isEqualTo(0); @@ -141,8 +146,8 @@ public void convertCurrencyShouldReturnConvertedByIntermediateMultiplierPrice() requestConversionRates.put(EUR, singletonMap(USD, BigDecimal.valueOf(1.2304))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, GBP, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, GBP); // then assertThat(price.compareTo(BigDecimal.valueOf(1.163))).isEqualTo(0); @@ -155,8 +160,8 @@ public void convertCurrencyShouldReturnConvertedBySingleDigitMultiplierPrice() { requestConversionRates.put(EUR, singletonMap(USD, BigDecimal.valueOf(0.5))); // when - final BigDecimal price = currencyService.convertCurrency(new BigDecimal("1.23"), requestConversionRates, EUR, - USD, false); + final BigDecimal price = currencyService.convertCurrency(new BigDecimal("1.23"), + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, USD); // then assertThat(price.compareTo(BigDecimal.valueOf(2.460))).isEqualTo(0); @@ -165,7 +170,8 @@ public void convertCurrencyShouldReturnConvertedBySingleDigitMultiplierPrice() { @Test public void convertCurrencyShouldUseLatestRatesIfRequestRatesIsNull() { // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, null, EUR, GBP, false); + final BigDecimal price = currencyService.convertCurrency( + BigDecimal.ONE, givenBidRequestWithCurrencies(null, false), EUR, GBP); // then assertThat(price.compareTo(BigDecimal.valueOf(1.149))).isEqualTo(0); @@ -178,8 +184,8 @@ public void convertCurrencyShouldUseConversionRateFromServerIfusepbsratesIsTrue( requestConversionRates.put(EUR, singletonMap(USD, BigDecimal.valueOf(0.6))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, GBP, - true); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, true), EUR, GBP); // then assertThat(price.compareTo(BigDecimal.valueOf(1.149))).isEqualTo(0); @@ -192,8 +198,8 @@ public void convertCurrencyShouldUseConversionRateFromRequestIfusepbsratesIsFals BigDecimal.valueOf(0.6))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, USD, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, USD); // then assertThat(price.compareTo(BigDecimal.valueOf(1.667))).isEqualTo(0); @@ -206,8 +212,8 @@ public void convertCurrencyShouldUseLatestRatesIfMultiplierWasNotFoundInRequestR singletonMap(EUR, BigDecimal.valueOf(0.8434))); // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, UAH, - false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, UAH); // then assertThat(price.compareTo(BigDecimal.valueOf(1.156))).isEqualTo(0); @@ -216,7 +222,8 @@ public void convertCurrencyShouldUseLatestRatesIfMultiplierWasNotFoundInRequestR @Test public void convertCurrencyShouldReturnSamePriceIfBidCurrencyIsNullAndServerCurrencyUSD() { // when - final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, emptyMap(), USD, null, false); + final BigDecimal price = currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(emptyMap(), false), USD, null); // then assertThat(price.compareTo(BigDecimal.ONE)).isEqualTo(0); @@ -229,8 +236,8 @@ public void convertCurrencyShouldFailWhenRequestRatesIsNullAndNoExternalRatesPro // when and then assertThatExceptionOfType(PreBidException.class) - .isThrownBy(() -> currencyConversionService.convertCurrency(BigDecimal.ONE, null, EUR, GBP, - false)) + .isThrownBy(() -> currencyConversionService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(null, false), EUR, GBP)) .withMessage("no currency conversion available"); } @@ -238,7 +245,8 @@ public void convertCurrencyShouldFailWhenRequestRatesIsNullAndNoExternalRatesPro public void convertCurrencyShouldThrowPrebidExceptionIfServerAndRequestRatesAreNull() { // when and then assertThatExceptionOfType(PreBidException.class) - .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, null, USD, EUR, false)) + .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(null, false), USD, EUR)) .withMessage("no currency conversion available"); } @@ -255,8 +263,8 @@ public void convertCurrencyShouldThrowPrebidExceptionIfMultiplierWasNotFoundFrom // then assertThatExceptionOfType(PreBidException.class) - .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, requestConversionRates, EUR, AUD, - false)) + .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(requestConversionRates, false), EUR, AUD)) .withMessage("no currency conversion available"); } @@ -270,7 +278,8 @@ public void convertCurrencyShouldThrowExceptionWhenCurrencyServerResponseStatusN // then assertThatExceptionOfType(PreBidException.class) - .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, null, UAH, AUD, false)) + .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(null, false), UAH, AUD)) .withMessage("no currency conversion available"); } @@ -284,7 +293,8 @@ public void convertCurrencyShouldThrowExceptionWhenCurrencyServerResponseContain // then assertThatExceptionOfType(PreBidException.class) - .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, null, UAH, AUD, false)) + .isThrownBy(() -> currencyService.convertCurrency(BigDecimal.ONE, + givenBidRequestWithCurrencies(null, false), UAH, AUD)) .withMessage("no currency conversion available"); } @@ -322,4 +332,12 @@ private static void givenHttpClientReturnsResponse(HttpClient httpClient, int st given(httpClient.get(anyString(), anyLong())) .willReturn(Future.succeededFuture(httpClientResponse)); } + + private BidRequest givenBidRequestWithCurrencies(Map> requestCurrencies, + Boolean usepbsrates) { + return BidRequest.builder() + .ext(ExtRequest.of(ExtRequestPrebid.builder() + .currency(ExtRequestCurrency.of(requestCurrencies, usepbsrates)).build())) + .build(); + } } diff --git a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java index 5f74dab3cef..2a371a21823 100644 --- a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java +++ b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java @@ -192,7 +192,7 @@ public void setUp() { given(responseBidValidator.validate(any())).willReturn(ValidationResult.success()); given(usersyncer.getCookieFamilyName()).willReturn("cookieFamily"); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())) + given(currencyService.convertCurrency(any(), any(), any(), any())) .willAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); given(storedResponseProcessor.getStoredResponseResult(any(), any(), any())) @@ -1798,7 +1798,7 @@ public void shouldReturnBidsWithUpdatedPriceCurrencyConversion() { identity()); final BigDecimal updatedPrice = BigDecimal.valueOf(5.0); - given(currencyService.convertCurrency(any(), any(), any(), any(), anyBoolean())).willReturn(updatedPrice); + given(currencyService.convertCurrency(any(), any(), any(), any())).willReturn(updatedPrice); givenBidResponseCreator(singletonList(Bid.builder().price(updatedPrice).build())); @@ -1822,7 +1822,7 @@ public void shouldReturnSameBidPriceIfNoChangesAppliedToBidPrice() { identity()); // returns the same price as in argument - given(currencyService.convertCurrency(any(), any(), any(), any(), anyBoolean())) + given(currencyService.convertCurrency(any(), any(), any(), any())) .willAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); // when @@ -1845,7 +1845,7 @@ public void shouldDropBidIfPrebidExceptionWasThrownDuringCurrencyConversion() { final BidRequest bidRequest = givenBidRequest(singletonList(givenImp(singletonMap("bidder", 2), identity())), identity()); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())) + given(currencyService.convertCurrency(any(), any(), any(), any())) .willThrow(new PreBidException("no currency conversion available")); // when @@ -1879,7 +1879,7 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndPriceAdjustmentFactor() .auctiontimestamp(1000L) .build()))); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())) + given(currencyService.convertCurrency(any(), any(), any(), any())) .willReturn(BigDecimal.valueOf(10)); // when @@ -1914,7 +1914,7 @@ public void shouldUpdatePriceForOneBidAndDropAnotherIfPrebidExceptionHappensForS identity()); final BigDecimal updatedPrice = BigDecimal.valueOf(10.0); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())).willReturn(updatedPrice) + given(currencyService.convertCurrency(any(), any(), any(), any())).willReturn(updatedPrice) .willThrow(new PreBidException("no currency conversion available")); // when @@ -1923,8 +1923,8 @@ public void shouldUpdatePriceForOneBidAndDropAnotherIfPrebidExceptionHappensForS // then final ArgumentCaptor> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(bidResponseCreator).create(argumentCaptor.capture(), any(), any(), anyBoolean()); - verify(currencyService).convertCurrency(eq(firstBidderPrice), eq(null), any(), eq("CUR1"), eq(null)); - verify(currencyService).convertCurrency(eq(secondBidderPrice), eq(null), any(), eq("CUR2"), eq(null)); + verify(currencyService).convertCurrency(eq(firstBidderPrice), eq(bidRequest), any(), eq("CUR1")); + verify(currencyService).convertCurrency(eq(secondBidderPrice), eq(bidRequest), any(), eq("CUR2")); assertThat(argumentCaptor.getValue()).hasSize(1); @@ -1954,8 +1954,8 @@ public void shouldRespondWithOneBidAndErrorWhenBidResponseContainsOneUnsupported identity()))).build(); final BigDecimal updatedPrice = BigDecimal.valueOf(20); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())).willReturn(updatedPrice); - given(currencyService.convertCurrency(any(), any(), eq("BAD"), eq("CUR"), any())) + given(currencyService.convertCurrency(any(), any(), any(), any())).willReturn(updatedPrice); + given(currencyService.convertCurrency(any(), any(), eq("BAD"), eq("CUR"))) .willThrow(new PreBidException("no currency conversion available")); // when @@ -1964,8 +1964,8 @@ public void shouldRespondWithOneBidAndErrorWhenBidResponseContainsOneUnsupported // then final ArgumentCaptor> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(bidResponseCreator).create(argumentCaptor.capture(), any(), any(), anyBoolean()); - verify(currencyService).convertCurrency(eq(firstBidderPrice), eq(null), eq("BAD"), eq("USD"), eq(null)); - verify(currencyService).convertCurrency(eq(secondBidderPrice), eq(null), eq("BAD"), eq("CUR"), eq(null)); + verify(currencyService).convertCurrency(eq(firstBidderPrice), eq(bidRequest), eq("BAD"), eq("USD")); + verify(currencyService).convertCurrency(eq(secondBidderPrice), eq(bidRequest), eq("BAD"), eq("CUR")); assertThat(argumentCaptor.getValue()).hasSize(2); @@ -1997,7 +1997,7 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndAddErrorAboutMultipleCu builder -> builder.cur(asList("CUR1", "CUR2", "CUR2"))); final BigDecimal updatedPrice = BigDecimal.valueOf(10.0); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())).willReturn(updatedPrice); + given(currencyService.convertCurrency(any(), any(), any(), any())).willReturn(updatedPrice); // when exchangeService.holdAuction(givenRequestContext(bidRequest)).result(); @@ -2005,7 +2005,7 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndAddErrorAboutMultipleCu // then final ArgumentCaptor> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(bidResponseCreator).create(argumentCaptor.capture(), any(), any(), anyBoolean()); - verify(currencyService).convertCurrency(eq(bidderPrice), eq(null), eq("CUR1"), eq("USD"), eq(null)); + verify(currencyService).convertCurrency(eq(bidderPrice), eq(bidRequest), eq("CUR1"), eq("USD")); assertThat(argumentCaptor.getValue()).hasSize(1); @@ -2041,8 +2041,8 @@ public void shouldUpdateBidPriceWithCurrencyConversionForMultipleBid() { singletonList(givenImp(impBidders, identity())), builder -> builder.cur(singletonList("USD"))); final BigDecimal updatedPrice = BigDecimal.valueOf(10.0); - given(currencyService.convertCurrency(any(), any(), any(), any(), any())).willReturn(updatedPrice); - given(currencyService.convertCurrency(any(), any(), any(), eq("USD"), any())).willReturn(bidder3Price); + given(currencyService.convertCurrency(any(), any(), any(), any())).willReturn(updatedPrice); + given(currencyService.convertCurrency(any(), any(), any(), eq("USD"))).willReturn(bidder3Price); // when exchangeService.holdAuction(givenRequestContext(bidRequest)).result(); @@ -2050,9 +2050,9 @@ public void shouldUpdateBidPriceWithCurrencyConversionForMultipleBid() { // then final ArgumentCaptor> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(bidResponseCreator).create(argumentCaptor.capture(), any(), any(), anyBoolean()); - verify(currencyService).convertCurrency(eq(bidder1Price), eq(null), eq("USD"), eq("EUR"), eq(null)); - verify(currencyService).convertCurrency(eq(bidder2Price), eq(null), eq("USD"), eq("GBP"), eq(null)); - verify(currencyService).convertCurrency(eq(bidder3Price), eq(null), eq("USD"), eq("USD"), eq(null)); + verify(currencyService).convertCurrency(eq(bidder1Price), eq(bidRequest), eq("USD"), eq("EUR")); + verify(currencyService).convertCurrency(eq(bidder2Price), eq(bidRequest), eq("USD"), eq("GBP")); + verify(currencyService).convertCurrency(eq(bidder3Price), eq(bidRequest), eq("USD"), eq("USD")); verifyNoMoreInteractions(currencyService); assertThat(argumentCaptor.getValue())