Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displayio Bidder: Bidfloor Validation Update #3516

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading