From 9c1f894097cb63edc60c2d80e401c97bd45a2253 Mon Sep 17 00:00:00 2001 From: nickluck8 Date: Fri, 11 Jun 2021 12:25:39 +0300 Subject: [PATCH 1/4] fix bid floor in between bidder --- .../server/bidder/between/BetweenBidder.java | 18 ++++-------------- .../bidder/between/BetweenBidderTest.java | 11 +++++------ .../between/test-auction-between-request.json | 4 +--- .../between/test-between-bid-request.json | 6 +----- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java index 0d1370e37e9..d452f31c145 100644 --- a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java +++ b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java @@ -27,7 +27,6 @@ import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.util.HttpUtil; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -44,7 +43,6 @@ public class BetweenBidder implements Bidder { new TypeReference>() { }; private static final String URL_HOST_MACRO = "{{Host}}"; - private static final BigDecimal DEFAULT_BID_FLOOR = BigDecimal.valueOf(0.00001); private final String endpointUrl; private final JacksonMapper mapper; @@ -64,7 +62,10 @@ public Result>> makeHttpRequests(BidRequest request try { validateImp(imp); extImpBetween = parseImpExt(imp); - modifiedImps.add(modifyImp(imp, secure, extImpBetween.getBidFloor(), extImpBetween.getBidFloorCur())); + modifiedImps.add(imp.toBuilder() + .banner(resolveBanner(imp.getBanner())) + .secure(secure) + .build()); } catch (PreBidException e) { errors.add(BidderError.badInput(e.getMessage())); } @@ -110,17 +111,6 @@ private ExtImpBetween parseImpExt(Imp imp) { return extImpBetween; } - private static Imp modifyImp(Imp imp, Integer secure, BigDecimal bidFloor, String bidFloorCur) { - final Banner resolvedBanner = resolveBanner(imp.getBanner()); - - return imp.toBuilder() - .banner(resolvedBanner) - .secure(secure) - .bidfloor(bidFloor == null || bidFloor.compareTo(BigDecimal.ZERO) <= 0 ? DEFAULT_BID_FLOOR : bidFloor) - .bidfloorcur(StringUtils.isNotBlank(bidFloorCur) ? bidFloorCur : imp.getBidfloorcur()) - .build(); - } - private static Banner resolveBanner(Banner banner) { if (banner.getW() == null && banner.getH() == null) { final List bannerFormat = banner.getFormat(); diff --git a/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java b/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java index 79f517acf5d..b37b5d4c7ca 100644 --- a/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java @@ -197,7 +197,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { } @Test - public void makeHttpRequestsShouldEnrichEveryImpWithSecureBidFlorAndBidFloorCurParams() { + public void makeHttpRequestsShouldEnrichEveryImpWithSecureBidFlor() { // given final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> bidRequestBuilder .site(Site.builder().page("https://page.com").build()), @@ -213,8 +213,8 @@ public void makeHttpRequestsShouldEnrichEveryImpWithSecureBidFlorAndBidFloorCurP assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) .flatExtracting(BidRequest::getImp) - .extracting(Imp::getSecure, Imp::getBidfloor, Imp::getBidfloorcur) - .containsExactly(tuple(1, BigDecimal.ONE, "EUR")); + .extracting(Imp::getSecure) + .containsExactly(1); } @Test @@ -225,7 +225,6 @@ public void makeHttpRequestsShouldSetDefaultParamsIfAnotherNotPresent() { impBuilder -> impBuilder .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("127.0.0.1", "pubId", BigDecimal.valueOf(-1), "")))) - .bidfloor(BigDecimal.valueOf(12)) .bidfloorcur("USD")); // when @@ -236,8 +235,8 @@ public void makeHttpRequestsShouldSetDefaultParamsIfAnotherNotPresent() { assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) .flatExtracting(BidRequest::getImp) - .extracting(Imp::getSecure, Imp::getBidfloor, Imp::getBidfloorcur) - .containsExactly(tuple(0, BigDecimal.valueOf(0.00001), "USD")); + .extracting(Imp::getSecure, Imp::getBidfloorcur) + .containsExactly(tuple(0, "USD")); } @Test diff --git a/src/test/resources/org/prebid/server/it/openrtb2/between/test-auction-between-request.json b/src/test/resources/org/prebid/server/it/openrtb2/between/test-auction-between-request.json index ead08d19038..92fbd7e5fba 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/between/test-auction-between-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/between/test-auction-between-request.json @@ -14,9 +14,7 @@ "ext": { "between": { "host": "lbs-ru1.ads", - "publisher_id": "publisherTestID", - "bid_floor": 12.2345, - "bid_floor_cur": "RUB" + "publisher_id": "publisherTestID" } } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/between/test-between-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/between/test-between-bid-request.json index e642c53db3c..27bec32f5d7 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/between/test-between-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/between/test-between-bid-request.json @@ -8,15 +8,11 @@ "w": 300, "h": 250 }, - "bidfloor": 12.2345, - "bidfloorcur": "RUB", "secure": 0, "ext": { "bidder": { "host": "lbs-ru1.ads", - "publisher_id": "publisherTestID", - "bid_floor": 12.2345, - "bid_floor_cur": "RUB" + "publisher_id": "publisherTestID" } } } From 5b4a4ec2d0a5193e0922290eea0039395e3615da Mon Sep 17 00:00:00 2001 From: nickluck8 Date: Fri, 11 Jun 2021 12:34:33 +0300 Subject: [PATCH 2/4] fix bid floor in between bidder --- .../ext/request/between/ExtImpBetween.java | 6 ----- .../bidder/between/BetweenBidderTest.java | 26 ++++++++----------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/between/ExtImpBetween.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/between/ExtImpBetween.java index 8b70201e053..f951e810006 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/between/ExtImpBetween.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/between/ExtImpBetween.java @@ -3,8 +3,6 @@ import lombok.AllArgsConstructor; import lombok.Value; -import java.math.BigDecimal; - @AllArgsConstructor(staticName = "of") @Value public class ExtImpBetween { @@ -12,8 +10,4 @@ public class ExtImpBetween { String host; String publisherId; - - BigDecimal bidFloor; - - String bidFloorCur; } diff --git a/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java b/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java index b37b5d4c7ca..05edb5cff93 100644 --- a/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/between/BetweenBidderTest.java @@ -26,7 +26,6 @@ import org.prebid.server.proto.openrtb.ext.request.between.ExtImpBetween; import org.prebid.server.util.HttpUtil; -import java.math.BigDecimal; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -59,11 +58,11 @@ public void creationShouldFailOnInvalidEndpointUrl() { public void makeHttpRequestsShouldReturnErrorIfImpExtContainEmptyOrNullHostParam() { // given final Imp firstImp = givenImp(impBuilder -> impBuilder - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("", "pubId", null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("", "pubId"))))); final Imp secondImp = givenImp(impBuilder -> impBuilder .id("456") - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of(null, "pubId", null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of(null, "pubId"))))); final BidRequest bidRequest = BidRequest.builder() .imp(Arrays.asList(firstImp, secondImp)) @@ -86,11 +85,11 @@ public void makeHttpRequestsShouldReturnErrorIfBannerNotPresentOrSizesNotExists( // given final Imp firstImp = givenImp(impBuilder -> impBuilder .banner(null) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", "pubId", null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", "pubId"))))); final Imp secondImp = givenImp(impBuilder -> impBuilder .banner(Banner.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", "pubId", null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", "pubId"))))); final BidRequest bidRequest = BidRequest.builder() .imp(Arrays.asList(firstImp, secondImp)) @@ -111,7 +110,7 @@ public void makeHttpRequestsShouldCorrectlyAddHeaders() { // given final Imp firstImp = givenImp(impBuilder -> impBuilder .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpBetween.of("host", "pubId", null, null))))); + ExtImpBetween.of("host", "pubId"))))); final BidRequest bidRequest = BidRequest.builder() .device(Device.builder().ua("someUa").dnt(5).ip("someIp").language("someLanguage").build()) @@ -140,11 +139,11 @@ public void makeHttpRequestsShouldCorrectlyAddHeaders() { public void makeHttpRequestsShouldReturnErrorIfImpExtContainEmptyOrNullPublisherIdParam() { // given final Imp firstImp = givenImp(impBuilder -> impBuilder - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", "", null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", ""))))); final Imp secondImp = givenImp(impBuilder -> impBuilder .id("456") - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", null, null, null))))); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("host", null))))); final BidRequest bidRequest = BidRequest.builder() .imp(Arrays.asList(firstImp, secondImp)) @@ -223,9 +222,7 @@ public void makeHttpRequestsShouldSetDefaultParamsIfAnotherNotPresent() { final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> bidRequestBuilder .site(Site.builder().page("http://page.com").build()), impBuilder -> impBuilder - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("127.0.0.1", "pubId", - BigDecimal.valueOf(-1), "")))) - .bidfloorcur("USD")); + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("127.0.0.1", "pubId"))))); // when final Result>> result = betweenBidder.makeHttpRequests(bidRequest); @@ -235,8 +232,8 @@ public void makeHttpRequestsShouldSetDefaultParamsIfAnotherNotPresent() { assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) .flatExtracting(BidRequest::getImp) - .extracting(Imp::getSecure, Imp::getBidfloorcur) - .containsExactly(tuple(0, "USD")); + .extracting(Imp::getSecure) + .containsExactly(0); } @Test @@ -356,8 +353,7 @@ private static Imp givenImp(Function impCustomiz return impCustomizer.apply(Imp.builder() .id("123") .banner(Banner.builder().w(23).h(25).build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("127.0.0.1", "pubId", - BigDecimal.ONE, "EUR"))))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpBetween.of("127.0.0.1", "pubId"))))) .build(); } From 4097d692fc500f0e86669926d48124e3c8d7bb90 Mon Sep 17 00:00:00 2001 From: nickluck8 Date: Fri, 11 Jun 2021 15:04:39 +0300 Subject: [PATCH 3/4] fix comments --- .../server/bidder/between/BetweenBidder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java index d452f31c145..41535e7f44d 100644 --- a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java +++ b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java @@ -62,10 +62,7 @@ public Result>> makeHttpRequests(BidRequest request try { validateImp(imp); extImpBetween = parseImpExt(imp); - modifiedImps.add(imp.toBuilder() - .banner(resolveBanner(imp.getBanner())) - .secure(secure) - .build()); + modifiedImps.add(modifyImp(imp, secure)); } catch (PreBidException e) { errors.add(BidderError.badInput(e.getMessage())); } @@ -111,6 +108,15 @@ private ExtImpBetween parseImpExt(Imp imp) { return extImpBetween; } + private static Imp modifyImp(Imp imp, Integer secure) { + final Banner resolvedBanner = resolveBanner(imp.getBanner()); + + return imp.toBuilder() + .banner(resolvedBanner) + .secure(secure) + .build(); + } + private static Banner resolveBanner(Banner banner) { if (banner.getW() == null && banner.getH() == null) { final List bannerFormat = banner.getFormat(); From 6c1edd614ffd85d4d49f58fe9d600cadfdf4330f Mon Sep 17 00:00:00 2001 From: nickluck8 Date: Fri, 11 Jun 2021 15:37:03 +0300 Subject: [PATCH 4/4] fix comments --- src/main/resources/static/bidder-params/between.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/resources/static/bidder-params/between.json b/src/main/resources/static/bidder-params/between.json index 032d38fec4b..64863462697 100644 --- a/src/main/resources/static/bidder-params/between.json +++ b/src/main/resources/static/bidder-params/between.json @@ -12,15 +12,6 @@ "publisher_id": { "type": "string", "description": "Publisher ID from Between Exchange control panel" - }, - "bid_floor": { - "type": "number", - "description": "The minimum price acceptable for a bid" - }, - "bid_floor_cur": { - "type": "string", - "description": "Currency of bid floor", - "enum": ["USD", "EUR", "RUB"] } }, "required": ["host", "publisher_id"]