Skip to content

Commit

Permalink
Displayio: Bidfloor Validation Update (#3516)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoxaAntoxic authored Oct 28, 2024
1 parent 7269ba8 commit 508180f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,8 @@ private BigDecimal resolveBidFloor(BidRequest bidRequest, Imp imp) {
final BigDecimal bidFloor = imp.getBidfloor();
final String bidFloorCurrency = imp.getBidfloorcur();

if (!BidderUtil.isValidPrice(bidFloor)) {
throw new PreBidException("BidFloor should be defined");
}

if (StringUtils.isNotBlank(bidFloorCurrency)
if (BidderUtil.isValidPrice(bidFloor)
&& StringUtils.isNotBlank(bidFloorCurrency)
&& !StringUtils.equalsIgnoreCase(bidFloorCurrency, BIDDER_CURRENCY)) {
return currencyConversionService.convertCurrency(bidFloor, bidRequest, bidFloorCurrency, BIDDER_CURRENCY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,22 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() {
}

@Test
public void makeHttpRequestsShouldReturnErrorWhenBidFloorIsMissing() {
public void makeHttpRequestsShouldSetDefaultCurrencyEvenWhenBidfloorIsAbsent() {
// given
final BidRequest bidRequest = givenBidRequest(imp -> imp.bidfloor(null));
final BidRequest bidRequest = givenBidRequest(imp -> imp.bidfloor(null).bidfloorcur("EUR"));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getValue()).isEmpty();
assertThat(result.getErrors()).containsOnly(BidderError.badInput("BidFloor should be defined"));
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getBidfloor, Imp::getBidfloorcur)
.containsOnly(tuple(null, "USD"));

verifyNoInteractions(currencyConversionService);
}

@Test
Expand Down Expand Up @@ -156,8 +162,7 @@ public void shouldMakeOneRequestWhenOneImpIsValidAndAnotherAreInvalid() {
// given
final BidRequest bidRequest = givenBidRequest(
imp -> imp.id("impId1").ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode()))),
imp -> imp.id("impId2").bidfloor(null),
imp -> imp.id("impId3"));
imp -> imp.id("impId2"));

//when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -167,7 +172,7 @@ public void shouldMakeOneRequestWhenOneImpIsValidAndAnotherAreInvalid() {
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getId)
.containsExactly("impId3");
.containsExactly("impId2");
}

@Test
Expand Down

0 comments on commit 508180f

Please sign in to comment.