From e8b2400a0f55dd8c8a6f2ec8a4d04da63ab58dbc Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko Date: Wed, 3 Apr 2024 11:17:21 -0400 Subject: [PATCH 01/58] Revert "Revert "Iqzone: Add mType support (#3044)" (#3089)" (#3090) This reverts commit a46a54c716a418697cde7bfcb7dafa28bf68122b. --- .../server/bidder/iqzone/IqzoneBidder.java | 69 ++++++++++--------- .../bidder/iqzone/IqzoneBidderTest.java | 54 +++++++++------ .../iqzone/test-auction-iqzone-response.json | 1 + .../iqzone/test-iqzone-bid-response.json | 1 + 4 files changed, 72 insertions(+), 53 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/iqzone/IqzoneBidder.java b/src/main/java/org/prebid/server/bidder/iqzone/IqzoneBidder.java index 7785cd476b8..c6f473bc52a 100644 --- a/src/main/java/org/prebid/server/bidder/iqzone/IqzoneBidder.java +++ b/src/main/java/org/prebid/server/bidder/iqzone/IqzoneBidder.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.node.TextNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; import org.apache.commons.collections4.CollectionUtils; @@ -49,32 +50,43 @@ public Result>> makeHttpRequests(BidRequest request final List> httpRequests = new ArrayList<>(); for (Imp imp : request.getImp()) { + final ExtImpIqzone extImpIqzone; try { - final ExtImpIqzone extImpIqzone = parseImpExt(imp); - final Imp modifiedImp = modifyImp(imp, extImpIqzone); - - httpRequests.add(makeHttpRequest(request, modifiedImp)); + extImpIqzone = parseImpExt(imp); } catch (IllegalArgumentException e) { return Result.withError(BidderError.badInput(e.getMessage())); } + + final Imp modifiedImp = modifyImp(imp, extImpIqzone); + httpRequests.add(makeHttpRequest(request, modifiedImp)); } return Result.withValues(httpRequests); } private ExtImpIqzone parseImpExt(Imp imp) { - return mapper.mapper().convertValue(imp.getExt(), IQZONE_EXT_TYPE_REFERENCE).getBidder(); + try { + return mapper.mapper().convertValue(imp.getExt(), IQZONE_EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException(e.getMessage()); + } } private Imp modifyImp(Imp imp, ExtImpIqzone impExt) { final String placementId = impExt.getPlacementId(); - final ObjectNode modifiedImpExtBidder = mapper.mapper().createObjectNode(); + final String endpointId = impExt.getEndpointId(); + + final boolean isPlacementIdEmpty = StringUtils.isEmpty(placementId); + if (isPlacementIdEmpty && StringUtils.isEmpty(endpointId)) { + return imp; + } - if (StringUtils.isNotEmpty(placementId)) { + final ObjectNode modifiedImpExtBidder = mapper.mapper().createObjectNode(); + if (!isPlacementIdEmpty) { modifiedImpExtBidder.set("placementId", TextNode.valueOf(placementId)); modifiedImpExtBidder.set("type", TextNode.valueOf("publisher")); } else { - modifiedImpExtBidder.set("endpointId", TextNode.valueOf(impExt.getEndpointId())); + modifiedImpExtBidder.set("endpointId", TextNode.valueOf(endpointId)); modifiedImpExtBidder.set("type", TextNode.valueOf("network")); } @@ -84,8 +96,7 @@ private Imp modifyImp(Imp imp, ExtImpIqzone impExt) { } private HttpRequest makeHttpRequest(BidRequest request, Imp imp) { - final BidRequest outgoingRequest = request.toBuilder().imp(List.of(imp)).build(); - + final BidRequest outgoingRequest = request.toBuilder().imp(Collections.singletonList(imp)).build(); return BidderUtil.defaultRequest(outgoingRequest, endpointUrl, mapper); } @@ -93,45 +104,39 @@ private HttpRequest makeHttpRequest(BidRequest request, Imp imp) { public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.of(extractBids(httpCall.getRequest().getPayload(), bidResponse), Collections.emptyList()); + return Result.withValues(extractBids(bidResponse)); } catch (DecodeException | PreBidException e) { return Result.withError(BidderError.badServerResponse(e.getMessage())); } } - private List extractBids(BidRequest bidRequest, BidResponse bidResponse) { + private List extractBids(BidResponse bidResponse) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); } - return bidsFromResponse(bidRequest, bidResponse); - } - - private List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) .filter(Objects::nonNull) .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), bidRequest.getImp()), bidResponse.getCur())) + .filter(Objects::nonNull) + .map(bid -> BidderBid.of(bid, getBidMediaType(bid), bidResponse.getCur())) .toList(); } - private static BidType getBidType(String impId, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(impId)) { - if (imp.getBanner() != null) { - return BidType.banner; - } - if (imp.getVideo() != null) { - return BidType.video; - } - if (imp.getXNative() != null) { - return BidType.xNative; - } - throw new PreBidException("Unknown impression type for ID: \"%s\"".formatted(impId)); - } + private static BidType getBidMediaType(Bid bid) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + throw new PreBidException("Missing MType for bid: " + bid.getId()); } - throw new PreBidException("Failed to find impression for ID: \"%s\"".formatted(impId)); + + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 4 -> BidType.xNative; + default -> throw new PreBidException( + "Unable to fetch mediaType " + bid.getMtype() + " in multi-format: " + bid.getImpid()); + }; } } diff --git a/src/test/java/org/prebid/server/bidder/iqzone/IqzoneBidderTest.java b/src/test/java/org/prebid/server/bidder/iqzone/IqzoneBidderTest.java index 94e31912408..5cb1f7f43fa 100644 --- a/src/test/java/org/prebid/server/bidder/iqzone/IqzoneBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/iqzone/IqzoneBidderTest.java @@ -3,11 +3,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; @@ -116,6 +113,26 @@ public void makeHttpRequestsShouldModifyImpExtWithEndpointIdAndTypeIfEndpointIdP .set("bidder", mapper.valueToTree(expectedImpExtBidder))); } + @Test + public void makeHttpRequestsShouldNotModifyImpExt() { + // given + final BidRequest bidRequest = givenBidRequest(impBuilder -> + impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpIqzone.of(null, null))))); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .extracting(HttpRequest::getPayload) + .flatExtracting(BidRequest::getImp) + .extracting(Imp::getExt) + .extracting(ext -> ext.get("bidder")) + .map(JsonNode::isEmpty) + .containsExactly(true); + } + @Test public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // given @@ -163,9 +180,8 @@ public void makeBidsShouldReturnEmptyResponseIfBidResponseSeatBidIsNull() throws @Test public void makeBidsShouldCorrectlyProceedWithVideo() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(givenBidRequest(impBuilder -> impBuilder - .id("someId").video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("someId")))); + final BidderCall httpCall = givenHttpCall(givenBidRequest(), + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(2)))); // when final Result> result = target.makeBids(httpCall, null); @@ -179,9 +195,8 @@ public void makeBidsShouldCorrectlyProceedWithVideo() throws JsonProcessingExcep @Test public void makeBidsShouldCorrectlyProceedWithNative() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(givenBidRequest(impBuilder -> impBuilder - .id("someId").xNative(Native.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("someId")))); + final BidderCall httpCall = givenHttpCall(givenBidRequest(), + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(4)))); // when final Result> result = target.makeBids(httpCall, null); @@ -195,9 +210,8 @@ public void makeBidsShouldCorrectlyProceedWithNative() throws JsonProcessingExce @Test public void makeBidsShouldCorrectlyProceedWithBanner() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(givenBidRequest(impBuilder -> impBuilder - .id("someId").banner(Banner.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("someId")))); + final BidderCall httpCall = givenHttpCall(givenBidRequest(), + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(1)))); // when final Result> result = target.makeBids(httpCall, null); @@ -211,9 +225,8 @@ public void makeBidsShouldCorrectlyProceedWithBanner() throws JsonProcessingExce @Test public void makeBidsShouldReturnErrorIfImpIdDoesNotMatchImpIdInBid() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall(givenBidRequest(impBuilder -> impBuilder - .id("someIdThatIsDifferentFromIDInBid").xNative(Native.builder().build())), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("someId")))); + final BidderCall httpCall = givenHttpCall(givenBidRequest(identity()), + mapper.writeValueAsString(givenBidResponse(identity()))); // when final Result> result = target.makeBids(httpCall, null); @@ -222,17 +235,16 @@ public void makeBidsShouldReturnErrorIfImpIdDoesNotMatchImpIdInBid() throws Json assertThat(result.getErrors()).hasSize(1) .allSatisfy(error -> { assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(error.getMessage()).startsWith("Failed to find impression for ID:"); + assertThat(error.getMessage()).startsWith("Missing MType for bid: null"); }); assertThat(result.getValue()).isEmpty(); } @Test - public void makeBidsShouldReturnErrorWhenMissingType() throws JsonProcessingException { + public void makeBidsShouldReturnErrorWhenMissingMType() throws JsonProcessingException { // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.id("someId")), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("someId")))); + final BidderCall httpCall = givenHttpCall(givenBidRequest(), + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.mtype(null)))); // when final Result> result = target.makeBids(httpCall, null); @@ -241,7 +253,7 @@ public void makeBidsShouldReturnErrorWhenMissingType() throws JsonProcessingExce assertThat(result.getErrors()).hasSize(1) .allSatisfy(error -> { assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(error.getMessage()).startsWith("Unknown impression type for ID"); + assertThat(error.getMessage()).startsWith("Missing MType for bid: null"); }); } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-auction-iqzone-response.json b/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-auction-iqzone-response.json index ec5eadf42d0..4a6e48aac57 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-auction-iqzone-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-auction-iqzone-response.json @@ -8,6 +8,7 @@ "impid": "imp_id", "price": 3.33, "adm": "adm001", + "mtype": 1, "adid": "adid001", "cid": "cid001", "crid": "crid001", diff --git a/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-iqzone-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-iqzone-bid-response.json index 31a6f4419e3..26af1edc5a3 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-iqzone-bid-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/iqzone/test-iqzone-bid-response.json @@ -7,6 +7,7 @@ "id": "bid_id", "impid": "imp_id", "price": 3.33, + "mtype": 1, "adid": "adid001", "crid": "crid001", "cid": "cid001", From 4cc7cefd28718b7de4dab1ce15059b2fdf338942 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko Date: Thu, 4 Apr 2024 09:58:23 -0400 Subject: [PATCH 02/58] Core: Stop removing AuctionRequest.video.plcmt during OpenRTB downgrade (#3092) * Stop removing AuctionRequest.video.plcmt during OpenRTB downgrade * Add functional tests * Fix remark --- .../down/BidRequestOrtb26To25Converter.java | 4 +--- .../functional/tests/OrtbConverterSpec.groovy | 14 +++++++++----- .../down/BidRequestOrtb26To25ConverterTest.java | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java index e0198ac0d20..3a968fc8192 100644 --- a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java +++ b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java @@ -155,8 +155,7 @@ private static Video modifyVideo(Video video) { video.getPodseq(), video.getRqddurs(), video.getSlotinpod(), - video.getMincpmpersec(), - video.getPlcmt()) + video.getMincpmpersec()) ? video.toBuilder() .maxseq(null) @@ -166,7 +165,6 @@ private static Video modifyVideo(Video video) { .rqddurs(null) .slotinpod(null) .mincpmpersec(null) - .plcmt(null) .build() : null; diff --git a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy index cc6832c479d..b22ef5438c6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy @@ -586,8 +586,9 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should remove imp[0].video.* when we don't support ortb 2.6"() { + def "PBS should remove imp[0].video.* and keep imp[0].video.plcmt when we don't support ortb 2.6"() { given: "Default bid request with imp[0].video.*" + def placement = PBSUtils.getRandomEnum(VideoPlcmtSubtype) def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].video = Video.defaultVideo.tap { rqddurs = [PBSUtils.randomNumber] @@ -597,15 +598,16 @@ class OrtbConverterSpec extends BaseSpec { podseq = PBSUtils.randomNumber mincpmpersec = PBSUtils.randomDecimal slotinpod = PBSUtils.randomNumber - plcmt = PBSUtils.getRandomEnum(VideoPlcmtSubtype) + plcmt = placement } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].video.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { + then: "Bidder request shouldn't contain the imp[0].video.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + verifyAll(bidderRequest) { !imp[0].video.rqddurs !imp[0].video.maxseq !imp[0].video.poddur @@ -613,8 +615,10 @@ class OrtbConverterSpec extends BaseSpec { !imp[0].video.podseq !imp[0].video.mincpmpersec !imp[0].video.slotinpod - !imp[0].video.plcmt } + + and: "Bidder request should contain the imp[0].video.* as on request" + bidderRequest.imp[0].video.plcmt == placement } def "PBS shouldn't remove imp[0].video.* when we support ortb 2.6"() { diff --git a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java index 4a53da795c9..5dd9ef12906 100644 --- a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java +++ b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java @@ -209,7 +209,6 @@ public void convertShouldRemoveFieldsThatAreNotInOrtb25() { .rqddurs(singletonList(1)) .slotinpod(1) .mincpmpersec(BigDecimal.ONE) - .plcmt(1) .build()) .audio(Audio.builder() .poddur(1) From 6edccb2934009b7bd6345e2dc15a8590b670ae4e Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko Date: Thu, 4 Apr 2024 15:30:20 -0400 Subject: [PATCH 03/58] Prebid Server prepare release 2.15.0 --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 4 ++-- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index be81544e27c..d2fde518f7e 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0-SNAPSHOT + 2.15.0 ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 441193ecfdc..f0a9d7a0fe2 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0-SNAPSHOT + 2.15.0 confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index 6adeeffd6c1..bda681b2ddb 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0-SNAPSHOT + 2.15.0 ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index 210b18aaeb9..c150475fc54 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0-SNAPSHOT + 2.15.0 pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index fdff9b712fa..486e92085ed 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0-SNAPSHOT + 2.15.0 ../../extra/pom.xml @@ -43,7 +43,7 @@ org.prebid prebid-server - 2.15.0-SNAPSHOT + 2.15.0 org.projectlombok diff --git a/extra/pom.xml b/extra/pom.xml index 8f4d4596e62..d53a63b62e1 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 2.15.0-SNAPSHOT + 2.15.0 pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - HEAD + 2.15.0 diff --git a/pom.xml b/pom.xml index 0bb91e7d086..c1392b5b039 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0-SNAPSHOT + 2.15.0 extra/pom.xml From 37753fea7dbd56cfeb514bf8e7034361d9c60daa Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko Date: Thu, 4 Apr 2024 15:34:39 -0400 Subject: [PATCH 04/58] Prebid Server prepare for next development iteration --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 4 ++-- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index d2fde518f7e..30748f5061f 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0 + 3.0.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index f0a9d7a0fe2..0bb36be1d10 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0 + 3.0.0-SNAPSHOT confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index bda681b2ddb..2fe803c1ba6 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0 + 3.0.0-SNAPSHOT ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index c150475fc54..436fd2a33d3 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 2.15.0 + 3.0.0-SNAPSHOT pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 486e92085ed..6a0d60bc391 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0 + 3.0.0-SNAPSHOT ../../extra/pom.xml @@ -43,7 +43,7 @@ org.prebid prebid-server - 2.15.0 + 3.0.0-SNAPSHOT org.projectlombok diff --git a/extra/pom.xml b/extra/pom.xml index d53a63b62e1..0ef8a94ae56 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 2.15.0 + 3.0.0-SNAPSHOT pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - 2.15.0 + HEAD diff --git a/pom.xml b/pom.xml index c1392b5b039..abbd1a513e1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 2.15.0 + 3.0.0-SNAPSHOT extra/pom.xml From c6036576fc697da4c2ea243bab89e23507a4d6eb Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Fri, 5 Apr 2024 05:58:10 +0300 Subject: [PATCH 05/58] Remove PG code (#3028) * Remove PG code. * Delete tests. * Remove `LocalMessageCodec` --------- Co-authored-by: Alex Maltsev --- docs/config-app.md | 52 +- docs/deals.md | 152 -- docs/metrics.md | 26 - .../analytics/model/NotificationEvent.java | 2 - .../server/auction/BidResponseCreator.java | 237 +- .../server/auction/ExchangeService.java | 122 +- .../auction/WinningBidComparatorFactory.java | 72 +- .../server/auction/model/AuctionContext.java | 8 - .../prebid/server/auction/model/BidInfo.java | 4 - .../server/auction/model/BidderRequest.java | 6 - .../requestfactory/AmpRequestFactory.java | 4 +- .../requestfactory/AuctionRequestFactory.java | 11 +- .../requestfactory/Ortb2RequestFactory.java | 43 +- .../requestfactory/VideoRequestFactory.java | 4 +- ...BidderRequestCompletionTrackerFactory.java | 96 - .../org/prebid/server/cache/CacheService.java | 41 +- .../server/deals/AdminCentralService.java | 239 -- .../prebid/server/deals/AlertHttpService.java | 143 -- .../org/prebid/server/deals/DealsService.java | 318 --- .../deals/DeliveryProgressReportFactory.java | 313 --- .../server/deals/DeliveryProgressService.java | 208 -- .../server/deals/DeliveryStatsService.java | 294 --- .../prebid/server/deals/LineItemService.java | 591 ----- .../prebid/server/deals/PlannerService.java | 239 -- .../prebid/server/deals/RegisterService.java | 187 -- .../org/prebid/server/deals/Suspendable.java | 6 - .../prebid/server/deals/TargetingService.java | 335 --- .../deals/UserAdditionalInfoService.java | 319 --- .../org/prebid/server/deals/UserService.java | 294 --- .../deals/deviceinfo/DeviceInfoService.java | 16 - .../deals/events/AdminEventProcessor.java | 8 - .../deals/events/AdminEventService.java | 30 - .../events/ApplicationEventProcessor.java | 17 - .../deals/events/ApplicationEventService.java | 57 - .../deals/events/EventServiceInitializer.java | 53 - .../server/deals/lineitem/DeliveryPlan.java | 184 -- .../deals/lineitem/DeliveryProgress.java | 349 --- .../server/deals/lineitem/DeliveryToken.java | 72 - .../server/deals/lineitem/LineItem.java | 276 --- .../server/deals/lineitem/LineItemStatus.java | 167 -- .../server/deals/lineitem/LostToLineItem.java | 15 - .../server/deals/model/AdminAccounts.java | 13 - .../deals/model/AdminCentralResponse.java | 25 - .../server/deals/model/AdminLineItems.java | 13 - .../prebid/server/deals/model/AlertEvent.java | 25 - .../server/deals/model/AlertPriority.java | 6 - .../deals/model/AlertProxyProperties.java | 23 - .../server/deals/model/AlertSource.java | 25 - .../prebid/server/deals/model/Command.java | 14 - .../server/deals/model/DeepDebugLog.java | 45 - .../model/DeliveryProgressProperties.java | 13 - .../deals/model/DeliveryStatsProperties.java | 31 - .../deals/model/DeploymentProperties.java | 25 - .../prebid/server/deals/model/DeviceInfo.java | 35 - .../prebid/server/deals/model/DeviceType.java | 43 - .../prebid/server/deals/model/ExtUser.java | 15 - .../server/deals/model/LogCriteriaFilter.java | 19 - .../prebid/server/deals/model/LogTracer.java | 19 - .../deals/model/MatchLineItemsResult.java | 14 - .../server/deals/model/PlannerProperties.java | 26 - .../prebid/server/deals/model/Segment.java | 11 - .../server/deals/model/ServicesCommand.java | 11 - .../deals/model/SimulationProperties.java | 15 - .../org/prebid/server/deals/model/TxnLog.java | 60 - .../org/prebid/server/deals/model/User.java | 15 - .../prebid/server/deals/model/UserData.java | 17 - .../server/deals/model/UserDetails.java | 21 - .../deals/model/UserDetailsProperties.java | 23 - .../deals/model/UserDetailsRequest.java | 15 - .../deals/model/UserDetailsResponse.java | 11 - .../org/prebid/server/deals/model/UserId.java | 13 - .../prebid/server/deals/model/UserIdRule.java | 19 - .../deals/model/WinEventNotification.java | 37 - .../deals/proto/CurrencyServiceState.java | 13 - .../server/deals/proto/DeliverySchedule.java | 30 - .../server/deals/proto/FrequencyCap.java | 23 - .../server/deals/proto/LineItemMetaData.java | 57 - .../server/deals/proto/LineItemSize.java | 16 - .../org/prebid/server/deals/proto/Price.java | 15 - .../server/deals/proto/RegisterRequest.java | 24 - .../org/prebid/server/deals/proto/Status.java | 18 - .../org/prebid/server/deals/proto/Token.java | 16 - .../proto/report/DeliveryProgressReport.java | 37 - .../report/DeliveryProgressReportBatch.java | 21 - .../deals/proto/report/DeliverySchedule.java | 26 - .../server/deals/proto/report/Event.java | 15 - .../deals/proto/report/LineItemStatus.java | 77 - .../proto/report/LineItemStatusReport.java | 33 - .../deals/proto/report/LostToLineItem.java | 18 - .../server/deals/proto/report/Token.java | 18 - .../DealsSimulationAdminHandler.java | 165 -- ...imulationAwareDeliveryProgressService.java | 74 - .../SimulationAwareDeliveryStatsService.java | 52 - .../SimulationAwareHttpBidderRequester.java | 177 -- .../SimulationAwareLineItemService.java | 62 - .../SimulationAwarePlannerService.java | 107 - .../SimulationAwareRegisterService.java | 61 - .../SimulationAwareUserService.java | 57 - .../deals/targeting/RequestContext.java | 422 ---- .../deals/targeting/TargetingDefinition.java | 10 - .../server/deals/targeting/interpret/And.java | 27 - .../DomainMetricAwareExpression.java | 25 - .../deals/targeting/interpret/Expression.java | 8 - .../server/deals/targeting/interpret/In.java | 30 - .../deals/targeting/interpret/InIntegers.java | 21 - .../deals/targeting/interpret/InStrings.java | 48 - .../deals/targeting/interpret/Intersects.java | 31 - .../interpret/IntersectsIntegers.java | 21 - .../targeting/interpret/IntersectsSizes.java | 22 - .../interpret/IntersectsStrings.java | 28 - .../deals/targeting/interpret/Matches.java | 44 - .../interpret/NonTerminalExpression.java | 4 - .../server/deals/targeting/interpret/Not.java | 21 - .../server/deals/targeting/interpret/Or.java | 27 - .../interpret/TerminalExpression.java | 4 - .../deals/targeting/interpret/Within.java | 49 - .../deals/targeting/model/GeoLocation.java | 13 - .../deals/targeting/model/GeoRegion.java | 17 - .../deals/targeting/model/LookupResult.java | 33 - .../server/deals/targeting/model/Size.java | 13 - .../targeting/syntax/BooleanOperator.java | 29 - .../targeting/syntax/MatchingFunction.java | 34 - .../targeting/syntax/TargetingCategory.java | 132 -- .../prebid/server/events/EventRequest.java | 2 - .../org/prebid/server/events/EventUtil.java | 7 - .../prebid/server/events/EventsService.java | 18 +- .../exception/TargetingSyntaxException.java | 12 - .../server/handler/DealsStatusHandler.java | 48 - .../handler/ForceDealsUpdateHandler.java | 104 - .../server/handler/LineItemStatusHandler.java | 76 - .../handler/NotificationEventHandler.java | 106 +- .../server/handler/TracerLogHandler.java | 19 +- .../server/handler/openrtb2/AmpHandler.java | 9 +- .../handler/openrtb2/AuctionHandler.java | 28 +- .../server/handler/openrtb2/VideoHandler.java | 1 + .../java/org/prebid/server/log/Criteria.java | 64 +- .../prebid/server/log/CriteriaLogManager.java | 23 +- .../prebid/server/log/CriteriaManager.java | 42 +- .../org/prebid/server/metric/MetricName.java | 26 - .../org/prebid/server/metric/Metrics.java | 70 - .../org/prebid/server/metric/PgMetrics.java | 10 - .../ext/response/ExtDebugPgmetrics.java | 41 - .../openrtb/ext/response/ExtDebugTrace.java | 14 - .../ext/response/ExtResponseDebug.java | 5 - .../openrtb/ext/response/ExtTraceDeal.java | 40 - .../config/AdminEndpointsConfiguration.java | 93 - .../spring/config/DealsConfiguration.java | 914 -------- .../spring/config/ServiceConfiguration.java | 21 +- .../spring/config/VertxConfiguration.java | 10 - .../spring/config/WebConfiguration.java | 23 +- .../java/org/prebid/server/util/HttpUtil.java | 54 +- .../org/prebid/server/util/LineItemUtil.java | 76 - .../validation/ResponseBidValidator.java | 193 +- .../org/prebid/server/vast/VastModifier.java | 8 +- .../server/vertx/LocalMessageCodec.java | 46 - src/main/resources/application.yaml | 15 - .../model/deals/alert/Action.groovy | 6 - .../model/deals/alert/AlertEvent.groovy | 20 - .../model/deals/alert/AlertPriority.groovy | 6 - .../model/deals/alert/AlertSource.groovy | 17 - .../deals/lineitem/DeliverySchedule.groovy | 37 - .../model/deals/lineitem/FrequencyCap.groovy | 23 - .../model/deals/lineitem/LineItem.groovy | 74 - .../model/deals/lineitem/LineItemSize.groovy | 16 - .../deals/lineitem/LineItemStatus.groovy | 22 - .../model/deals/lineitem/MediaType.groovy | 20 - .../model/deals/lineitem/PeriodType.groovy | 24 - .../model/deals/lineitem/Price.groovy | 15 - .../deals/lineitem/RelativePriority.groovy | 24 - .../model/deals/lineitem/Token.groovy | 19 - .../lineitem/targeting/BooleanOperator.groovy | 20 - .../targeting/MatchingFunction.groovy | 18 - .../targeting/MatchingFunctionNode.groovy | 17 - .../deals/lineitem/targeting/Targeting.groovy | 92 - .../lineitem/targeting/TargetingNode.groovy | 13 - .../lineitem/targeting/TargetingType.groovy | 46 - .../register/CurrencyServiceState.groovy | 11 - .../deals/register/RegisterRequest.groovy | 13 - .../model/deals/register/Status.groovy | 11 - .../deals/report/DeliverySchedule.groovy | 15 - .../report/DeliveryStatisticsReport.groovy | 19 - .../model/deals/report/Event.groovy | 10 - .../model/deals/report/LineItemStatus.groovy | 30 - .../deals/report/LineItemStatusReport.groovy | 17 - .../model/deals/report/LostToLineItem.groovy | 11 - .../model/deals/report/Token.groovy | 17 - .../model/deals/userdata/Segment.groovy | 14 - .../model/deals/userdata/User.groovy | 16 - .../model/deals/userdata/UserData.groovy | 19 - .../model/deals/userdata/UserDetails.groovy | 10 - .../deals/userdata/UserDetailsRequest.groovy | 12 - .../deals/userdata/UserDetailsResponse.groovy | 14 - .../model/deals/userdata/UserExt.groovy | 14 - .../model/deals/userdata/UserId.groovy | 10 - .../userdata/WinEventNotification.groovy | 19 - .../generalplanner/PlansResponse.groovy | 19 - .../ForceDealsUpdateRequest.groovy | 48 - .../model/request/event/EventRequest.groovy | 2 - .../model/response/auction/BidResponse.groovy | 13 - .../service/PrebidServerService.groovy | 22 - .../testcontainers/PbsPgConfig.groovy | 135 -- .../scaffolding/pg/Alert.groovy | 50 - .../scaffolding/pg/DeliveryStatistics.groovy | 57 - .../scaffolding/pg/GeneralPlanner.groovy | 96 - .../scaffolding/pg/UserData.groovy | 77 - .../functional/tests/pg/AlertSpec.groovy | 281 --- .../functional/tests/pg/BasePgSpec.groovy | 60 - .../functional/tests/pg/CurrencySpec.groovy | 98 - .../tests/pg/LineItemStatusSpec.groovy | 193 -- .../functional/tests/pg/PgAuctionSpec.groovy | 520 ----- .../tests/pg/PgBidResponseSpec.groovy | 211 -- .../tests/pg/PgBidderRequestSpec.groovy | 167 -- .../tests/pg/PgDealsOnlySpec.groovy | 190 -- .../functional/tests/pg/PlansSpec.groovy | 57 - .../functional/tests/pg/RegisterSpec.groovy | 229 -- .../functional/tests/pg/ReportSpec.groovy | 559 ----- .../pg/TargetingFirstPartyDataSpec.groovy | 707 ------ .../functional/tests/pg/TargetingSpec.groovy | 560 ----- .../functional/tests/pg/TokenSpec.groovy | 317 --- .../tests/pg/UserDetailsSpec.groovy | 343 --- .../tests/privacy/PrivacyBaseSpec.groovy | 9 +- .../server/functional/util/HttpUtil.groovy | 11 - .../pubstack/PubstackEventHandlerTest.java | 4 - .../auction/BidResponseCreatorTest.java | 233 +- .../server/auction/ExchangeServiceTest.java | 197 +- .../WinningBidComparatorFactoryTest.java | 261 +-- .../requestfactory/AmpRequestFactoryTest.java | 6 +- .../AuctionRequestFactoryTest.java | 10 +- .../Ortb2RequestFactoryTest.java | 79 +- .../VideoRequestFactoryTest.java | 7 +- .../bidder/HttpBidderRequesterTest.java | 44 +- .../prebid/server/cache/CacheServiceTest.java | 36 +- .../server/deals/AdminCentralServiceTest.java | 437 ---- .../server/deals/AlertHttpServiceTest.java | 233 -- .../prebid/server/deals/DealsServiceTest.java | 403 ---- .../DeliveryProgressReportFactoryTest.java | 201 -- .../deals/DeliveryProgressServiceTest.java | 426 ---- .../deals/DeliveryStatsServiceTest.java | 428 ---- .../server/deals/LineItemServiceTest.java | 2076 ----------------- .../server/deals/PlannerServiceTest.java | 351 --- .../server/deals/RegisterServiceTest.java | 269 --- .../server/deals/TargetingServiceTest.java | 919 -------- .../deals/UserAdditionalInfoServiceTest.java | 507 ---- .../prebid/server/deals/UserServiceTest.java | 596 ----- .../deals/events/AdminEventServiceTest.java | 83 - .../events/ApplicationEventServiceTest.java | 156 -- .../deals/lineitem/DeliveryPlanTest.java | 30 - .../deals/lineitem/DeliveryProgressTest.java | 365 --- .../server/deals/model/DeepDebugLogTest.java | 51 - .../DealsSimulationAdminHandlerTest.java | 227 -- ...imulationAwareHttpBidderRequesterTest.java | 324 --- .../SimulationAwarePlannerServiceTest.java | 164 -- .../deals/targeting/RequestContextTest.java | 1262 ---------- .../deals/targeting/interpret/AndTest.java | 52 - .../targeting/interpret/InIntegersTest.java | 65 - .../targeting/interpret/InStringsTest.java | 85 - .../interpret/IntersectsIntegersTest.java | 74 - .../interpret/IntersectsSizesTest.java | 77 - .../interpret/IntersectsStringsTest.java | 83 - .../targeting/interpret/MatchesTest.java | 168 -- .../deals/targeting/interpret/NotTest.java | 42 - .../deals/targeting/interpret/OrTest.java | 52 - .../deals/targeting/interpret/WithinTest.java | 65 - .../targeting/syntax/BooleanOperatorTest.java | 51 - .../syntax/MatchingFunctionTest.java | 52 - .../syntax/TargetingCategoryTest.java | 121 - .../prebid/server/events/EventUtilTest.java | 10 +- .../server/events/EventsServiceTest.java | 47 +- .../handler/DealsStatusHandlerTest.java | 86 - .../handler/ForceDealsUpdateHandlerTest.java | 240 -- .../handler/LineItemStatusHandlerTest.java | 104 - .../handler/NotificationEventHandlerTest.java | 178 +- .../server/handler/TracerLogHandlerTest.java | 4 +- .../handler/openrtb2/AmpHandlerTest.java | 2 +- .../handler/openrtb2/AuctionHandlerTest.java | 3 +- .../org/prebid/server/it/ApplicationTest.java | 1 - .../prebid/server/it/DealsSimulationTest.java | 269 --- .../java/org/prebid/server/it/DealsTest.java | 333 --- .../org/prebid/server/it/IntegrationTest.java | 82 - .../prebid/server/it/PrematureReturnTest.java | 451 ---- .../server/log/CriteriaManagerTest.java | 25 +- .../org/prebid/server/log/CriteriaTest.java | 67 +- .../org/prebid/server/metric/MetricsTest.java | 143 -- .../org/prebid/server/util/HttpUtilTest.java | 52 - .../validation/ResponseBidValidatorTest.java | 211 +- .../prebid/server/vast/VastModifierTest.java | 126 +- .../targeting/test-device-targeting.json | 20 - ...rgeting-definition-and-with-non-array.json | 3 - ...nition-category-incompatible-function.json | 5 - ...on-category-incompatible-geo-function.json | 5 - ...ategory-incompatible-segment-function.json | 5 - ...category-incompatible-string-function.json | 5 - ...-category-incompatible-typed-function.json | 5 - ...geting-definition-category-non-object.json | 3 - ...ng-definition-in-integers-non-integer.json | 7 - ...eting-definition-intersects-non-array.json | 5 - ...efinition-intersects-sizes-empty-size.json | 8 - ...finition-intersects-sizes-non-objects.json | 8 - ...on-intersects-sizes-non-readable-size.json | 9 - ...g-definition-intersects-strings-empty.json | 7 - ...inition-intersects-strings-non-string.json | 7 - ...id-targeting-definition-matches-empty.json | 5 - ...rgeting-definition-matches-non-string.json | 5 - ...finition-multiple-fields-boolean-args.json | 8 - ...g-definition-multiple-fields-function.json | 6 - ...-targeting-definition-multiple-fields.json | 4 - ...valid-targeting-definition-non-object.json | 3 - ...geting-definition-not-with-non-object.json | 3 - ...tion-typed-function-incompatible-type.json | 7 - ...definition-typed-function-mixed-types.json | 8 - ...id-targeting-definition-unknown-field.json | 3 - ...targeting-definition-unknown-function.json | 5 - ...ng-definition-unknown-string-function.json | 5 - ...ing-definition-unknown-typed-function.json | 5 - ...ing-definition-within-empty-georegion.json | 6 - ...argeting-definition-within-non-object.json | 5 - ...inition-within-non-readable-georegion.json | 7 - .../targeting/test-not-and-definition.json | 28 - .../test-not-in-integers-definition.json | 10 - .../test-not-in-strings-definition.json | 10 - ...est-not-intersects-integer-definition.json | 10 - .../test-not-intersects-sizes-definition.json | 16 - .../test-not-matches-definition.json | 7 - .../targeting/test-not-or-definition.json | 28 - .../targeting/test-not-within-definition.json | 11 - .../test-valid-targeting-definition.json | 354 --- ...est-auction-first-and-second-response.json | 461 ---- .../test-auction-first-bid-only-response.json | 458 ---- .../test-auction-in-order-response.json | 458 ---- ...est-auction-in-reverse-order-response.json | 464 ---- ...test-auction-second-bid-only-response.json | 462 ---- ...est-auction-third-and-second-response.json | 463 ---- .../test-auction-third-bid-only-response.json | 462 ---- .../deals/premature/test-auction-request.json | 53 - .../premature/test-planner-plan-response.json | 209 -- .../test-rubicon-bid-response-1.json | 20 - .../test-rubicon-bid-response-2.json | 20 - .../test-rubicon-bid-response-3.json | 20 - .../test-rubicon-no-bid-response-1.json | 11 - .../test-rubicon-no-bid-response-2.json | 11 - .../test-rubicon-no-bid-response-3.json | 10 - .../simulation/test-auction-request.json | 53 - .../simulation/test-auction-response-1.json | 366 --- .../simulation/test-auction-response-2.json | 350 --- .../it/deals/simulation/test-bid-rates.json | 5 - ...est-delivery-stats-progress-request-1.json | 149 -- ...est-delivery-stats-progress-request-2.json | 98 - .../test-planner-plan-response-1.json | 257 -- .../test-planner-register-request-1.json | 6 - .../server/it/deals/test-auction-request.json | 133 -- .../it/deals/test-auction-response.json | 877 ------- .../it/deals/test-cache-deals-request.json | 79 - .../server/it/deals/test-cache-matcher.json | 5 - .../deals/test-deals-application.properties | 46 - ...st-deals-simulation-application.properties | 3 - .../test-delivery-stats-progress-request.json | 203 -- .../it/deals/test-generic-bid-request.json | 236 -- .../it/deals/test-generic-bid-response.json | 40 - .../it/deals/test-planner-plan-response.json | 347 --- .../deals/test-planner-register-request.json | 15 - .../deals/test-planner-register-response.json | 12 - ...st-user-data-details-generic-response.json | 35 - .../deals/test-user-data-details-request.json | 8 - ...st-user-data-details-rubicon-response.json | 35 - .../test-user-data-win-event-request.json | 20 - .../server/it/test-application.properties | 2 - 366 files changed, 493 insertions(+), 37628 deletions(-) delete mode 100644 docs/deals.md delete mode 100644 src/main/java/org/prebid/server/bidder/DealsBidderRequestCompletionTrackerFactory.java delete mode 100644 src/main/java/org/prebid/server/deals/AdminCentralService.java delete mode 100644 src/main/java/org/prebid/server/deals/AlertHttpService.java delete mode 100644 src/main/java/org/prebid/server/deals/DealsService.java delete mode 100644 src/main/java/org/prebid/server/deals/DeliveryProgressReportFactory.java delete mode 100644 src/main/java/org/prebid/server/deals/DeliveryProgressService.java delete mode 100644 src/main/java/org/prebid/server/deals/DeliveryStatsService.java delete mode 100644 src/main/java/org/prebid/server/deals/LineItemService.java delete mode 100644 src/main/java/org/prebid/server/deals/PlannerService.java delete mode 100644 src/main/java/org/prebid/server/deals/RegisterService.java delete mode 100644 src/main/java/org/prebid/server/deals/Suspendable.java delete mode 100644 src/main/java/org/prebid/server/deals/TargetingService.java delete mode 100644 src/main/java/org/prebid/server/deals/UserAdditionalInfoService.java delete mode 100644 src/main/java/org/prebid/server/deals/UserService.java delete mode 100644 src/main/java/org/prebid/server/deals/deviceinfo/DeviceInfoService.java delete mode 100644 src/main/java/org/prebid/server/deals/events/AdminEventProcessor.java delete mode 100644 src/main/java/org/prebid/server/deals/events/AdminEventService.java delete mode 100644 src/main/java/org/prebid/server/deals/events/ApplicationEventProcessor.java delete mode 100644 src/main/java/org/prebid/server/deals/events/ApplicationEventService.java delete mode 100644 src/main/java/org/prebid/server/deals/events/EventServiceInitializer.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/DeliveryPlan.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/DeliveryProgress.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/DeliveryToken.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/LineItem.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/LineItemStatus.java delete mode 100644 src/main/java/org/prebid/server/deals/lineitem/LostToLineItem.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AdminAccounts.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AdminCentralResponse.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AdminLineItems.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AlertEvent.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AlertPriority.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AlertProxyProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/AlertSource.java delete mode 100644 src/main/java/org/prebid/server/deals/model/Command.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeepDebugLog.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeliveryProgressProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeliveryStatsProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeploymentProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeviceInfo.java delete mode 100644 src/main/java/org/prebid/server/deals/model/DeviceType.java delete mode 100644 src/main/java/org/prebid/server/deals/model/ExtUser.java delete mode 100644 src/main/java/org/prebid/server/deals/model/LogCriteriaFilter.java delete mode 100644 src/main/java/org/prebid/server/deals/model/LogTracer.java delete mode 100644 src/main/java/org/prebid/server/deals/model/MatchLineItemsResult.java delete mode 100644 src/main/java/org/prebid/server/deals/model/PlannerProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/Segment.java delete mode 100644 src/main/java/org/prebid/server/deals/model/ServicesCommand.java delete mode 100644 src/main/java/org/prebid/server/deals/model/SimulationProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/TxnLog.java delete mode 100644 src/main/java/org/prebid/server/deals/model/User.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserData.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserDetails.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserDetailsProperties.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserDetailsRequest.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserDetailsResponse.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserId.java delete mode 100644 src/main/java/org/prebid/server/deals/model/UserIdRule.java delete mode 100644 src/main/java/org/prebid/server/deals/model/WinEventNotification.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/CurrencyServiceState.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/DeliverySchedule.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/FrequencyCap.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/LineItemMetaData.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/LineItemSize.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/Price.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/RegisterRequest.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/Status.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/Token.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReport.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReportBatch.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/DeliverySchedule.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/Event.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/LineItemStatus.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/LineItemStatusReport.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/LostToLineItem.java delete mode 100644 src/main/java/org/prebid/server/deals/proto/report/Token.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandler.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryProgressService.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryStatsService.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequester.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareLineItemService.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareRegisterService.java delete mode 100644 src/main/java/org/prebid/server/deals/simulation/SimulationAwareUserService.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/RequestContext.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/TargetingDefinition.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/And.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/DomainMetricAwareExpression.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Expression.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/In.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/InIntegers.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/InStrings.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Intersects.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegers.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsSizes.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsStrings.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Matches.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/NonTerminalExpression.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Not.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Or.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/TerminalExpression.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/interpret/Within.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/model/GeoLocation.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/model/GeoRegion.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/model/LookupResult.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/model/Size.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/syntax/BooleanOperator.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/syntax/MatchingFunction.java delete mode 100644 src/main/java/org/prebid/server/deals/targeting/syntax/TargetingCategory.java delete mode 100644 src/main/java/org/prebid/server/exception/TargetingSyntaxException.java delete mode 100644 src/main/java/org/prebid/server/handler/DealsStatusHandler.java delete mode 100644 src/main/java/org/prebid/server/handler/ForceDealsUpdateHandler.java delete mode 100644 src/main/java/org/prebid/server/handler/LineItemStatusHandler.java delete mode 100644 src/main/java/org/prebid/server/metric/PgMetrics.java delete mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugPgmetrics.java delete mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtTraceDeal.java delete mode 100644 src/main/java/org/prebid/server/spring/config/DealsConfiguration.java delete mode 100644 src/main/java/org/prebid/server/util/LineItemUtil.java delete mode 100644 src/main/java/org/prebid/server/vertx/LocalMessageCodec.java delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/alert/Action.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertEvent.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertPriority.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertSource.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/DeliverySchedule.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/FrequencyCap.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItem.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemSize.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemStatus.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/MediaType.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/PeriodType.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Price.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/RelativePriority.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Token.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/BooleanOperator.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunction.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunctionNode.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/Targeting.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingNode.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingType.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/register/CurrencyServiceState.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/register/RegisterRequest.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/register/Status.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/DeliverySchedule.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/DeliveryStatisticsReport.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/Event.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatus.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatusReport.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/LostToLineItem.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/report/Token.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/Segment.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/User.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserData.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetails.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsRequest.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsResponse.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserExt.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserId.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/deals/userdata/WinEventNotification.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/mock/services/generalplanner/PlansResponse.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/request/dealsupdate/ForceDealsUpdateRequest.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/testcontainers/PbsPgConfig.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/Alert.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/DeliveryStatistics.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/GeneralPlanner.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/UserData.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/AlertSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/BasePgSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/CurrencySpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/LineItemStatusSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/PgAuctionSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/PgBidResponseSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/PgBidderRequestSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/PgDealsOnlySpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/PlansSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/RegisterSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/ReportSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/TargetingFirstPartyDataSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/TargetingSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/TokenSpec.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/tests/pg/UserDetailsSpec.groovy delete mode 100644 src/test/java/org/prebid/server/deals/AdminCentralServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/AlertHttpServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/DealsServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/DeliveryProgressReportFactoryTest.java delete mode 100644 src/test/java/org/prebid/server/deals/DeliveryProgressServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/DeliveryStatsServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/LineItemServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/PlannerServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/RegisterServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/TargetingServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/UserAdditionalInfoServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/UserServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/events/AdminEventServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/events/ApplicationEventServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/lineitem/DeliveryPlanTest.java delete mode 100644 src/test/java/org/prebid/server/deals/lineitem/DeliveryProgressTest.java delete mode 100644 src/test/java/org/prebid/server/deals/model/DeepDebugLogTest.java delete mode 100644 src/test/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandlerTest.java delete mode 100644 src/test/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequesterTest.java delete mode 100644 src/test/java/org/prebid/server/deals/simulation/SimulationAwarePlannerServiceTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/RequestContextTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/AndTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/InIntegersTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/InStringsTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegersTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsSizesTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsStringsTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/MatchesTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/NotTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/OrTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/interpret/WithinTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/syntax/BooleanOperatorTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/syntax/MatchingFunctionTest.java delete mode 100644 src/test/java/org/prebid/server/deals/targeting/syntax/TargetingCategoryTest.java delete mode 100644 src/test/java/org/prebid/server/handler/DealsStatusHandlerTest.java delete mode 100644 src/test/java/org/prebid/server/handler/ForceDealsUpdateHandlerTest.java delete mode 100644 src/test/java/org/prebid/server/handler/LineItemStatusHandlerTest.java delete mode 100644 src/test/java/org/prebid/server/it/DealsSimulationTest.java delete mode 100644 src/test/java/org/prebid/server/it/DealsTest.java delete mode 100644 src/test/java/org/prebid/server/it/PrematureReturnTest.java delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-device-targeting.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-and-with-non-array.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-geo-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-segment-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-string-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-typed-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-non-object.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-in-integers-non-integer.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-non-array.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-empty-size.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-objects.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-readable-size.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-empty.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-non-string.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-empty.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-non-string.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-boolean-args.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-non-object.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-not-with-non-object.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-incompatible-type.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-mixed-types.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-field.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-string-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-typed-function.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-empty-georegion.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-object.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-readable-georegion.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-and-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-in-integers-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-in-strings-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-integer-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-sizes-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-matches-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-or-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-not-within-definition.json delete mode 100644 src/test/resources/org/prebid/server/deals/targeting/test-valid-targeting-definition.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-and-second-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-bid-only-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-order-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-reverse-order-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-second-bid-only-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-and-second-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-bid-only-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-auction-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-planner-plan-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-2.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-3.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-2.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-3.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-auction-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-2.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-bid-rates.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-2.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-planner-plan-response-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/simulation/test-planner-register-request-1.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-auction-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-auction-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-cache-deals-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-cache-matcher.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-deals-application.properties delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-deals-simulation-application.properties delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-delivery-stats-progress-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-generic-bid-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-generic-bid-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-planner-plan-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-planner-register-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-planner-register-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-user-data-details-generic-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-user-data-details-request.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-user-data-details-rubicon-response.json delete mode 100644 src/test/resources/org/prebid/server/it/deals/test-user-data-win-event-request.json diff --git a/docs/config-app.md b/docs/config-app.md index 79cbf9f85ef..0ae973cf9f5 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -202,17 +202,7 @@ Also, each bidder could have its own bidder-specific options. - `admin-endpoints.tracelog.enabled` - if equals to `true` the endpoint will be available. - `admin-endpoints.tracelog.path` - the server context path where the endpoint will be accessible. - `admin-endpoints.tracelog.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.tracelog.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - -- `admin-endpoints.deals-status.enabled` - if equals to `true` the endpoint will be available. -- `admin-endpoints.deals-status.path` - the server context path where the endpoint will be accessible. -- `admin-endpoints.deals-status.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.deals-status.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - -- `admin-endpoints.lineitem-status.enabled` - if equals to `true` the endpoint will be available. -- `admin-endpoints.lineitem-status.path` - the server context path where the endpoint will be accessible. -- `admin-endpoints.lineitem-status.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.lineitem-status.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` +- `admin-endpoints.tracelog.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - `admin-endpoints.e2eadmin.enabled` - if equals to `true` the endpoint will be available. - `admin-endpoints.e2eadmin.path` - the server context path where the endpoint will be accessible. @@ -224,11 +214,6 @@ Also, each bidder could have its own bidder-specific options. - `admin-endpoints.collected-metrics.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. - `admin-endpoints.collected-metrics.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` -- `admin-endpoints.force-deals-update.enabled` - if equals to `true` the endpoint will be available. -- `admin-endpoints.force-deals-update.path` - the server context path where the endpoint will be accessible. -- `admin-endpoints.force-deals-update.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.force-deals-update.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - - `admin-endpoints.credentials` - user and password for access to admin endpoints if `admin-endpoints.[NAME].protected` is true`. ## Metrics @@ -442,41 +427,6 @@ If not defined in config all other Health Checkers would be disabled and endpoin - `analytics.pubstack.buffers.count` - threshold in events count for buffer to send events - `analytics.pubstack.buffers.report-ttl-ms` - max period between two reports. -## Programmatic Guaranteed Delivery -- `deals.planner.plan-endpoint` - planner endpoint to get plans from. -- `deals.planner.update-period` - cron expression to start job for requesting Line Item metadata updates from the Planner. -- `deals.planner.plan-advance-period` - cron expression to start job for advancing Line Items to the next plan. -- `deals.planner.retry-period-sec` - how long (in seconds) to wait before re-sending a request to the Planner that previously failed with 5xx HTTP error code. -- `deals.planner.timeout-ms` - default operation timeout for requests to planner's endpoints. -- `deals.planner.register-endpoint` - register endpoint to get plans from. -- `deals.planner.register-period-sec` - time period (in seconds) to send register request to the Planner. -- `deals.planner.username` - username for planner BasicAuth. -- `deals.planner.password` - password for planner BasicAuth. -- `deals.delivery-stats.delivery-period` - cron expression to start job for sending delivery progress to planner. -- `deals.delivery-stats.cached-reports-number` - how many reports to cache while planner is unresponsive. -- `deals.delivery-stats.timeout-ms` - default operation timeout for requests to delivery progress endpoints. -- `deals.delivery-stats.username` - username for delivery progress BasicAuth. -- `deals.delivery-stats.password` - password for delivery progress BasicAuth. -- `deals.delivery-stats.line-items-per-report` - max number of line items in each report to split for batching. Default is 25. -- `deals.delivery-stats.reports-interval-ms` - interval in ms between consecutive reports. Default is 0. -- `deals.delivery-stats.batches-interval-ms` - interval in ms between consecutive batches. Default is 1000. -- `deals.delivery-stats.request-compression-enabled` - enables request gzip compression when set to true. -- `deals.delivery-progress.line-item-status-ttl-sec` - how long to store line item's metrics after it was expired. -- `deals.delivery-progress.cached-plans-number` - how many plans to store in metrics per line item. -- `deals.delivery-progress.report-reset-period`- cron expression to start job for closing current delivery progress and starting new one. -- `deals.delivery-progress-report.competitors-number`- number of line items top competitors to send in delivery progress report. -- `deals.user-data.user-details-endpoint` - user Data Store endpoint to get user details from. -- `deals.user-data.win-event-endpoint` - user Data Store endpoint to which win events should be sent. -- `deals.user-data.timeout` - time to wait (in milliseconds) for User Data Service response. -- `deals.user-data.user-ids` - list of Rules for determining user identifiers to send to User Data Store. -- `deals.max-deals-per-bidder` - maximum number of deals to send to each bidder. -- `deals.alert-proxy.enabled` - enable alert proxy service if `true`. -- `deals.alert-proxy.url` - alert service endpoint to send alerts to. -- `deals.alert-proxy.timeout-sec` - default operation timeout for requests to alert service endpoint. -- `deals.alert-proxy.username` - username for alert proxy BasicAuth. -- `deals.alert-proxy.password` - password for alert proxy BasicAuth. -- `deals.alert-proxy.alert-types` - key value pair of alert type and sampling factor to send high priority alert. - ## Debugging - `debug.override-token` - special string token for overriding Prebid Server account and/or adapter debug information presence in the auction response. diff --git a/docs/deals.md b/docs/deals.md deleted file mode 100644 index fca8c585e26..00000000000 --- a/docs/deals.md +++ /dev/null @@ -1,152 +0,0 @@ -# Deals - -## Planner and Register services - -### Planner service - -Periodically request Line Item metadata from the Planner. Line Item metadata includes: -1. Line Item details -2. Targeting -3. Frequency caps -4. Delivery schedule - -### Register service - -Each Prebid Server instance register itself with the General Planner with a health index -(QoS indicator based on its internal counters like circuit breaker trip counters, timeouts, etc.) -and KPI like ad requests per second. - -Also allows planner send command to PBS admin endpoint to stored request caches and tracelogs. - -### Planner and register service configuration - -```yaml -planner: - register-endpoint: - plan-endpoint: - update-period: "0 */1 * * * *" - register-period-sec: 60 - timeout-ms: 8000 - username: - password: -``` - -## Deals stats service - -Supports sending reports to delivery stats serving with following metrics: - -1. Number of client requests seen since start-up -2. For each Line Item -- Number of tokens spent so far at each token class within active and expired plans -- Number of times the account made requests (this will be the same across all LineItem for the account) -- Number of win notifications -- Number of times the domain part of the target matched -- Number of times impressions matched whole target -- Number of times impressions matched the target but was frequency capped -- Number of times impressions matched the target but the fcap lookup failed -- Number of times LineItem was sent to the bidder -- Number of times LineItem was sent to the bidder as the top match -- Number of times LineItem came back from the bidder -- Number of times the LineItem response was invalidated -- Number of times the LineItem was sent to the client -- Number of times the LineItem was sent to the client as the top match -- Array of top 10 competing LineItems sent to client - -### Deals stats service configuration - -```yaml -delivery-stats: - endpoint: - delivery-period: "0 */1 * * * *" - cached-reports-number: 20 - line-item-status-ttl-sec: 3600 - timeout-ms: 8000 - username: - password: -``` - -## Alert service - -Sends out alerts when PBS cannot talk to general planner and other critical situations. Alerts are simply JSON messages -over HTTP sent to a central proxy server. - -```yaml - alert-proxy: - enabled: truew - timeout-sec: 10 - url: - username: - password: - alert-types: - : - pbs-planner-empty-response-error: 15 -``` - -## GeoLocation service - -This service currently has 1 implementation: -- MaxMind - -In order to support targeting by geographical attributes the service will provide the following information: - -1. `continent` - Continent code -2. `region` - Region code using ISO-3166-2 -3. `metro` - Nielsen DMAs -4. `city` - city using provider specific encoding -5. `lat` - latitude from -90.0 to +90.0, where negative is south -6. `lon` - longitude from -180.0 to +180.0, where negative is west - -### GeoLocation service configuration for MaxMind - -```yaml -geolocation: - enabled: true - type: maxmind - maxmind: - remote-file-syncer: - download-url: - save-filepath: - tmp-filepath: - retry-count: 3 - retry-interval-ms: 3000 - timeout-ms: 300000 - update-interval-ms: 0 - http-client: - connect-timeout-ms: 2500 - max-redirects: 3 -``` - -## User Service - -This service is responsible for: -- Requesting user targeting segments and frequency capping status from the User Data Store -- Reporting to User Data Store when users finally see ads to aid in correctly enforcing frequency caps - -### User service configuration - -```yaml - user-data: - win-event-endpoint: - user-details-endpoint: - timeout: 1000 - user-ids: - - location: rubicon - source: uid - type: khaos -``` -1. khaos, adnxs - types of the ids that will be specified in requests to User Data Store -2. source - source of the id, the only supported value so far is “uids” which stands for uids cookie -3. location - where exactly in the source to look for id - -## Device Info Service - -DeviceInfoService returns device-related attributes based on User-Agent for use in targeting: -- deviceClass: desktop, tablet, phone, ctv -- os: windows, ios, android, osx, unix, chromeos -- osVersion -- browser: chrome, firefox, edge, safari -- browserVersion - -## See also - -- [Configuration](config.md) diff --git a/docs/metrics.md b/docs/metrics.md index 41dd45cc916..f1af81cbd0a 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -133,29 +133,3 @@ Following metrics are collected and submitted if account is configured with `det - `analytics..(auction|amp|video|cookie_sync|event|setuid).timeout` - number of event requests, failed with timeout cause - `analytics..(auction|amp|video|cookie_sync|event|setuid).err` - number of event requests, failed with errors - `analytics..(auction|amp|video|cookie_sync|event|setuid).badinput` - number of event requests, rejected with bad input cause - -## win notifications -- `win_notifications` - total number of win notifications. -- `win_requests` - total number of requests sent to user service for win notifications. -- `win_request_preparation_failed` - number of request failed validation and were not sent. -- `win_request_time` - latency between request to user service and response for win notifications. -- `win_request_failed` - number of failed request sent to user service for win notifications. -- `win_request_successful` - number of successful request sent to user service for win notifications. - -## user details -- `user_details_requests` - total number of requests sent to user service to get user details. -- `user_details_request_preparation_failed` - number of request failed validation and were not sent. -- `user_details_request_time` - latency between request to user service and response to get user details. -- `user_details_request_failed` - number of failed request sent to user service to get user details. -- `user_details_request_successful` - number of successful request sent to user service to get user details. - -## Programmatic guaranteed metrics -- `pg.planner_lineitems_received` - number of line items received from general planner. -- `pg.planner_requests` - total number of requests sent to general planner. -- `pg.planner_request_failed` - number of failed request sent to general planner. -- `pg.planner_request_successful` - number of successful requests sent to general planner. -- `pg.planner_request_time` - latency between request to general planner and its successful (200 OK) response. -- `pg.delivery_requests` - total number of requests to delivery stats service. -- `pg.delivery_request_failed` - number of failed requests to delivery stats service. -- `pg.delivery_request_successful` - number of successful requests to delivery stats service. -- `pg.delivery_request_time` - latency between request to delivery stats and its successful (200 OK) response. diff --git a/src/main/java/org/prebid/server/analytics/model/NotificationEvent.java b/src/main/java/org/prebid/server/analytics/model/NotificationEvent.java index 090dd818f07..9bbfdc88845 100644 --- a/src/main/java/org/prebid/server/analytics/model/NotificationEvent.java +++ b/src/main/java/org/prebid/server/analytics/model/NotificationEvent.java @@ -20,8 +20,6 @@ public class NotificationEvent { Account account; - String lineItemId; - String bidder; Long timestamp; diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index 30aed97692f..c1ccc7922f9 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -46,8 +46,6 @@ import org.prebid.server.cache.model.CacheInfo; import org.prebid.server.cache.model.CacheServiceResult; import org.prebid.server.cache.model.DebugHttpCall; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.events.EventsContext; import org.prebid.server.events.EventsService; import org.prebid.server.exception.InvalidRequestException; @@ -61,7 +59,6 @@ import org.prebid.server.identity.IdGeneratorType; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.request.ExtImp; import org.prebid.server.proto.openrtb.ext.request.ExtImpAuctionEnvironment; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; @@ -81,13 +78,11 @@ import org.prebid.server.proto.openrtb.ext.response.ExtBidResponseFledge; import org.prebid.server.proto.openrtb.ext.response.ExtBidResponsePrebid; import org.prebid.server.proto.openrtb.ext.response.ExtBidderError; -import org.prebid.server.proto.openrtb.ext.response.ExtDebugPgmetrics; import org.prebid.server.proto.openrtb.ext.response.ExtDebugTrace; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.ExtResponseCache; import org.prebid.server.proto.openrtb.ext.response.ExtResponseDebug; import org.prebid.server.proto.openrtb.ext.response.ExtTraceActivityInfrastructure; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import org.prebid.server.proto.openrtb.ext.response.seatnonbid.NonBid; import org.prebid.server.proto.openrtb.ext.response.seatnonbid.SeatNonBid; @@ -98,7 +93,6 @@ import org.prebid.server.settings.model.AccountEventsConfig; import org.prebid.server.settings.model.AccountTargetingConfig; import org.prebid.server.settings.model.VideoStoredDataResult; -import org.prebid.server.util.LineItemUtil; import org.prebid.server.util.StreamUtil; import org.prebid.server.vast.VastModifier; @@ -190,42 +184,40 @@ Future create(AuctionContext auctionContext, BidRequestCacheInfo cacheInfo, Map bidderToMultiBids) { - final List auctionParticipations = auctionContext.getAuctionParticipations(); - final List imps = auctionContext.getBidRequest().getImp(); + return videoStoredDataResult(auctionContext) + .compose(videoStoredData -> create(videoStoredData, auctionContext, cacheInfo, bidderToMultiBids)) + .map(bidResponse -> populateSeatNonBid(auctionContext, bidResponse)); + } + + private Future create(VideoStoredDataResult videoStoredDataResult, + AuctionContext auctionContext, + BidRequestCacheInfo cacheInfo, + Map bidderToMultiBids) { + final EventsContext eventsContext = createEventsContext(auctionContext); - final List bidderResponses = auctionParticipations.stream() + final List bidderResponses = auctionContext.getAuctionParticipations().stream() .filter(auctionParticipation -> !auctionParticipation.isRequestBlocked()) .map(AuctionParticipation::getBidderResponse) .toList(); - return videoStoredDataResult(auctionContext).compose(videoStoredDataResult -> - invokeProcessedBidderResponseHooks( - updateBids(bidderResponses, videoStoredDataResult, auctionContext, eventsContext, imps), - auctionContext) - - .compose(updatedResponses -> - invokeAllProcessedBidResponsesHook(updatedResponses, auctionContext)) - - .compose(updatedResponses -> - createCategoryMapping(auctionContext, updatedResponses)) - - .compose(categoryMappingResult -> cacheBidsAndCreateResponse( - toBidderResponseInfos(categoryMappingResult, imps), - auctionContext, - cacheInfo, - bidderToMultiBids, - videoStoredDataResult, - eventsContext)) - - .map(bidResponse -> populateSeatNonBid(auctionContext, bidResponse))); + return updateBids(bidderResponses, videoStoredDataResult, auctionContext, eventsContext) + .compose(updatedResponses -> invokeProcessedBidderResponseHooks(updatedResponses, auctionContext)) + .compose(updatedResponses -> invokeAllProcessedBidResponsesHook(updatedResponses, auctionContext)) + .compose(updatedResponses -> createCategoryMapping(auctionContext, updatedResponses)) + .compose(categoryMappingResult -> cacheBidsAndCreateResponse( + toBidderResponseInfos(categoryMappingResult, auctionContext.getBidRequest().getImp()), + auctionContext, + cacheInfo, + bidderToMultiBids, + videoStoredDataResult, + eventsContext)); } - private List updateBids(List bidderResponses, - VideoStoredDataResult videoStoredDataResult, - AuctionContext auctionContext, - EventsContext eventsContext, - List imps) { + private Future> updateBids(List bidderResponses, + VideoStoredDataResult videoStoredDataResult, + AuctionContext auctionContext, + EventsContext eventsContext) { final List result = new ArrayList<>(); @@ -238,12 +230,8 @@ private List updateBids(List bidderResponses, final Bid receivedBid = bidderBid.getBid(); final BidType bidType = bidderBid.getType(); - final Imp correspondingImp = correspondingImp(receivedBid, imps); - final ExtDealLine extDealLine = LineItemUtil.extDealLineFrom(receivedBid, correspondingImp, mapper); - final String lineItemId = extDealLine != null ? extDealLine.getLineItemId() : null; - final Bid updatedBid = updateBid( - receivedBid, bidType, bidder, videoStoredDataResult, auctionContext, eventsContext, lineItemId); + receivedBid, bidType, bidder, videoStoredDataResult, auctionContext, eventsContext); modifiedBidderBids.add(bidderBid.toBuilder().bid(updatedBid).build()); } @@ -251,7 +239,7 @@ private List updateBids(List bidderResponses, result.add(bidderResponse.with(modifiedSeatBid)); } - return result; + return Future.succeededFuture(result); } private Bid updateBid(Bid bid, @@ -259,8 +247,7 @@ private Bid updateBid(Bid bid, String bidder, VideoStoredDataResult videoStoredDataResult, AuctionContext auctionContext, - EventsContext eventsContext, - String lineItemId) { + EventsContext eventsContext) { final Account account = auctionContext.getAccount(); final List debugWarnings = auctionContext.getDebugWarnings(); @@ -277,8 +264,7 @@ private Bid updateBid(Bid bid, account, eventsContext, effectiveBidId, - debugWarnings, - lineItemId)) + debugWarnings)) .ext(updateBidExt( bid, bidType, @@ -287,8 +273,7 @@ private Bid updateBid(Bid bid, videoStoredDataResult, eventsContext, generatedBidId, - effectiveBidId, - lineItemId)) + effectiveBidId)) .build(); } @@ -298,8 +283,7 @@ private String updateBidAdm(Bid bid, Account account, EventsContext eventsContext, String effectiveBidId, - List debugWarnings, - String lineItemId) { + List debugWarnings) { final String bidAdm = bid.getAdm(); return BidType.video.equals(bidType) @@ -310,8 +294,7 @@ private String updateBidAdm(Bid bid, effectiveBidId, account.getId(), eventsContext, - debugWarnings, - lineItemId) + debugWarnings) : bidAdm; } @@ -322,8 +305,7 @@ private ObjectNode updateBidExt(Bid bid, VideoStoredDataResult videoStoredDataResult, EventsContext eventsContext, String generatedBidId, - String effectiveBidId, - String lineItemId) { + String effectiveBidId) { final ExtBidPrebid updatedExtBidPrebid = updateBidExtPrebid( bid, @@ -333,8 +315,7 @@ private ObjectNode updateBidExt(Bid bid, videoStoredDataResult, eventsContext, generatedBidId, - effectiveBidId, - lineItemId); + effectiveBidId); final ObjectNode existingBidExt = bid.getExt(); final ObjectNode updatedBidExt = mapper.mapper().createObjectNode(); @@ -355,11 +336,10 @@ private ExtBidPrebid updateBidExtPrebid(Bid bid, VideoStoredDataResult videoStoredDataResult, EventsContext eventsContext, String generatedBidId, - String effectiveBidId, - String lineItemId) { + String effectiveBidId) { final Video storedVideo = videoStoredDataResult.getImpIdToStoredVideo().get(bid.getImpid()); - final Events events = createEvents(bidder, account, effectiveBidId, eventsContext, lineItemId); + final Events events = createEvents(bidder, account, effectiveBidId, eventsContext); final ExtBidPrebidVideo extBidPrebidVideo = getExtBidPrebidVideo(bid.getExt()).orElse(null); final ExtBidPrebid.ExtBidPrebidBuilder extBidPrebidBuilder = getExtPrebid(bid.getExt(), ExtBidPrebid.class) @@ -422,16 +402,11 @@ private BidInfo toBidInfo(Bid bid, String bidder, CategoryMappingResult categoryMappingResult) { - final Imp correspondingImp = correspondingImp(bid, imps); - final ExtDealLine extDealLine = LineItemUtil.extDealLineFrom(bid, correspondingImp, mapper); - final String lineItemId = extDealLine != null ? extDealLine.getLineItemId() : null; - return BidInfo.builder() .bid(bid) .bidType(type) .bidder(bidder) - .correspondingImp(correspondingImp) - .lineItemId(lineItemId) + .correspondingImp(correspondingImp(bid, imps)) .category(categoryMappingResult.getCategory(bid)) .satisfiedPriority(categoryMappingResult.isBidSatisfiesPriority(bid)) .build(); @@ -474,12 +449,11 @@ private static BidderResponse rejectBidderResponseOrProceed( HookStageExecutionResult stageResult, BidderResponse bidderResponse) { - final List bids = - stageResult.isShouldReject() ? Collections.emptyList() : stageResult.getPayload().bids(); + final List bids = stageResult.isShouldReject() + ? Collections.emptyList() + : stageResult.getPayload().bids(); - return bidderResponse - .with(bidderResponse.getSeatBid() - .with(bids)); + return bidderResponse.with(bidderResponse.getSeatBid().with(bids)); } private Future createCategoryMapping(AuctionContext auctionContext, @@ -535,10 +509,9 @@ private Future cacheBidsAndCreateResponse(List } final ExtRequestTargeting targeting = targeting(bidRequest); - final TxnLog txnLog = auctionContext.getTxnLog(); final List bidderResponseInfos = toBidderResponseWithTargetingBidInfos( - bidderResponses, bidderToMultiBids, preferDeals(targeting), txnLog); + bidderResponses, bidderToMultiBids, preferDeals(targeting)); final Set bidInfos = bidderResponseInfos.stream() .map(BidderResponseInfo::getSeatBid) @@ -553,8 +526,6 @@ private Future cacheBidsAndCreateResponse(List .filter(bidInfo -> bidInfo.getTargetingInfo().isWinningBid()) .collect(Collectors.toSet()); - updateSentToClientTxnLog(txnLog, bidInfos); - final Set bidsToCache = cacheInfo.isShouldCacheWinningBidsOnly() ? winningBidInfos : bidInfos; return cacheBids(bidsToCache, auctionContext, cacheInfo, eventsContext) @@ -581,8 +552,7 @@ private static boolean preferDeals(ExtRequestTargeting targeting) { private List toBidderResponseWithTargetingBidInfos( List bidderResponses, Map bidderToMultiBids, - boolean preferDeals, - TxnLog txnLog) { + boolean preferDeals) { final Map> bidderResponseToReducedBidInfos = bidderResponses.stream() .collect(Collectors.toMap( @@ -611,13 +581,6 @@ private List toBidderResponseWithTargetingBidInfos( .ifPresent(winningBids::add); } - final Map> impIdToLineItemIds = impIdToBidderToBidInfos.entrySet().stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - impIdToBidderToBidInfoEntry -> toLineItemIds(impIdToBidderToBidInfoEntry.getValue().values()))); - - updateTopMatchAndLostAuctionLineItemsMetric(winningBids, txnLog, impIdToLineItemIds); - return bidderResponseToReducedBidInfos.entrySet().stream() .map(responseToBidInfos -> injectBidInfoWithTargeting( responseToBidInfos.getKey(), @@ -652,33 +615,6 @@ private List sortReducedBidInfo(List bidInfos, int limit, bool .toList(); } - private static Set toLineItemIds(Collection> bidInfos) { - return bidInfos.stream() - .flatMap(Collection::stream) - .map(BidInfo::getLineItemId) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); - } - - /** - * Updates sent to client as top match and auction lost to line item metric. - */ - private static void updateTopMatchAndLostAuctionLineItemsMetric(Set winningBidInfos, - TxnLog txnLog, - Map> impToLineItemIds) { - for (BidInfo winningBidInfo : winningBidInfos) { - final String winningLineItemId = winningBidInfo.getLineItemId(); - if (winningLineItemId != null) { - txnLog.lineItemSentToClientAsTopMatch().add(winningLineItemId); - - final String impIdOfWinningBid = winningBidInfo.getBid().getImpid(); - impToLineItemIds.get(impIdOfWinningBid).stream() - .filter(lineItemId -> !Objects.equals(lineItemId, winningLineItemId)) - .forEach(lineItemId -> txnLog.lostAuctionToLineItems().get(lineItemId).add(winningLineItemId)); - } - } - } - private static BidderResponseInfo injectBidInfoWithTargeting(BidderResponseInfo bidderResponseInfo, List bidderBidInfos, Map bidderToMultiBids, @@ -744,16 +680,6 @@ private static List injectTargeting(List bidderImpIdBidInfos, return result; } - /** - * Increments sent to client metrics for each bid with deal. - */ - private static void updateSentToClientTxnLog(TxnLog txnLog, Set bidInfos) { - bidInfos.stream() - .map(BidInfo::getLineItemId) - .filter(Objects::nonNull) - .forEach(lineItemId -> txnLog.lineItemsSentToClient().add(lineItemId)); - } - /** * Returns {@link ExtBidResponse} object, populated with response time, errors and debug info (if requested) * from all bidders. @@ -853,13 +779,10 @@ private static ExtResponseDebug toExtResponseDebug(List bidd : null; final BidRequest bidRequest = debugEnabled ? auctionContext.getBidRequest() : null; - - final ExtDebugPgmetrics extDebugPgmetrics = debugEnabled ? toExtDebugPgmetrics( - auctionContext.getTxnLog()) : null; final ExtDebugTrace extDebugTrace = toExtDebugTrace(auctionContext); - return ObjectUtils.anyNotNull(httpCalls, bidRequest, extDebugPgmetrics, extDebugTrace) - ? ExtResponseDebug.of(httpCalls, bidRequest, extDebugPgmetrics, extDebugTrace) + return ObjectUtils.anyNotNull(httpCalls, bidRequest, extDebugTrace) + ? ExtResponseDebug.of(httpCalls, bidRequest, extDebugTrace) : null; } @@ -963,54 +886,16 @@ private static ExtHttpCall toExtHttpCall(DebugHttpCall debugHttpCall) { .build(); } - private static ExtDebugPgmetrics toExtDebugPgmetrics(TxnLog txnLog) { - final ExtDebugPgmetrics extDebugPgmetrics = ExtDebugPgmetrics.builder() - .matchedDomainTargeting(nullIfEmpty(txnLog.lineItemsMatchedDomainTargeting())) - .matchedWholeTargeting(nullIfEmpty(txnLog.lineItemsMatchedWholeTargeting())) - .matchedTargetingFcapped(nullIfEmpty(txnLog.lineItemsMatchedTargetingFcapped())) - .matchedTargetingFcapLookupFailed(nullIfEmpty(txnLog.lineItemsMatchedTargetingFcapLookupFailed())) - .readyToServe(nullIfEmpty(txnLog.lineItemsReadyToServe())) - .pacingDeferred(nullIfEmpty(txnLog.lineItemsPacingDeferred())) - .sentToBidder(nullIfEmpty(txnLog.lineItemsSentToBidder())) - .sentToBidderAsTopMatch(nullIfEmpty(txnLog.lineItemsSentToBidderAsTopMatch())) - .receivedFromBidder(nullIfEmpty(txnLog.lineItemsReceivedFromBidder())) - .responseInvalidated(nullIfEmpty(txnLog.lineItemsResponseInvalidated())) - .sentToClient(nullIfEmpty(txnLog.lineItemsSentToClient())) - .sentToClientAsTopMatch(nullIfEmpty(txnLog.lineItemSentToClientAsTopMatch())) - .build(); - return extDebugPgmetrics.equals(ExtDebugPgmetrics.EMPTY) ? null : extDebugPgmetrics; - } - private static ExtDebugTrace toExtDebugTrace(AuctionContext auctionContext) { - final DeepDebugLog deepDebugLog = auctionContext.getDeepDebugLog(); - - final boolean dealsTraceEnabled = deepDebugLog.isDeepDebugEnabled(); - final boolean activityInfrastructureTraceEnabled = auctionContext.getDebugContext().getTraceLevel() != null; - if (!dealsTraceEnabled && !activityInfrastructureTraceEnabled) { + if (auctionContext.getDebugContext().getTraceLevel() == null) { return null; } - final List entries = dealsTraceEnabled ? deepDebugLog.entries() : null; - final List dealsTrace = dealsTraceEnabled - ? entries.stream() - .filter(extTraceDeal -> StringUtils.isEmpty(extTraceDeal.getLineItemId())) - .toList() - : null; - final Map> lineItemsTrace = dealsTraceEnabled - ? entries.stream() - .filter(extTraceDeal -> StringUtils.isNotEmpty(extTraceDeal.getLineItemId())) - .collect(Collectors.groupingBy(ExtTraceDeal::getLineItemId, Collectors.toList())) - : null; - - final List activityInfrastructureTrace = activityInfrastructureTraceEnabled - ? new ArrayList<>(auctionContext.getActivityInfrastructure().debugTrace()) - : null; + final List activityInfrastructureTrace = + new ArrayList<>(auctionContext.getActivityInfrastructure().debugTrace()); - return CollectionUtils.isNotEmpty(entries) || CollectionUtils.isNotEmpty(activityInfrastructureTrace) - ? ExtDebugTrace.of( - CollectionUtils.isEmpty(dealsTrace) ? null : dealsTrace, - MapUtils.isEmpty(lineItemsTrace) ? null : lineItemsTrace, - CollectionUtils.isEmpty(activityInfrastructureTrace) ? null : activityInfrastructureTrace) + return CollectionUtils.isNotEmpty(activityInfrastructureTrace) + ? ExtDebugTrace.of(activityInfrastructureTrace) : null; } @@ -1160,6 +1045,7 @@ private static Map> toExtBidderWarnings( List bidderResponses, AuctionContext auctionContext, Map> bidWarnings) { + final Map> warnings = new HashMap<>(); warnings.putAll(extractContextWarnings(auctionContext)); @@ -1598,20 +1484,14 @@ private static String integrationFrom(AuctionContext auctionContext) { private Events createEvents(String bidder, Account account, String bidId, - EventsContext eventsContext, - String lineItemId) { + EventsContext eventsContext) { - if (!eventsContext.isEnabledForAccount()) { - return null; - } - - return eventsContext.isEnabledForRequest() || StringUtils.isNotEmpty(lineItemId) + return eventsContext.isEnabledForAccount() && eventsContext.isEnabledForRequest() ? eventsService.createEvent( bidId, bidder, account.getId(), - lineItemId, - eventsContext.isEnabledForRequest(), + true, eventsContext) : null; } @@ -1824,13 +1704,6 @@ private static Set nullIfEmpty(Set set) { return Collections.unmodifiableSet(set); } - private static Map nullIfEmpty(Map map) { - if (map.isEmpty()) { - return null; - } - return Collections.unmodifiableMap(map); - } - /** * Creates {@link ExtBidPrebidVideo} from bid extension. */ diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index 43b2515c2a6..967046d3ae8 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -8,7 +8,6 @@ import com.iab.openrtb.request.App; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Content; -import com.iab.openrtb.request.Deal; import com.iab.openrtb.request.Dooh; import com.iab.openrtb.request.Eid; import com.iab.openrtb.request.Imp; @@ -60,9 +59,6 @@ import org.prebid.server.bidder.model.BidderSeatBid; import org.prebid.server.cookie.UidsCookie; import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.DealsService; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; @@ -125,7 +121,6 @@ import org.prebid.server.proto.openrtb.ext.response.ExtModulesTraceStageOutcome; import org.prebid.server.settings.model.Account; import org.prebid.server.util.HttpUtil; -import org.prebid.server.util.LineItemUtil; import org.prebid.server.util.ObjectUtil; import org.prebid.server.util.StreamUtil; import org.prebid.server.validation.ResponseBidValidator; @@ -146,9 +141,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; -import java.util.function.Supplier; import java.util.stream.Collectors; -import java.util.stream.IntStream; import java.util.stream.Stream; /** @@ -173,7 +166,6 @@ public class ExchangeService { private final double logSamplingRate; private final BidderCatalog bidderCatalog; private final StoredResponseProcessor storedResponseProcessor; - private final DealsService dealsService; private final PrivacyEnforcementService privacyEnforcementService; private final FpdResolver fpdResolver; private final SupplyChainResolver supplyChainResolver; @@ -187,7 +179,6 @@ public class ExchangeService { private final ResponseBidValidator responseBidValidator; private final CurrencyConversionService currencyService; private final BidResponseCreator bidResponseCreator; - private final ApplicationEventService applicationEventService; private final BidResponsePostProcessor bidResponsePostProcessor; private final HookStageExecutor hookStageExecutor; private final HttpInteractionLogger httpInteractionLogger; @@ -204,7 +195,6 @@ public class ExchangeService { public ExchangeService(double logSamplingRate, BidderCatalog bidderCatalog, StoredResponseProcessor storedResponseProcessor, - DealsService dealsService, PrivacyEnforcementService privacyEnforcementService, FpdResolver fpdResolver, SupplyChainResolver supplyChainResolver, @@ -220,7 +210,6 @@ public ExchangeService(double logSamplingRate, BidResponseCreator bidResponseCreator, BidResponsePostProcessor bidResponsePostProcessor, HookStageExecutor hookStageExecutor, - ApplicationEventService applicationEventService, HttpInteractionLogger httpInteractionLogger, PriceFloorAdjuster priceFloorAdjuster, PriceFloorEnforcer priceFloorEnforcer, @@ -235,7 +224,6 @@ public ExchangeService(double logSamplingRate, this.logSamplingRate = logSamplingRate; this.bidderCatalog = Objects.requireNonNull(bidderCatalog); this.storedResponseProcessor = Objects.requireNonNull(storedResponseProcessor); - this.dealsService = dealsService; this.privacyEnforcementService = Objects.requireNonNull(privacyEnforcementService); this.fpdResolver = Objects.requireNonNull(fpdResolver); this.supplyChainResolver = Objects.requireNonNull(supplyChainResolver); @@ -251,7 +239,6 @@ public ExchangeService(double logSamplingRate, this.bidResponseCreator = Objects.requireNonNull(bidResponseCreator); this.bidResponsePostProcessor = Objects.requireNonNull(bidResponsePostProcessor); this.hookStageExecutor = Objects.requireNonNull(hookStageExecutor); - this.applicationEventService = applicationEventService; this.httpInteractionLogger = Objects.requireNonNull(httpInteractionLogger); this.priceFloorAdjuster = Objects.requireNonNull(priceFloorAdjuster); this.priceFloorEnforcer = Objects.requireNonNull(priceFloorEnforcer); @@ -302,11 +289,8 @@ private Future runAuction(AuctionContext receivedContext) { return storedResponseProcessor.getStoredResponseResult(bidRequest.getImp(), timeout) .map(storedResponseResult -> populateStoredResponse(storedResponseResult, storedAuctionResponses)) .compose(storedResponseResult -> extractAuctionParticipations( - receivedContext, storedResponseResult, aliases, bidderToMultiBid)) - - .map(auctionParticipations -> matchAndPopulateDeals(auctionParticipations, aliases, receivedContext)) - .map(auctionParticipations -> postProcessDeals(auctionParticipations, receivedContext)) - .map(auctionParticipations -> fillContext(receivedContext, auctionParticipations)) + receivedContext, storedResponseResult, aliases, bidderToMultiBid) + .map(receivedContext::with)) .map(context -> updateRequestMetric(context, uidsCookie, aliases, account, requestTypeMetric)) @@ -330,9 +314,11 @@ private Future runAuction(AuctionContext receivedContext) { .map(context::with)) // produce response from bidder results .compose(context -> bidResponseCreator.create(context, cacheInfo, bidderToMultiBid) - .map(bidResponse -> publishAuctionEvent(bidResponse, context)) - .map(bidResponse -> criteriaLogManager.traceResponse(logger, bidResponse, - context.getBidRequest(), context.getDebugContext().isDebugEnabled())) + .map(bidResponse -> criteriaLogManager.traceResponse( + logger, + bidResponse, + context.getBidRequest(), + context.getDebugContext().isDebugEnabled())) .compose(bidResponse -> bidResponsePostProcessor.postProcess( context.getHttpRequest(), uidsCookie, bidRequest, bidResponse, account)) .map(context::with)); @@ -538,8 +524,13 @@ private Future> extractAuctionParticipations( final Map> impBidderToStoredBidResponse = storedResponseResult.getImpBidderToStoredBidResponse(); - return makeAuctionParticipation(bidders, context, aliases, impBidderToStoredBidResponse, - imps, bidderToMultiBid); + return makeAuctionParticipation( + bidders, + context, + aliases, + impBidderToStoredBidResponse, + imps, + bidderToMultiBid); } private Set bidderNamesFromImpExt(Imp imp, BidderAliases aliases) { @@ -603,9 +594,15 @@ private Future> makeAuctionParticipation( prepareUsers(bidders, context, aliases, biddersToConfigs, eidPermissions); return privacyEnforcementService.mask(context, bidderToUser, aliases) - .map(bidderToPrivacyResult -> - getAuctionParticipation(bidderToPrivacyResult, bidRequest, impBidderToStoredResponse, imps, - bidderToMultiBid, biddersToConfigs, aliases, context)); + .map(bidderToPrivacyResult -> getAuctionParticipation( + bidderToPrivacyResult, + bidRequest, + impBidderToStoredResponse, + imps, + bidderToMultiBid, + biddersToConfigs, + aliases, + context)); } private Map getBiddersToConfigs(ExtRequestPrebid prebid) { @@ -1219,32 +1216,6 @@ private ObjectNode prepareBidderParameters(ExtRequestPrebid prebid, String bidde return params != null ? mapper.mapper().createObjectNode().set(bidder, params) : null; } - private List matchAndPopulateDeals(List auctionParticipants, - BidderAliases aliases, - AuctionContext context) { - - if (dealsService == null) { - return auctionParticipants; - } - - final List updatedBidderRequests = auctionParticipants.stream() - .map(auctionParticipation -> !auctionParticipation.isRequestBlocked() - ? dealsService.matchAndPopulateDeals(auctionParticipation.getBidderRequest(), aliases, context) - : null) - .toList(); - - return IntStream.range(0, auctionParticipants.size()) - .mapToObj(i -> auctionParticipants.get(i).toBuilder() - .bidderRequest(updatedBidderRequests.get(i)) - .build()) - .toList(); - } - - private static List postProcessDeals(List auctionParticipations, - AuctionContext context) { - return DealsService.removePgDealsOnlyImpsWithoutDeals(auctionParticipations, context); - } - /** * Updates 'account.*.request', 'request' and 'no_cookie_requests' metrics for each {@link AuctionParticipation} . */ @@ -1278,26 +1249,6 @@ private AuctionContext updateRequestMetric(AuctionContext context, return context; } - private static AuctionContext fillContext(AuctionContext context, - List auctionParticipations) { - - final Map> impIdToDeals = new HashMap<>(); - auctionParticipations.stream() - .map(AuctionParticipation::getBidderRequest) - .map(BidderRequest::getImpIdToDeals) - .filter(Objects::nonNull) - .map(Map::entrySet) - .flatMap(Collection::stream) - .forEach(entry -> impIdToDeals - .computeIfAbsent(entry.getKey(), key -> new ArrayList<>()) - .addAll(entry.getValue())); - - return context.toBuilder() - .bidRequest(DealsService.populateDeals(context.getBidRequest(), impIdToDeals)) - .auctionParticipations(auctionParticipations) - .build(); - } - private Future processAndRequestBids(AuctionContext auctionContext, BidderRequest bidderRequest, Timeout timeout, @@ -1514,13 +1465,8 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar final List bids = seatBid.getBids(); final List validBids = new ArrayList<>(bids.size()); - final TxnLog txnLog = auctionContext.getTxnLog(); - final String bidder = bidderResponse.getBidder(); for (final BidderBid bid : bids) { - final String lineItemId = LineItemUtil.lineItemIdFrom(bid.getBid(), bidRequest.getImp(), mapper); - maybeRecordInTxnLog(lineItemId, () -> txnLog.lineItemsReceivedFromBidder().get(bidder)); - final ValidationResult validationResult = responseBidValidator.validate( bid, bidderResponse.getBidder(), @@ -1531,11 +1477,6 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar errors.add(makeValidationBidderError(bid.getBid(), validationResult)); } - if (validationResult.hasErrors()) { - maybeRecordInTxnLog(lineItemId, txnLog::lineItemsResponseInvalidated); - continue; - } - if (!validationResult.hasErrors()) { validBids.add(bid); } @@ -1562,19 +1503,6 @@ private BidderError makeValidationBidderError(Bid bid, ValidationResult validati return BidderError.invalidBid("BidId `" + bidId + "` validation messages: " + validationErrors); } - private static void maybeRecordInTxnLog(String lineItemId, Supplier> metricSupplier) { - if (lineItemId != null) { - metricSupplier.get().add(lineItemId); - } - } - - private BidResponse publishAuctionEvent(BidResponse bidResponse, AuctionContext auctionContext) { - if (applicationEventService != null) { - applicationEventService.publishAuctionEvent(auctionContext); - } - return bidResponse; - } - /** * Performs changes on {@link Bid}s price depends on different between adServerCurrency and bidCurrency, * and adjustment factor. Will drop bid if currency conversion is needed but not possible. @@ -1716,8 +1644,8 @@ private List updateResponsesMetrics(List WINNING_BID_PRICE_COMPARATOR = new WinningBidPriceComparator(); private static final Comparator WINNING_BID_DEAL_COMPARATOR = new WinningBidDealComparator(); - private static final Comparator WINNING_BID_PG_COMPARATOR = new WinningBidPgComparator(); - private static final Comparator BID_INFO_COMPARATOR = WINNING_BID_PG_COMPARATOR - .thenComparing(WINNING_BID_DEAL_COMPARATOR) + private static final Comparator BID_INFO_COMPARATOR = WINNING_BID_DEAL_COMPARATOR .thenComparing(WINNING_BID_PRICE_COMPARATOR); - private static final Comparator PREFER_PRICE_COMPARATOR = WINNING_BID_PG_COMPARATOR - .thenComparing(WINNING_BID_PRICE_COMPARATOR); + private static final Comparator PREFER_PRICE_COMPARATOR = WINNING_BID_PRICE_COMPARATOR; public Comparator create(boolean preferDeals) { return preferDeals @@ -43,63 +35,9 @@ private static class WinningBidDealComparator implements Comparator { @Override public int compare(BidInfo bidInfo1, BidInfo bidInfo2) { - final boolean isPresentBidDealId1 = bidInfo1.getBid().getDealid() != null; - final boolean isPresentBidDealId2 = bidInfo2.getBid().getDealid() != null; - - if (!Boolean.logicalXor(isPresentBidDealId1, isPresentBidDealId2)) { - return 0; - } - - return isPresentBidDealId1 ? 1 : -1; - } - } - - /** - * Compares two {@link BidInfo} arguments for order based on PG deal priority. - * Returns negative integer when first does not have a pg deal and second has, or when both have a pg deal, - * but first has higher index in deals array that means lower priority. - * Returns positive integer when first has a pg deal and second does not, or when both have a pg deal, - * but first has lower index in deals array that means higher priority. - * Returns zero when both dont have pg deals. - */ - private static class WinningBidPgComparator implements Comparator { - - private final Comparator dealIndexComparator = Comparator.comparingInt(Integer::intValue).reversed(); - - @Override - public int compare(BidInfo bidInfo1, BidInfo bidInfo2) { - final Imp imp = bidInfo1.getCorrespondingImp(); - final Pmp pmp = imp.getPmp(); - final List impDeals = pmp != null ? pmp.getDeals() : null; - - if (CollectionUtils.isEmpty(impDeals)) { - return 0; - } - - final Bid bid1 = bidInfo1.getBid(); - final Bid bid2 = bidInfo2.getBid(); - - int indexOfBidDealId1 = -1; - int indexOfBidDealId2 = -1; - - // search for indexes of deals - for (int i = 0; i < impDeals.size(); i++) { - final String dealId = impDeals.get(i).getId(); - if (Objects.equals(dealId, bid1.getDealid())) { - indexOfBidDealId1 = i; - } - if (Objects.equals(dealId, bid2.getDealid())) { - indexOfBidDealId2 = i; - } - } - - final boolean isPresentImpDealId1 = indexOfBidDealId1 != -1; - final boolean isPresentImpDealId2 = indexOfBidDealId2 != -1; - - final boolean isOneOrBothDealIdNotPresent = !isPresentImpDealId1 || !isPresentImpDealId2; - return isOneOrBothDealIdNotPresent - ? isPresentImpDealId1 ? 1 : -1 // case when no deal IDs found is covered by response validator - : dealIndexComparator.compare(indexOfBidDealId1, indexOfBidDealId2); + final int bidDeal1Weight = bidInfo1.getBid().getDealid() != null ? 1 : 0; + final int bidDeal2Weight = bidInfo2.getBid().getDealid() != null ? 1 : 0; + return bidDeal1Weight - bidDeal2Weight; } } diff --git a/src/main/java/org/prebid/server/auction/model/AuctionContext.java b/src/main/java/org/prebid/server/auction/model/AuctionContext.java index a4c8087f0c7..2012897f44f 100644 --- a/src/main/java/org/prebid/server/auction/model/AuctionContext.java +++ b/src/main/java/org/prebid/server/auction/model/AuctionContext.java @@ -10,8 +10,6 @@ import org.prebid.server.auction.model.debug.DebugContext; import org.prebid.server.cache.model.DebugHttpCall; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.geolocation.model.GeoInfo; import org.prebid.server.hooks.execution.model.HookExecutionContext; import org.prebid.server.metric.MetricName; @@ -69,12 +67,6 @@ public class AuctionContext { boolean requestRejected; - @JsonIgnore - TxnLog txnLog; - - @JsonIgnore - DeepDebugLog deepDebugLog; - CachedDebugLog cachedDebugLog; public AuctionContext with(Account account) { diff --git a/src/main/java/org/prebid/server/auction/model/BidInfo.java b/src/main/java/org/prebid/server/auction/model/BidInfo.java index 025de675be2..2b0c452fa88 100644 --- a/src/main/java/org/prebid/server/auction/model/BidInfo.java +++ b/src/main/java/org/prebid/server/auction/model/BidInfo.java @@ -25,10 +25,6 @@ public class BidInfo { CacheInfo cacheInfo; - String lineItemId; - - String lineItemSource; - TargetingInfo targetingInfo; String category; diff --git a/src/main/java/org/prebid/server/auction/model/BidderRequest.java b/src/main/java/org/prebid/server/auction/model/BidderRequest.java index 1d18519a0f8..ad60230e54b 100644 --- a/src/main/java/org/prebid/server/auction/model/BidderRequest.java +++ b/src/main/java/org/prebid/server/auction/model/BidderRequest.java @@ -1,14 +1,10 @@ package org.prebid.server.auction.model; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; import lombok.Builder; import lombok.Value; import org.prebid.server.auction.versionconverter.OrtbVersion; -import java.util.List; -import java.util.Map; - @Builder(toBuilder = true) @Value public class BidderRequest { @@ -19,8 +15,6 @@ public class BidderRequest { String storedResponse; - Map> impIdToDeals; - BidRequest bidRequest; public BidderRequest with(BidRequest bidRequest) { diff --git a/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java index 433584f8aa4..76c8b921196 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java @@ -170,11 +170,9 @@ public Future fromRequest(RoutingContext routingContext, long st .compose(auctionContext -> ortb2RequestFactory.executeProcessedAuctionRequestHooks(auctionContext) .map(auctionContext::with)) - .compose(ortb2RequestFactory::populateUserAdditionalInfo) - .map(ortb2RequestFactory::enrichWithPriceFloors) - .map(auctionContext -> ortb2RequestFactory.updateTimeout(auctionContext, startTime)) + .map(ortb2RequestFactory::updateTimeout) .recover(ortb2RequestFactory::restoreResultFromRejection); } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/AuctionRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/AuctionRequestFactory.java index 95f5768c523..1e0369b75b1 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/AuctionRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/AuctionRequestFactory.java @@ -100,7 +100,6 @@ public Future fromRequest(RoutingContext routingContext, long st return ortb2RequestFactory.executeEntrypointHooks(routingContext, body, initialAuctionContext) .compose(httpRequest -> parseBidRequest(httpRequest, initialAuctionContext.getPrebidErrors()) - .map(bidRequest -> ortb2RequestFactory .enrichAuctionContext(initialAuctionContext, httpRequest, bidRequest, startTime) .with(requestTypeMetric(bidRequest)))) @@ -137,11 +136,9 @@ public Future fromRequest(RoutingContext routingContext, long st .compose(auctionContext -> ortb2RequestFactory.executeProcessedAuctionRequestHooks(auctionContext) .map(auctionContext::with)) - .compose(ortb2RequestFactory::populateUserAdditionalInfo) - .map(ortb2RequestFactory::enrichWithPriceFloors) - .map(auctionContext -> ortb2RequestFactory.updateTimeout(auctionContext, startTime)) + .map(ortb2RequestFactory::updateTimeout) .recover(ortb2RequestFactory::restoreResultFromRejection); } @@ -226,14 +223,12 @@ private Regs fillRegsWithValuesFromHttpRequest(Regs regs, HttpRequestContext htt */ private Future updateAndValidateBidRequest(AuctionContext auctionContext) { final Account account = auctionContext.getAccount(); + final HttpRequestContext httpRequest = auctionContext.getHttpRequest(); final List debugWarnings = auctionContext.getDebugWarnings(); return storedRequestProcessor.processAuctionRequest(account.getId(), auctionContext.getBidRequest()) .compose(auctionStoredResult -> updateBidRequest(auctionStoredResult, auctionContext)) - .compose(bidRequest -> ortb2RequestFactory.validateRequest( - bidRequest, - auctionContext.getHttpRequest(), - debugWarnings)) + .compose(bidRequest -> ortb2RequestFactory.validateRequest(bidRequest, httpRequest, debugWarnings)) .map(interstitialProcessor::process); } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index d26add02847..61fe2069a60 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -13,6 +13,7 @@ import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; +import lombok.Getter; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -27,9 +28,6 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.auction.model.debug.DebugContext; import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.deals.UserAdditionalInfoService; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.exception.BlacklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; @@ -61,7 +59,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestTargeting; -import org.prebid.server.proto.openrtb.ext.request.TraceLevel; import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountAuctionConfig; @@ -75,7 +72,6 @@ import org.prebid.server.validation.RequestValidator; import org.prebid.server.validation.model.ValidationResult; -import java.time.Clock; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -101,13 +97,11 @@ public class Ortb2RequestFactory { private final TimeoutFactory timeoutFactory; private final StoredRequestProcessor storedRequestProcessor; private final ApplicationSettings applicationSettings; - private final UserAdditionalInfoService userAdditionalInfoService; private final IpAddressHelper ipAddressHelper; private final HookStageExecutor hookStageExecutor; private final PriceFloorProcessor priceFloorProcessor; private final CountryCodeMapper countryCodeMapper; private final Metrics metrics; - private final Clock clock; public Ortb2RequestFactory(int timeoutAdjustmentFactor, double logSamplingRate, @@ -121,11 +115,9 @@ public Ortb2RequestFactory(int timeoutAdjustmentFactor, ApplicationSettings applicationSettings, IpAddressHelper ipAddressHelper, HookStageExecutor hookStageExecutor, - UserAdditionalInfoService userAdditionalInfoService, PriceFloorProcessor priceFloorProcessor, CountryCodeMapper countryCodeMapper, - Metrics metrics, - Clock clock) { + Metrics metrics) { if (timeoutAdjustmentFactor < 0 || timeoutAdjustmentFactor > 100) { throw new IllegalArgumentException("Expected timeout adjustment factor should be in [0, 100]."); @@ -143,11 +135,9 @@ public Ortb2RequestFactory(int timeoutAdjustmentFactor, this.applicationSettings = Objects.requireNonNull(applicationSettings); this.ipAddressHelper = Objects.requireNonNull(ipAddressHelper); this.hookStageExecutor = Objects.requireNonNull(hookStageExecutor); - this.userAdditionalInfoService = userAdditionalInfoService; this.priceFloorProcessor = Objects.requireNonNull(priceFloorProcessor); this.countryCodeMapper = Objects.requireNonNull(countryCodeMapper); this.metrics = Objects.requireNonNull(metrics); - this.clock = Objects.requireNonNull(clock); } public AuctionContext createAuctionContext(Endpoint endpoint, MetricName requestTypeMetric) { @@ -158,7 +148,6 @@ public AuctionContext createAuctionContext(Endpoint endpoint, MetricName request .hookExecutionContext(HookExecutionContext.of(endpoint)) .debugContext(DebugContext.empty()) .requestRejected(false) - .txnLog(TxnLog.create()) .debugHttpCalls(new HashMap<>()) .bidRejectionTrackers(new TreeMap<>(String.CASE_INSENSITIVE_ORDER)) .build(); @@ -174,7 +163,6 @@ public AuctionContext enrichAuctionContext(AuctionContext auctionContext, .uidsCookie(uidsCookieService.parseFromRequest(httpRequest)) .bidRequest(bidRequest) .timeoutContext(TimeoutContext.of(startTime, timeout(bidRequest, startTime), timeoutAdjustmentFactor)) - .deepDebugLog(createDeepDebugLog(bidRequest)) .build(); } @@ -383,18 +371,13 @@ private static BidRequest toBidRequest(HookStageExecutionResult populateUserAdditionalInfo(AuctionContext auctionContext) { - return userAdditionalInfoService != null - ? userAdditionalInfoService.populate(auctionContext) - : Future.succeededFuture(auctionContext); - } - public AuctionContext enrichWithPriceFloors(AuctionContext auctionContext) { return priceFloorProcessor.enrichWithPriceFloors(auctionContext); } - public AuctionContext updateTimeout(AuctionContext auctionContext, long startTime) { + public AuctionContext updateTimeout(AuctionContext auctionContext) { final TimeoutContext timeoutContext = auctionContext.getTimeoutContext(); + final long startTime = timeoutContext.getStartTime(); final Timeout currentTimeout = timeoutContext.getTimeout(); final BidRequest bidRequest = auctionContext.getBidRequest(); @@ -690,19 +673,7 @@ private static CaseInsensitiveMultiMap toCaseInsensitiveMultiMap(MultiMap origin return mapBuilder.build(); } - private DeepDebugLog createDeepDebugLog(BidRequest bidRequest) { - final ExtRequest ext = bidRequest.getExt(); - return DeepDebugLog.create(ext != null && isDeepDebugEnabled(ext), clock); - } - - /** - * Determines deep debug flag from {@link ExtRequest}. - */ - private static boolean isDeepDebugEnabled(ExtRequest extRequest) { - final ExtRequestPrebid extRequestPrebid = extRequest != null ? extRequest.getPrebid() : null; - return extRequestPrebid != null && extRequestPrebid.getTrace() == TraceLevel.verbose; - } - + @Getter static class RejectedRequestException extends RuntimeException { private final AuctionContext auctionContext; @@ -710,10 +681,6 @@ static class RejectedRequestException extends RuntimeException { RejectedRequestException(AuctionContext auctionContext) { this.auctionContext = auctionContext; } - - public AuctionContext getAuctionContext() { - return auctionContext; - } } private record TargetingValueResolver(ExtRequestTargeting targeting, diff --git a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java index 32ff1c32585..31e150f78cf 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java @@ -145,11 +145,9 @@ public Future> fromRequest(RoutingContext routingC .compose(auctionContext -> ortb2RequestFactory.executeProcessedAuctionRequestHooks(auctionContext) .map(auctionContext::with)) - .compose(ortb2RequestFactory::populateUserAdditionalInfo) - .map(ortb2RequestFactory::enrichWithPriceFloors) - .map(auctionContext -> ortb2RequestFactory.updateTimeout(auctionContext, startTime)) + .map(ortb2RequestFactory::updateTimeout) .recover(ortb2RequestFactory::restoreResultFromRejection) diff --git a/src/main/java/org/prebid/server/bidder/DealsBidderRequestCompletionTrackerFactory.java b/src/main/java/org/prebid/server/bidder/DealsBidderRequestCompletionTrackerFactory.java deleted file mode 100644 index 8be85f88415..00000000000 --- a/src/main/java/org/prebid/server/bidder/DealsBidderRequestCompletionTrackerFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.prebid.server.bidder; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; -import com.iab.openrtb.response.Bid; -import io.vertx.core.Future; -import io.vertx.core.Promise; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.bidder.model.BidderBid; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -public class DealsBidderRequestCompletionTrackerFactory implements BidderRequestCompletionTrackerFactory { - - public BidderRequestCompletionTracker create(BidRequest bidRequest) { - final Map impToTopDealMap = new HashMap<>(); - for (final Imp imp : bidRequest.getImp()) { - final Pmp pmp = imp.getPmp(); - final List deals = pmp != null ? pmp.getDeals() : null; - final Deal topDeal = CollectionUtils.isNotEmpty(deals) ? deals.get(0) : null; - - impToTopDealMap.put(imp.getId(), topDeal != null ? topDeal.getId() : null); - } - - return !impToTopDealMap.containsValue(null) - ? new TopDealsReceivedTracker(impToTopDealMap) - : new NeverCompletedTracker(); - } - - private static class NeverCompletedTracker implements BidderRequestCompletionTracker { - - @Override - public Future future() { - return Future.failedFuture("No deals to wait for"); - } - - @Override - public void processBids(List bids) { - // no need to process bid when no deals to wait for - } - } - - private static class TopDealsReceivedTracker implements BidderRequestCompletionTracker { - - private final Map impToTopDealMap; - - private final Promise completionPromise; - - private TopDealsReceivedTracker(Map impToTopDealMap) { - this.impToTopDealMap = new HashMap<>(impToTopDealMap); - this.completionPromise = Promise.promise(); - } - - @Override - public Future future() { - return completionPromise.future(); - } - - @Override - public void processBids(List bids) { - if (completionPromise.future().isComplete()) { - return; - } - - bids.stream() - .map(BidderBid::getBid) - .filter(Objects::nonNull) - .map(this::toImpIdIfTopDeal) - .filter(Objects::nonNull) - .forEach(impToTopDealMap::remove); - - if (impToTopDealMap.isEmpty()) { - completionPromise.tryComplete(); - } - } - - private String toImpIdIfTopDeal(Bid bid) { - final String impId = bid.getImpid(); - final String dealId = bid.getDealid(); - if (StringUtils.isNoneBlank(impId, dealId)) { - final String topDealForImp = impToTopDealMap.get(impId); - if (topDealForImp != null && Objects.equals(dealId, topDealForImp)) { - return impId; - } - } - - return null; - } - } -} diff --git a/src/main/java/org/prebid/server/cache/CacheService.java b/src/main/java/org/prebid/server/cache/CacheService.java index 255144d0df9..9656dd38501 100644 --- a/src/main/java/org/prebid/server/cache/CacheService.java +++ b/src/main/java/org/prebid/server/cache/CacheService.java @@ -64,7 +64,7 @@ /** * Client stores values in Prebid Cache. *

- * For more info, see https://github.com/prebid/prebid-cache project. + * For more info, see Prebid Cache project. */ public class CacheService { @@ -471,12 +471,11 @@ private CachedCreative createJsonPutObjectOpenrtb(CacheBid cacheBid, final Bid bid = bidInfo.getBid(); final ObjectNode bidObjectNode = mapper.mapper().valueToTree(bid); - final String eventUrl = - generateWinUrl(bidInfo.getBidId(), - bidInfo.getBidder(), - accountId, - eventsContext, - bidInfo.getLineItemId()); + final String eventUrl = generateWinUrl( + bidInfo.getBidId(), + bidInfo.getBidder(), + accountId, + eventsContext); if (eventUrl != null) { bidObjectNode.put(BID_WURL_ATTRIBUTE, eventUrl); } @@ -521,24 +520,16 @@ private static String resolveCustomCacheKey(String hbCacheId, String category) { private String generateWinUrl(String bidId, String bidder, String accountId, - EventsContext eventsContext, - String lineItemId) { - - if (!eventsContext.isEnabledForAccount()) { - return null; - } - - if (eventsContext.isEnabledForRequest() || StringUtils.isNotBlank(lineItemId)) { - return eventsService.winUrl( - bidId, - bidder, - accountId, - lineItemId, - eventsContext.isEnabledForRequest(), - eventsContext); - } - - return null; + EventsContext eventsContext) { + + return eventsContext.isEnabledForAccount() && eventsContext.isEnabledForRequest() + ? eventsService.winUrl( + bidId, + bidder, + accountId, + true, + eventsContext) + : null; } /** diff --git a/src/main/java/org/prebid/server/deals/AdminCentralService.java b/src/main/java/org/prebid/server/deals/AdminCentralService.java deleted file mode 100644 index f5bd033b051..00000000000 --- a/src/main/java/org/prebid/server/deals/AdminCentralService.java +++ /dev/null @@ -1,239 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.deals.events.AdminEventProcessor; -import org.prebid.server.deals.model.AdminAccounts; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.deals.model.AdminLineItems; -import org.prebid.server.deals.model.Command; -import org.prebid.server.deals.model.LogTracer; -import org.prebid.server.deals.model.ServicesCommand; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.log.CriteriaManager; -import org.prebid.server.settings.CachingApplicationSettings; -import org.prebid.server.settings.SettingsCache; -import org.prebid.server.settings.proto.request.InvalidateSettingsCacheRequest; -import org.prebid.server.settings.proto.request.UpdateSettingsCacheRequest; -import org.prebid.server.util.ObjectUtil; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - -public class AdminCentralService implements AdminEventProcessor { - - private static final Logger logger = LoggerFactory.getLogger(AdminCentralService.class); - - private static final String START = "start"; - private static final String STOP = "stop"; - private static final String INVALIDATE = "invalidate"; - private static final String SAVE = "save"; - private static final String STORED_REQUEST_CACHE = "stored request cache"; - private static final String AMP_STORED_REQUEST_CACHE = "amp stored request cache"; - - private final CriteriaManager criteriaManager; - private final LineItemService lineItemService; - private final DeliveryProgressService deliveryProgressService; - private final SettingsCache settingsCache; - private final SettingsCache ampSettingsCache; - private final CachingApplicationSettings cachingApplicationSettings; - private final JacksonMapper mapper; - private final List suspendableServices; - - public AdminCentralService(CriteriaManager criteriaManager, - LineItemService lineItemService, - DeliveryProgressService deliveryProgressService, - SettingsCache settingsCache, - SettingsCache ampSettingsCache, - CachingApplicationSettings cachingApplicationSettings, - JacksonMapper mapper, - List suspendableServices) { - this.criteriaManager = Objects.requireNonNull(criteriaManager); - this.lineItemService = Objects.requireNonNull(lineItemService); - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.settingsCache = settingsCache; - this.ampSettingsCache = ampSettingsCache; - this.cachingApplicationSettings = cachingApplicationSettings; - this.mapper = Objects.requireNonNull(mapper); - this.suspendableServices = Objects.requireNonNull(suspendableServices); - } - - @Override - public void processAdminCentralEvent(AdminCentralResponse centralAdminResponse) { - final LogTracer logTracer = centralAdminResponse.getTracer(); - if (logTracer != null) { - handleLogTracer(centralAdminResponse.getTracer()); - } - - final Command lineItemsCommand = centralAdminResponse.getLineItems(); - if (lineItemsCommand != null) { - handleLineItems(lineItemsCommand); - } - - final Command storedRequestCommand = centralAdminResponse.getStoredRequest(); - if (storedRequestCommand != null && settingsCache != null) { - handleStoredRequest(settingsCache, storedRequestCommand, STORED_REQUEST_CACHE); - } - - final Command storedRequestAmpCommand = centralAdminResponse.getStoredRequestAmp(); - if (storedRequestAmpCommand != null && ampSettingsCache != null) { - handleStoredRequest(ampSettingsCache, storedRequestAmpCommand, AMP_STORED_REQUEST_CACHE); - } - - final Command accountCommand = centralAdminResponse.getAccount(); - if (accountCommand != null && cachingApplicationSettings != null) { - handleAccountCommand(accountCommand); - } - - final ServicesCommand servicesCommand = centralAdminResponse.getServices(); - if (servicesCommand != null) { - handleServiceCommand(servicesCommand); - } - } - - private void handleAccountCommand(Command accountCommand) { - final String cmd = accountCommand.getCmd(); - if (StringUtils.isBlank(cmd)) { - logger.warn("Command for account action was not defined in register response"); - return; - } - - if (!Objects.equals(cmd, INVALIDATE)) { - logger.warn("Account commands supports only `invalidate` command, but received {0}", cmd); - return; - } - - final ObjectNode body = accountCommand.getBody(); - final AdminAccounts adminAccounts; - try { - adminAccounts = body != null - ? mapper.mapper().convertValue(body, AdminAccounts.class) - : null; - } catch (IllegalArgumentException e) { - logger.warn("Can't parse admin accounts body, failed with exception message : {0}", e.getMessage()); - return; - } - - final List accounts = ObjectUtil.getIfNotNull(adminAccounts, AdminAccounts::getAccounts); - if (CollectionUtils.isNotEmpty(accounts)) { - accounts.forEach(cachingApplicationSettings::invalidateAccountCache); - } else { - cachingApplicationSettings.invalidateAllAccountCache(); - } - } - - private void handleLineItems(Command lineItemsCommand) { - final String cmd = lineItemsCommand.getCmd(); - if (StringUtils.isBlank(cmd)) { - logger.warn("Command for line-items action was not defined in register response."); - return; - } - - if (!Objects.equals(cmd, INVALIDATE)) { - logger.warn("Line Items section supports only `invalidate` command, but received {0}", cmd); - return; - } - - final ObjectNode body = lineItemsCommand.getBody(); - final AdminLineItems adminLineItems; - try { - adminLineItems = body != null - ? mapper.mapper().convertValue(body, AdminLineItems.class) - : null; - } catch (IllegalArgumentException e) { - logger.warn("Can't parse admin line items body, failed with exception message : {0}", e.getMessage()); - return; - } - - final List lineItemIds = ObjectUtil.getIfNotNull(adminLineItems, AdminLineItems::getIds); - - if (CollectionUtils.isNotEmpty(lineItemIds)) { - lineItemService.invalidateLineItemsByIds(lineItemIds); - deliveryProgressService.invalidateLineItemsByIds(lineItemIds); - } else { - lineItemService.invalidateLineItems(); - deliveryProgressService.invalidateLineItems(); - } - } - - private void handleStoredRequest(SettingsCache settingsCache, Command storedRequestCommand, String serviceName) { - final String cmd = storedRequestCommand.getCmd(); - if (StringUtils.isBlank(cmd)) { - logger.warn("Command for {0} was not defined.", serviceName); - return; - } - - final ObjectNode body = storedRequestCommand.getBody(); - if (body == null) { - logger.warn("Command body for {0} was not defined.", serviceName); - return; - } - - switch (cmd) { - case INVALIDATE -> invalidateStoredRequests(settingsCache, serviceName, body); - case SAVE -> saveStoredRequests(settingsCache, serviceName, body); - default -> logger.warn("Command for {0} should has value 'save' or 'invalidate' but was {1}.", - serviceName, cmd); - } - } - - private void saveStoredRequests(SettingsCache settingsCache, String serviceName, ObjectNode body) { - final UpdateSettingsCacheRequest saveRequest; - try { - saveRequest = mapper.mapper().convertValue(body, UpdateSettingsCacheRequest.class); - } catch (IllegalArgumentException e) { - logger.warn("Can't parse save settings cache request object for {0}," - + " failed with exception message : {1}", serviceName, e.getMessage()); - return; - } - final Map storedRequests = MapUtils.emptyIfNull(saveRequest.getRequests()); - final Map storedImps = MapUtils.emptyIfNull(saveRequest.getImps()); - settingsCache.save(storedRequests, storedImps); - logger.info("Stored request with ids {0} and stored impressions with ids {1} were successfully saved", - String.join(", ", storedRequests.keySet()), String.join(", ", storedImps.keySet())); - } - - private void invalidateStoredRequests(SettingsCache settingsCache, String serviceName, ObjectNode body) { - final InvalidateSettingsCacheRequest invalidateRequest; - try { - invalidateRequest = mapper.mapper().convertValue(body, InvalidateSettingsCacheRequest.class); - } catch (IllegalArgumentException e) { - logger.warn("Can't parse invalidate settings cache request object for {0}," - + " failed with exception message : {1}", serviceName, e.getMessage()); - return; - } - final List requestIds = ListUtils.emptyIfNull(invalidateRequest.getRequests()); - final List impIds = ListUtils.emptyIfNull(invalidateRequest.getImps()); - settingsCache.invalidate(requestIds, impIds); - logger.info("Stored requests with ids {0} and impression with ids {1} were successfully invalidated", - String.join(", ", requestIds), String.join(", ", impIds)); - } - - private void handleLogTracer(LogTracer logTracer) { - final String command = logTracer.getCmd(); - if (StringUtils.isBlank(command)) { - logger.warn("Command for traceLogger was not defined"); - return; - } - - switch (command) { - case START -> criteriaManager.addCriteria(logTracer.getFilters(), logTracer.getDurationInSeconds()); - case STOP -> criteriaManager.stop(); - default -> logger.warn("Command for trace logger should has value 'start' or 'stop' but was {0}.", command); - } - } - - private void handleServiceCommand(ServicesCommand servicesCommand) { - final String command = servicesCommand.getCmd(); - if (command != null && command.equalsIgnoreCase(STOP)) { - suspendableServices.forEach(Suspendable::suspend); - } - logger.info("PBS services were successfully suspended"); - } -} diff --git a/src/main/java/org/prebid/server/deals/AlertHttpService.java b/src/main/java/org/prebid/server/deals/AlertHttpService.java deleted file mode 100644 index 3b89b0f2bd8..00000000000 --- a/src/main/java/org/prebid/server/deals/AlertHttpService.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.prebid.server.deals; - -import io.netty.handler.codec.http.HttpHeaderValues; -import io.vertx.core.AsyncResult; -import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.prebid.server.deals.model.AlertEvent; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.AlertProxyProperties; -import org.prebid.server.deals.model.AlertSource; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.json.EncodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class AlertHttpService { - - private static final Logger logger = LoggerFactory.getLogger(AlertHttpService.class); - private static final String RAISE = "RAISE"; - private static final Long DEFAULT_HIGH_ALERT_PERIOD = 15L; - - private final JacksonMapper mapper; - private final HttpClient httpClient; - private final Clock clock; - private final AlertProxyProperties alertProxyProperties; - private final AlertSource alertSource; - private final boolean enabled; - private final String url; - private final long timeoutMillis; - private final String authHeaderValue; - private final Map alertTypes; - private final Map alertTypesCounters; - - public AlertHttpService(JacksonMapper mapper, HttpClient httpClient, Clock clock, - DeploymentProperties deploymentProperties, - AlertProxyProperties alertProxyProperties) { - this.mapper = Objects.requireNonNull(mapper); - this.httpClient = Objects.requireNonNull(httpClient); - this.clock = Objects.requireNonNull(clock); - this.alertProxyProperties = Objects.requireNonNull(alertProxyProperties); - this.alertSource = makeSource(Objects.requireNonNull(deploymentProperties)); - this.enabled = alertProxyProperties.isEnabled(); - this.timeoutMillis = TimeUnit.SECONDS.toMillis(alertProxyProperties.getTimeoutSec()); - this.url = HttpUtil.validateUrl(Objects.requireNonNull(alertProxyProperties.getUrl())); - this.authHeaderValue = HttpUtil.makeBasicAuthHeaderValue(alertProxyProperties.getUsername(), - alertProxyProperties.getPassword()); - this.alertTypes = new ConcurrentHashMap<>(alertProxyProperties.getAlertTypes()); - this.alertTypesCounters = new ConcurrentHashMap<>(alertTypes.keySet().stream() - .collect(Collectors.toMap(Function.identity(), s -> 0L))); - } - - private static AlertSource makeSource(DeploymentProperties deploymentProperties) { - return AlertSource.builder() - .env(deploymentProperties.getProfile()) - .region(deploymentProperties.getPbsRegion()) - .dataCenter(deploymentProperties.getDataCenter()) - .subSystem(deploymentProperties.getSubSystem()) - .system(deploymentProperties.getSystem()) - .hostId(deploymentProperties.getPbsHostId()) - .build(); - } - - public void alertWithPeriod(String serviceName, String alertType, AlertPriority alertPriority, String message) { - if (alertTypes.get(alertType) == null) { - alertTypes.put(alertType, DEFAULT_HIGH_ALERT_PERIOD); - alertTypesCounters.put(alertType, 0L); - } - - long count = alertTypesCounters.get(alertType); - final long period = alertTypes.get(alertType); - - alertTypesCounters.put(alertType, ++count); - final String formattedMessage = "Service %s failed to send request %s time(s) with error message : %s" - .formatted(serviceName, count, message); - if (count == 1) { - alert(alertType, alertPriority, formattedMessage); - } else if (count % period == 0) { - alert(alertType, AlertPriority.HIGH, formattedMessage); - } - } - - public void resetAlertCount(String alertType) { - alertTypesCounters.put(alertType, 0L); - } - - public void alert(String name, AlertPriority alertPriority, String message) { - if (!enabled) { - logger.warn("Alert to proxy is not enabled in pbs configuration"); - return; - } - - final AlertEvent alertEvent = makeEvent(RAISE, alertPriority, name, message, alertSource); - - try { - httpClient.post(alertProxyProperties.getUrl(), headers(), - mapper.encodeToString(Collections.singletonList(alertEvent)), timeoutMillis) - .onComplete(this::handleResponse); - } catch (EncodeException e) { - logger.warn("Can't parse alert proxy payload: {0}", e.getMessage()); - } - } - - private AlertEvent makeEvent(String action, AlertPriority priority, String name, String details, - AlertSource alertSource) { - return AlertEvent.builder() - .id(UUID.randomUUID().toString()) - .action(action.toUpperCase()) - .priority(priority) - .name(name) - .details(details) - .updatedAt(ZonedDateTime.now(clock)) - .source(alertSource) - .build(); - } - - private MultiMap headers() { - return MultiMap.caseInsensitiveMultiMap() - .add(HttpUtil.PG_TRX_ID, UUID.randomUUID().toString()) - .add(HttpUtil.CONTENT_TYPE_HEADER, HttpHeaderValues.APPLICATION_JSON) - .add(HttpUtil.AUTHORIZATION_HEADER, authHeaderValue); - } - - private void handleResponse(AsyncResult httpClientResponseResult) { - if (httpClientResponseResult.failed()) { - logger.error("Error occurred during sending alert to proxy at {0}::{1} ", url, - httpClientResponseResult.cause().getMessage()); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/DealsService.java b/src/main/java/org/prebid/server/deals/DealsService.java deleted file mode 100644 index 662b6b8dc14..00000000000 --- a/src/main/java/org/prebid/server/deals/DealsService.java +++ /dev/null @@ -1,318 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.ObjectUtils; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.auction.model.AuctionParticipation; -import org.prebid.server.auction.model.BidderRequest; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.MatchLineItemsResult; -import org.prebid.server.deals.proto.LineItemSize; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; -import org.prebid.server.util.ObjectUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.BiFunction; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -public class DealsService { - - private static final Logger logger = LoggerFactory.getLogger(DealsService.class); - - private static final String LINE_FIELD = "line"; - private static final String LINE_BIDDER_FIELD = "bidder"; - private static final String BIDDER_FIELD = "bidder"; - private static final String PG_DEALS_ONLY = "pgdealsonly"; - - private final LineItemService lineItemService; - private final JacksonMapper mapper; - private final CriteriaLogManager criteriaLogManager; - - public DealsService(LineItemService lineItemService, - JacksonMapper mapper, - CriteriaLogManager criteriaLogManager) { - - this.lineItemService = Objects.requireNonNull(lineItemService); - this.mapper = Objects.requireNonNull(mapper); - this.criteriaLogManager = Objects.requireNonNull(criteriaLogManager); - } - - public BidderRequest matchAndPopulateDeals(BidderRequest bidderRequest, - BidderAliases aliases, - AuctionContext context) { - - final String bidder = bidderRequest.getBidder(); - final BidRequest bidRequest = bidderRequest.getBidRequest(); - - final Map> impIdToDeals = match(bidRequest, bidder, aliases, context); - final BidRequest modifiedRequest = populateDeals(bidRequest, impIdToDeals, combinerFor(bidder, aliases)); - - return bidderRequest.toBuilder() - .impIdToDeals(impIdToDeals) - .bidRequest(modifiedRequest) - .build(); - } - - private Map> match(BidRequest bidRequest, - String bidder, - BidderAliases aliases, - AuctionContext context) { - - final boolean accountHasDeals = lineItemService.accountHasDeals(context); - if (!accountHasDeals) { - return Collections.emptyMap(); - } - - final Map> impIdToDeals = new HashMap<>(); - for (Imp imp : bidRequest.getImp()) { - final MatchLineItemsResult matchResult = lineItemService.findMatchingLineItems( - bidRequest, imp, bidder, aliases, context); - final List lineItems = matchResult.getLineItems(); - - final List deals = lineItems.stream() - .peek(this::logLineItem) - .map(lineItem -> toDeal(lineItem, imp)) - .toList(); - - if (!deals.isEmpty()) { - impIdToDeals.put(imp.getId(), deals); - } - } - - return impIdToDeals; - } - - private void logLineItem(LineItem lineItem) { - criteriaLogManager.log( - logger, - lineItem.getAccountId(), - lineItem.getSource(), - lineItem.getLineItemId(), - "LineItem %s is ready to be served".formatted(lineItem.getLineItemId()), logger::debug); - } - - private Deal toDeal(LineItem lineItem, Imp imp) { - return Deal.builder() - .id(lineItem.getDealId()) - .ext(mapper.mapper().valueToTree(ExtDeal.of(toExtDealLine(imp, lineItem)))) - .build(); - } - - private static ExtDealLine toExtDealLine(Imp imp, LineItem lineItem) { - final List formats = ObjectUtil.getIfNotNull(imp.getBanner(), Banner::getFormat); - final List lineItemSizes = lineItem.getSizes(); - - final List lineSizes = CollectionUtils.isNotEmpty(formats) && CollectionUtils.isNotEmpty(lineItemSizes) - ? intersectionOf(formats, lineItemSizes) - : null; - - return ExtDealLine.of(lineItem.getLineItemId(), lineItem.getExtLineItemId(), lineSizes, lineItem.getSource()); - } - - private static List intersectionOf(List formats, List lineItemSizes) { - final Set formatsSet = new HashSet<>(formats); - final Set lineItemFormatsSet = lineItemSizes.stream() - .map(size -> Format.builder().w(size.getW()).h(size.getH()).build()) - .collect(Collectors.toSet()); - - final List matchedSizes = lineItemFormatsSet.stream() - .filter(formatsSet::contains) - .toList(); - - return CollectionUtils.isNotEmpty(matchedSizes) ? matchedSizes : null; - } - - private static BiFunction, List, List> combinerFor(String bidder, BidderAliases aliases) { - return (originalDeals, matchedDeals) -> - Stream.concat( - originalDeals.stream().filter(deal -> isDealCorrespondsToBidder(deal, bidder, aliases)), - matchedDeals.stream()) - .map(DealsService::prepareDealForExchange) - .toList(); - } - - private static boolean isDealCorrespondsToBidder(Deal deal, String bidder, BidderAliases aliases) { - final JsonNode extLineBidder = extLineBidder(deal); - if (!isTextual(extLineBidder)) { - return true; - } - - return aliases.isSame(extLineBidder.textValue(), bidder); - } - - private static JsonNode extLineBidder(Deal deal) { - final ObjectNode ext = deal != null ? deal.getExt() : null; - final JsonNode extLine = ext != null ? ext.get(LINE_FIELD) : null; - return extLine != null ? extLine.get(LINE_BIDDER_FIELD) : null; - } - - private static boolean isTextual(JsonNode jsonNode) { - return jsonNode != null && jsonNode.isTextual(); - } - - private static Deal prepareDealForExchange(Deal deal) { - final JsonNode extLineBidder = extLineBidder(deal); - if (!isTextual(extLineBidder)) { - return deal; - } - - final ObjectNode updatedExt = deal.getExt().deepCopy(); - - final ObjectNode updatedExtLine = (ObjectNode) updatedExt.get(LINE_FIELD); - updatedExtLine.remove(LINE_BIDDER_FIELD); - - if (updatedExtLine.isEmpty()) { - updatedExt.remove(LINE_FIELD); - } - - return deal.toBuilder().ext(!updatedExt.isEmpty() ? updatedExt : null).build(); - } - - public static BidRequest populateDeals(BidRequest bidRequest, Map> impIdToDeals) { - return populateDeals(bidRequest, impIdToDeals, ListUtils::union); - } - - private static BidRequest populateDeals(BidRequest bidRequest, - Map> impIdToDeals, - BiFunction, List, List> dealsCombiner) { - - final List originalImps = bidRequest.getImp(); - final List updatedImp = originalImps.stream() - .map(imp -> populateDeals(imp, impIdToDeals.get(imp.getId()), dealsCombiner)) - .toList(); - - if (updatedImp.stream().allMatch(Objects::isNull)) { - return bidRequest; - } - - return bidRequest.toBuilder() - .imp(IntStream.range(0, originalImps.size()) - .mapToObj(i -> ObjectUtils.defaultIfNull(updatedImp.get(i), originalImps.get(i))) - .toList()) - .build(); - } - - private static Imp populateDeals(Imp imp, - List matchedDeals, - BiFunction, List, List> dealsCombiner) { - - final Pmp pmp = imp.getPmp(); - final List originalDeal = pmp != null ? pmp.getDeals() : null; - - final List combinedDeals = dealsCombiner.apply( - ListUtils.emptyIfNull(originalDeal), - ListUtils.emptyIfNull(matchedDeals)); - if (CollectionUtils.isEmpty(combinedDeals)) { - return null; - } - - final Pmp.PmpBuilder pmpBuilder = pmp != null ? pmp.toBuilder() : Pmp.builder(); - return imp.toBuilder() - .pmp(pmpBuilder.deals(combinedDeals).build()) - .build(); - } - - public static List removePgDealsOnlyImpsWithoutDeals( - List auctionParticipations, - AuctionContext context) { - - return auctionParticipations.stream() - .map(auctionParticipation -> removePgDealsOnlyImpsWithoutDeals(auctionParticipation, context)) - .filter(Objects::nonNull) - .toList(); - } - - private static AuctionParticipation removePgDealsOnlyImpsWithoutDeals(AuctionParticipation auctionParticipation, - AuctionContext context) { - - final BidderRequest bidderRequest = auctionParticipation.getBidderRequest(); - final String bidder = bidderRequest.getBidder(); - final BidRequest bidRequest = bidderRequest.getBidRequest(); - final List imps = bidRequest.getImp(); - - final Set impsIndicesToRemove = IntStream.range(0, imps.size()) - .filter(i -> isPgDealsOnly(imps.get(i))) - .filter(i -> !havePgDeal(imps.get(i), bidderRequest.getImpIdToDeals())) - .boxed() - .collect(Collectors.toSet()); - - if (impsIndicesToRemove.isEmpty()) { - return auctionParticipation; - } - if (impsIndicesToRemove.size() == imps.size()) { - logImpsExclusion(context, bidder, imps); - return null; - } - - final List impsToRemove = new ArrayList<>(); - final List filteredImps = new ArrayList<>(); - for (int i = 0; i < imps.size(); i++) { - final Imp imp = imps.get(i); - if (impsIndicesToRemove.contains(i)) { - impsToRemove.add(imp); - } else { - filteredImps.add(imp); - } - } - - logImpsExclusion(context, bidder, impsToRemove); - - return auctionParticipation.toBuilder() - .bidderRequest(bidderRequest.toBuilder() - .bidRequest(bidRequest.toBuilder() - .imp(filteredImps) - .build()) - .build()) - .build(); - } - - private static boolean isPgDealsOnly(Imp imp) { - final JsonNode extBidder = imp.getExt().get(BIDDER_FIELD); - if (extBidder == null || !extBidder.isObject()) { - return false; - } - - final JsonNode pgDealsOnlyNode = extBidder.path(PG_DEALS_ONLY); - return pgDealsOnlyNode.isBoolean() && pgDealsOnlyNode.asBoolean(); - } - - private static boolean havePgDeal(Imp imp, Map> impIdToDeals) { - return impIdToDeals != null && CollectionUtils.isNotEmpty(impIdToDeals.get(imp.getId())); - } - - private static void logImpsExclusion(AuctionContext context, - String bidder, - List imps) { - - final String impsIds = imps.stream() - .map(Imp::getId) - .collect(Collectors.joining(", ")); - context.getDebugWarnings().add( - "Not calling %s bidder for impressions %s due to %s flag and no available PG line items." - .formatted(bidder, impsIds, PG_DEALS_ONLY)); - } -} diff --git a/src/main/java/org/prebid/server/deals/DeliveryProgressReportFactory.java b/src/main/java/org/prebid/server/deals/DeliveryProgressReportFactory.java deleted file mode 100644 index 85d3089b79a..00000000000 --- a/src/main/java/org/prebid/server/deals/DeliveryProgressReportFactory.java +++ /dev/null @@ -1,313 +0,0 @@ -package org.prebid.server.deals; - -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.deals.lineitem.DeliveryPlan; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.lineitem.DeliveryToken; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.DeliveryProgressReportBatch; -import org.prebid.server.deals.proto.report.DeliverySchedule; -import org.prebid.server.deals.proto.report.LineItemStatus; -import org.prebid.server.deals.proto.report.LostToLineItem; -import org.prebid.server.deals.proto.report.Token; -import org.prebid.server.util.ObjectUtil; - -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class DeliveryProgressReportFactory { - - private static final Logger logger = LoggerFactory.getLogger(DeliveryProgressReportFactory.class); - - private static final LostToLineItemComparator LOST_TO_LINE_ITEM_COMPARATOR = new LostToLineItemComparator(); - - private final DeploymentProperties deploymentProperties; - private final int competitorsNumber; - private final LineItemService lineItemService; - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - public DeliveryProgressReportFactory( - DeploymentProperties deploymentProperties, int competitorsNumber, LineItemService lineItemService) { - this.deploymentProperties = Objects.requireNonNull(deploymentProperties); - this.competitorsNumber = competitorsNumber; - this.lineItemService = Objects.requireNonNull(lineItemService); - } - - public DeliveryProgressReport fromDeliveryProgress( - DeliveryProgress deliveryProgress, - ZonedDateTime now, - boolean isOverall) { - final List lineItemStatuses = - new ArrayList<>(deliveryProgress.getLineItemStatuses().values()); - return DeliveryProgressReport.builder() - .reportId(UUID.randomUUID().toString()) - .reportTimeStamp(now != null ? formatTimeStamp(now) : null) - .dataWindowStartTimeStamp(isOverall ? null : formatTimeStamp(deliveryProgress.getStartTimeStamp())) - .dataWindowEndTimeStamp(isOverall ? null : formatTimeStamp(deliveryProgress.getEndTimeStamp())) - .instanceId(deploymentProperties.getPbsHostId()) - .region(deploymentProperties.getPbsRegion()) - .vendor(deploymentProperties.getPbsVendor()) - .clientAuctions(deliveryProgress.getRequests().sum()) - .lineItemStatus(makeLineItemStatusReports(deliveryProgress, lineItemStatuses, - deliveryProgress.getLineItemStatuses(), isOverall)) - .build(); - } - - public DeliveryProgressReportBatch batchFromDeliveryProgress( - DeliveryProgress deliveryProgress, - Map overallLineItemStatuses, - ZonedDateTime now, - int batchSize, - boolean isOverall) { - final List lineItemStatuses - = new ArrayList<>(deliveryProgress.getLineItemStatuses().values()); - final String reportId = UUID.randomUUID().toString(); - final String reportTimeStamp = now != null ? formatTimeStamp(now) : null; - final String dataWindowStartTimeStamp = isOverall - ? null - : formatTimeStamp(deliveryProgress.getStartTimeStamp()); - final String dataWindowEndTimeStamp = isOverall ? null : formatTimeStamp(deliveryProgress.getEndTimeStamp()); - final long clientAuctions = deliveryProgress.getRequests().sum(); - - final int lineItemsCount = lineItemStatuses.size(); - final int batchesNumber = lineItemsCount / batchSize + (lineItemsCount % batchSize > 0 ? 1 : 0); - final Set reportsBatch = IntStream.range(0, batchesNumber) - .mapToObj(batchNumber -> updateReportWithLineItems(deliveryProgress, lineItemStatuses, - overallLineItemStatuses, lineItemsCount, batchNumber, batchSize, isOverall)) - .map(deliveryProgressReport -> deliveryProgressReport - .reportId(reportId) - .reportTimeStamp(reportTimeStamp) - .dataWindowStartTimeStamp(dataWindowStartTimeStamp) - .dataWindowEndTimeStamp(dataWindowEndTimeStamp) - .clientAuctions(clientAuctions) - .instanceId(deploymentProperties.getPbsHostId()) - .region(deploymentProperties.getPbsRegion()) - .vendor(deploymentProperties.getPbsVendor()) - .build()) - .collect(Collectors.toSet()); - - logNotDeliveredLineItems(deliveryProgress, reportsBatch); - return DeliveryProgressReportBatch.of(reportsBatch, reportId, dataWindowEndTimeStamp); - } - - private DeliveryProgressReport.DeliveryProgressReportBuilder updateReportWithLineItems( - DeliveryProgress deliveryProgress, - List lineItemStatuses, - Map overallLineItemStatuses, - int lineItemsCount, - int batchNumber, - int batchSize, - boolean isOverall) { - final int startBatchIndex = batchNumber * batchSize; - final int endBatchIndex = (batchNumber + 1) * batchSize; - final List batchList = - lineItemStatuses.subList(startBatchIndex, Math.min(endBatchIndex, lineItemsCount)); - return DeliveryProgressReport.builder() - .lineItemStatus(makeLineItemStatusReports(deliveryProgress, batchList, - overallLineItemStatuses, isOverall)); - } - - private Set makeLineItemStatusReports( - DeliveryProgress deliveryProgress, - List lineItemStatuses, - Map overallLineItemStatuses, - boolean isOverall) { - - return lineItemStatuses.stream() - .map(lineItemStatus -> toLineItemStatusReport(lineItemStatus, - overallLineItemStatuses != null - ? overallLineItemStatuses.get(lineItemStatus.getLineItemId()) - : null, - deliveryProgress, isOverall)) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); - } - - private static void logNotDeliveredLineItems(DeliveryProgress deliveryProgress, - Set reportsBatch) { - final Set reportedLineItems = reportsBatch.stream() - .map(DeliveryProgressReport::getLineItemStatus) - .flatMap(Collection::stream) - .map(LineItemStatus::getLineItemId) - .collect(Collectors.toSet()); - - final String notDeliveredLineItems = deliveryProgress.getLineItemStatuses().keySet().stream() - .filter(id -> !reportedLineItems.contains(id)) - .collect(Collectors.joining(", ")); - if (StringUtils.isNotBlank(notDeliveredLineItems)) { - logger.info("Line item with id {0} will not be reported," - + " as it does not have active delivery schedules during report window.", notDeliveredLineItems); - } - } - - DeliveryProgressReport updateReportTimeStamp(DeliveryProgressReport deliveryProgressReport, ZonedDateTime now) { - return deliveryProgressReport.toBuilder().reportTimeStamp(formatTimeStamp(now)).build(); - } - - private LineItemStatus toLineItemStatusReport(org.prebid.server.deals.lineitem.LineItemStatus lineItemStatus, - org.prebid.server.deals.lineitem.LineItemStatus overallLineItemStatus, - DeliveryProgress deliveryProgress, boolean isOverall) { - final String lineItemId = lineItemStatus.getLineItemId(); - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - if (isOverall && lineItem == null) { - return null; - } - final DeliveryPlan activeDeliveryPlan = ObjectUtil.getIfNotNull(lineItem, LineItem::getActiveDeliveryPlan); - final Set deliverySchedules = deliverySchedule(lineItemStatus, overallLineItemStatus, - activeDeliveryPlan); - if (CollectionUtils.isEmpty(deliverySchedules) && !isOverall) { - return null; - } - - return LineItemStatus.builder() - .lineItemSource(ObjectUtil.firstNonNull(lineItemStatus::getSource, - () -> ObjectUtil.getIfNotNull(lineItem, LineItem::getSource))) - .lineItemId(lineItemId) - .dealId(ObjectUtil.firstNonNull(lineItemStatus::getDealId, - () -> ObjectUtil.getIfNotNull(lineItem, LineItem::getDealId))) - .extLineItemId(ObjectUtil.firstNonNull(lineItemStatus::getExtLineItemId, - () -> ObjectUtil.getIfNotNull(lineItem, LineItem::getExtLineItemId))) - .accountAuctions(accountRequests(ObjectUtil.firstNonNull(lineItemStatus::getAccountId, - () -> ObjectUtil.getIfNotNull(lineItem, LineItem::getAccountId)), deliveryProgress)) - .domainMatched(lineItemStatus.getDomainMatched().sum()) - .targetMatched(lineItemStatus.getTargetMatched().sum()) - .targetMatchedButFcapped(lineItemStatus.getTargetMatchedButFcapped().sum()) - .targetMatchedButFcapLookupFailed(lineItemStatus.getTargetMatchedButFcapLookupFailed().sum()) - .pacingDeferred(lineItemStatus.getPacingDeferred().sum()) - .sentToBidder(lineItemStatus.getSentToBidder().sum()) - .sentToBidderAsTopMatch(lineItemStatus.getSentToBidderAsTopMatch().sum()) - .receivedFromBidder(lineItemStatus.getReceivedFromBidder().sum()) - .receivedFromBidderInvalidated(lineItemStatus.getReceivedFromBidderInvalidated().sum()) - .sentToClient(lineItemStatus.getSentToClient().sum()) - .sentToClientAsTopMatch(lineItemStatus.getSentToClientAsTopMatch().sum()) - .lostToLineItems(lostToLineItems(lineItemStatus, deliveryProgress)) - .events(lineItemStatus.getEvents()) - .deliverySchedule(deliverySchedules) - .readyAt(isOverall ? toReadyAt(lineItem) : null) - .spentTokens(isOverall && activeDeliveryPlan != null ? activeDeliveryPlan.getSpentTokens() : null) - .pacingFrequency(isOverall && activeDeliveryPlan != null - ? activeDeliveryPlan.getDeliveryRateInMilliseconds() - : null) - .build(); - } - - private String toReadyAt(LineItem lineItem) { - final ZonedDateTime readyAt = ObjectUtil.getIfNotNull(lineItem, LineItem::getReadyAt); - return readyAt != null ? UTC_MILLIS_FORMATTER.format(readyAt) : null; - } - - private Long accountRequests(String accountId, DeliveryProgress deliveryProgress) { - final LongAdder accountRequests = accountId != null - ? deliveryProgress.getRequestsPerAccount().get(accountId) - : null; - return accountRequests != null ? accountRequests.sum() : null; - } - - private Set lostToLineItems(org.prebid.server.deals.lineitem.LineItemStatus lineItemStatus, - DeliveryProgress deliveryProgress) { - final Map lostTo = - deliveryProgress.getLineItemIdToLost().get(lineItemStatus.getLineItemId()); - - if (lostTo != null) { - return lostTo.values().stream() - .sorted(LOST_TO_LINE_ITEM_COMPARATOR.reversed()) - .map(this::toLostToLineItems) - .limit(competitorsNumber) - .collect(Collectors.toSet()); - } - - return null; - } - - private LostToLineItem toLostToLineItems(org.prebid.server.deals.lineitem.LostToLineItem lostToLineItem) { - final String lineItemId = lostToLineItem.getLineItemId(); - return LostToLineItem.of( - ObjectUtil.getIfNotNull(lineItemService.getLineItemById(lineItemId), LineItem::getSource), lineItemId, - lostToLineItem.getCount().sum()); - } - - private static Set deliverySchedule( - org.prebid.server.deals.lineitem.LineItemStatus lineItemStatus, - org.prebid.server.deals.lineitem.LineItemStatus overallLineItemStatus, - DeliveryPlan activeDeliveryPlan) { - - final Map idToDeliveryPlan = overallLineItemStatus != null - ? overallLineItemStatus.getDeliveryPlans().stream() - .collect(Collectors.toMap(DeliveryPlan::getPlanId, Function.identity())) - : Collections.emptyMap(); - - final Set deliverySchedules = lineItemStatus.getDeliveryPlans().stream() - .map(deliveryPlan -> toDeliverySchedule(deliveryPlan, idToDeliveryPlan.get(deliveryPlan.getPlanId()))) - .collect(Collectors.toSet()); - - if (CollectionUtils.isEmpty(deliverySchedules)) { - if (activeDeliveryPlan != null) { - deliverySchedules.add(DeliveryProgressReportFactory - .toDeliverySchedule(activeDeliveryPlan.withoutSpentTokens())); - } - } - return deliverySchedules; - } - - static DeliverySchedule toDeliverySchedule(DeliveryPlan deliveryPlan) { - return toDeliverySchedule(deliveryPlan, null); - } - - private static DeliverySchedule toDeliverySchedule(DeliveryPlan plan, DeliveryPlan overallPlan) { - final Map priorityClassToTotalSpent = overallPlan != null - ? overallPlan.getDeliveryTokens().stream() - .collect(Collectors.toMap(DeliveryToken::getPriorityClass, deliveryToken -> deliveryToken.getSpent() - .sum())) - : Collections.emptyMap(); - - final Set tokens = plan.getDeliveryTokens().stream() - .map(token -> Token.of(token.getPriorityClass(), token.getTotal(), - token.getSpent().sum(), priorityClassToTotalSpent.get(token.getPriorityClass()))) - .collect(Collectors.toSet()); - - return DeliverySchedule.builder() - .planId(plan.getPlanId()) - .planStartTimeStamp(formatTimeStamp(plan.getStartTimeStamp())) - .planExpirationTimeStamp(formatTimeStamp(plan.getEndTimeStamp())) - .planUpdatedTimeStamp(formatTimeStamp(plan.getUpdatedTimeStamp())) - .tokens(tokens) - .build(); - } - - private static String formatTimeStamp(ZonedDateTime zonedDateTime) { - return zonedDateTime != null - ? UTC_MILLIS_FORMATTER.format(zonedDateTime) - : null; - } - - private static class LostToLineItemComparator implements - Comparator { - - @Override - public int compare(org.prebid.server.deals.lineitem.LostToLineItem lostToLineItem1, - org.prebid.server.deals.lineitem.LostToLineItem lostToLineItem2) { - return Long.compare(lostToLineItem1.getCount().sum(), lostToLineItem2.getCount().sum()); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/DeliveryProgressService.java b/src/main/java/org/prebid/server/deals/DeliveryProgressService.java deleted file mode 100644 index ab65595ea47..00000000000 --- a/src/main/java/org/prebid/server/deals/DeliveryProgressService.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.prebid.server.deals; - -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.events.ApplicationEventProcessor; -import org.prebid.server.deals.lineitem.DeliveryPlan; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.lineitem.LineItemStatus; -import org.prebid.server.deals.model.DeliveryProgressProperties; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.DeliverySchedule; -import org.prebid.server.deals.proto.report.LineItemStatusReport; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.log.CriteriaLogManager; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -/** - * Tracks {@link LineItem}s' progress. - */ -public class DeliveryProgressService implements ApplicationEventProcessor { - - private static final Logger logger = LoggerFactory.getLogger(DeliveryProgressService.class); - - private final DeliveryProgressProperties deliveryProgressProperties; - private final LineItemService lineItemService; - private final DeliveryStatsService deliveryStatsService; - private final DeliveryProgressReportFactory deliveryProgressReportFactory; - private final Clock clock; - private final CriteriaLogManager criteriaLogManager; - - private final long lineItemStatusTtl; - - protected final DeliveryProgress overallDeliveryProgress; - protected DeliveryProgress currentDeliveryProgress; - - public DeliveryProgressService(DeliveryProgressProperties deliveryProgressProperties, - LineItemService lineItemService, - DeliveryStatsService deliveryStatsService, - DeliveryProgressReportFactory deliveryProgressReportFactory, - Clock clock, - CriteriaLogManager criteriaLogManager) { - this.deliveryProgressProperties = Objects.requireNonNull(deliveryProgressProperties); - this.lineItemService = Objects.requireNonNull(lineItemService); - this.deliveryStatsService = Objects.requireNonNull(deliveryStatsService); - this.deliveryProgressReportFactory = Objects.requireNonNull(deliveryProgressReportFactory); - this.clock = Objects.requireNonNull(clock); - this.criteriaLogManager = Objects.requireNonNull(criteriaLogManager); - - this.lineItemStatusTtl = TimeUnit.SECONDS.toMillis(deliveryProgressProperties.getLineItemStatusTtlSeconds()); - - final ZonedDateTime now = ZonedDateTime.now(clock); - overallDeliveryProgress = DeliveryProgress.of(now, lineItemService); - currentDeliveryProgress = DeliveryProgress.of(now, lineItemService); - } - - public void shutdown() { - createDeliveryProgressReports(ZonedDateTime.now(clock)); - deliveryStatsService.sendDeliveryProgressReports(); - } - - /** - * Updates copy of overall {@link DeliveryProgress} with current delivery progress and - * creates {@link DeliveryProgressReport}. - */ - public DeliveryProgressReport getOverallDeliveryProgressReport() { - final DeliveryProgress overallDeliveryProgressCopy = - overallDeliveryProgress.copyWithOriginalPlans(); - - lineItemService.getLineItems() - .forEach(lineItem -> overallDeliveryProgressCopy.getLineItemStatuses() - .putIfAbsent(lineItem.getLineItemId(), LineItemStatus.of(lineItem.getLineItemId(), - lineItem.getSource(), lineItem.getDealId(), lineItem.getExtLineItemId(), - lineItem.getAccountId()))); - - overallDeliveryProgressCopy.mergeFrom(currentDeliveryProgress); - return deliveryProgressReportFactory.fromDeliveryProgress(overallDeliveryProgressCopy, ZonedDateTime.now(clock), - true); - } - - /** - * Updates delivery progress from {@link AuctionContext} statistics. - */ - @Override - public void processAuctionEvent(AuctionContext auctionContext) { - processAuctionEvent(auctionContext.getTxnLog(), auctionContext.getAccount().getId(), ZonedDateTime.now(clock)); - } - - /** - * Updates delivery progress from {@link AuctionContext} statistics for defined date. - */ - protected void processAuctionEvent(TxnLog txnLog, String accountId, ZonedDateTime now) { - final Map planIdToTokenPriority = new HashMap<>(); - - txnLog.lineItemSentToClientAsTopMatch().stream() - .map(lineItemService::getLineItemById) - .filter(Objects::nonNull) - .filter(lineItem -> lineItem.getActiveDeliveryPlan() != null) - .forEach(lineItem -> incrementTokens(lineItem, now, planIdToTokenPriority)); - - currentDeliveryProgress.recordTransactionLog(txnLog, planIdToTokenPriority, accountId); - } - - /** - * Updates delivery progress with win event. - */ - @Override - public void processLineItemWinEvent(String lineItemId) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - if (lineItem != null) { - currentDeliveryProgress.recordWinEvent(lineItemId); - criteriaLogManager.log(logger, lineItem.getAccountId(), lineItem.getSource(), lineItemId, - "Win event for LineItem with id %s was recorded".formatted(lineItemId), logger::debug); - } - } - - @Override - public void processDeliveryProgressUpdateEvent() { - lineItemService.getLineItems() - .stream() - .filter(lineItem -> lineItem.getActiveDeliveryPlan() != null) - .forEach(this::mergePlanFromLineItem); - } - - private void mergePlanFromLineItem(LineItem lineItem) { - overallDeliveryProgress.upsertPlanReferenceFromLineItem(lineItem); - currentDeliveryProgress.mergePlanFromLineItem(lineItem); - } - - /** - * Prepare report from statuses to send it to delivery stats. - */ - public void createDeliveryProgressReports(ZonedDateTime now) { - final DeliveryProgress deliveryProgressToReport = currentDeliveryProgress; - - currentDeliveryProgress = DeliveryProgress.of(now, lineItemService); - - deliveryProgressToReport.setEndTimeStamp(now); - deliveryProgressToReport.updateWithActiveLineItems(lineItemService.getLineItems()); - - overallDeliveryProgress.mergeFrom(deliveryProgressToReport); - - deliveryStatsService.addDeliveryProgress(deliveryProgressToReport, - overallDeliveryProgress.getLineItemStatuses()); - - overallDeliveryProgress.cleanLineItemStatuses( - now, lineItemStatusTtl, deliveryProgressProperties.getCachedPlansNumber()); - } - - public void invalidateLineItemsByIds(List lineItemIds) { - overallDeliveryProgress.getLineItemStatuses().entrySet() - .removeIf(stringLineItemEntry -> lineItemIds.contains(stringLineItemEntry.getKey())); - currentDeliveryProgress.getLineItemStatuses().entrySet() - .removeIf(stringLineItemEntry -> lineItemIds.contains(stringLineItemEntry.getKey())); - } - - public void invalidateLineItems() { - overallDeliveryProgress.getLineItemStatuses().clear(); - currentDeliveryProgress.getLineItemStatuses().clear(); - } - - /** - * Increments tokens for specified in parameters lineItem, plan and class priority. - */ - protected void incrementTokens(LineItem lineItem, ZonedDateTime now, Map planIdToTokenPriority) { - final Integer classPriority = lineItem.incSpentToken(now); - if (classPriority != null) { - planIdToTokenPriority.put(lineItem.getActiveDeliveryPlan().getPlanId(), classPriority); - } - } - - /** - * Returns {@link LineItemStatusReport} for the given {@link LineItem}'s ID. - */ - public LineItemStatusReport getLineItemStatusReport(String lineItemId) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - if (lineItem == null) { - throw new PreBidException("LineItem not found: " + lineItemId); - } - - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - if (activeDeliveryPlan == null) { - return LineItemStatusReport.builder() - .lineItemId(lineItemId) - .build(); - } - - final DeliverySchedule deliverySchedule = DeliveryProgressReportFactory.toDeliverySchedule(activeDeliveryPlan); - return LineItemStatusReport.builder() - .lineItemId(lineItemId) - .deliverySchedule(deliverySchedule) - .readyToServeTimestamp(lineItem.getReadyAt()) - .spentTokens(activeDeliveryPlan.getSpentTokens()) - .pacingFrequency(activeDeliveryPlan.getDeliveryRateInMilliseconds()) - .accountId(lineItem.getAccountId()) - .target(lineItem.getTargeting()) - .build(); - } -} diff --git a/src/main/java/org/prebid/server/deals/DeliveryStatsService.java b/src/main/java/org/prebid/server/deals/DeliveryStatsService.java deleted file mode 100644 index 8fe8973b394..00000000000 --- a/src/main/java/org/prebid/server/deals/DeliveryStatsService.java +++ /dev/null @@ -1,294 +0,0 @@ -package org.prebid.server.deals; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.http.HttpHeaders; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.lineitem.LineItemStatus; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeliveryStatsProperties; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.DeliveryProgressReportBatch; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.MetricName; -import org.prebid.server.metric.Metrics; -import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.Base64; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Map; -import java.util.NavigableSet; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentSkipListSet; -import java.util.zip.GZIPOutputStream; - -public class DeliveryStatsService implements Suspendable { - - private static final Logger logger = LoggerFactory.getLogger(DeliveryStatsService.class); - - private static final String BASIC_AUTH_PATTERN = "Basic %s"; - private static final String PG_TRX_ID = "pg-trx-id"; - private static final String PBS_DELIVERY_CLIENT_ERROR = "pbs-delivery-stats-client-error"; - private static final String SERVICE_NAME = "deliveryStats"; - public static final String GZIP = "gzip"; - - private final DeliveryStatsProperties deliveryStatsProperties; - private final DeliveryProgressReportFactory deliveryProgressReportFactory; - private final AlertHttpService alertHttpService; - private final HttpClient httpClient; - private final Metrics metrics; - private final Clock clock; - private final Vertx vertx; - private final JacksonMapper mapper; - - private final String basicAuthHeader; - private final NavigableSet requiredBatches; - private volatile boolean isSuspended; - - public DeliveryStatsService(DeliveryStatsProperties deliveryStatsProperties, - DeliveryProgressReportFactory deliveryProgressReportFactory, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - Vertx vertx, - JacksonMapper mapper) { - - this.deliveryStatsProperties = Objects.requireNonNull(deliveryStatsProperties); - this.deliveryProgressReportFactory = Objects.requireNonNull(deliveryProgressReportFactory); - this.alertHttpService = Objects.requireNonNull(alertHttpService); - this.httpClient = Objects.requireNonNull(httpClient); - this.clock = Objects.requireNonNull(clock); - this.vertx = Objects.requireNonNull(vertx); - this.metrics = Objects.requireNonNull(metrics); - this.mapper = Objects.requireNonNull(mapper); - this.basicAuthHeader = authHeader(deliveryStatsProperties.getUsername(), deliveryStatsProperties.getPassword()); - - requiredBatches = new ConcurrentSkipListSet<>(Comparator - .comparing(DeliveryProgressReportBatch::getDataWindowEndTimeStamp) - .thenComparing(DeliveryProgressReportBatch::hashCode)); - } - - @Override - public void suspend() { - isSuspended = true; - } - - public void addDeliveryProgress(DeliveryProgress deliveryProgress, - Map overallLineItemStatuses) { - requiredBatches.add(deliveryProgressReportFactory.batchFromDeliveryProgress(deliveryProgress, - overallLineItemStatuses, null, deliveryStatsProperties.getLineItemsPerReport(), false)); - } - - public void sendDeliveryProgressReports() { - sendDeliveryProgressReports(ZonedDateTime.now(clock)); - } - - public void sendDeliveryProgressReports(ZonedDateTime now) { - if (isSuspended) { - logger.warn("Report will not be sent, as service was suspended from register response"); - return; - } - final long batchesIntervalMs = deliveryStatsProperties.getBatchesIntervalMs(); - final int batchesCount = requiredBatches.size(); - final Set sentBatches = new HashSet<>(); - requiredBatches.stream() - .reduce(Future.succeededFuture(), - (future, batch) -> future.compose(v -> sendBatch(batch, now) - .map(aVoid -> sentBatches.add(batch)) - .compose(aVoid -> batchesIntervalMs > 0 && batchesCount > sentBatches.size() - ? setInterval(batchesIntervalMs) - : Future.succeededFuture())), - // combiner does not do any useful operations, just required for this type of reduce operation - (a, b) -> Promise.promise().future()) - .onComplete(result -> handleDeliveryResult(result, batchesCount, sentBatches)); - } - - protected Future sendBatch(DeliveryProgressReportBatch deliveryProgressReportBatch, ZonedDateTime now) { - final Promise promise = Promise.promise(); - final MultiMap headers = headers(); - final Set sentReports = new HashSet<>(); - final long reportIntervalMs = deliveryStatsProperties.getReportsIntervalMs(); - final Set reports = deliveryProgressReportBatch.getReports(); - final int reportsCount = reports.size(); - reports.stream() - .reduce(Future.succeededFuture(), - (future, report) -> future.compose(v -> sendReport(report, headers, now) - .map(aVoid -> sentReports.add(report))) - .compose(aVoid -> reportIntervalMs > 0 && reportsCount > sentReports.size() - ? setInterval(reportIntervalMs) - : Future.succeededFuture()), - (a, b) -> Promise.promise().future()) - .onComplete(result -> handleBatchDelivery(result, deliveryProgressReportBatch, sentReports, promise)); - return promise.future(); - } - - protected Future sendReport(DeliveryProgressReport deliveryProgressReport, MultiMap headers, - ZonedDateTime now) { - final Promise promise = Promise.promise(); - final long startTime = clock.millis(); - if (isSuspended) { - logger.warn("Report will not be sent, as service was suspended from register response"); - promise.complete(); - return promise.future(); - } - - final String body = mapper.encodeToString(deliveryProgressReportFactory - .updateReportTimeStamp(deliveryProgressReport, now)); - - logger.info("Sending delivery progress report to Delivery Stats, {0} is {1}", PG_TRX_ID, - headers.get(PG_TRX_ID)); - logger.debug("Delivery progress report is: {0}", body); - if (deliveryStatsProperties.isRequestCompressionEnabled()) { - headers.add(HttpHeaders.CONTENT_ENCODING, GZIP); - httpClient.request(HttpMethod.POST, deliveryStatsProperties.getEndpoint(), headers, gzipBody(body), - deliveryStatsProperties.getTimeoutMs()) - .onComplete(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, - startTime)); - } else { - httpClient.post(deliveryStatsProperties.getEndpoint(), headers, body, - deliveryStatsProperties.getTimeoutMs()) - .onComplete(result -> handleDeliveryProgressReport(result, deliveryProgressReport, promise, - startTime)); - } - - return promise.future(); - } - - /** - * Handles delivery report response from Planner. - */ - private void handleDeliveryProgressReport(AsyncResult result, - DeliveryProgressReport deliveryProgressReport, - Promise promise, - long startTime) { - metrics.updateRequestTimeMetric(MetricName.delivery_request_time, clock.millis() - startTime); - if (result.failed()) { - logger.warn("Cannot send delivery progress report to delivery stats service", result.cause()); - promise.fail(new PreBidException("Sending report with id = %s failed in a reason: %s" - .formatted(deliveryProgressReport.getReportId(), result.cause().getMessage()))); - } else { - final int statusCode = result.result().getStatusCode(); - final String reportId = deliveryProgressReport.getReportId(); - if (statusCode == 200 || statusCode == 409) { - handleSuccessfulResponse(deliveryProgressReport, promise, statusCode, reportId); - } else { - logger.warn("HTTP status code {0}", statusCode); - promise.fail(new PreBidException( - "Delivery stats service responded with status code = %s for report with id = %s" - .formatted(statusCode, deliveryProgressReport.getReportId()))); - } - } - } - - private void handleSuccessfulResponse(DeliveryProgressReport deliveryProgressReport, Promise promise, - int statusCode, String reportId) { - metrics.updateDeliveryRequestMetric(true); - promise.complete(); - if (statusCode == 409) { - logger.info("Delivery stats service respond with 409 duplicated, report with {0} line items and id = {1}" - + " was already delivered before and will be removed from from delivery queue", - deliveryProgressReport.getLineItemStatus().size(), reportId); - } else { - logger.info("Delivery progress report with {0} line items and id = {1} was successfully sent to" - + " delivery stats service", deliveryProgressReport.getLineItemStatus().size(), reportId); - } - } - - private Future setInterval(long interval) { - final Promise promise = Promise.promise(); - vertx.setTimer(interval, event -> promise.complete()); - return promise.future(); - } - - private void handleDeliveryResult(AsyncResult result, int reportBatchesNumber, - Set sentBatches) { - if (result.failed()) { - logger.warn("Failed to send {0} report batches, {1} report batches left to send." - + " Reason is: {2}", reportBatchesNumber, reportBatchesNumber - sentBatches.size(), - result.cause().getMessage()); - alertHttpService.alertWithPeriod( - SERVICE_NAME, - PBS_DELIVERY_CLIENT_ERROR, - AlertPriority.MEDIUM, - "Report was not send to delivery stats service with a reason: " + result.cause().getMessage()); - requiredBatches.removeAll(sentBatches); - handleFailedReportDelivery(); - } else { - requiredBatches.clear(); - alertHttpService.resetAlertCount(PBS_DELIVERY_CLIENT_ERROR); - logger.info("{0} report batches were successfully sent.", reportBatchesNumber); - } - } - - private void handleBatchDelivery(AsyncResult result, - DeliveryProgressReportBatch deliveryProgressReportBatch, - Set sentReports, - Promise promise) { - final String reportId = deliveryProgressReportBatch.getReportId(); - final String endTimeWindow = deliveryProgressReportBatch.getDataWindowEndTimeStamp(); - final int batchSize = deliveryProgressReportBatch.getReports().size(); - final int sentSize = sentReports.size(); - if (result.succeeded()) { - logger.info("Batch of reports with reports id = {0}, end time window = {1} and size {2} was successfully" - + " sent", reportId, endTimeWindow, batchSize); - promise.complete(); - } else { - logger.warn("Failed to sent batch of reports with reports id = {0} end time windows = {1}." - + " {2} out of {3} were sent.", reportId, endTimeWindow, sentSize, batchSize); - deliveryProgressReportBatch.removeReports(sentReports); - promise.fail(result.cause().getMessage()); - } - } - - protected MultiMap headers() { - return MultiMap.caseInsensitiveMultiMap() - .add(HttpUtil.AUTHORIZATION_HEADER, basicAuthHeader) - .add(HttpUtil.CONTENT_TYPE_HEADER, HttpUtil.APPLICATION_JSON_CONTENT_TYPE) - .add(PG_TRX_ID, UUID.randomUUID().toString()); - } - - /** - * Creates Authorization header value from username and password. - */ - private static String authHeader(String username, String password) { - return BASIC_AUTH_PATTERN - .formatted(Base64.getEncoder().encodeToString((username + ':' + password).getBytes())); - } - - private static byte[] gzipBody(String body) { - try ( - ByteArrayOutputStream obj = new ByteArrayOutputStream(); - GZIPOutputStream gzip = new GZIPOutputStream(obj)) { - gzip.write(body.getBytes(StandardCharsets.UTF_8)); - gzip.finish(); - return obj.toByteArray(); - } catch (IOException e) { - throw new PreBidException("Failed to gzip request with a reason : " + e.getMessage()); - } - } - - private void handleFailedReportDelivery() { - metrics.updateDeliveryRequestMetric(false); - while (requiredBatches.size() > deliveryStatsProperties.getCachedReportsNumber()) { - requiredBatches.pollFirst(); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/LineItemService.java b/src/main/java/org/prebid/server/deals/LineItemService.java deleted file mode 100644 index 1fafdadfa9b..00000000000 --- a/src/main/java/org/prebid/server/deals/LineItemService.java +++ /dev/null @@ -1,591 +0,0 @@ -package org.prebid.server.deals; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.lineitem.DeliveryPlan; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.MatchLineItemsResult; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.deals.targeting.TargetingDefinition; -import org.prebid.server.exception.TargetingSyntaxException; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category; -import org.prebid.server.util.HttpUtil; - -import java.math.BigDecimal; -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -/** - * Works with {@link LineItem} related information. - */ -public class LineItemService { - - private static final Logger logger = LoggerFactory.getLogger(LineItemService.class); - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String ACTIVE = "active"; - private static final String PG_IGNORE_PACING_VALUE = "1"; - - private final Comparator lineItemComparator = Comparator - .comparing(LineItem::getHighestUnspentTokensClass, Comparator.nullsLast(Comparator.naturalOrder())) - .thenComparing(LineItem::getRelativePriority, Comparator.nullsLast(Comparator.naturalOrder())) - .thenComparing(LineItem::getCpm, Comparator.nullsLast(Comparator.reverseOrder())); - - private final int maxDealsPerBidder; - private final TargetingService targetingService; - private final CurrencyConversionService conversionService; - protected final ApplicationEventService applicationEventService; - private final String adServerCurrency; - private final Clock clock; - private final CriteriaLogManager criteriaLogManager; - - protected final Map idToLineItems; - protected volatile boolean isPlannerResponsive; - - public LineItemService(int maxDealsPerBidder, - TargetingService targetingService, - CurrencyConversionService conversionService, - ApplicationEventService applicationEventService, - String adServerCurrency, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - this.maxDealsPerBidder = maxDealsPerBidder; - this.targetingService = Objects.requireNonNull(targetingService); - this.conversionService = Objects.requireNonNull(conversionService); - this.applicationEventService = Objects.requireNonNull(applicationEventService); - this.adServerCurrency = Objects.requireNonNull(adServerCurrency); - this.clock = Objects.requireNonNull(clock); - this.criteriaLogManager = Objects.requireNonNull(criteriaLogManager); - - idToLineItems = new ConcurrentHashMap<>(); - } - - /** - * Returns {@link LineItem} by its id. - */ - public LineItem getLineItemById(String lineItemId) { - return idToLineItems.get(lineItemId); - } - - /** - * Returns true when account has at least one active {@link LineItem}. - */ - public boolean accountHasDeals(AuctionContext auctionContext) { - return accountHasDeals(auctionContext.getAccount().getId(), ZonedDateTime.now(clock)); - } - - /** - * Returns true when account has at least one active {@link LineItem} in the given time. - */ - public boolean accountHasDeals(String account, ZonedDateTime now) { - return StringUtils.isNotEmpty(account) - && idToLineItems.values().stream().anyMatch(lineItem -> Objects.equals(lineItem.getAccountId(), account) - && lineItem.isActive(now)); - } - - /** - * Finds among active Line Items those matching Imp of the OpenRTB2 request - * taking into account Line Items’ targeting and delivery progress. - */ - public MatchLineItemsResult findMatchingLineItems(BidRequest bidRequest, - Imp imp, - String bidder, - BidderAliases aliases, - AuctionContext auctionContext) { - - final ZonedDateTime now = ZonedDateTime.now(clock); - return findMatchingLineItems(bidRequest, imp, bidder, aliases, auctionContext, now); - } - - /** - * Finds among active Line Items those matching Imp of the OpenRTB2 request - * taking into account Line Items’ targeting and delivery progress by the given time. - */ - protected MatchLineItemsResult findMatchingLineItems(BidRequest bidRequest, - Imp imp, - String bidder, - BidderAliases aliases, - AuctionContext auctionContext, - ZonedDateTime now) { - - final List matchedLineItems = - getPreMatchedLineItems(auctionContext.getAccount().getId(), bidder, aliases).stream() - .filter(lineItem -> isTargetingMatched(lineItem, bidRequest, imp, auctionContext)) - .toList(); - - return MatchLineItemsResult.of( - postProcessMatchedLineItems(matchedLineItems, bidRequest, imp, auctionContext, now)); - } - - public void updateIsPlannerResponsive(boolean isPlannerResponsive) { - this.isPlannerResponsive = isPlannerResponsive; - } - - /** - * Updates metadata, starts tracking new {@link LineItem}s and {@link DeliverySchedule}s - * and remove from tracking expired. - */ - public void updateLineItems(List planResponse, boolean isPlannerResponsive) { - updateLineItems(planResponse, isPlannerResponsive, ZonedDateTime.now(clock)); - } - - public void updateLineItems(List planResponse, boolean isPlannerResponsive, ZonedDateTime now) { - this.isPlannerResponsive = isPlannerResponsive; - if (isPlannerResponsive) { - final List lineItemsMetaData = ListUtils.emptyIfNull(planResponse).stream() - .filter(lineItemMetaData -> !isExpired(now, lineItemMetaData.getEndTimeStamp())) - .filter(lineItemMetaData -> Objects.equals(lineItemMetaData.getStatus(), ACTIVE)) - .toList(); - - removeInactiveLineItems(planResponse, now); - lineItemsMetaData.forEach(lineItemMetaData -> updateLineItem(lineItemMetaData, now)); - } - } - - public void invalidateLineItemsByIds(List lineItemIds) { - idToLineItems.entrySet().removeIf(stringLineItemEntry -> lineItemIds.contains(stringLineItemEntry.getKey())); - logger.info("Line Items with ids {0} were removed", String.join(", ", lineItemIds)); - } - - public void invalidateLineItems() { - final String lineItemsToRemove = String.join(", ", idToLineItems.keySet()); - idToLineItems.clear(); - logger.info("Line Items with ids {0} were removed", lineItemsToRemove); - } - - private boolean isExpired(ZonedDateTime now, ZonedDateTime endTime) { - return now.isAfter(endTime); - } - - private void removeInactiveLineItems(List planResponse, ZonedDateTime now) { - final Set lineItemsToRemove = ListUtils.emptyIfNull(planResponse).stream() - .filter(lineItemMetaData -> !Objects.equals(lineItemMetaData.getStatus(), ACTIVE) - || isExpired(now, lineItemMetaData.getEndTimeStamp())) - .map(LineItemMetaData::getLineItemId) - .collect(Collectors.toSet()); - - idToLineItems.entrySet().stream() - .filter(entry -> isExpired(now, entry.getValue().getEndTimeStamp())) - .map(Map.Entry::getKey) - .collect(Collectors.toCollection(() -> lineItemsToRemove)); - - if (CollectionUtils.isNotEmpty(lineItemsToRemove)) { - logger.info("Line Items {0} were dropped as expired or inactive", String.join(", ", lineItemsToRemove)); - } - idToLineItems.entrySet().removeIf(entry -> lineItemsToRemove.contains(entry.getKey())); - } - - protected Collection getLineItems() { - return idToLineItems.values(); - } - - protected void updateLineItem(LineItemMetaData lineItemMetaData, ZonedDateTime now) { - final TargetingDefinition targetingDefinition = makeTargeting(lineItemMetaData); - final Price normalizedPrice = normalizedPrice(lineItemMetaData); - - idToLineItems.compute(lineItemMetaData.getLineItemId(), (id, li) -> li != null - ? li.withUpdatedMetadata(lineItemMetaData, normalizedPrice, targetingDefinition, li.getReadyAt(), now) - : LineItem.of(lineItemMetaData, normalizedPrice, targetingDefinition, now)); - } - - public void advanceToNextPlan(ZonedDateTime now) { - final Collection lineItems = idToLineItems.values(); - for (LineItem lineItem : lineItems) { - lineItem.advanceToNextPlan(now, isPlannerResponsive); - } - applicationEventService.publishDeliveryUpdateEvent(); - } - - /** - * Creates {@link TargetingDefinition} from {@link LineItemMetaData} targeting json node. - */ - private TargetingDefinition makeTargeting(LineItemMetaData lineItemMetaData) { - TargetingDefinition targetingDefinition; - try { - targetingDefinition = targetingService.parseTargetingDefinition(lineItemMetaData.getTargeting(), - lineItemMetaData.getLineItemId()); - } catch (TargetingSyntaxException e) { - criteriaLogManager.log( - logger, - lineItemMetaData.getAccountId(), - lineItemMetaData.getSource(), - lineItemMetaData.getLineItemId(), - "Line item targeting parsing failed with a reason: " + e.getMessage(), - logger::warn); - targetingDefinition = null; - } - return targetingDefinition; - } - - /** - * Returns {@link Price} with converted lineItem cpm to adServerCurrency. - */ - private Price normalizedPrice(LineItemMetaData lineItemMetaData) { - final Price price = lineItemMetaData.getPrice(); - if (price == null) { - return null; - } - - final String receivedCur = price.getCurrency(); - if (StringUtils.equals(adServerCurrency, receivedCur)) { - return price; - } - final BigDecimal updatedCpm = conversionService - .convertCurrency(price.getCpm(), Collections.emptyMap(), receivedCur, adServerCurrency, null); - - return Price.of(updatedCpm, adServerCurrency); - } - - private List getPreMatchedLineItems(String accountId, String bidder, BidderAliases aliases) { - if (StringUtils.isBlank(accountId)) { - return Collections.emptyList(); - } - - final List accountsLineItems = idToLineItems.values().stream() - .filter(lineItem -> lineItem.getAccountId().equals(accountId)) - .toList(); - - if (accountsLineItems.isEmpty()) { - criteriaLogManager.log( - logger, - accountId, - "There are no line items for account " + accountId, - logger::debug); - return Collections.emptyList(); - } - - return accountsLineItems.stream() - .filter(lineItem -> aliases.isSame(bidder, lineItem.getSource())) - .toList(); - } - - /** - * Returns true if {@link LineItem}s {@link TargetingDefinition} matches to {@link Imp}. - *

- * Updates deep debug log with matching information. - */ - private boolean isTargetingMatched(LineItem lineItem, - BidRequest bidRequest, - Imp imp, - AuctionContext auctionContext) { - - final TargetingDefinition targetingDefinition = lineItem.getTargetingDefinition(); - final String accountId = auctionContext.getAccount().getId(); - final String source = lineItem.getSource(); - final String lineItemId = lineItem.getLineItemId(); - if (targetingDefinition == null) { - deepDebug( - auctionContext, - Category.targeting, - "Line Item %s targeting was not defined or has incorrect format".formatted(lineItemId), - accountId, - source, - lineItemId); - return false; - } - - final boolean matched = targetingService.matchesTargeting( - bidRequest, imp, lineItem.getTargetingDefinition(), auctionContext); - - final String debugMessage = matched - ? "Line Item %s targeting matched imp with id %s".formatted(lineItemId, imp.getId()) - : "Line Item %s targeting did not match imp with id %s".formatted(lineItemId, imp.getId()); - deepDebug( - auctionContext, - Category.targeting, - debugMessage, - accountId, - source, - lineItemId); - - return matched; - } - - /** - * Filters {@link LineItem}s by next parameters: fcaps, readyAt, limit per bidder, same deal line items. - */ - private List postProcessMatchedLineItems(List lineItems, - BidRequest bidRequest, - Imp imp, - AuctionContext auctionContext, - ZonedDateTime now) { - - final TxnLog txnLog = auctionContext.getTxnLog(); - final List fcapIds = bidRequest.getUser().getExt().getFcapIds(); - - return lineItems.stream() - .peek(lineItem -> txnLog.lineItemsMatchedWholeTargeting().add(lineItem.getLineItemId())) - .filter(lineItem -> isNotFrequencyCapped(fcapIds, lineItem, auctionContext, txnLog)) - .filter(lineItem -> planHasTokensIfPresent(lineItem, auctionContext)) - .filter(lineItem -> isReadyAtInPast(now, lineItem, auctionContext, txnLog)) - .peek(lineItem -> txnLog.lineItemsReadyToServe().add(lineItem.getLineItemId())) - .collect(Collectors.groupingBy(lineItem -> lineItem.getSource().toLowerCase())) - .values().stream() - .map(valueAsLineItems -> filterLineItemPerBidder(valueAsLineItems, auctionContext, imp)) - .filter(CollectionUtils::isNotEmpty) - .peek(lineItemsForBidder -> recordInTxnSentToBidderAsTopMatch(txnLog, lineItemsForBidder)) - .flatMap(Collection::stream) - .peek(lineItem -> txnLog.lineItemsSentToBidder().get(lineItem.getSource()) - .add(lineItem.getLineItemId())) - .toList(); - } - - private boolean planHasTokensIfPresent(LineItem lineItem, AuctionContext auctionContext) { - if (hasUnspentTokens(lineItem) || ignorePacing(auctionContext)) { - return true; - } - - final String lineItemId = lineItem.getLineItemId(); - final String lineItemSource = lineItem.getSource(); - auctionContext.getTxnLog().lineItemsPacingDeferred().add(lineItemId); - deepDebug( - auctionContext, - Category.pacing, - "Matched Line Item %s for bidder %s does not have unspent tokens to be served" - .formatted(lineItemId, lineItemSource), - auctionContext.getAccount().getId(), - lineItemSource, - lineItemId); - - return false; - } - - private boolean hasUnspentTokens(LineItem lineItem) { - final DeliveryPlan deliveryPlan = lineItem.getActiveDeliveryPlan(); - return deliveryPlan == null || deliveryPlan.getDeliveryTokens().stream() - .anyMatch(deliveryToken -> deliveryToken.getUnspent() > 0); - } - - private static boolean ignorePacing(AuctionContext auctionContext) { - return PG_IGNORE_PACING_VALUE - .equals(auctionContext.getHttpRequest().getHeaders().get(HttpUtil.PG_IGNORE_PACING)); - } - - private boolean isReadyAtInPast(ZonedDateTime now, - LineItem lineItem, - AuctionContext auctionContext, - TxnLog txnLog) { - - final ZonedDateTime readyAt = lineItem.getReadyAt(); - final boolean ready = (readyAt != null && isBeforeOrEqual(readyAt, now)) || ignorePacing(auctionContext); - final String accountId = auctionContext.getAccount().getId(); - final String lineItemSource = lineItem.getSource(); - final String lineItemId = lineItem.getLineItemId(); - - if (ready) { - deepDebug( - auctionContext, - Category.pacing, - "Matched Line Item %s for bidder %s ready to serve. relPriority %d" - .formatted(lineItemId, lineItemSource, lineItem.getRelativePriority()), - accountId, - lineItemSource, - lineItemId); - } else { - txnLog.lineItemsPacingDeferred().add(lineItemId); - deepDebug( - auctionContext, - Category.pacing, - "Matched Line Item %s for bidder %s not ready to serve. Will be ready at %s, current time is %s" - .formatted( - lineItemId, - lineItemSource, - readyAt != null ? UTC_MILLIS_FORMATTER.format(readyAt) : "never", - UTC_MILLIS_FORMATTER.format(now)), - accountId, - lineItemSource, - lineItemId); - } - - return ready; - } - - private static boolean isBeforeOrEqual(ZonedDateTime before, ZonedDateTime after) { - return before.isBefore(after) || before.isEqual(after); - } - - /** - * Returns false if {@link LineItem} has fcaps defined and either - * - one of them present in the list of fcaps reached - * - list of fcaps reached is null which means that calling User Data Store failed - *

- * Otherwise returns true - *

- * Has side effect - records discarded line item id in the transaction log - */ - private boolean isNotFrequencyCapped(List frequencyCappedByIds, - LineItem lineItem, - AuctionContext auctionContext, - TxnLog txnLog) { - - if (CollectionUtils.isEmpty(lineItem.getFcapIds())) { - return true; - } - - final String lineItemId = lineItem.getLineItemId(); - final String accountId = auctionContext.getAccount().getId(); - final String lineItemSource = lineItem.getSource(); - - if (frequencyCappedByIds == null) { - txnLog.lineItemsMatchedTargetingFcapLookupFailed().add(lineItemId); - final String message = """ - Failed to match fcap for Line Item %s bidder %s in a reason of bad \ - response from user data service""".formatted(lineItemId, lineItemSource); - deepDebug(auctionContext, Category.pacing, message, accountId, lineItemSource, lineItemId); - criteriaLogManager.log( - logger, - lineItem.getAccountId(), - lineItem.getSource(), - lineItemId, - "Failed to match fcap for lineItem %s in a reason of bad response from user data service" - .formatted(lineItemId), - logger::debug); - - return false; - } else if (!frequencyCappedByIds.isEmpty()) { - final Optional fcapIdOptional = lineItem.getFcapIds().stream() - .filter(frequencyCappedByIds::contains).findFirst(); - if (fcapIdOptional.isPresent()) { - final String fcapId = fcapIdOptional.get(); - txnLog.lineItemsMatchedTargetingFcapped().add(lineItemId); - final String message = "Matched Line Item %s for bidder %s is frequency capped by fcap id %s." - .formatted(lineItemId, lineItemSource, fcapId); - deepDebug(auctionContext, Category.pacing, message, accountId, lineItemSource, lineItemId); - criteriaLogManager.log( - logger, lineItem.getAccountId(), lineItem.getSource(), lineItemId, message, logger::debug); - return false; - } - } - - return true; - } - - /** - * Filters {@link LineItem} with the same deal id and cuts {@link List} by maxDealsPerBidder value. - */ - private List filterLineItemPerBidder(List lineItems, AuctionContext auctionContext, Imp imp) { - final List sortedLineItems = new ArrayList<>(lineItems); - Collections.shuffle(sortedLineItems); - sortedLineItems.sort(lineItemComparator); - - final List filteredLineItems = uniqueBySentToBidderAsTopMatch(sortedLineItems, auctionContext, imp); - updateLostToLineItems(filteredLineItems, auctionContext.getTxnLog()); - - final Set dealIds = new HashSet<>(); - final List resolvedLineItems = new ArrayList<>(); - for (final LineItem lineItem : filteredLineItems) { - final String dealId = lineItem.getDealId(); - if (!dealIds.contains(dealId)) { - dealIds.add(dealId); - resolvedLineItems.add(lineItem); - } - } - return resolvedLineItems.size() > maxDealsPerBidder - ? cutLineItemsToDealMaxNumber(resolvedLineItems) - : resolvedLineItems; - } - - /** - * Removes from consideration any line items that have already been sent to bidder as the TopMatch - * in a previous impression for auction. - */ - private List uniqueBySentToBidderAsTopMatch(List lineItems, - AuctionContext auctionContext, - Imp imp) { - - final TxnLog txnLog = auctionContext.getTxnLog(); - final Set topMatchedLineItems = txnLog.lineItemsSentToBidderAsTopMatch().values().stream() - .flatMap(Collection::stream) - .collect(Collectors.toSet()); - - final List result = new ArrayList<>(lineItems); - for (LineItem lineItem : lineItems) { - final String lineItemId = lineItem.getLineItemId(); - if (!topMatchedLineItems.contains(lineItemId)) { - return result; - } - result.remove(lineItem); - deepDebug( - auctionContext, - Category.cleanup, - "LineItem %s was dropped from imp with id %s because it was top match in another imp" - .formatted(lineItemId, imp.getId()), - auctionContext.getAccount().getId(), - lineItem.getSource(), - lineItemId); - } - return result; - } - - private List cutLineItemsToDealMaxNumber(List resolvedLineItems) { - resolvedLineItems.subList(maxDealsPerBidder, resolvedLineItems.size()) - .forEach(lineItem -> criteriaLogManager.log( - logger, - lineItem.getAccountId(), - lineItem.getSource(), - lineItem.getLineItemId(), - "LineItem %s was dropped by max deal per bidder limit %s" - .formatted(lineItem.getLineItemId(), maxDealsPerBidder), - logger::debug)); - return resolvedLineItems.subList(0, maxDealsPerBidder); - } - - private void updateLostToLineItems(List lineItems, TxnLog txnLog) { - for (int i = 1; i < lineItems.size(); i++) { - final LineItem lineItem = lineItems.get(i); - final Set lostTo = lineItems.subList(0, i).stream() - .map(LineItem::getLineItemId) - .collect(Collectors.toSet()); - txnLog.lostMatchingToLineItems().put(lineItem.getLineItemId(), lostTo); - } - } - - private void deepDebug(AuctionContext auctionContext, - Category category, - String message, - String accountId, - String bidder, - String lineItemId) { - - criteriaLogManager.log(logger, accountId, bidder, lineItemId, message, logger::debug); - auctionContext.getDeepDebugLog().add(lineItemId, category, () -> message); - } - - private static void recordInTxnSentToBidderAsTopMatch(TxnLog txnLog, List lineItemsForBidder) { - final LineItem topLineItem = lineItemsForBidder.get(0); - txnLog.lineItemsSentToBidderAsTopMatch() - .get(topLineItem.getSource()) - .add(topLineItem.getLineItemId()); - } -} diff --git a/src/main/java/org/prebid/server/deals/PlannerService.java b/src/main/java/org/prebid/server/deals/PlannerService.java deleted file mode 100644 index e719ad314f2..00000000000 --- a/src/main/java/org/prebid/server/deals/PlannerService.java +++ /dev/null @@ -1,239 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.type.TypeReference; -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.MetricName; -import org.prebid.server.metric.Metrics; -import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.time.Clock; -import java.util.Base64; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Class manages line item metadata retrieving from planner and reporting. - */ -public class PlannerService implements Suspendable { - - private static final Logger logger = LoggerFactory.getLogger(PlannerService.class); - - protected static final TypeReference> LINE_ITEM_METADATA_TYPE_REFERENCE = - new TypeReference<>() { - }; - - private static final String BASIC_AUTH_PATTERN = "Basic %s"; - private static final String PG_TRX_ID = "pg-trx-id"; - private static final String INSTANCE_ID_PARAMETER = "instanceId"; - private static final String REGION_PARAMETER = "region"; - private static final String VENDOR_PARAMETER = "vendor"; - private static final String SERVICE_NAME = "planner"; - private static final String PBS_PLANNER_CLIENT_ERROR = "pbs-planner-client-error"; - private static final String PBS_PLANNER_EMPTY_RESPONSE = "pbs-planner-empty-response-error"; - - private final LineItemService lineItemService; - private final DeliveryProgressService deliveryProgressService; - private final AlertHttpService alertHttpService; - protected final HttpClient httpClient; - private final Metrics metrics; - private final Clock clock; - private final JacksonMapper mapper; - - protected final String planEndpoint; - private final long plannerTimeout; - private final String basicAuthHeader; - - protected final AtomicBoolean isPlannerResponsive; - private volatile boolean isSuspended; - - public PlannerService(PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - LineItemService lineItemService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - JacksonMapper mapper) { - this.lineItemService = Objects.requireNonNull(lineItemService); - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.alertHttpService = Objects.requireNonNull(alertHttpService); - this.httpClient = Objects.requireNonNull(httpClient); - this.metrics = Objects.requireNonNull(metrics); - this.clock = Objects.requireNonNull(clock); - this.mapper = Objects.requireNonNull(mapper); - - this.planEndpoint = buildPlannerMetaDataUrl(plannerProperties.getPlanEndpoint(), - deploymentProperties.getPbsHostId(), - deploymentProperties.getPbsRegion(), - deploymentProperties.getPbsVendor()); - this.plannerTimeout = plannerProperties.getTimeoutMs(); - this.basicAuthHeader = authHeader(plannerProperties.getUsername(), plannerProperties.getPassword()); - - this.isPlannerResponsive = new AtomicBoolean(true); - } - - @Override - public void suspend() { - isSuspended = true; - } - - /** - * Fetches line items meta data from Planner - */ - protected Future> fetchLineItemMetaData(String plannerUrl, MultiMap headers) { - logger.info("Requesting line items metadata and plans from Planner, {0} is {1}", PG_TRX_ID, - headers.get(PG_TRX_ID)); - final long startTime = clock.millis(); - return httpClient.get(plannerUrl, headers, plannerTimeout) - .map(httpClientResponse -> processLineItemMetaDataResponse(httpClientResponse, startTime)); - } - - protected MultiMap headers() { - return MultiMap.caseInsensitiveMultiMap() - .add(HttpUtil.AUTHORIZATION_HEADER, basicAuthHeader) - .add(PG_TRX_ID, UUID.randomUUID().toString()); - } - - /** - * Processes response from planner. - * If status code == 4xx - stop fetching process. - * If status code =! 2xx - start retry fetching process. - * If status code == 200 - parse response. - */ - protected List processLineItemMetaDataResponse(HttpClientResponse response, long startTime) { - final int statusCode = response.getStatusCode(); - if (statusCode != 200) { - throw new PreBidException("Failed to fetch data from Planner, HTTP status code " + statusCode); - } - - final String body = response.getBody(); - if (body == null) { - throw new PreBidException("Failed to fetch data from planner, response can't be null"); - } - - metrics.updateRequestTimeMetric(MetricName.planner_request_time, clock.millis() - startTime); - - logger.debug("Received line item metadata and plans from Planner: {0}", body); - - try { - final List lineItemMetaData = mapper.decodeValue(body, - LINE_ITEM_METADATA_TYPE_REFERENCE); - validateForEmptyResponse(lineItemMetaData); - metrics.updateLineItemsNumberMetric(lineItemMetaData.size()); - logger.info("Received line item metadata from Planner, amount: {0}", lineItemMetaData.size()); - - return lineItemMetaData; - } catch (DecodeException e) { - final String errorMessage = "Cannot parse response: " + body; - throw new PreBidException(errorMessage, e); - } - } - - private void validateForEmptyResponse(List lineItemMetaData) { - if (CollectionUtils.isEmpty(lineItemMetaData)) { - alertHttpService.alertWithPeriod(SERVICE_NAME, PBS_PLANNER_EMPTY_RESPONSE, AlertPriority.LOW, - "Response without line items was received from planner"); - } else { - alertHttpService.resetAlertCount(PBS_PLANNER_EMPTY_RESPONSE); - } - } - - /** - * Creates Authorization header value from username and password. - */ - private static String authHeader(String username, String password) { - return BASIC_AUTH_PATTERN - .formatted(Base64.getEncoder().encodeToString((username + ':' + password).getBytes())); - } - - /** - * Builds url for fetching metadata from planner - */ - private static String buildPlannerMetaDataUrl(String plannerMetaDataUrl, String pbsHostname, String pbsRegion, - String pbsVendor) { - return "%s?%s=%s&%s=%s&%s=%s".formatted( - plannerMetaDataUrl, - INSTANCE_ID_PARAMETER, - pbsHostname, - REGION_PARAMETER, - pbsRegion, - VENDOR_PARAMETER, - pbsVendor); - } - - /** - * Fetches line item metadata from planner during the regular, not retry flow. - */ - public void updateLineItemMetaData() { - if (isSuspended) { - logger.warn("Fetch request was not sent to general planner, as planner service is suspended from" - + " register endpoint."); - return; - } - - final MultiMap headers = headers(); - fetchLineItemMetaData(planEndpoint, headers) - .recover(ignored -> startRecoveryProcess(planEndpoint, headers)) - .onComplete(this::handleInitializationResult); - } - - private Future> startRecoveryProcess(String planEndpoint, MultiMap headers) { - metrics.updatePlannerRequestMetric(false); - logger.info("Retry to fetch line items from general planner by uri = {0}", planEndpoint); - - return fetchLineItemMetaData(planEndpoint, headers); - } - - /** - * Handles result of initialization process. Sets metadata if request was successful. - */ - protected void handleInitializationResult(AsyncResult> plannerResponse) { - if (plannerResponse.succeeded()) { - handleSuccessInitialization(plannerResponse); - } else { - handleFailedInitialization(plannerResponse); - } - } - - private void handleSuccessInitialization(AsyncResult> plannerResponse) { - alertHttpService.resetAlertCount(PBS_PLANNER_CLIENT_ERROR); - metrics.updatePlannerRequestMetric(true); - isPlannerResponsive.set(true); - lineItemService.updateIsPlannerResponsive(true); - updateMetaData(plannerResponse.result()); - } - - private void handleFailedInitialization(AsyncResult> plannerResponse) { - final String message = "Failed to retrieve line items from GP. Reason: " + plannerResponse.cause().getMessage(); - alertHttpService.alertWithPeriod(SERVICE_NAME, PBS_PLANNER_CLIENT_ERROR, AlertPriority.MEDIUM, message); - logger.warn(message); - isPlannerResponsive.set(false); - lineItemService.updateIsPlannerResponsive(false); - metrics.updatePlannerRequestMetric(false); - } - - /** - * Overwrites maps with metadata - */ - private void updateMetaData(List metaData) { - lineItemService.updateLineItems(metaData, isPlannerResponsive.get()); - deliveryProgressService.processDeliveryProgressUpdateEvent(); - } -} diff --git a/src/main/java/org/prebid/server/deals/RegisterService.java b/src/main/java/org/prebid/server/deals/RegisterService.java deleted file mode 100644 index fd77aa00248..00000000000 --- a/src/main/java/org/prebid/server/deals/RegisterService.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.prebid.server.deals; - -import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.AsyncResult; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.events.AdminEventService; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.proto.CurrencyServiceState; -import org.prebid.server.deals.proto.RegisterRequest; -import org.prebid.server.deals.proto.Status; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.health.HealthMonitor; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.math.BigDecimal; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.Base64; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -public class RegisterService implements Initializable, Suspendable { - - private static final Logger logger = LoggerFactory.getLogger(RegisterService.class); - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String BASIC_AUTH_PATTERN = "Basic %s"; - private static final String PG_TRX_ID = "pg-trx-id"; - private static final String PBS_REGISTER_CLIENT_ERROR = "pbs-register-client-error"; - private static final String SERVICE_NAME = "register"; - - private final PlannerProperties plannerProperties; - private final DeploymentProperties deploymentProperties; - private final AdminEventService adminEventService; - private final DeliveryProgressService deliveryProgressService; - private final AlertHttpService alertHttpService; - private final HealthMonitor healthMonitor; - private final CurrencyConversionService currencyConversionService; - private final HttpClient httpClient; - private final Vertx vertx; - private final JacksonMapper mapper; - - private final long registerTimeout; - private final long registerPeriod; - private final String basicAuthHeader; - private volatile long registerTimerId; - private volatile boolean isSuspended; - - public RegisterService(PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - AdminEventService adminEventService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HealthMonitor healthMonitor, - CurrencyConversionService currencyConversionService, - HttpClient httpClient, - Vertx vertx, - JacksonMapper mapper) { - this.plannerProperties = Objects.requireNonNull(plannerProperties); - this.deploymentProperties = Objects.requireNonNull(deploymentProperties); - this.adminEventService = Objects.requireNonNull(adminEventService); - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.alertHttpService = Objects.requireNonNull(alertHttpService); - this.healthMonitor = Objects.requireNonNull(healthMonitor); - this.currencyConversionService = Objects.requireNonNull(currencyConversionService); - this.httpClient = Objects.requireNonNull(httpClient); - this.vertx = Objects.requireNonNull(vertx); - this.mapper = Objects.requireNonNull(mapper); - - this.registerTimeout = plannerProperties.getTimeoutMs(); - this.registerPeriod = TimeUnit.SECONDS.toMillis(plannerProperties.getRegisterPeriodSeconds()); - this.basicAuthHeader = authHeader(plannerProperties.getUsername(), plannerProperties.getPassword()); - } - - /** - * Creates Authorization header value from username and password. - */ - private static String authHeader(String username, String password) { - return BASIC_AUTH_PATTERN - .formatted(Base64.getEncoder().encodeToString((username + ':' + password).getBytes())); - } - - @Override - public void suspend() { - isSuspended = true; - vertx.cancelTimer(registerTimerId); - } - - @Override - public void initialize() { - registerTimerId = vertx.setPeriodic(registerPeriod, ignored -> performRegistration()); - performRegistration(); - } - - public void performRegistration() { - register(headers()); - } - - protected void register(MultiMap headers) { - if (isSuspended) { - logger.warn("Register request was not sent to general planner, as planner service is suspended from" - + " register endpoint."); - return; - } - - final BigDecimal healthIndex = healthMonitor.calculateHealthIndex(); - final ZonedDateTime currencyLastUpdate = currencyConversionService.getLastUpdated(); - final RegisterRequest request = RegisterRequest.of( - healthIndex, - Status.of(currencyLastUpdate != null - ? CurrencyServiceState.of(UTC_MILLIS_FORMATTER.format(currencyLastUpdate)) - : null, - deliveryProgressService.getOverallDeliveryProgressReport()), - deploymentProperties.getPbsHostId(), - deploymentProperties.getPbsRegion(), - deploymentProperties.getPbsVendor()); - final String body = mapper.encodeToString(request); - - logger.info("Sending register request to Planner, {0} is {1}", PG_TRX_ID, headers.get(PG_TRX_ID)); - logger.debug("Register request payload: {0}", body); - - httpClient.post(plannerProperties.getRegisterEndpoint(), headers, body, registerTimeout) - .onComplete(this::handleRegister); - } - - protected MultiMap headers() { - return MultiMap.caseInsensitiveMultiMap() - .add(HttpUtil.AUTHORIZATION_HEADER, basicAuthHeader) - .add(PG_TRX_ID, UUID.randomUUID().toString()); - } - - private void handleRegister(AsyncResult asyncResult) { - if (asyncResult.failed()) { - final Throwable cause = asyncResult.cause(); - final String errorMessage = "Error occurred while registering with the Planner: " + cause; - alert(errorMessage, logger::warn); - } else { - final HttpClientResponse response = asyncResult.result(); - final int statusCode = response.getStatusCode(); - final String responseBody = response.getBody(); - if (statusCode == HttpResponseStatus.OK.code()) { - if (StringUtils.isNotBlank(responseBody)) { - adminEventService.publishAdminCentralEvent(parseRegisterResponse(responseBody)); - } - alertHttpService.resetAlertCount(PBS_REGISTER_CLIENT_ERROR); - } else { - final String errorMessage = "Planner responded with non-successful code %s, response: %s" - .formatted(statusCode, responseBody); - alert(errorMessage, logger::warn); - } - } - } - - private AdminCentralResponse parseRegisterResponse(String responseBody) { - try { - return mapper.decodeValue(responseBody, AdminCentralResponse.class); - } catch (DecodeException e) { - final String errorMessage = "Cannot parse register response: " + responseBody; - alert(errorMessage, logger::warn); - throw new PreBidException(errorMessage, e); - } - } - - private void alert(String message, Consumer logger) { - alertHttpService.alertWithPeriod(SERVICE_NAME, PBS_REGISTER_CLIENT_ERROR, AlertPriority.MEDIUM, message); - logger.accept(message); - } -} diff --git a/src/main/java/org/prebid/server/deals/Suspendable.java b/src/main/java/org/prebid/server/deals/Suspendable.java deleted file mode 100644 index b834b4badfe..00000000000 --- a/src/main/java/org/prebid/server/deals/Suspendable.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.deals; - -public interface Suspendable { - - void suspend(); -} diff --git a/src/main/java/org/prebid/server/deals/TargetingService.java b/src/main/java/org/prebid/server/deals/TargetingService.java deleted file mode 100644 index 17adefbafe5..00000000000 --- a/src/main/java/org/prebid/server/deals/TargetingService.java +++ /dev/null @@ -1,335 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.JsonNodeType; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.TargetingDefinition; -import org.prebid.server.deals.targeting.interpret.And; -import org.prebid.server.deals.targeting.interpret.DomainMetricAwareExpression; -import org.prebid.server.deals.targeting.interpret.Expression; -import org.prebid.server.deals.targeting.interpret.InIntegers; -import org.prebid.server.deals.targeting.interpret.InStrings; -import org.prebid.server.deals.targeting.interpret.IntersectsIntegers; -import org.prebid.server.deals.targeting.interpret.IntersectsSizes; -import org.prebid.server.deals.targeting.interpret.IntersectsStrings; -import org.prebid.server.deals.targeting.interpret.Matches; -import org.prebid.server.deals.targeting.interpret.Not; -import org.prebid.server.deals.targeting.interpret.Or; -import org.prebid.server.deals.targeting.interpret.Within; -import org.prebid.server.deals.targeting.model.GeoRegion; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.BooleanOperator; -import org.prebid.server.deals.targeting.syntax.MatchingFunction; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; -import org.prebid.server.exception.TargetingSyntaxException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.StreamUtil; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * Responsible for parsing and interpreting targeting defined in the Line Items’ metadata - * and determining if individual requests match those targeting conditions. - */ -public class TargetingService { - - private final JacksonMapper mapper; - - public TargetingService(JacksonMapper mapper) { - this.mapper = Objects.requireNonNull(mapper); - } - - /** - * Accepts targeting definition expressed in JSON syntax (see below), - * parses it and transforms it into an object supporting efficient evaluation - * of the targeting rules against the OpenRTB2 request. - */ - public TargetingDefinition parseTargetingDefinition(JsonNode targetingDefinition, String lineItemId) { - return TargetingDefinition.of(parseNode(targetingDefinition, lineItemId)); - } - - /** - * Accepts OpenRTB2 request and particular Imp object to evaluate Line Item targeting - * definition against and returns whether it is matched or not. - */ - public boolean matchesTargeting(BidRequest bidRequest, - Imp imp, - TargetingDefinition targetingDefinition, - AuctionContext auctionContext) { - - final RequestContext requestContext = new RequestContext(bidRequest, imp, auctionContext.getTxnLog(), mapper); - return targetingDefinition.getRootExpression().matches(requestContext); - } - - private Expression parseNode(JsonNode node, String lineItemId) { - final Map.Entry field = validateIsSingleElementObject(node); - final String fieldName = field.getKey(); - - if (BooleanOperator.isBooleanOperator(fieldName)) { - return parseBooleanOperator(fieldName, field.getValue(), lineItemId); - } else if (TargetingCategory.isTargetingCategory(fieldName)) { - return parseTargetingCategory(fieldName, field.getValue(), lineItemId); - } else { - throw new TargetingSyntaxException( - "Expected either boolean operator or targeting category, got " + fieldName); - } - } - - private Expression parseBooleanOperator(String fieldName, JsonNode value, String lineItemId) { - final BooleanOperator operator = BooleanOperator.fromString(fieldName); - return switch (operator) { - case AND -> new And(parseArray(value, node -> parseNode(node, lineItemId))); - case OR -> new Or(parseArray(value, node -> parseNode(node, lineItemId))); - case NOT -> new Not(parseNode(value, lineItemId)); - }; - } - - private Expression parseTargetingCategory(String fieldName, JsonNode value, String lineItemId) { - final TargetingCategory category = TargetingCategory.fromString(fieldName); - return switch (category.type()) { - case size -> new IntersectsSizes(category, - parseArrayFunction(value, MatchingFunction.INTERSECTS, this::parseSize)); - case mediaType, userSegment -> new IntersectsStrings(category, - parseArrayFunction(value, MatchingFunction.INTERSECTS, TargetingService::parseString)); - case domain -> prepareDomainExpression(category, value, lineItemId); - case publisherDomain -> new DomainMetricAwareExpression(parseStringFunction(category, value), lineItemId); - case referrer, appBundle, adslot -> parseStringFunction(category, value); - case pagePosition, dow, hour -> new InIntegers(category, - parseArrayFunction(value, MatchingFunction.IN, TargetingService::parseInteger)); - case deviceGeoExt, deviceExt -> new InStrings(category, - parseArrayFunction(value, MatchingFunction.IN, TargetingService::parseString)); - case location -> new Within(category, parseSingleObjectFunction(value, MatchingFunction.WITHIN, - this::parseGeoRegion)); - case bidderParam, userFirstPartyData, siteFirstPartyData -> parseTypedFunction(category, value); - }; - } - - private static Or prepareDomainExpression(TargetingCategory category, JsonNode value, String lineItemId) { - final DomainMetricAwareExpression domainExpression = - new DomainMetricAwareExpression(parseStringFunction(category, value), lineItemId); - - final TargetingCategory publisherDomainCategory = new TargetingCategory(TargetingCategory.Type.publisherDomain); - final DomainMetricAwareExpression publisherDomainExpression = - new DomainMetricAwareExpression(parseStringFunction(publisherDomainCategory, value), lineItemId); - - return new Or(List.of(domainExpression, publisherDomainExpression)); - } - - private static List parseArrayFunction(JsonNode value, MatchingFunction function, - Function mapper) { - - return parseArray(validateIsFunction(value, function), mapper); - } - - private static T parseSingleObjectFunction( - JsonNode value, MatchingFunction function, Function mapper) { - - return mapper.apply(validateIsFunction(value, function)); - } - - private static Expression parseStringFunction(TargetingCategory category, JsonNode value) { - final Map.Entry field = validateIsSingleElementObject(value); - final MatchingFunction function = - validateCompatibleFunction(field, MatchingFunction.MATCHES, MatchingFunction.IN); - - return switch (function) { - case MATCHES -> new Matches(category, parseString(field.getValue())); - case IN -> createInStringsFunction(category, field.getValue()); - default -> throw new IllegalStateException("Unexpected string function " + function.value()); - }; - } - - private static Expression parseTypedFunction(TargetingCategory category, JsonNode value) { - final Map.Entry field = validateIsSingleElementObject(value); - final MatchingFunction function = validateCompatibleFunction(field, - MatchingFunction.MATCHES, MatchingFunction.IN, MatchingFunction.INTERSECTS); - - final JsonNode functionValue = field.getValue(); - return switch (function) { - case MATCHES -> new Matches(category, parseString(functionValue)); - case IN -> parseTypedInFunction(category, functionValue); - case INTERSECTS -> parseTypedIntersectsFunction(category, functionValue); - default -> throw new IllegalStateException("Unexpected typed function " + function.value()); - }; - } - - private Size parseSize(JsonNode node) { - validateIsObject(node); - - final Size size; - try { - size = mapper.mapper().treeToValue(node, Size.class); - } catch (JsonProcessingException e) { - throw new TargetingSyntaxException( - "Exception occurred while parsing size: " + e.getMessage(), e); - } - - if (size.getH() == null || size.getW() == null) { - throw new TargetingSyntaxException("Height and width in size definition could not be null or missing"); - } - - return size; - } - - private static String parseString(JsonNode node) { - validateIsString(node); - - final String value = node.textValue(); - if (StringUtils.isEmpty(value)) { - throw new TargetingSyntaxException("String value could not be empty"); - } - return value; - } - - private static Integer parseInteger(JsonNode node) { - validateIsInteger(node); - - return node.intValue(); - } - - private GeoRegion parseGeoRegion(JsonNode node) { - validateIsObject(node); - - final GeoRegion region; - try { - region = mapper.mapper().treeToValue(node, GeoRegion.class); - } catch (JsonProcessingException e) { - throw new TargetingSyntaxException( - "Exception occurred while parsing geo region: " + e.getMessage(), e); - } - - if (region.getLat() == null || region.getLon() == null || region.getRadiusMiles() == null) { - throw new TargetingSyntaxException( - "Lat, lon and radiusMiles in geo region definition could not be null or missing"); - } - - return region; - } - - private static List parseArray(JsonNode node, Function mapper) { - validateIsArray(node); - - return StreamUtil.asStream(node.spliterator()).map(mapper).toList(); - } - - private static Expression parseTypedInFunction(TargetingCategory category, JsonNode value) { - return parseTypedArrayFunction(category, value, TargetingService::createInIntegersFunction, - TargetingService::createInStringsFunction); - } - - private static Expression parseTypedIntersectsFunction(TargetingCategory category, JsonNode value) { - return parseTypedArrayFunction(category, value, TargetingService::createIntersectsIntegersFunction, - TargetingService::createIntersectsStringsFunction); - } - - private static Expression parseTypedArrayFunction( - TargetingCategory category, JsonNode value, - BiFunction integerCreator, - BiFunction stringCreator) { - - validateIsArray(value); - - final Iterator iterator = value.iterator(); - - final JsonNodeType dataType = iterator.hasNext() ? iterator.next().getNodeType() : JsonNodeType.STRING; - return switch (dataType) { - case NUMBER -> integerCreator.apply(category, value); - case STRING -> stringCreator.apply(category, value); - default -> throw new TargetingSyntaxException("Expected integer or string, got " + dataType); - }; - } - - private static Expression createInIntegersFunction(TargetingCategory category, JsonNode value) { - return new InIntegers(category, parseArray(value, TargetingService::parseInteger)); - } - - private static InStrings createInStringsFunction(TargetingCategory category, JsonNode value) { - return new InStrings(category, parseArray(value, TargetingService::parseString)); - } - - private static Expression createIntersectsStringsFunction(TargetingCategory category, JsonNode value) { - return new IntersectsStrings(category, parseArray(value, TargetingService::parseString)); - } - - private static Expression createIntersectsIntegersFunction(TargetingCategory category, JsonNode value) { - return new IntersectsIntegers(category, parseArray(value, TargetingService::parseInteger)); - } - - private static void validateIsObject(JsonNode value) { - if (!value.isObject()) { - throw new TargetingSyntaxException("Expected object, got " + value.getNodeType()); - } - } - - private static Map.Entry validateIsSingleElementObject(JsonNode value) { - validateIsObject(value); - - if (value.size() != 1) { - throw new TargetingSyntaxException( - "Expected only one element in the object, got " + value.size()); - } - - return value.fields().next(); - } - - private static void validateIsArray(JsonNode value) { - if (!value.isArray()) { - throw new TargetingSyntaxException("Expected array, got " + value.getNodeType()); - } - } - - private static void validateIsString(JsonNode value) { - if (!value.isTextual()) { - throw new TargetingSyntaxException("Expected string, got " + value.getNodeType()); - } - } - - private static void validateIsInteger(JsonNode value) { - if (!value.isInt()) { - throw new TargetingSyntaxException("Expected integer, got " + value.getNodeType()); - } - } - - private static JsonNode validateIsFunction(JsonNode value, MatchingFunction function) { - final Map.Entry field = validateIsSingleElementObject(value); - final String fieldName = field.getKey(); - - if (!MatchingFunction.isMatchingFunction(fieldName)) { - throw new TargetingSyntaxException("Expected matching function, got " + fieldName); - } else if (MatchingFunction.fromString(fieldName) != function) { - throw new TargetingSyntaxException( - "Expected %s matching function, got %s".formatted(function.value(), fieldName)); - } - - return field.getValue(); - } - - private static MatchingFunction validateCompatibleFunction(Map.Entry field, - MatchingFunction... compatibleFunctions) { - final String fieldName = field.getKey(); - - if (!MatchingFunction.isMatchingFunction(fieldName)) { - throw new TargetingSyntaxException("Expected matching function, got " + fieldName); - } - - final MatchingFunction function = MatchingFunction.fromString(fieldName); - if (!Arrays.asList(compatibleFunctions).contains(function)) { - throw new TargetingSyntaxException("Expected one of %s matching functions, got %s".formatted( - Arrays.stream(compatibleFunctions).map(MatchingFunction::value).collect(Collectors.joining(", ")), - fieldName)); - } - return function; - } -} diff --git a/src/main/java/org/prebid/server/deals/UserAdditionalInfoService.java b/src/main/java/org/prebid/server/deals/UserAdditionalInfoService.java deleted file mode 100644 index 58892f3142d..00000000000 --- a/src/main/java/org/prebid/server/deals/UserAdditionalInfoService.java +++ /dev/null @@ -1,319 +0,0 @@ -package org.prebid.server.deals; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Data; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; -import com.iab.openrtb.request.Segment; -import com.iab.openrtb.request.User; -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.core.Promise; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.ObjectUtils; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.auction.model.Tuple3; -import org.prebid.server.deals.deviceinfo.DeviceInfoService; -import org.prebid.server.deals.model.DeviceInfo; -import org.prebid.server.deals.model.UserData; -import org.prebid.server.deals.model.UserDetails; -import org.prebid.server.execution.Timeout; -import org.prebid.server.geolocation.GeoLocationService; -import org.prebid.server.geolocation.model.GeoInfo; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtDeviceVendor; -import org.prebid.server.proto.openrtb.ext.request.ExtGeo; -import org.prebid.server.proto.openrtb.ext.request.ExtGeoVendor; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.request.ExtUserTime; -import org.prebid.server.util.ObjectUtil; - -import java.time.Clock; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.temporal.WeekFields; -import java.util.List; -import java.util.Objects; - -public class UserAdditionalInfoService { - - private static final Logger logger = LoggerFactory.getLogger(UserAdditionalInfoService.class); - - private final LineItemService lineItemService; - private final DeviceInfoService deviceInfoService; - private final GeoLocationService geoLocationService; - private final UserService userService; - private final Clock clock; - private final JacksonMapper mapper; - private final CriteriaLogManager criteriaLogManager; - - public UserAdditionalInfoService(LineItemService lineItemService, - DeviceInfoService deviceInfoService, - GeoLocationService geoLocationService, - UserService userService, - Clock clock, - JacksonMapper mapper, - CriteriaLogManager criteriaLogManager) { - - this.lineItemService = Objects.requireNonNull(lineItemService); - this.deviceInfoService = deviceInfoService; - this.geoLocationService = geoLocationService; - this.userService = Objects.requireNonNull(userService); - this.clock = Objects.requireNonNull(clock); - this.mapper = Objects.requireNonNull(mapper); - this.criteriaLogManager = Objects.requireNonNull(criteriaLogManager); - } - - public Future populate(AuctionContext context) { - final boolean accountHasDeals = lineItemService.accountHasDeals(context); - final String accountId = context.getAccount().getId(); - if (!accountHasDeals) { - criteriaLogManager.log( - logger, accountId, "Account %s does not have deals".formatted(accountId), logger::debug); - - return Future.succeededFuture(context); - } - - final Device device = context.getBidRequest().getDevice(); - final Timeout timeout = context.getTimeoutContext().getTimeout(); - final GeoInfo geoInfo = context.getGeoInfo(); - - final CompositeFuture compositeFuture = CompositeFuture.join( - lookupDeviceInfo(device), - geoInfo != null ? Future.succeededFuture(geoInfo) : lookupGeoInfo(device, timeout), - userService.getUserDetails(context, timeout)); - - // AsyncResult has atomic nature: its result() method returns null when at least one future fails. - // So, in handler it is ignored and original CompositeFuture used to process obtained results - // to avoid explicit casting to CompositeFuture implementation. - final Promise> promise = Promise.promise(); - compositeFuture.onComplete(ignored -> handleInfos(compositeFuture, promise, context.getAccount().getId())); - return promise.future().map(tuple -> enrichAuctionContext(context, tuple)); - } - - private Future lookupDeviceInfo(Device device) { - return deviceInfoService != null - ? deviceInfoService.getDeviceInfo(device.getUa()) - : Future.failedFuture("Device info is disabled by configuration"); - } - - private Future lookupGeoInfo(Device device, Timeout timeout) { - return geoLocationService != null - ? geoLocationService.lookup(ObjectUtils.defaultIfNull(device.getIp(), device.getIpv6()), timeout) - : Future.failedFuture("Geo location is disabled by configuration"); - } - - private void handleInfos(CompositeFuture compositeFuture, - Promise> resultPromise, - String account) { - - DeviceInfo deviceInfo = null; - GeoInfo geoInfo = null; - UserDetails userDetails = null; - - for (int i = 0; i < compositeFuture.list().size(); i++) { - final Object o = compositeFuture.resultAt(i); - if (o == null) { - criteriaLogManager.log( - logger, - account, - "Deals processing error: " + compositeFuture.cause(i), - logger::warn); - continue; - } - - if (o instanceof DeviceInfo) { - deviceInfo = (DeviceInfo) o; - } else if (o instanceof GeoInfo) { - geoInfo = (GeoInfo) o; - } else if (o instanceof UserDetails) { - userDetails = (UserDetails) o; - } - } - - resultPromise.complete(Tuple3.of(deviceInfo, geoInfo, userDetails)); - } - - private AuctionContext enrichAuctionContext(AuctionContext auctionContext, - Tuple3 tuple) { - - final DeviceInfo deviceInfo = tuple.getLeft(); - final GeoInfo geoInfo = tuple.getMiddle(); - final UserDetails userDetails = tuple.getRight(); - - final BidRequest bidRequest = auctionContext.getBidRequest(); - final Device originalDevice = bidRequest.getDevice(); - - final BidRequest enrichedBidRequest = bidRequest.toBuilder() - .device(deviceInfo != null || geoInfo != null - ? updateDevice(originalDevice, deviceInfo, geoInfo) - : originalDevice) - .user(updateUser(bidRequest.getUser(), userDetails, geoInfo)) - .build(); - - return auctionContext.toBuilder() - .bidRequest(enrichedBidRequest) - .geoInfo(geoInfo) - .build(); - } - - private Device updateDevice(Device device, DeviceInfo deviceInfo, GeoInfo geoInfo) { - final ExtDevice updatedExtDevice = - fillExtDeviceWith( - fillExtDeviceWith( - ObjectUtil.getIfNotNull(device, Device::getExt), - ObjectUtil.getIfNotNull(deviceInfo, DeviceInfo::getVendor), - extDeviceVendorFrom(deviceInfo)), - ObjectUtil.getIfNotNull(geoInfo, GeoInfo::getVendor), - extDeviceVendorFrom(geoInfo)); - final Geo updatedGeo = updateDeviceGeo(ObjectUtil.getIfNotNull(device, Device::getGeo), geoInfo); - - final Device.DeviceBuilder deviceBuilder = device != null ? device.toBuilder() : Device.builder(); - return deviceBuilder - .geo(updatedGeo) - .ext(updatedExtDevice) - .build(); - } - - private ExtDevice fillExtDeviceWith(ExtDevice extDevice, String vendor, ExtDeviceVendor extDeviceVendor) { - if (extDeviceVendor.equals(ExtDeviceVendor.EMPTY)) { - return extDevice; - } - - final ExtDevice effectiveExtDevice = extDevice != null ? extDevice : ExtDevice.empty(); - effectiveExtDevice.addProperty(vendor, mapper.mapper().valueToTree(extDeviceVendor)); - - return effectiveExtDevice; - } - - private static ExtDeviceVendor extDeviceVendorFrom(DeviceInfo deviceInfo) { - return deviceInfo != null - ? ExtDeviceVendor.builder() - .type(deviceInfo.getDeviceTypeRaw()) - .osfamily(null) - .os(deviceInfo.getOs()) - .osver(deviceInfo.getOsVersion()) - .browser(deviceInfo.getBrowser()) - .browserver(deviceInfo.getBrowserVersion()) - .make(deviceInfo.getManufacturer()) - .model(deviceInfo.getModel()) - .language(deviceInfo.getLanguage()) - .carrier(deviceInfo.getCarrier()) - .build() - : ExtDeviceVendor.EMPTY; - } - - private static ExtDeviceVendor extDeviceVendorFrom(GeoInfo geoInfo) { - return geoInfo != null - ? ExtDeviceVendor.builder() - .connspeed(geoInfo.getConnectionSpeed()) - .build() - : ExtDeviceVendor.EMPTY; - } - - private Geo updateDeviceGeo(Geo geo, GeoInfo geoInfo) { - if (geoInfo == null) { - return geo; - } - - final ExtGeo updatedExtGeo = fillExtGeoWith( - ObjectUtil.getIfNotNull(geo, Geo::getExt), - geoInfo.getVendor(), - extGeoVendorFrom(geoInfo)); - - final Geo.GeoBuilder geoBuilder = geo != null ? geo.toBuilder() : Geo.builder(); - return geoBuilder - .country(geoInfo.getCountry()) - .region(geoInfo.getRegion()) - .metro(geoInfo.getMetroGoogle()) - .lat(geoInfo.getLat()) - .lon(geoInfo.getLon()) - .ext(updatedExtGeo) - .build(); - } - - private ExtGeo fillExtGeoWith(ExtGeo extGeo, String vendor, ExtGeoVendor extGeoVendor) { - if (extGeoVendor.equals(ExtGeoVendor.EMPTY)) { - return extGeo; - } - - final ExtGeo effectiveExtGeo = extGeo != null ? extGeo : ExtGeo.of(); - effectiveExtGeo.addProperty(vendor, mapper.mapper().valueToTree(extGeoVendor)); - - return effectiveExtGeo; - } - - private static ExtGeoVendor extGeoVendorFrom(GeoInfo geoInfo) { - return ExtGeoVendor.builder() - .continent(geoInfo.getContinent()) - .country(geoInfo.getCountry()) - .region(geoInfo.getRegionCode()) - .metro(geoInfo.getMetroNielsen()) - .city(geoInfo.getCity()) - .zip(geoInfo.getZip()) - .build(); - } - - private User updateUser(User user, UserDetails userDetails, GeoInfo geoInfo) { - final User.UserBuilder userBuilder = user != null ? user.toBuilder() : User.builder(); - return userBuilder - .data(userDetails != null ? makeData(userDetails) : null) - .ext(updateExtUser(ObjectUtil.getIfNotNull(user, User::getExt), userDetails, geoInfo)) - .build(); - } - - private static List makeData(UserDetails userDetails) { - final List userData = userDetails.getUserData(); - return userData != null - ? userData.stream() - .map(userDataElement -> Data.builder() - .id(userDataElement.getName()) - .segment(makeSegments(userDataElement.getSegment())) - .build()) - .toList() - : null; - } - - private static List makeSegments(List segments) { - return segments != null - ? segments.stream() - .map(segment -> Segment.builder().id(segment.getId()).build()) - .toList() - : null; - } - - private ExtUser updateExtUser(ExtUser extUser, UserDetails userDetails, GeoInfo geoInfo) { - final ExtUser.ExtUserBuilder extUserBuilder = extUser != null ? extUser.toBuilder() : ExtUser.builder(); - return extUserBuilder - .fcapIds(ObjectUtils.defaultIfNull( - resolveFcapIds(userDetails), - ObjectUtil.getIfNotNull(extUser, ExtUser::getFcapIds))) - .time(resolveExtUserTime(geoInfo)) - .build(); - } - - private static List resolveFcapIds(UserDetails userDetails) { - return userDetails != null - // Indicate that the call to User Data Store has been made successfully even if the user is not frequency - // capped - ? ListUtils.emptyIfNull(userDetails.getFcapIds()) - // otherwise leave cappedIds null to indicate that call to User Data Store failed - : null; - } - - private ExtUserTime resolveExtUserTime(GeoInfo geoInfo) { - final ZoneId timeZone = ObjectUtils.firstNonNull( - ObjectUtil.getIfNotNull(geoInfo, GeoInfo::getTimeZone), - clock.getZone()); - - final ZonedDateTime dateTime = ZonedDateTime.now(clock).withZoneSameInstant(timeZone); - - return ExtUserTime.of( - dateTime.getDayOfWeek().get(WeekFields.SUNDAY_START.dayOfWeek()), - dateTime.getHour()); - } -} diff --git a/src/main/java/org/prebid/server/deals/UserService.java b/src/main/java/org/prebid/server/deals/UserService.java deleted file mode 100644 index 41e0b300b67..00000000000 --- a/src/main/java/org/prebid/server/deals/UserService.java +++ /dev/null @@ -1,294 +0,0 @@ -package org.prebid.server.deals; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.cache.model.DebugHttpCall; -import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.cookie.model.UidWithExpiry; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.User; -import org.prebid.server.deals.model.UserDetails; -import org.prebid.server.deals.model.UserDetailsProperties; -import org.prebid.server.deals.model.UserDetailsRequest; -import org.prebid.server.deals.model.UserDetailsResponse; -import org.prebid.server.deals.model.UserId; -import org.prebid.server.deals.model.UserIdRule; -import org.prebid.server.deals.model.WinEventNotification; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.execution.Timeout; -import org.prebid.server.handler.NotificationEventHandler; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.MetricName; -import org.prebid.server.metric.Metrics; -import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * Works with user related information. - */ -public class UserService { - - private static final Logger logger = LoggerFactory.getLogger(UserService.class); - private static final String USER_SERVICE = "userservice"; - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private final LineItemService lineItemService; - private final HttpClient httpClient; - private final Clock clock; - private final Metrics metrics; - private final JacksonMapper mapper; - - private final String userDetailsUrl; - private final String winEventUrl; - private final long timeout; - private final List userIdRules; - private final String dataCenterRegion; - - public UserService(UserDetailsProperties userDetailsProperties, - String dataCenterRegion, - LineItemService lineItemService, - HttpClient httpClient, - Clock clock, - Metrics metrics, - JacksonMapper mapper) { - - this.lineItemService = Objects.requireNonNull(lineItemService); - this.httpClient = Objects.requireNonNull(httpClient); - this.clock = Objects.requireNonNull(clock); - this.metrics = Objects.requireNonNull(metrics); - - this.userDetailsUrl = Objects.requireNonNull( - HttpUtil.validateUrl(userDetailsProperties.getUserDetailsEndpoint())); - this.winEventUrl = Objects.requireNonNull(HttpUtil.validateUrl(userDetailsProperties.getWinEventEndpoint())); - this.timeout = userDetailsProperties.getTimeout(); - this.userIdRules = Objects.requireNonNull(userDetailsProperties.getUserIds()); - this.dataCenterRegion = Objects.requireNonNull(dataCenterRegion); - this.mapper = Objects.requireNonNull(mapper); - } - - /** - * Fetches {@link UserDetails} from the User Data Store. - */ - public Future getUserDetails(AuctionContext context, Timeout timeout) { - final Map uidsMap = context.getUidsCookie().getCookieUids().getUids(); - if (CollectionUtils.isEmpty(uidsMap.values())) { - metrics.updateUserDetailsRequestPreparationFailed(); - context.getDebugHttpCalls().put(USER_SERVICE, Collections.singletonList(DebugHttpCall.empty())); - return Future.succeededFuture(UserDetails.empty()); - } - - final List userIds = getUserIds(uidsMap); - if (CollectionUtils.isEmpty(userIds)) { - metrics.updateUserDetailsRequestPreparationFailed(); - context.getDebugHttpCalls().put(USER_SERVICE, Collections.singletonList(DebugHttpCall.empty())); - return Future.succeededFuture(UserDetails.empty()); - } - - final UserDetailsRequest userDetailsRequest = UserDetailsRequest.of( - UTC_MILLIS_FORMATTER.format(ZonedDateTime.now(clock)), userIds); - final String body = mapper.encodeToString(userDetailsRequest); - - final long requestTimeout = Math.min(this.timeout, timeout.remaining()); - - final long startTime = clock.millis(); - return httpClient.post(userDetailsUrl, body, requestTimeout) - .map(httpClientResponse -> toUserServiceResult(httpClientResponse, context, - userDetailsUrl, body, startTime)) - .recover(throwable -> failGetDetailsResponse(throwable, context, userDetailsUrl, body, startTime)); - } - - /** - * Retrieves the UID from UIDs Map by each {@link UserIdRule#getLocation()} and if UID is present - creates a - * {@link UserId} object that contains {@link UserIdRule#getType()} and UID and adds it to UserId list. - */ - private List getUserIds(Map bidderToUid) { - final List userIds = new ArrayList<>(); - for (UserIdRule rule : userIdRules) { - final UidWithExpiry uid = bidderToUid.get(rule.getLocation()); - if (uid != null) { - userIds.add(UserId.of(rule.getType(), uid.getUid())); - } - } - return userIds; - } - - /** - * Transforms response from User Data Store into {@link Future} of {@link UserDetails}. - *

- * Throws {@link PreBidException} if an error occurs during response body deserialization. - */ - private UserDetails toUserServiceResult(HttpClientResponse clientResponse, AuctionContext context, - String requestUrl, String requestBody, long startTime) { - final int responseStatusCode = clientResponse.getStatusCode(); - verifyStatusCode(responseStatusCode); - - final String responseBody = clientResponse.getBody(); - final User user; - final int responseTime = responseTime(startTime); - try { - user = parseUserDetailsResponse(responseBody); - } finally { - context.getDebugHttpCalls().put(USER_SERVICE, Collections.singletonList( - DebugHttpCall.builder() - .requestUri(requestUrl) - .requestBody(requestBody) - .responseStatus(responseStatusCode) - .responseBody(responseBody) - .responseTimeMillis(responseTime) - .build())); - } - metrics.updateRequestTimeMetric(MetricName.user_details_request_time, responseTime); - metrics.updateUserDetailsRequestMetric(true); - return UserDetails.of(user.getData(), user.getExt().getFcapIds()); - } - - private User parseUserDetailsResponse(String responseBody) { - final UserDetailsResponse userDetailsResponse; - try { - userDetailsResponse = mapper.decodeValue(responseBody, UserDetailsResponse.class); - } catch (DecodeException e) { - throw new PreBidException("Cannot parse response: " + responseBody, e); - } - - final User user = userDetailsResponse.getUser(); - if (user == null) { - throw new PreBidException("Field 'user' is missing in response: " + responseBody); - } - - if (user.getData() == null) { - throw new PreBidException("Field 'user.data' is missing in response: " + responseBody); - } - - if (user.getExt() == null) { - throw new PreBidException("Field 'user.ext' is missing in response: " + responseBody); - } - return user; - } - - /** - * Throw {@link PreBidException} if response status is not 200. - */ - private static void verifyStatusCode(int statusCode) { - if (statusCode != 200) { - throw new PreBidException("Bad response status code: " + statusCode); - } - } - - /** - * Handles errors that occurred during getUserDetails HTTP request or response processing. - */ - private Future failGetDetailsResponse(Throwable exception, AuctionContext context, String requestUrl, - String requestBody, long startTime) { - final int responseTime = responseTime(startTime); - context.getDebugHttpCalls().putIfAbsent(USER_SERVICE, - Collections.singletonList( - DebugHttpCall.builder() - .requestUri(requestUrl) - .requestBody(requestBody) - .responseTimeMillis(responseTime) - .build())); - metrics.updateUserDetailsRequestMetric(false); - metrics.updateRequestTimeMetric(MetricName.user_details_request_time, responseTime); - logger.warn("Error occurred while fetching user details", exception); - return Future.failedFuture(exception); - } - - /** - * Calculates execution time since the given start time. - */ - private int responseTime(long startTime) { - return Math.toIntExact(clock.millis() - startTime); - } - - /** - * Accepts lineItemId and bidId from the {@link NotificationEventHandler}, - * joins event data with corresponding Line Item metadata (provided by LineItemService) - * and passes this information to the User Data Store to facilitate frequency capping. - */ - public void processWinEvent(String lineItemId, String bidId, UidsCookie uids) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - final List userIds = getUserIds(uids.getCookieUids().getUids()); - - if (!hasRequiredData(lineItem, userIds, lineItemId)) { - metrics.updateWinRequestPreparationFailed(); - return; - } - - final String body = mapper.encodeToString(WinEventNotification.builder() - .bidderCode(lineItem.getSource()) - .bidId(bidId) - .lineItemId(lineItemId) - .region(dataCenterRegion) - .userIds(userIds) - .winEventDateTime(ZonedDateTime.now(clock)) - .lineUpdatedDateTime(lineItem.getUpdatedTimeStamp()) - .frequencyCaps(lineItem.getFrequencyCaps()) - .build()); - - metrics.updateWinNotificationMetric(); - final long startTime = clock.millis(); - httpClient.post(winEventUrl, body, timeout) - .onComplete(result -> handleWinResponse(result, startTime)); - } - - /** - * Verify that all necessary data is present and log error if something is missing. - */ - private static boolean hasRequiredData(LineItem lineItem, List userIds, String lineItemId) { - if (lineItem == null) { - logger.error("Meta Data for Line Item Id {0} does not exist", lineItemId); - return false; - } - - if (CollectionUtils.isEmpty(userIds)) { - logger.error("User Ids cannot be empty"); - return false; - } - return true; - } - - /** - * Checks response from User Data Store. - */ - private void handleWinResponse(AsyncResult asyncResult, long startTime) { - metrics.updateWinRequestTime(responseTime(startTime)); - if (asyncResult.succeeded()) { - try { - verifyStatusCode(asyncResult.result().getStatusCode()); - metrics.updateWinEventRequestMetric(true); - } catch (PreBidException e) { - metrics.updateWinEventRequestMetric(false); - logWinEventError(e); - } - } else { - metrics.updateWinEventRequestMetric(false); - logWinEventError(asyncResult.cause()); - } - } - - /** - * Logs errors that occurred during processWinEvent HTTP request or bad response code. - */ - private static void logWinEventError(Throwable exception) { - logger.warn("Error occurred while pushing win event notification", exception); - } -} diff --git a/src/main/java/org/prebid/server/deals/deviceinfo/DeviceInfoService.java b/src/main/java/org/prebid/server/deals/deviceinfo/DeviceInfoService.java deleted file mode 100644 index 1e680ebd51f..00000000000 --- a/src/main/java/org/prebid/server/deals/deviceinfo/DeviceInfoService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.prebid.server.deals.deviceinfo; - -import io.vertx.core.Future; -import org.prebid.server.deals.model.DeviceInfo; - -/** - * Processes device related information. - */ -@FunctionalInterface -public interface DeviceInfoService { - - /** - * Provides information about device based on User-Agent string and other available attributes. - */ - Future getDeviceInfo(String ua); -} diff --git a/src/main/java/org/prebid/server/deals/events/AdminEventProcessor.java b/src/main/java/org/prebid/server/deals/events/AdminEventProcessor.java deleted file mode 100644 index dbf9133a902..00000000000 --- a/src/main/java/org/prebid/server/deals/events/AdminEventProcessor.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.deals.events; - -import org.prebid.server.deals.model.AdminCentralResponse; - -public interface AdminEventProcessor { - - void processAdminCentralEvent(AdminCentralResponse adminCentralResponse); -} diff --git a/src/main/java/org/prebid/server/deals/events/AdminEventService.java b/src/main/java/org/prebid/server/deals/events/AdminEventService.java deleted file mode 100644 index f8f6130c6b5..00000000000 --- a/src/main/java/org/prebid/server/deals/events/AdminEventService.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.deals.events; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.EventBus; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.vertx.LocalMessageCodec; - -import java.util.Objects; - -public class AdminEventService { - - private static final String ADDRESS_ADMIN_CENTRAL_COMMAND = "event.admin-central"; - - private static final DeliveryOptions DELIVERY_OPTIONS = - new DeliveryOptions() - .setCodecName(LocalMessageCodec.codecName()); - - private final EventBus eventBus; - - public AdminEventService(EventBus eventBus) { - this.eventBus = Objects.requireNonNull(eventBus); - } - - /** - * Publishes admin central event. - */ - public void publishAdminCentralEvent(AdminCentralResponse adminCentralResponse) { - eventBus.publish(ADDRESS_ADMIN_CENTRAL_COMMAND, adminCentralResponse, DELIVERY_OPTIONS); - } -} diff --git a/src/main/java/org/prebid/server/deals/events/ApplicationEventProcessor.java b/src/main/java/org/prebid/server/deals/events/ApplicationEventProcessor.java deleted file mode 100644 index ed1595d1eda..00000000000 --- a/src/main/java/org/prebid/server/deals/events/ApplicationEventProcessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.deals.events; - -import org.prebid.server.auction.model.AuctionContext; - -/** - * Interface for the components able to consume application events. - * - * @see ApplicationEventService - */ -public interface ApplicationEventProcessor { - - void processAuctionEvent(AuctionContext auctionContext); - - void processLineItemWinEvent(String lineItemId); - - void processDeliveryProgressUpdateEvent(); -} diff --git a/src/main/java/org/prebid/server/deals/events/ApplicationEventService.java b/src/main/java/org/prebid/server/deals/events/ApplicationEventService.java deleted file mode 100644 index 78dec0ae622..00000000000 --- a/src/main/java/org/prebid/server/deals/events/ApplicationEventService.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.prebid.server.deals.events; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.EventBus; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.vertx.LocalMessageCodec; - -import java.util.Objects; - -/** - * Main purpose of this service is decoupling of application events delivery from their generators to consumers. - *

- * This service is essentially a facade for Vert.x {@link EventBus}, it encapsulates addressing and consumers - * configuration concerns and provides type-safe API for publishing different application events which are consumed - * by all {@link ApplicationEventProcessor}s registered in the application. - *

- * Implementation notes: - * Communication through {@link EventBus} is performed only locally, that's why no serialization/deserialization - * happens for objects passed over the bus and hence no implied performance penalty (see {@link LocalMessageCodec}). - */ -public class ApplicationEventService { - - private static final String ADDRESS_EVENT_OPENRTB2_AUCTION = "event.openrtb2-auction"; - private static final String ADDRESS_EVENT_LINE_ITEM_WIN = "event.line-item-win"; - private static final String ADDRESS_EVENT_DELIVERY_UPDATE = "event.delivery-update"; - - private static final DeliveryOptions DELIVERY_OPTIONS = - new DeliveryOptions() - .setCodecName(LocalMessageCodec.codecName()); - - private final EventBus eventBus; - - public ApplicationEventService(EventBus eventBus) { - this.eventBus = Objects.requireNonNull(eventBus); - } - - /** - * Publishes auction event. - */ - public void publishAuctionEvent(AuctionContext auctionContext) { - eventBus.publish(ADDRESS_EVENT_OPENRTB2_AUCTION, auctionContext, DELIVERY_OPTIONS); - } - - /** - * Publishes line item win event. - */ - public void publishLineItemWinEvent(String lineItemId) { - eventBus.publish(ADDRESS_EVENT_LINE_ITEM_WIN, lineItemId); - } - - /** - * Publishes delivery update event. - */ - public void publishDeliveryUpdateEvent() { - eventBus.publish(ADDRESS_EVENT_DELIVERY_UPDATE, null); - } -} diff --git a/src/main/java/org/prebid/server/deals/events/EventServiceInitializer.java b/src/main/java/org/prebid/server/deals/events/EventServiceInitializer.java deleted file mode 100644 index 93802bbadd0..00000000000 --- a/src/main/java/org/prebid/server/deals/events/EventServiceInitializer.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.prebid.server.deals.events; - -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.vertx.Initializable; - -import java.util.List; -import java.util.Objects; - -public class EventServiceInitializer implements Initializable { - - private static final String ADDRESS_EVENT_OPENRTB2_AUCTION = "event.openrtb2-auction"; - private static final String ADDRESS_EVENT_LINE_ITEM_WIN = "event.line-item-win"; - private static final String ADDRESS_EVENT_DELIVERY_UPDATE = "event.delivery-update"; - private static final String ADDRESS_ADMIN_CENTRAL_COMMAND = "event.admin-central"; - - private final List applicationEventProcessors; - private final List adminEventProcessors; - private final EventBus eventBus; - - public EventServiceInitializer(List applicationEventProcessors, - List adminEventProcessors, - EventBus eventBus) { - this.applicationEventProcessors = Objects.requireNonNull(applicationEventProcessors); - this.adminEventProcessors = Objects.requireNonNull(adminEventProcessors); - this.eventBus = Objects.requireNonNull(eventBus); - } - - @Override - public void initialize() { - eventBus.localConsumer( - ADDRESS_EVENT_OPENRTB2_AUCTION, - (Message message) -> applicationEventProcessors.forEach( - recorder -> recorder.processAuctionEvent(message.body()))); - - eventBus.localConsumer( - ADDRESS_EVENT_LINE_ITEM_WIN, - (Message message) -> applicationEventProcessors.forEach( - recorder -> recorder.processLineItemWinEvent(message.body()))); - - eventBus.localConsumer( - ADDRESS_EVENT_DELIVERY_UPDATE, - (Message message) -> applicationEventProcessors.forEach( - ApplicationEventProcessor::processDeliveryProgressUpdateEvent)); - - eventBus.localConsumer( - ADDRESS_ADMIN_CENTRAL_COMMAND, - (Message message) -> adminEventProcessors.forEach( - recorder -> recorder.processAdminCentralEvent(message.body()))); - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/DeliveryPlan.java b/src/main/java/org/prebid/server/deals/lineitem/DeliveryPlan.java deleted file mode 100644 index fe373f114f5..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/DeliveryPlan.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import org.apache.commons.collections4.SetUtils; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.Token; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class DeliveryPlan { - - private final DeliverySchedule deliverySchedule; - - private final Set deliveryTokens; - - private DeliveryPlan(DeliverySchedule deliverySchedule) { - this(Objects.requireNonNull(deliverySchedule), toDeliveryTokens(deliverySchedule.getTokens())); - } - - private DeliveryPlan(DeliverySchedule deliverySchedule, Set deliveryTokens) { - this.deliverySchedule = Objects.requireNonNull(deliverySchedule); - this.deliveryTokens = Objects.requireNonNull(deliveryTokens); - } - - public static DeliveryPlan of(DeliverySchedule deliverySchedule) { - return new DeliveryPlan(deliverySchedule); - } - - /** - * Returns number of not spent tokens in {@link DeliveryPlan}. - */ - public int getUnspentTokens() { - return deliveryTokens.stream().mapToInt(DeliveryToken::getUnspent).sum(); - } - - /** - * Returns number of spent tokens in {@link DeliveryPlan}. - */ - public long getSpentTokens() { - return deliveryTokens.stream().map(DeliveryToken::getSpent).mapToLong(LongAdder::sum).sum(); - } - - public long getTotalTokens() { - return deliveryTokens.stream().mapToLong(DeliveryToken::getTotal).sum(); - } - - /** - * Returns lowest (which means highest priority) token's class value with unspent tokens. - */ - public Integer getHighestUnspentTokensClass() { - return deliveryTokens.stream() - .filter(token -> token.getUnspent() > 0) - .map(DeliveryToken::getPriorityClass) - .findFirst() - .orElse(null); - } - - /** - * Increments tokens in {@link DeliveryToken} with highest priority within {@link DeliveryPlan} - * - * @return class of the token incremented - */ - public Integer incSpentToken() { - final DeliveryToken unspentToken = deliveryTokens.stream() - .filter(token -> token.getUnspent() > 0) - .findFirst() - .orElse(null); - if (unspentToken != null) { - unspentToken.inc(); - return unspentToken.getPriorityClass(); - } - - return null; - } - - /** - * Merges tokens from expired {@link DeliveryPlan} to the next one. - */ - public DeliveryPlan mergeWithNextDeliverySchedule(DeliverySchedule nextDeliverySchedule, boolean sumTotal) { - - final Map nextTokensByClass = nextDeliverySchedule.getTokens().stream() - .collect(Collectors.toMap(Token::getPriorityClass, Function.identity())); - - final Set mergedTokens = new TreeSet<>(); - - for (final DeliveryToken expiredToken : deliveryTokens) { - final Integer priorityClass = expiredToken.getPriorityClass(); - final Token nextToken = nextTokensByClass.get(priorityClass); - - mergedTokens.add(expiredToken.mergeWithToken(nextToken, sumTotal)); - - nextTokensByClass.remove(priorityClass); - } - - // add remaining (not merged) tokens - nextTokensByClass.values().stream().map(DeliveryToken::of).forEach(mergedTokens::add); - - return new DeliveryPlan(nextDeliverySchedule, mergedTokens); - } - - public DeliveryPlan mergeWithNextDeliveryPlan(DeliveryPlan anotherPlan) { - return mergeWithNextDeliverySchedule(anotherPlan.deliverySchedule, false); - } - - public DeliveryPlan withoutSpentTokens() { - return new DeliveryPlan(deliverySchedule, deliveryTokens.stream() - .map(DeliveryToken::of) - .collect(Collectors.toSet())); - } - - public void incTokenWithPriority(Integer tokenPriority) { - deliveryTokens.stream() - .filter(token -> Objects.equals(token.getPriorityClass(), tokenPriority)) - .findAny() - .ifPresent(DeliveryToken::inc); - } - - /** - * Calculates readyAt from expirationDate and number of unspent tokens. - */ - public ZonedDateTime calculateReadyAt() { - final ZonedDateTime planStartTime = deliverySchedule.getStartTimeStamp(); - final long spentTokens = getSpentTokens(); - final long unspentTokens = getUnspentTokens(); - final long timeShift = spentTokens * ((deliverySchedule.getEndTimeStamp().toInstant().toEpochMilli() - - planStartTime.toInstant().toEpochMilli()) / getTotalTokens()); - return unspentTokens > 0 - ? ZonedDateTime.ofInstant(planStartTime.toInstant().plusMillis(timeShift), ZoneOffset.UTC) - : null; - } - - public Long getDeliveryRateInMilliseconds() { - return getUnspentTokens() > 0 - ? (deliverySchedule.getEndTimeStamp().toInstant().toEpochMilli() - - deliverySchedule.getStartTimeStamp().toInstant().toEpochMilli()) - / getTotalTokens() - : null; - } - - public boolean isUpdated(DeliverySchedule deliverySchedule) { - final ZonedDateTime currentPlanUpdatedDate = this.deliverySchedule.getUpdatedTimeStamp(); - final ZonedDateTime newPlanUpdatedDate = deliverySchedule.getUpdatedTimeStamp(); - return !(currentPlanUpdatedDate == null && newPlanUpdatedDate == null) - && (currentPlanUpdatedDate == null || newPlanUpdatedDate == null - || currentPlanUpdatedDate.isBefore(newPlanUpdatedDate)); - } - - public String getPlanId() { - return deliverySchedule.getPlanId(); - } - - public ZonedDateTime getStartTimeStamp() { - return deliverySchedule.getStartTimeStamp(); - } - - public ZonedDateTime getEndTimeStamp() { - return deliverySchedule.getEndTimeStamp(); - } - - public ZonedDateTime getUpdatedTimeStamp() { - return deliverySchedule.getUpdatedTimeStamp(); - } - - public Set getDeliveryTokens() { - return deliveryTokens; - } - - public DeliverySchedule getDeliverySchedule() { - return deliverySchedule; - } - - private static Set toDeliveryTokens(Set tokens) { - return SetUtils.emptyIfNull(tokens).stream() - .map(DeliveryToken::of) - .collect(Collectors.toCollection(TreeSet::new)); - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/DeliveryProgress.java b/src/main/java/org/prebid/server/deals/lineitem/DeliveryProgress.java deleted file mode 100644 index f14dbef4a07..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/DeliveryProgress.java +++ /dev/null @@ -1,349 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.report.Event; - -import java.time.ZonedDateTime; -import java.time.temporal.ChronoUnit; -import java.util.Collection; -import java.util.Comparator; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -public class DeliveryProgress { - - private static final String WIN_EVENT_TYPE = "win"; - - private final Map lineItemStatuses; - private final Map requestsPerAccount; - private final Map> lineItemIdToLost; - private final LongAdder requests; - private ZonedDateTime startTimeStamp; - private ZonedDateTime endTimeStamp; - private final LineItemService lineItemService; - - private DeliveryProgress(ZonedDateTime startTimeStamp, LineItemService lineItemService) { - this.startTimeStamp = Objects.requireNonNull(startTimeStamp); - this.lineItemStatuses = new ConcurrentHashMap<>(); - this.requests = new LongAdder(); - this.requestsPerAccount = new ConcurrentHashMap<>(); - this.lineItemIdToLost = new ConcurrentHashMap<>(); - this.lineItemService = Objects.requireNonNull(lineItemService); - } - - public static DeliveryProgress of(ZonedDateTime startTimeStamp, LineItemService lineItemService) { - return new DeliveryProgress(startTimeStamp, lineItemService); - } - - public DeliveryProgress copyWithOriginalPlans() { - final DeliveryProgress progress = DeliveryProgress.of(this.getStartTimeStamp(), - this.lineItemService); - - for (final LineItemStatus originalStatus : this.lineItemStatuses.values()) { - progress.lineItemStatuses.put(originalStatus.getLineItemId(), createStatusWithPlans(originalStatus)); - } - - progress.mergeFrom(this); - - return progress; - } - - private LineItemStatus createStatusWithPlans(LineItemStatus originalStatus) { - final LineItemStatus status = createLineItemStatus(originalStatus.getLineItemId()); - status.getDeliveryPlans().addAll(originalStatus.getDeliveryPlans()); - return status; - } - - /** - * Updates delivery progress from {@link TxnLog}. - */ - public void recordTransactionLog(TxnLog txnLog, Map planIdToTokenPriority, String accountId) { - accountRequests(accountId).increment(); - requests.increment(); - - txnLog.lineItemSentToClientAsTopMatch() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incSentToClientAsTopMatch)); - txnLog.lineItemsSentToClient() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incSentToClient)); - txnLog.lineItemsMatchedDomainTargeting() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incDomainMatched)); - txnLog.lineItemsMatchedWholeTargeting() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incTargetMatched)); - txnLog.lineItemsMatchedTargetingFcapped() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incTargetMatchedButFcapped)); - txnLog.lineItemsMatchedTargetingFcapLookupFailed() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incTargetMatchedButFcapLookupFailed)); - txnLog.lineItemsPacingDeferred() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incPacingDeferred)); - txnLog.lineItemsSentToBidder().values().forEach(idList -> idList - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incSentToBidder))); - txnLog.lineItemsSentToBidderAsTopMatch().values().forEach(bidderList -> bidderList - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incSentToBidderAsTopMatch))); - txnLog.lineItemsReceivedFromBidder().values().forEach(idList -> idList - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incReceivedFromBidder))); - txnLog.lineItemsResponseInvalidated() - .forEach(lineItemId -> increment(lineItemId, LineItemStatus::incReceivedFromBidderInvalidated)); - - txnLog.lineItemSentToClientAsTopMatch() - .forEach(lineItemId -> incToken(lineItemId, planIdToTokenPriority)); - - txnLog.lostMatchingToLineItems().forEach((lineItemId, lostToLineItemsIds) -> - updateLostToEachLineItem(lineItemId, lostToLineItemsIds, lineItemIdToLost)); - txnLog.lostAuctionToLineItems().forEach((lineItemId, lostToLineItemsIds) -> - updateLostToEachLineItem(lineItemId, lostToLineItemsIds, lineItemIdToLost)); - } - - /** - * Increments {@link LineItemStatus} win type {@link Event} counter. Creates new {@link LineItemStatus} if not - * exists. - */ - public void recordWinEvent(String lineItemId) { - final LineItemStatus lineItemStatus = lineItemStatuses.computeIfAbsent(lineItemId, this::createLineItemStatus); - final Event winEvent = lineItemStatus.getEvents().stream() - .filter(event -> event.getType().equals(WIN_EVENT_TYPE)) - .findAny() - .orElseGet(() -> Event.of(WIN_EVENT_TYPE, new LongAdder())); - - winEvent.getCount().increment(); - lineItemStatus.getEvents().add(winEvent); - } - - private LineItemStatus createLineItemStatus(String lineItemId) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - return lineItem != null - ? LineItemStatus.of(lineItem) - : LineItemStatus.of(lineItemId); - } - - /** - * Updates delivery progress from another {@link DeliveryProgress}. - */ - public void mergeFrom(DeliveryProgress another) { - requests.add(another.requests.sum()); - - another.requestsPerAccount.forEach((accountId, requestsCount) -> - mergeRequestsCount(accountId, requestsCount, requestsPerAccount)); - - another.lineItemStatuses.forEach((lineItemId, lineItemStatus) -> - lineItemStatuses.computeIfAbsent(lineItemId, this::createLineItemStatus).merge(lineItemStatus)); - - another.lineItemIdToLost.forEach((lineItemId, currentLineItemLost) -> - mergeCurrentLineItemLostReportToOverall(lineItemId, currentLineItemLost, lineItemIdToLost)); - } - - public void upsertPlanReferenceFromLineItem(LineItem lineItem) { - final String lineItemId = lineItem.getLineItemId(); - final LineItemStatus existingLineItemStatus = lineItemStatuses.get(lineItemId); - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - if (existingLineItemStatus == null) { - final LineItemStatus lineItemStatus = createLineItemStatus(lineItem.getLineItemId()); - lineItemStatus.getDeliveryPlans().add(activeDeliveryPlan); - lineItemStatuses.put(lineItemId, lineItemStatus); - } else { - updateLineItemStatusWithActiveDeliveryPlan(existingLineItemStatus, activeDeliveryPlan); - } - } - - /** - * Updates {@link LineItemStatus} with current {@link DeliveryPlan}. - */ - public void mergePlanFromLineItem(LineItem lineItem) { - final LineItemStatus currentLineItemStatus = lineItemStatuses.computeIfAbsent(lineItem.getLineItemId(), - this::createLineItemStatus); - final DeliveryPlan updatedDeliveryPlan = lineItem.getActiveDeliveryPlan(); - - final Set deliveryPlans = currentLineItemStatus.getDeliveryPlans(); - final DeliveryPlan currentPlan = deliveryPlans.stream() - .filter(plan -> Objects.equals(plan.getPlanId(), updatedDeliveryPlan.getPlanId())) - .findFirst() - .orElse(null); - - if (currentPlan == null) { - deliveryPlans.add(updatedDeliveryPlan.withoutSpentTokens()); - } else if (currentPlan.isUpdated(updatedDeliveryPlan.getDeliverySchedule())) { - final DeliveryPlan updatedPlan = currentPlan.mergeWithNextDeliveryPlan(updatedDeliveryPlan); - deliveryPlans.remove(currentPlan); - deliveryPlans.add(updatedPlan); - } - } - - /** - * Remove stale {@link LineItemStatus} from statistic. - */ - public void cleanLineItemStatuses(ZonedDateTime now, long lineItemStatusTtl, int maxPlanNumberInDeliveryProgress) { - lineItemStatuses.entrySet().removeIf(entry -> isLineItemStatusExpired(entry.getKey(), now, lineItemStatusTtl)); - - lineItemStatuses.values().forEach( - lineItemStatus -> cutCachedDeliveryPlans(lineItemStatus, maxPlanNumberInDeliveryProgress)); - } - - /** - * Returns true when lineItem is not in metaData and it is expired for more then defined in configuration time. - */ - private boolean isLineItemStatusExpired(String lineItemId, ZonedDateTime now, long lineItemStatusTtl) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - - return lineItem == null || ChronoUnit.MILLIS.between(lineItem.getEndTimeStamp(), now) > lineItemStatusTtl; - } - - /** - * Cuts number of plans in {@link LineItemStatus} from overall statistic by number defined in configuration. - */ - private void cutCachedDeliveryPlans(LineItemStatus lineItemStatus, int maxPlanNumberInDeliveryProgress) { - final Set deliveryPlans = lineItemStatus.getDeliveryPlans(); - if (deliveryPlans.size() > maxPlanNumberInDeliveryProgress) { - final Set plansToRemove = deliveryPlans.stream() - .sorted(Comparator.comparing(DeliveryPlan::getEndTimeStamp)) - .limit(deliveryPlans.size() - maxPlanNumberInDeliveryProgress) - .collect(Collectors.toSet()); - plansToRemove.forEach(deliveryPlans::remove); - } - } - - /** - * Updates {@link LineItemStatus} with active {@link DeliveryPlan}. - */ - private void updateLineItemStatusWithActiveDeliveryPlan(LineItemStatus lineItemStatus, - DeliveryPlan updatedDeliveryPlan) { - final Set deliveryPlans = lineItemStatus.getDeliveryPlans(); - final DeliveryPlan currentPlan = deliveryPlans.stream() - .filter(plan -> Objects.equals(plan.getPlanId(), updatedDeliveryPlan.getPlanId())) - .filter(plan -> plan.isUpdated(updatedDeliveryPlan.getDeliverySchedule())) - .findAny() - .orElse(null); - if (currentPlan != null) { - if (!Objects.equals(currentPlan.getUpdatedTimeStamp(), updatedDeliveryPlan.getUpdatedTimeStamp())) { - deliveryPlans.add(updatedDeliveryPlan); - deliveryPlans.remove(currentPlan); - } - } else { - deliveryPlans.add(updatedDeliveryPlan); - } - } - - public void updateWithActiveLineItems(Collection lineItems) { - lineItems.forEach(lineItem -> lineItemStatuses.putIfAbsent(lineItem.getLineItemId(), - createLineItemStatus(lineItem.getLineItemId()))); - } - - public Map getLineItemStatuses() { - return lineItemStatuses; - } - - public Map getRequestsPerAccount() { - return requestsPerAccount; - } - - public Map> getLineItemIdToLost() { - return lineItemIdToLost; - } - - public LongAdder getRequests() { - return requests; - } - - public ZonedDateTime getStartTimeStamp() { - return startTimeStamp; - } - - public void setStartTimeStamp(ZonedDateTime startTimeStamp) { - this.startTimeStamp = startTimeStamp; - } - - public void setEndTimeStamp(ZonedDateTime endTimeStamp) { - this.endTimeStamp = endTimeStamp; - } - - public ZonedDateTime getEndTimeStamp() { - return endTimeStamp; - } - - private LongAdder accountRequests(String account) { - return requestsPerAccount.computeIfAbsent(account, ignored -> new LongAdder()); - } - - /** - * Increments {@link LineItemStatus} metric, creates line item status if does not exist. - */ - private void increment(String lineItemId, Consumer inc) { - inc.accept(lineItemStatuses.computeIfAbsent(lineItemId, this::createLineItemStatus)); - } - - /** - * Increment tokens in active delivery report. - */ - private void incToken(String lineItemId, Map planIdToTokenPriority) { - final LineItemStatus lineItemStatus = lineItemStatuses.get(lineItemId); - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - final DeliveryPlan lineItemActivePlan = lineItem.getActiveDeliveryPlan(); - if (lineItemActivePlan != null) { - DeliveryPlan reportActivePlan = lineItemStatus.getDeliveryPlans().stream() - .filter(plan -> Objects.equals(plan.getPlanId(), lineItemActivePlan.getPlanId())) - .findFirst() - .orElse(null); - if (reportActivePlan == null) { - reportActivePlan = lineItemActivePlan.withoutSpentTokens(); - lineItemStatus.getDeliveryPlans().add(reportActivePlan); - } - - final Integer tokenPriority = planIdToTokenPriority.get(reportActivePlan.getPlanId()); - if (tokenPriority != null) { - reportActivePlan.incTokenWithPriority(tokenPriority); - } - } - } - - /** - * Updates lostToLineItem metric for line item specified by lineItemId parameter against line item ids from - * parameter lostToLineItemIds - */ - private void updateLostToEachLineItem(String lineItemId, Set lostToLineItemsIds, - Map> lostToLineItemTimes) { - final Map lostToLineItemsTimes = lostToLineItemTimes - .computeIfAbsent(lineItemId, key -> new ConcurrentHashMap<>()); - lostToLineItemsIds.forEach(lostToLineItemId -> incLostToLineItemTimes(lostToLineItemId, lostToLineItemsTimes)); - } - - /** - * Updates listToLineItem metric against line item specified in parameter lostToLineItemId - */ - private void incLostToLineItemTimes(String lostToLineItemId, Map lostToLineItemsTimes) { - final LostToLineItem lostToLineItem = lostToLineItemsTimes.computeIfAbsent(lostToLineItemId, - ignored -> LostToLineItem.of(lostToLineItemId, new LongAdder())); - lostToLineItem.getCount().increment(); - } - - /** - * Merges requests per account to overall statistics. - */ - private void mergeRequestsCount(String accountId, LongAdder requestsCount, - Map requestsPerAccount) { - requestsPerAccount.computeIfPresent(accountId, (key, oldValue) -> { - oldValue.add(requestsCount.sum()); - return oldValue; - }); - requestsPerAccount.putIfAbsent(accountId, requestsCount); - } - - private void mergeCurrentLineItemLostReportToOverall( - String lineItemId, - Map currentLineItemLost, - Map> overallLineItemIdToLost) { - final Map overallLineItemLost = overallLineItemIdToLost - .computeIfAbsent(lineItemId, ignored -> new ConcurrentHashMap<>()); - currentLineItemLost.forEach((lineItemIdLostTo, currentLostToLineItem) -> - overallLineItemLost.merge(lineItemIdLostTo, currentLostToLineItem, this::addToCount) - ); - } - - private LostToLineItem addToCount(LostToLineItem mergeTo, LostToLineItem mergeFrom) { - mergeTo.getCount().add(mergeFrom.getCount().sum()); - return mergeTo; - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/DeliveryToken.java b/src/main/java/org/prebid/server/deals/lineitem/DeliveryToken.java deleted file mode 100644 index 67188cc96e9..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/DeliveryToken.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import org.prebid.server.deals.proto.Token; - -import java.util.Comparator; -import java.util.Objects; -import java.util.concurrent.atomic.LongAdder; - -public class DeliveryToken implements Comparable { - - private static final Comparator COMPARATOR = Comparator.comparing(DeliveryToken::getPriorityClass); - - private final Token token; - - private final LongAdder spent; - - private DeliveryToken(Token token) { - this(token, new LongAdder()); - } - - private DeliveryToken(Token token, LongAdder spent) { - this.token = Objects.requireNonNull(token); - this.spent = Objects.requireNonNull(spent); - } - - public static DeliveryToken of(DeliveryToken deliveryToken) { - return new DeliveryToken(deliveryToken.token); - } - - public static DeliveryToken of(Token token) { - return new DeliveryToken(token); - } - - /** - * Return unspent tokens from {@link DeliveryToken}. - */ - public int getUnspent() { - return (int) (token.getTotal() - spent.sum()); - } - - public void inc() { - spent.increment(); - } - - public DeliveryToken mergeWithToken(Token nextToken, boolean sumTotal) { - if (nextToken == null) { - return this; - } else { - final int total = sumTotal - ? getTotal() + nextToken.getTotal() - : nextToken.getTotal(); - return new DeliveryToken(Token.of(getPriorityClass(), total), spent); - } - } - - public LongAdder getSpent() { - return spent; - } - - public Integer getTotal() { - return token.getTotal(); - } - - public Integer getPriorityClass() { - return token.getPriorityClass(); - } - - @Override - public int compareTo(DeliveryToken another) { - return COMPARATOR.compare(this, another); - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/LineItem.java b/src/main/java/org/prebid/server/deals/lineitem/LineItem.java deleted file mode 100644 index 58554ab6cdd..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/LineItem.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.FrequencyCap; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.LineItemSize; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.deals.targeting.TargetingDefinition; - -import java.math.BigDecimal; -import java.time.ZonedDateTime; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -public class LineItem { - - private static final Logger logger = LoggerFactory.getLogger(LineItem.class); - - private final LineItemMetaData metaData; - - private final Price normalizedPrice; - - private final List fcapIds; - - private final TargetingDefinition targetingDefinition; - - private final AtomicReference activeDeliveryPlan; - - private final AtomicReference readyAt; - - private LineItem(LineItemMetaData metaData, Price normalizedPrice, TargetingDefinition targetingDefinition) { - this.metaData = Objects.requireNonNull(metaData); - this.normalizedPrice = normalizedPrice; - this.targetingDefinition = targetingDefinition; - - this.fcapIds = extractFcapIds(metaData); - - activeDeliveryPlan = new AtomicReference<>(); - readyAt = new AtomicReference<>(); - } - - private LineItem(LineItemMetaData metaData, - Price normalizedPrice, - TargetingDefinition targetingDefinition, - ZonedDateTime readyAt, - ZonedDateTime now, - DeliveryPlan currentPlan) { - this(metaData, normalizedPrice, targetingDefinition); - this.readyAt.set(readyAt); - - updateOrAdvanceActivePlan(now, true, currentPlan); - } - - private LineItem(LineItemMetaData metaData, - Price normalizedPrice, - TargetingDefinition targetingDefinition, - ZonedDateTime now) { - this(metaData, normalizedPrice, targetingDefinition, null, now, null); - } - - public static LineItem of(LineItemMetaData metaData, - Price normalizedPrice, - TargetingDefinition targetingDefinition, - ZonedDateTime now) { - return new LineItem(metaData, normalizedPrice, targetingDefinition, now); - } - - public LineItem withUpdatedMetadata(LineItemMetaData metaData, - Price normalizedPrice, - TargetingDefinition targetingDefinition, - ZonedDateTime readyAt, - ZonedDateTime now) { - return new LineItem(metaData, normalizedPrice, targetingDefinition, readyAt, now, getActiveDeliveryPlan()); - } - - public void advanceToNextPlan(ZonedDateTime now, boolean isPlannerResponsive) { - updateOrAdvanceActivePlan(now, isPlannerResponsive, getActiveDeliveryPlan()); - } - - /** - * Increments tokens in {@link DeliveryToken} with highest priority within {@link DeliveryPlan}. - * - * @return class of the token incremented. - */ - public Integer incSpentToken(ZonedDateTime now) { - return incSpentToken(now, 0); - } - - public Integer incSpentToken(ZonedDateTime now, long adjustment) { - final DeliveryPlan deliveryPlan = activeDeliveryPlan.get(); - - if (deliveryPlan != null) { - final Integer tokenClassIncremented = deliveryPlan.incSpentToken(); - ZonedDateTime readyAtNewValue = deliveryPlan.calculateReadyAt(); - readyAtNewValue = readyAtNewValue != null && adjustment != 0 - ? readyAtNewValue.plusNanos(TimeUnit.MILLISECONDS.toNanos(adjustment)) - : readyAtNewValue; - readyAt.set(readyAtNewValue); - if (logger.isDebugEnabled()) { - logger.debug("ReadyAt for lineItem {0} plan {1} was updated to {2} after token was spent. Total number" - + " of unspent token is {3}. Current time is {4}", - getLineItemId(), deliveryPlan.getPlanId(), - readyAt.get(), deliveryPlan.getUnspentTokens(), now); - } - return tokenClassIncremented; - } - return null; - } - - public Integer getHighestUnspentTokensClass() { - final DeliveryPlan activeDeliveryPlan = getActiveDeliveryPlan(); - return activeDeliveryPlan != null ? activeDeliveryPlan.getHighestUnspentTokensClass() : null; - } - - public boolean isActive(ZonedDateTime now) { - return dateBetween(now, metaData.getStartTimeStamp(), metaData.getEndTimeStamp()); - } - - public DeliveryPlan getActiveDeliveryPlan() { - return activeDeliveryPlan.get(); - } - - public ZonedDateTime getReadyAt() { - return readyAt.get(); - } - - public BigDecimal getCpm() { - if (normalizedPrice != null) { - return normalizedPrice.getCpm(); - } - return null; - } - - public String getCurrency() { - if (normalizedPrice != null) { - return normalizedPrice.getCurrency(); - } - return null; - } - - public String getLineItemId() { - return metaData.getLineItemId(); - } - - public String getExtLineItemId() { - return metaData.getExtLineItemId(); - } - - public String getDealId() { - return metaData.getDealId(); - } - - public String getAccountId() { - return metaData.getAccountId(); - } - - public String getSource() { - return metaData.getSource(); - } - - public Integer getRelativePriority() { - return metaData.getRelativePriority(); - } - - public ZonedDateTime getEndTimeStamp() { - return metaData.getEndTimeStamp(); - } - - public ZonedDateTime getStartTimeStamp() { - return metaData.getStartTimeStamp(); - } - - public ZonedDateTime getUpdatedTimeStamp() { - return metaData.getUpdatedTimeStamp(); - } - - public List getFrequencyCaps() { - return metaData.getFrequencyCaps(); - } - - public List getSizes() { - return metaData.getSizes(); - } - - public ObjectNode getTargeting() { - return metaData.getTargeting(); - } - - public TargetingDefinition getTargetingDefinition() { - return targetingDefinition; - } - - public List getFcapIds() { - return fcapIds; - } - - private static List extractFcapIds(LineItemMetaData metaData) { - return CollectionUtils.emptyIfNull(metaData.getFrequencyCaps()).stream() - .map(FrequencyCap::getFcapId) - .toList(); - } - - private void updateOrAdvanceActivePlan(ZonedDateTime now, boolean isPlannerResponsive, DeliveryPlan currentPlan) { - final DeliverySchedule currentSchedule = ListUtils.emptyIfNull(metaData.getDeliverySchedules()).stream() - .filter(schedule -> dateBetween(now, schedule.getStartTimeStamp(), schedule.getEndTimeStamp())) - .findFirst() - .orElse(null); - - if (currentSchedule != null) { - final DeliveryPlan resolvedPlan = resolveActivePlan(currentPlan, currentSchedule, isPlannerResponsive); - final ZonedDateTime readyAtBeforeUpdate = readyAt.get(); - if (currentPlan != resolvedPlan) { - readyAt.set(currentPlan == null || !Objects.equals(currentSchedule.getPlanId(), currentPlan.getPlanId()) - ? calculateReadyAfterMovingToNextPlan(now, resolvedPlan) - : calculateReadyAtAfterPlanUpdated(now, resolvedPlan)); - logger.info("ReadyAt for Line Item `{0}` was updated from plan {1} to {2} and readyAt from {3} to {4}" - + " at time is {5}", getLineItemId(), - currentPlan != null ? currentPlan.getPlanId() : " no plan ", resolvedPlan.getPlanId(), - readyAtBeforeUpdate, getReadyAt(), now); - if (logger.isDebugEnabled()) { - logger.debug("Unspent tokens number for plan {0} is {1}", resolvedPlan.getPlanId(), - resolvedPlan.getUnspentTokens()); - } - } - activeDeliveryPlan.set(resolvedPlan); - } else { - activeDeliveryPlan.set(null); - readyAt.set(null); - logger.info("Active plan for Line Item `{0}` was not found at time is {1}, readyAt updated with 'never'," - + " until active plan become available", getLineItemId(), now); - } - } - - private ZonedDateTime calculateReadyAtAfterPlanUpdated(ZonedDateTime now, DeliveryPlan resolvedPlan) { - final ZonedDateTime resolvedReadyAt = resolvedPlan.calculateReadyAt(); - logger.debug("Current plan for Line Item `{0}` was considered as updated from GP response and readyAt will be " - + "updated from {1} to {2} at time is {3}", getLineItemId(), getReadyAt(), resolvedReadyAt, now); - return resolvedReadyAt; - } - - private ZonedDateTime calculateReadyAfterMovingToNextPlan(ZonedDateTime now, DeliveryPlan resolvedPlan) { - return resolvedPlan.getDeliveryTokens().stream().anyMatch(deliveryToken -> deliveryToken.getTotal() > 0) - ? now - : null; - } - - private static DeliveryPlan resolveActivePlan(DeliveryPlan currentPlan, - DeliverySchedule currentSchedule, - boolean isPlannerResponsive) { - if (currentPlan != null) { - if (Objects.equals(currentPlan.getPlanId(), currentSchedule.getPlanId())) { - return currentPlan.getUpdatedTimeStamp().isBefore(currentSchedule.getUpdatedTimeStamp()) - ? currentPlan.mergeWithNextDeliverySchedule(currentSchedule, false) - : currentPlan; - } else if (!isPlannerResponsive) { - return currentPlan.mergeWithNextDeliverySchedule(currentSchedule, true); - } - } - - return DeliveryPlan.of(currentSchedule); - } - - /** - * Returns true when now parameter is after startDate and before expirationDate. - */ - private static boolean dateBetween(ZonedDateTime now, ZonedDateTime startDate, ZonedDateTime expirationDate) { - return (now.isEqual(startDate) || now.isAfter(startDate)) && now.isBefore(expirationDate); - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/LineItemStatus.java b/src/main/java/org/prebid/server/deals/lineitem/LineItemStatus.java deleted file mode 100644 index e05cd399d0d..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/LineItemStatus.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import io.vertx.core.impl.ConcurrentHashSet; -import lombok.Value; -import org.prebid.server.deals.proto.report.Event; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Value -public class LineItemStatus { - - String lineItemId; - - String source; - - String dealId; - - String extLineItemId; - - String accountId; - - LongAdder domainMatched; - - LongAdder targetMatched; - - LongAdder targetMatchedButFcapped; - - LongAdder targetMatchedButFcapLookupFailed; - - LongAdder pacingDeferred; - - LongAdder sentToBidder; - - LongAdder sentToBidderAsTopMatch; - - LongAdder receivedFromBidder; - - LongAdder receivedFromBidderInvalidated; - - LongAdder sentToClient; - - LongAdder sentToClientAsTopMatch; - - Set lostToLineItems; - - Set events; - - Set deliveryPlans; - - private LineItemStatus(String lineItemId, String source, String dealId, String extLineItemId, String accountId) { - this.lineItemId = lineItemId; - this.source = source; - this.dealId = dealId; - this.extLineItemId = extLineItemId; - this.accountId = accountId; - - domainMatched = new LongAdder(); - targetMatched = new LongAdder(); - targetMatchedButFcapped = new LongAdder(); - targetMatchedButFcapLookupFailed = new LongAdder(); - pacingDeferred = new LongAdder(); - sentToBidder = new LongAdder(); - sentToBidderAsTopMatch = new LongAdder(); - receivedFromBidder = new LongAdder(); - receivedFromBidderInvalidated = new LongAdder(); - sentToClient = new LongAdder(); - sentToClientAsTopMatch = new LongAdder(); - - lostToLineItems = new ConcurrentHashSet<>(); - events = new ConcurrentHashSet<>(); - deliveryPlans = new ConcurrentHashSet<>(); - } - - public static LineItemStatus of(String lineItemId, String source, String dealId, String extLineItemId, - String accountId) { - return new LineItemStatus(lineItemId, source, dealId, extLineItemId, accountId); - } - - public static LineItemStatus of(LineItem lineItem) { - return new LineItemStatus(lineItem.getLineItemId(), lineItem.getSource(), lineItem.getDealId(), - lineItem.getExtLineItemId(), lineItem.getAccountId()); - } - - public static LineItemStatus of(String lineItemId) { - return new LineItemStatus(lineItemId, null, null, null, null); - } - - public void incDomainMatched() { - domainMatched.increment(); - } - - public void incTargetMatched() { - targetMatched.increment(); - } - - public void incTargetMatchedButFcapped() { - targetMatchedButFcapped.increment(); - } - - public void incTargetMatchedButFcapLookupFailed() { - targetMatchedButFcapLookupFailed.increment(); - } - - public void incPacingDeferred() { - pacingDeferred.increment(); - } - - public void incSentToBidder() { - sentToBidder.increment(); - } - - public void incSentToBidderAsTopMatch() { - sentToBidderAsTopMatch.increment(); - } - - public void incReceivedFromBidder() { - receivedFromBidder.increment(); - } - - public void incReceivedFromBidderInvalidated() { - receivedFromBidderInvalidated.increment(); - } - - public void incSentToClient() { - sentToClient.increment(); - } - - public void incSentToClientAsTopMatch() { - sentToClientAsTopMatch.increment(); - } - - public void merge(LineItemStatus other) { - domainMatched.add(other.domainMatched.sum()); - targetMatched.add(other.targetMatched.sum()); - targetMatchedButFcapped.add(other.targetMatchedButFcapped.sum()); - targetMatchedButFcapLookupFailed.add(other.getTargetMatchedButFcapLookupFailed().sum()); - pacingDeferred.add(other.pacingDeferred.sum()); - sentToBidder.add(other.sentToBidder.sum()); - sentToBidderAsTopMatch.add(other.sentToBidderAsTopMatch.sum()); - receivedFromBidder.add(other.receivedFromBidder.sum()); - receivedFromBidderInvalidated.add(other.receivedFromBidderInvalidated.sum()); - sentToClient.add(other.sentToClient.sum()); - sentToClientAsTopMatch.add(other.sentToClientAsTopMatch.sum()); - mergeEvents(other); - } - - private void mergeEvents(LineItemStatus other) { - final Map typesToEvent = other.events.stream() - .collect(Collectors.toMap(Event::getType, Function.identity())); - typesToEvent.forEach(this::addOrUpdateEvent); - } - - private void addOrUpdateEvent(String type, Event distEvent) { - final Event sameTypeEvent = events.stream() - .filter(event -> event.getType().equals(type)) - .findFirst().orElse(null); - if (sameTypeEvent != null) { - sameTypeEvent.getCount().add(distEvent.getCount().sum()); - } else { - events.add(distEvent); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/lineitem/LostToLineItem.java b/src/main/java/org/prebid/server/deals/lineitem/LostToLineItem.java deleted file mode 100644 index 0b7be6d1f21..00000000000 --- a/src/main/java/org/prebid/server/deals/lineitem/LostToLineItem.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.concurrent.atomic.LongAdder; - -@AllArgsConstructor(staticName = "of") -@Value -public class LostToLineItem { - - String lineItemId; - - LongAdder count; -} diff --git a/src/main/java/org/prebid/server/deals/model/AdminAccounts.java b/src/main/java/org/prebid/server/deals/model/AdminAccounts.java deleted file mode 100644 index b5829dab3e6..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AdminAccounts.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@Value -@AllArgsConstructor(staticName = "of") -public class AdminAccounts { - - List accounts; -} diff --git a/src/main/java/org/prebid/server/deals/model/AdminCentralResponse.java b/src/main/java/org/prebid/server/deals/model/AdminCentralResponse.java deleted file mode 100644 index 034389ddd78..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AdminCentralResponse.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class AdminCentralResponse { - - LogTracer tracer; - - @JsonProperty("storedrequest") - Command storedRequest; - - @JsonProperty("storedrequest-amp") - Command storedRequestAmp; - - @JsonProperty("line-items") - Command lineItems; - - Command account; - - ServicesCommand services; -} diff --git a/src/main/java/org/prebid/server/deals/model/AdminLineItems.java b/src/main/java/org/prebid/server/deals/model/AdminLineItems.java deleted file mode 100644 index 14f2ecca150..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AdminLineItems.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@Value -@AllArgsConstructor(staticName = "of") -public class AdminLineItems { - - List ids; -} diff --git a/src/main/java/org/prebid/server/deals/model/AlertEvent.java b/src/main/java/org/prebid/server/deals/model/AlertEvent.java deleted file mode 100644 index 157ab84c41f..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AlertEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.Value; - -import java.time.ZonedDateTime; - -@Builder -@Value -public class AlertEvent { - - String id; - - String action; - - AlertPriority priority; - - ZonedDateTime updatedAt; - - String name; - - String details; - - AlertSource source; -} diff --git a/src/main/java/org/prebid/server/deals/model/AlertPriority.java b/src/main/java/org/prebid/server/deals/model/AlertPriority.java deleted file mode 100644 index 074fa5e164c..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AlertPriority.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.deals.model; - -public enum AlertPriority { - - HIGH, MEDIUM, LOW -} diff --git a/src/main/java/org/prebid/server/deals/model/AlertProxyProperties.java b/src/main/java/org/prebid/server/deals/model/AlertProxyProperties.java deleted file mode 100644 index 28d076129da..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AlertProxyProperties.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.Value; - -import java.util.Map; - -@Builder -@Value -public class AlertProxyProperties { - - boolean enabled; - - String url; - - int timeoutSec; - - Map alertTypes; - - String username; - - String password; -} diff --git a/src/main/java/org/prebid/server/deals/model/AlertSource.java b/src/main/java/org/prebid/server/deals/model/AlertSource.java deleted file mode 100644 index a673a18cb5b..00000000000 --- a/src/main/java/org/prebid/server/deals/model/AlertSource.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -@Builder -@Value -public class AlertSource { - - String env; - - @JsonProperty("data-center") - String dataCenter; - - String region; - - String system; - - @JsonProperty("sub-system") - String subSystem; - - @JsonProperty("host-id") - String hostId; -} diff --git a/src/main/java/org/prebid/server/deals/model/Command.java b/src/main/java/org/prebid/server/deals/model/Command.java deleted file mode 100644 index 7acbec5e4c0..00000000000 --- a/src/main/java/org/prebid/server/deals/model/Command.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class Command { - - String cmd; - - ObjectNode body; -} diff --git a/src/main/java/org/prebid/server/deals/model/DeepDebugLog.java b/src/main/java/org/prebid/server/deals/model/DeepDebugLog.java deleted file mode 100644 index 597c55f63b0..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeepDebugLog.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.prebid.server.deals.model; - -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.function.Supplier; - -public class DeepDebugLog { - - private final boolean deepDebugEnabled; - - private final List entries; - - private final Clock clock; - - private DeepDebugLog(boolean deepDebugEnabled, Clock clock) { - this.deepDebugEnabled = deepDebugEnabled; - this.entries = deepDebugEnabled ? new LinkedList<>() : null; - this.clock = Objects.requireNonNull(clock); - } - - public static DeepDebugLog create(boolean deepDebugEnabled, Clock clock) { - return new DeepDebugLog(deepDebugEnabled, clock); - } - - public void add(String lineItemId, Category category, Supplier messageSupplier) { - if (deepDebugEnabled) { - entries.add(ExtTraceDeal.of(lineItemId, ZonedDateTime.now(clock), category, messageSupplier.get())); - } - } - - public boolean isDeepDebugEnabled() { - return deepDebugEnabled; - } - - public List entries() { - return entries == null ? Collections.emptyList() : Collections.unmodifiableList(entries); - } -} diff --git a/src/main/java/org/prebid/server/deals/model/DeliveryProgressProperties.java b/src/main/java/org/prebid/server/deals/model/DeliveryProgressProperties.java deleted file mode 100644 index 95007f33ea0..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeliveryProgressProperties.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class DeliveryProgressProperties { - - long lineItemStatusTtlSeconds; - - int cachedPlansNumber; -} diff --git a/src/main/java/org/prebid/server/deals/model/DeliveryStatsProperties.java b/src/main/java/org/prebid/server/deals/model/DeliveryStatsProperties.java deleted file mode 100644 index 237c094a33b..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeliveryStatsProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.NonNull; -import lombok.Value; - -@Builder -@Value -public class DeliveryStatsProperties { - - @NonNull - String endpoint; - - int cachedReportsNumber; - - long timeoutMs; - - int lineItemsPerReport; - - int reportsIntervalMs; - - int batchesIntervalMs; - - boolean requestCompressionEnabled; - - @NonNull - String username; - - @NonNull - String password; -} diff --git a/src/main/java/org/prebid/server/deals/model/DeploymentProperties.java b/src/main/java/org/prebid/server/deals/model/DeploymentProperties.java deleted file mode 100644 index afd08710145..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeploymentProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.Value; - -@Builder -@Value -public class DeploymentProperties { - - String pbsHostId; - - String pbsRegion; - - String pbsVendor; - - String profile; - - String infra; - - String dataCenter; - - String system; - - String subSystem; -} diff --git a/src/main/java/org/prebid/server/deals/model/DeviceInfo.java b/src/main/java/org/prebid/server/deals/model/DeviceInfo.java deleted file mode 100644 index e58f9bcedf9..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeviceInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.NonNull; -import lombok.Value; - -@Builder -@Value -public class DeviceInfo { - - @NonNull - String vendor; - - DeviceType deviceType; - - String deviceTypeRaw; - - String osfamily; - - String os; - - String osVersion; - - String manufacturer; - - String model; - - String browser; - - String browserVersion; - - String carrier; - - String language; -} diff --git a/src/main/java/org/prebid/server/deals/model/DeviceType.java b/src/main/java/org/prebid/server/deals/model/DeviceType.java deleted file mode 100644 index 04acc900bce..00000000000 --- a/src/main/java/org/prebid/server/deals/model/DeviceType.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.prebid.server.deals.model; - -public enum DeviceType { - - MOBILE("mobile"), - DESKTOP("desktop"), - TV("connected tv"), - PHONE("phone"), - DEVICE("connected device"), - SET_TOP_BOX("set top box"), - TABLET("tablet"); - - private final String name; - - DeviceType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public static DeviceType resolveDeviceType(String deviceType) { - if (deviceType == null) { - return null; - } - - return switch (deviceType) { - case "Mobile Phone", "Mobile", "SmartPhone", "SmallScreen" -> MOBILE; - case "Desktop", "Single-board Computer" -> DESKTOP; - case "TV", "Tv" -> TV; - case "Fixed Wireless Phone", "Vehicle Phone" -> PHONE; - case "Tablet" -> TABLET; - case "Digital Home Assistant", "Digital Signage Media Player", - "eReader", "EReader", "Console", "Games Console", "Media Player", - "Payment Terminal", "Refrigerator", "Vehicle Multimedia System", - "Weighing Scale", "Wristwatch", "SmartWatch" -> DEVICE; - // might not be correct for 51degrees (https://51degrees.com/resources/property-dictionary) - case "Set Top Box", "MediaHub" -> SET_TOP_BOX; - default -> null; - }; - } -} diff --git a/src/main/java/org/prebid/server/deals/model/ExtUser.java b/src/main/java/org/prebid/server/deals/model/ExtUser.java deleted file mode 100644 index 26f6d610fa3..00000000000 --- a/src/main/java/org/prebid/server/deals/model/ExtUser.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class ExtUser { - - @JsonProperty("fcapIds") - List fcapIds; -} diff --git a/src/main/java/org/prebid/server/deals/model/LogCriteriaFilter.java b/src/main/java/org/prebid/server/deals/model/LogCriteriaFilter.java deleted file mode 100644 index 758a40a6282..00000000000 --- a/src/main/java/org/prebid/server/deals/model/LogCriteriaFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class LogCriteriaFilter { - - @JsonProperty("accountId") - String accountId; - - @JsonProperty("bidderCode") - String bidderCode; - - @JsonProperty("lineItemId") - String lineItemId; -} diff --git a/src/main/java/org/prebid/server/deals/model/LogTracer.java b/src/main/java/org/prebid/server/deals/model/LogTracer.java deleted file mode 100644 index fb5c2e9c456..00000000000 --- a/src/main/java/org/prebid/server/deals/model/LogTracer.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class LogTracer { - - String cmd; - - Boolean raw; - - @JsonProperty("durationInSeconds") - Long durationInSeconds; - - LogCriteriaFilter filters; -} diff --git a/src/main/java/org/prebid/server/deals/model/MatchLineItemsResult.java b/src/main/java/org/prebid/server/deals/model/MatchLineItemsResult.java deleted file mode 100644 index 22d1cd01078..00000000000 --- a/src/main/java/org/prebid/server/deals/model/MatchLineItemsResult.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; -import org.prebid.server.deals.lineitem.LineItem; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class MatchLineItemsResult { - - List lineItems; -} diff --git a/src/main/java/org/prebid/server/deals/model/PlannerProperties.java b/src/main/java/org/prebid/server/deals/model/PlannerProperties.java deleted file mode 100644 index f7eac001842..00000000000 --- a/src/main/java/org/prebid/server/deals/model/PlannerProperties.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.NonNull; -import lombok.Value; - -@Builder -@Value -public class PlannerProperties { - - @NonNull - String planEndpoint; - - @NonNull - String registerEndpoint; - - long timeoutMs; - - long registerPeriodSeconds; - - @NonNull - String username; - - @NonNull - String password; -} diff --git a/src/main/java/org/prebid/server/deals/model/Segment.java b/src/main/java/org/prebid/server/deals/model/Segment.java deleted file mode 100644 index 648e3cf5f0c..00000000000 --- a/src/main/java/org/prebid/server/deals/model/Segment.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class Segment { - - String id; -} diff --git a/src/main/java/org/prebid/server/deals/model/ServicesCommand.java b/src/main/java/org/prebid/server/deals/model/ServicesCommand.java deleted file mode 100644 index f58c26791d5..00000000000 --- a/src/main/java/org/prebid/server/deals/model/ServicesCommand.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class ServicesCommand { - - String cmd; -} diff --git a/src/main/java/org/prebid/server/deals/model/SimulationProperties.java b/src/main/java/org/prebid/server/deals/model/SimulationProperties.java deleted file mode 100644 index fc520afbbcf..00000000000 --- a/src/main/java/org/prebid/server/deals/model/SimulationProperties.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.Builder; -import lombok.Value; - -@Builder -@Value -public class SimulationProperties { - - boolean enabled; - - boolean winEventsEnabled; - - boolean userDetailsEnabled; -} diff --git a/src/main/java/org/prebid/server/deals/model/TxnLog.java b/src/main/java/org/prebid/server/deals/model/TxnLog.java deleted file mode 100644 index f4a4ae34c48..00000000000 --- a/src/main/java/org/prebid/server/deals/model/TxnLog.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; -import lombok.experimental.FieldDefaults; -import org.apache.commons.collections4.Factory; -import org.apache.commons.collections4.MapUtils; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -@Getter -@Accessors(fluent = true, chain = true) -@NoArgsConstructor(staticName = "create") -@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) -@EqualsAndHashCode -public class TxnLog { - - Set lineItemsMatchedDomainTargeting = new HashSet<>(); - - Set lineItemsMatchedWholeTargeting = new HashSet<>(); - - Set lineItemsMatchedTargetingFcapped = new HashSet<>(); - - Set lineItemsMatchedTargetingFcapLookupFailed = new HashSet<>(); - - Set lineItemsReadyToServe = new HashSet<>(); - - Set lineItemsPacingDeferred = new HashSet<>(); - - Map> lineItemsSentToBidder = MapUtils.lazyMap( - new TreeMap<>(String.CASE_INSENSITIVE_ORDER), - (Factory>) HashSet::new); - - Map> lineItemsSentToBidderAsTopMatch = MapUtils.lazyMap( - new TreeMap<>(String.CASE_INSENSITIVE_ORDER), - (Factory>) HashSet::new); - - Map> lineItemsReceivedFromBidder = MapUtils.lazyMap( - new TreeMap<>(String.CASE_INSENSITIVE_ORDER), - (Factory>) HashSet::new); - - Set lineItemsResponseInvalidated = new HashSet<>(); - - Set lineItemsSentToClient = new HashSet<>(); - - Map> lostMatchingToLineItems = MapUtils.lazyMap(new HashMap<>(), - (Factory>) HashSet::new); - - Map> lostAuctionToLineItems = MapUtils.lazyMap(new HashMap<>(), - (Factory>) HashSet::new); - - Set lineItemSentToClientAsTopMatch = new HashSet<>(); -} diff --git a/src/main/java/org/prebid/server/deals/model/User.java b/src/main/java/org/prebid/server/deals/model/User.java deleted file mode 100644 index fcb777fb957..00000000000 --- a/src/main/java/org/prebid/server/deals/model/User.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class User { - - List data; - - ExtUser ext; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserData.java b/src/main/java/org/prebid/server/deals/model/UserData.java deleted file mode 100644 index e25f41ab6ff..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserData.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserData { - - String id; - - String name; - - List segment; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserDetails.java b/src/main/java/org/prebid/server/deals/model/UserDetails.java deleted file mode 100644 index 5ded7d3a481..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserDetails.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserDetails { - - private static final UserDetails EMPTY = UserDetails.of(null, null); - - List userData; - - List fcapIds; - - public static UserDetails empty() { - return EMPTY; - } -} diff --git a/src/main/java/org/prebid/server/deals/model/UserDetailsProperties.java b/src/main/java/org/prebid/server/deals/model/UserDetailsProperties.java deleted file mode 100644 index 2a01b7a1208..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserDetailsProperties.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.NonNull; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserDetailsProperties { - - @NonNull - String userDetailsEndpoint; - - @NonNull - String winEventEndpoint; - - long timeout; - - @NonNull - List userIds; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserDetailsRequest.java b/src/main/java/org/prebid/server/deals/model/UserDetailsRequest.java deleted file mode 100644 index b17091924a1..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserDetailsRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserDetailsRequest { - - String time; - - List ids; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserDetailsResponse.java b/src/main/java/org/prebid/server/deals/model/UserDetailsResponse.java deleted file mode 100644 index 09e83e5ef11..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserDetailsResponse.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserDetailsResponse { - - User user; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserId.java b/src/main/java/org/prebid/server/deals/model/UserId.java deleted file mode 100644 index 4ab19e907ba..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserId.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserId { - - String type; - - String id; -} diff --git a/src/main/java/org/prebid/server/deals/model/UserIdRule.java b/src/main/java/org/prebid/server/deals/model/UserIdRule.java deleted file mode 100644 index 674cd05f04b..00000000000 --- a/src/main/java/org/prebid/server/deals/model/UserIdRule.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.deals.model; - -import lombok.AllArgsConstructor; -import lombok.NonNull; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class UserIdRule { - - @NonNull - String type; - - @NonNull - String source; - - @NonNull - String location; -} diff --git a/src/main/java/org/prebid/server/deals/model/WinEventNotification.java b/src/main/java/org/prebid/server/deals/model/WinEventNotification.java deleted file mode 100644 index 06e4dbcd85f..00000000000 --- a/src/main/java/org/prebid/server/deals/model/WinEventNotification.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.prebid.server.deals.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; -import org.prebid.server.deals.proto.FrequencyCap; - -import java.time.ZonedDateTime; -import java.util.List; - -@Builder(toBuilder = true) -@Value -public class WinEventNotification { - - @JsonProperty("bidderCode") - String bidderCode; - - @JsonProperty("bidId") - String bidId; - - @JsonProperty("lineItemId") - String lineItemId; - - String region; - - @JsonProperty("userIds") - List userIds; - - @JsonProperty("winEventDateTime") - ZonedDateTime winEventDateTime; - - @JsonProperty("lineUpdatedDateTime") - ZonedDateTime lineUpdatedDateTime; - - @JsonProperty("frequencyCaps") - List frequencyCaps; -} diff --git a/src/main/java/org/prebid/server/deals/proto/CurrencyServiceState.java b/src/main/java/org/prebid/server/deals/proto/CurrencyServiceState.java deleted file mode 100644 index 937ccdc5c39..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/CurrencyServiceState.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class CurrencyServiceState { - - @JsonProperty("lastUpdate") - String lastUpdate; -} diff --git a/src/main/java/org/prebid/server/deals/proto/DeliverySchedule.java b/src/main/java/org/prebid/server/deals/proto/DeliverySchedule.java deleted file mode 100644 index 32f7b779fa2..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/DeliverySchedule.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.time.ZonedDateTime; -import java.util.Set; - -/** - * Defines the contract for lineItems[].deliverySchedules[]. - */ -@Builder -@Value -public class DeliverySchedule { - - @JsonProperty("planId") - String planId; - - @JsonProperty("startTimeStamp") - ZonedDateTime startTimeStamp; - - @JsonProperty("endTimeStamp") - ZonedDateTime endTimeStamp; - - @JsonProperty("updatedTimeStamp") - ZonedDateTime updatedTimeStamp; - - Set tokens; -} diff --git a/src/main/java/org/prebid/server/deals/proto/FrequencyCap.java b/src/main/java/org/prebid/server/deals/proto/FrequencyCap.java deleted file mode 100644 index 053a9331fab..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/FrequencyCap.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -/** - * Defines the contract for lineItems[].frequencyCap. - */ -@Builder -@Value -public class FrequencyCap { - - @JsonProperty("fcapId") - String fcapId; - - Long count; - - Integer periods; - - @JsonProperty("periodType") - String periodType; -} diff --git a/src/main/java/org/prebid/server/deals/proto/LineItemMetaData.java b/src/main/java/org/prebid/server/deals/proto/LineItemMetaData.java deleted file mode 100644 index 8bba4760ba1..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/LineItemMetaData.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.Builder; -import lombok.Value; - -import java.time.ZonedDateTime; -import java.util.List; - -/** - * Defines the contract for lineItems[]. - */ -@Builder(toBuilder = true) -@Value -public class LineItemMetaData { - - @JsonProperty("lineItemId") - String lineItemId; - - @JsonProperty("extLineItemId") - String extLineItemId; - - @JsonProperty("dealId") - String dealId; - - List sizes; - - @JsonProperty("accountId") - String accountId; - - String source; - - Price price; - - @JsonProperty("relativePriority") - Integer relativePriority; - - @JsonProperty("startTimeStamp") - ZonedDateTime startTimeStamp; - - @JsonProperty("endTimeStamp") - ZonedDateTime endTimeStamp; - - @JsonProperty("updatedTimeStamp") - ZonedDateTime updatedTimeStamp; - - String status; - - @JsonProperty("frequencyCaps") - List frequencyCaps; - - @JsonProperty("deliverySchedules") - List deliverySchedules; - - ObjectNode targeting; -} diff --git a/src/main/java/org/prebid/server/deals/proto/LineItemSize.java b/src/main/java/org/prebid/server/deals/proto/LineItemSize.java deleted file mode 100644 index 8715d22a59a..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/LineItemSize.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.prebid.server.deals.proto; - -import lombok.AllArgsConstructor; -import lombok.Value; - -/** - * Defines the contract for lineItems[].sizes[]. - */ -@AllArgsConstructor(staticName = "of") -@Value -public class LineItemSize { - - Integer w; - - Integer h; -} diff --git a/src/main/java/org/prebid/server/deals/proto/Price.java b/src/main/java/org/prebid/server/deals/proto/Price.java deleted file mode 100644 index 15c3c5f1963..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/Price.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.proto; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.math.BigDecimal; - -@AllArgsConstructor(staticName = "of") -@Value -public class Price { - - BigDecimal cpm; - - String currency; -} diff --git a/src/main/java/org/prebid/server/deals/proto/RegisterRequest.java b/src/main/java/org/prebid/server/deals/proto/RegisterRequest.java deleted file mode 100644 index 4895468c6b7..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/RegisterRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.math.BigDecimal; - -@AllArgsConstructor(staticName = "of") -@Value -public class RegisterRequest { - - @JsonProperty("healthIndex") - BigDecimal healthIndex; - - Status status; - - @JsonProperty("hostInstanceId") - String hostInstanceId; - - String region; - - String vendor; -} diff --git a/src/main/java/org/prebid/server/deals/proto/Status.java b/src/main/java/org/prebid/server/deals/proto/Status.java deleted file mode 100644 index 974ae7fe0f2..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/Status.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; - -@AllArgsConstructor(staticName = "of") -@Value -public class Status { - - @JsonProperty("currencyRates") - CurrencyServiceState currencyRates; - - @JsonProperty("dealsStatus") - DeliveryProgressReport deliveryProgressReport; - -} diff --git a/src/main/java/org/prebid/server/deals/proto/Token.java b/src/main/java/org/prebid/server/deals/proto/Token.java deleted file mode 100644 index ab004798820..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/Token.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.prebid.server.deals.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Value; - -/** - * Defines the contract for lineItems[].deliverySchedule[].tokens[]. - */ -@Value(staticConstructor = "of") -public class Token { - - @JsonProperty("class") - Integer priorityClass; - - Integer total; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReport.java b/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReport.java deleted file mode 100644 index b1a133b2299..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReport.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.Set; - -@Builder(toBuilder = true) -@Value -public class DeliveryProgressReport { - - @JsonProperty("reportId") - String reportId; - - @JsonProperty("reportTimeStamp") - String reportTimeStamp; - - @JsonProperty("dataWindowStartTimeStamp") - String dataWindowStartTimeStamp; - - @JsonProperty("dataWindowEndTimeStamp") - String dataWindowEndTimeStamp; - - @JsonProperty("instanceId") - String instanceId; - - String vendor; - - String region; - - @JsonProperty("clientAuctions") - Long clientAuctions; - - @JsonProperty("lineItemStatus") - Set lineItemStatus; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReportBatch.java b/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReportBatch.java deleted file mode 100644 index 91226ef7d32..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/DeliveryProgressReportBatch.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.Set; - -@Value -@AllArgsConstructor(staticName = "of") -public class DeliveryProgressReportBatch { - - Set reports; - - String reportId; - - String dataWindowEndTimeStamp; - - public void removeReports(Set reports) { - this.reports.removeAll(reports); - } -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/DeliverySchedule.java b/src/main/java/org/prebid/server/deals/proto/report/DeliverySchedule.java deleted file mode 100644 index de1e2df8427..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/DeliverySchedule.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.Set; - -@Builder(toBuilder = true) -@Value -public class DeliverySchedule { - - @JsonProperty("planId") - String planId; - - @JsonProperty("planStartTimeStamp") - String planStartTimeStamp; - - @JsonProperty("planExpirationTimeStamp") - String planExpirationTimeStamp; - - @JsonProperty("planUpdatedTimeStamp") - String planUpdatedTimeStamp; - - Set tokens; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/Event.java b/src/main/java/org/prebid/server/deals/proto/report/Event.java deleted file mode 100644 index 686f84b0e96..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/Event.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.concurrent.atomic.LongAdder; - -@AllArgsConstructor(staticName = "of") -@Value -public class Event { - - String type; - - LongAdder count; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/LineItemStatus.java b/src/main/java/org/prebid/server/deals/proto/report/LineItemStatus.java deleted file mode 100644 index cb5f1629848..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/LineItemStatus.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Builder; -import lombok.Value; - -import java.util.Set; - -@Builder -@Value -public class LineItemStatus { - - @JsonProperty("lineItemSource") - String lineItemSource; - - @JsonProperty("lineItemId") - String lineItemId; - - @JsonProperty("dealId") - String dealId; - - @JsonProperty("extLineItemId") - String extLineItemId; - - @JsonProperty("accountAuctions") - Long accountAuctions; - - @JsonProperty("domainMatched") - Long domainMatched; - - @JsonProperty("targetMatched") - Long targetMatched; - - @JsonProperty("targetMatchedButFcapped") - Long targetMatchedButFcapped; - - @JsonProperty("targetMatchedButFcapLookupFailed") - Long targetMatchedButFcapLookupFailed; - - @JsonProperty("pacingDeferred") - Long pacingDeferred; - - @JsonProperty("sentToBidder") - Long sentToBidder; - - @JsonProperty("sentToBidderAsTopMatch") - Long sentToBidderAsTopMatch; - - @JsonProperty("receivedFromBidder") - Long receivedFromBidder; - - @JsonProperty("receivedFromBidderInvalidated") - Long receivedFromBidderInvalidated; - - @JsonProperty("sentToClient") - Long sentToClient; - - @JsonProperty("sentToClientAsTopMatch") - Long sentToClientAsTopMatch; - - @JsonProperty("lostToLineItems") - Set lostToLineItems; - - Set events; - - @JsonProperty("deliverySchedule") - Set deliverySchedule; - - @JsonProperty("readyAt") - String readyAt; - - @JsonProperty("spentTokens") - Long spentTokens; - - @JsonProperty("pacingFrequency") - Long pacingFrequency; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/LineItemStatusReport.java b/src/main/java/org/prebid/server/deals/proto/report/LineItemStatusReport.java deleted file mode 100644 index d301993e6d1..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/LineItemStatusReport.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.Builder; -import lombok.Value; - -import java.time.ZonedDateTime; - -@Builder -@Value -public class LineItemStatusReport { - - @JsonProperty("lineItemId") - String lineItemId; - - @JsonProperty("deliverySchedule") - DeliverySchedule deliverySchedule; - - @JsonProperty("spentTokens") - Long spentTokens; - - @JsonProperty("readyToServeTimestamp") - ZonedDateTime readyToServeTimestamp; - - @JsonProperty("pacingFrequency") - Long pacingFrequency; - - @JsonProperty("accountId") - String accountId; - - ObjectNode target; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/LostToLineItem.java b/src/main/java/org/prebid/server/deals/proto/report/LostToLineItem.java deleted file mode 100644 index 137f3cc8f4a..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/LostToLineItem.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class LostToLineItem { - - @JsonProperty("lineItemSource") - String lineItemSource; - - @JsonProperty("lineItemId") - String lineItemId; - - Long count; -} diff --git a/src/main/java/org/prebid/server/deals/proto/report/Token.java b/src/main/java/org/prebid/server/deals/proto/report/Token.java deleted file mode 100644 index 7e17ece8b8e..00000000000 --- a/src/main/java/org/prebid/server/deals/proto/report/Token.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.prebid.server.deals.proto.report; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Value; - -@Value(staticConstructor = "of") -public class Token { - - @JsonProperty("class") - Integer priorityClass; - - Integer total; - - Long spent; - - @JsonProperty("totalSpent") - Long totalSpent; -} diff --git a/src/main/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandler.java b/src/main/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandler.java deleted file mode 100644 index 18444679938..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandler.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.fasterxml.jackson.core.type.TypeReference; -import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; -import io.vertx.core.MultiMap; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.ext.web.RoutingContext; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.exception.InvalidRequestException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.HttpUtil; - -import java.time.ZonedDateTime; -import java.util.Map; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class DealsSimulationAdminHandler implements Handler { - - private static final TypeReference> BID_RATES_TYPE_REFERENCE = - new TypeReference<>() { - }; - - private static final Logger logger = LoggerFactory.getLogger(DealsSimulationAdminHandler.class); - - private static final Pattern URL_SUFFIX_PATTERN = Pattern.compile("/pbs-admin/e2eAdmin(.*)"); - private static final String PLANNER_REGISTER_PATH = "/planner/register"; - private static final String PLANNER_FETCH_PATH = "/planner/fetchLineItems"; - private static final String ADVANCE_PLAN_PATH = "/advancePlans"; - private static final String REPORT_PATH = "/dealstats/report"; - private static final String BID_RATE_PATH = "/bidRate"; - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - - private final SimulationAwareRegisterService registerService; - private final SimulationAwarePlannerService plannerService; - private final SimulationAwareDeliveryProgressService deliveryProgressService; - private final SimulationAwareDeliveryStatsService deliveryStatsService; - private final SimulationAwareHttpBidderRequester httpBidderRequester; - private final JacksonMapper mapper; - private final String endpoint; - - public DealsSimulationAdminHandler( - SimulationAwareRegisterService registerService, - SimulationAwarePlannerService plannerService, - SimulationAwareDeliveryProgressService deliveryProgressService, - SimulationAwareDeliveryStatsService deliveryStatsService, - SimulationAwareHttpBidderRequester httpBidderRequester, - JacksonMapper mapper, - String endpoint) { - - this.registerService = Objects.requireNonNull(registerService); - this.plannerService = Objects.requireNonNull(plannerService); - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.deliveryStatsService = Objects.requireNonNull(deliveryStatsService); - this.httpBidderRequester = httpBidderRequester; - this.mapper = Objects.requireNonNull(mapper); - this.endpoint = Objects.requireNonNull(endpoint); - } - - @Override - public void handle(RoutingContext routingContext) { - final HttpServerRequest request = routingContext.request(); - final Matcher matcher = URL_SUFFIX_PATTERN.matcher(request.uri()); - - if (!matcher.find() || StringUtils.isBlank(matcher.group(1))) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.NOT_FOUND.code()) - .end("Requested url was not found")); - return; - } - - try { - final String endpointPath = matcher.group(1); - final ZonedDateTime now = getPgSimDate(endpointPath, request.headers()); - handleEndpoint(routingContext, endpointPath, now); - - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.OK.code()) - .end()); - } catch (InvalidRequestException e) { - logger.error(e.getMessage(), e); - respondWith(routingContext, HttpResponseStatus.BAD_REQUEST, e.getMessage()); - } catch (NotFoundException e) { - logger.error(e.getMessage(), e); - respondWith(routingContext, HttpResponseStatus.NOT_FOUND, e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage(), e); - respondWith(routingContext, HttpResponseStatus.INTERNAL_SERVER_ERROR, e.getMessage()); - } - } - - private ZonedDateTime getPgSimDate(String endpointPath, MultiMap headers) { - ZonedDateTime now = null; - if (!endpointPath.equals(BID_RATE_PATH)) { - now = HttpUtil.getDateFromHeader(headers, PG_SIM_TIMESTAMP); - if (now == null) { - throw new InvalidRequestException( - "pg-sim-timestamp with simulated current date is required for endpoints: %s, %s, %s, %s" - .formatted(PLANNER_REGISTER_PATH, PLANNER_FETCH_PATH, ADVANCE_PLAN_PATH, REPORT_PATH)); - } - } - return now; - } - - private void handleEndpoint(RoutingContext routingContext, String endpointPath, ZonedDateTime now) { - if (endpointPath.startsWith(PLANNER_REGISTER_PATH)) { - registerService.performRegistration(now); - - } else if (endpointPath.startsWith(PLANNER_FETCH_PATH)) { - plannerService.initiateLineItemsFetching(now); - - } else if (endpointPath.startsWith(ADVANCE_PLAN_PATH)) { - plannerService.advancePlans(now); - - } else if (endpointPath.startsWith(REPORT_PATH)) { - deliveryProgressService.createDeliveryProgressReport(now); - deliveryStatsService.sendDeliveryProgressReports(now); - - } else if (endpointPath.startsWith(BID_RATE_PATH)) { - if (httpBidderRequester != null) { - handleBidRatesEndpoint(routingContext); - } else { - throw new InvalidRequestException(""" - Calling %s is not make sense since Prebid Server configured \ - to use real bidder exchanges in simulation mode""".formatted(BID_RATE_PATH)); - } - } else { - throw new NotFoundException("Requested url %s was not found".formatted(endpointPath)); - } - } - - private void handleBidRatesEndpoint(RoutingContext routingContext) { - final Buffer body = routingContext.getBody(); - if (body == null) { - throw new InvalidRequestException("Body is required for %s endpoint".formatted(BID_RATE_PATH)); - } - - try { - httpBidderRequester.setBidRates(mapper.decodeValue(body, BID_RATES_TYPE_REFERENCE)); - } catch (DecodeException e) { - throw new InvalidRequestException("Failed to parse bid rates body: " + e.getMessage()); - } - } - - private void respondWith(RoutingContext routingContext, HttpResponseStatus status, String body) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(status.code()) - .end(body)); - } - - private static class NotFoundException extends RuntimeException { - NotFoundException(String message) { - super(message); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryProgressService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryProgressService.java deleted file mode 100644 index 511c37207fb..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryProgressService.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.prebid.server.deals.simulation; - -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.DeliveryProgressReportFactory; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.DeliveryProgressProperties; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.util.HttpUtil; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.Map; - -public class SimulationAwareDeliveryProgressService extends DeliveryProgressService { - - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - - private final long readyAtAdjustment; - private volatile boolean firstReportUpdate; - - public SimulationAwareDeliveryProgressService(DeliveryProgressProperties deliveryProgressProperties, - LineItemService lineItemService, - DeliveryStatsService deliveryStatsService, - DeliveryProgressReportFactory deliveryProgressReportFactory, - long readyAtAdjustment, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - super( - deliveryProgressProperties, - lineItemService, - deliveryStatsService, - deliveryProgressReportFactory, - clock, - criteriaLogManager); - this.readyAtAdjustment = readyAtAdjustment; - this.firstReportUpdate = true; - } - - @Override - public void shutdown() { - // disable sending report during bean destroying process - } - - @Override - public void processAuctionEvent(AuctionContext auctionContext) { - final ZonedDateTime now = HttpUtil.getDateFromHeader(auctionContext.getHttpRequest().getHeaders(), - PG_SIM_TIMESTAMP); - if (firstReportUpdate) { - firstReportUpdate = false; - updateDeliveryProgressesStartTime(now); - } - super.processAuctionEvent(auctionContext.getTxnLog(), auctionContext.getAccount().getId(), now); - } - - protected void incrementTokens(LineItem lineItem, ZonedDateTime now, Map planIdToTokenPriority) { - final Integer classPriority = lineItem.incSpentToken(now, readyAtAdjustment); - if (classPriority != null) { - planIdToTokenPriority.put(lineItem.getActiveDeliveryPlan().getPlanId(), classPriority); - } - } - - private void updateDeliveryProgressesStartTime(ZonedDateTime now) { - overallDeliveryProgress.setStartTimeStamp(now); - currentDeliveryProgress.setStartTimeStamp(now); - } - - void createDeliveryProgressReport(ZonedDateTime now) { - createDeliveryProgressReports(now); - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryStatsService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryStatsService.java deleted file mode 100644 index 7debdb649ed..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareDeliveryStatsService.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.deals.simulation; - -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressReportFactory; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.model.DeliveryStatsProperties; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; - -public class SimulationAwareDeliveryStatsService extends DeliveryStatsService { - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - - public SimulationAwareDeliveryStatsService(DeliveryStatsProperties deliveryStatsProperties, - DeliveryProgressReportFactory deliveryProgressReportFactory, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - Vertx vertx, - JacksonMapper mapper) { - super(deliveryStatsProperties, - deliveryProgressReportFactory, - alertHttpService, - httpClient, - metrics, - clock, - vertx, - mapper); - } - - @Override - protected Future sendReport(DeliveryProgressReport deliveryProgressReport, MultiMap headers, - ZonedDateTime now) { - return super.sendReport(deliveryProgressReport, - headers().add(PG_SIM_TIMESTAMP, UTC_MILLIS_FORMATTER.format(now)), now); - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequester.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequester.java deleted file mode 100644 index 8c201ac081f..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequester.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import io.vertx.core.Future; -import lombok.AllArgsConstructor; -import lombok.Value; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.BidRejectionReason; -import org.prebid.server.auction.model.BidRejectionTracker; -import org.prebid.server.auction.model.BidderRequest; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.BidderErrorNotifier; -import org.prebid.server.bidder.BidderRequestCompletionTrackerFactory; -import org.prebid.server.bidder.HttpBidderRequestEnricher; -import org.prebid.server.bidder.HttpBidderRequester; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.BidderSeatBid; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.execution.Timeout; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.model.CaseInsensitiveMultiMap; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.vertx.http.HttpClient; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class SimulationAwareHttpBidderRequester extends HttpBidderRequester { - - private static final BigDecimal DEFAULT_CPM = BigDecimal.ONE; - private static final String DEFAULT_ADM = ""; - private static final String DEFAULT_CRID = "crid"; - private static final String DEFAULT_CURRENCY = "USD"; - private static final String BID_ID_FORMAT = "%s-%s"; - - private final Map bidRates; - private final LineItemService lineItemService; - private final JacksonMapper mapper; - - public SimulationAwareHttpBidderRequester( - HttpClient httpClient, - BidderRequestCompletionTrackerFactory bidderRequestCompletionTrackerFactory, - BidderErrorNotifier bidderErrorNotifier, - HttpBidderRequestEnricher requestEnricher, - LineItemService lineItemService, - JacksonMapper mapper) { - - super(httpClient, bidderRequestCompletionTrackerFactory, bidderErrorNotifier, requestEnricher, mapper); - - this.lineItemService = Objects.requireNonNull(lineItemService); - this.mapper = Objects.requireNonNull(mapper); - this.bidRates = new HashMap<>(); - } - - void setBidRates(Map bidRates) { - this.bidRates.putAll(bidRates); - } - - @Override - public Future requestBids(Bidder bidder, - BidderRequest bidderRequest, - BidRejectionTracker bidRejectionTracker, - Timeout timeout, - CaseInsensitiveMultiMap requestHeaders, - BidderAliases aliases, - boolean debugEnabled) { - - final List imps = bidderRequest.getBidRequest().getImp(); - final Map idToImps = imps.stream().collect(Collectors.toMap(Imp::getId, Function.identity())); - final Map> impsToDealInfo = imps.stream() - .filter(imp -> imp.getPmp() != null) - .collect(Collectors.toMap(Imp::getId, imp -> imp.getPmp().getDeals().stream() - .map(deal -> DealInfo.of(deal.getId(), getLineItemId(deal))) - .filter(dealInfo -> dealInfo.getLineItemId() != null) - .collect(Collectors.toSet()))); - - if (impsToDealInfo.values().stream().noneMatch(CollectionUtils::isNotEmpty)) { - bidRejectionTracker.rejectAll(BidRejectionReason.FAILED_TO_REQUEST_BIDS); - - return Future.succeededFuture(BidderSeatBid.builder() - .errors(Collections.singletonList(BidderError.failedToRequestBids( - "Matched or ready to serve line items were not found, but required in simulation mode"))) - .build()); - } - - final List bidderBids = impsToDealInfo.entrySet().stream() - .flatMap(impToDealInfo -> impToDealInfo.getValue() - .stream() - .map(dealInfo -> createBid(idToImps.get(impToDealInfo.getKey()), dealInfo.getDealId(), - dealInfo.getLineItemId())) - .filter(Objects::nonNull)) - .map(bid -> BidderBid.of(bid, BidType.banner, DEFAULT_CURRENCY)) - .toList(); - - return Future.succeededFuture(BidderSeatBid.of(bidderBids)); - } - - private String getLineItemId(Deal deal) { - final JsonNode extDealNode = deal.getExt(); - final ExtDeal extDeal = extDealNode != null ? getExtDeal(extDealNode) : null; - final ExtDealLine extDealLine = extDeal != null ? extDeal.getLine() : null; - return extDealLine != null ? extDealLine.getLineItemId() : null; - } - - private Bid createBid(Imp imp, String dealId, String lineItemId) { - final Double rate = bidRates.get(lineItemId); - if (rate == null) { - throw new PreBidException("Bid rate for line item with id %s was not found".formatted(lineItemId)); - } - final String impId = imp.getId(); - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - final List sizes = getLineItemSizes(imp); - return Math.random() < rate - ? Bid.builder() - .id(BID_ID_FORMAT.formatted(impId, lineItemId)) - .impid(impId) - .dealid(dealId) - .price(lineItem != null ? lineItem.getCpm() : DEFAULT_CPM) - .adm(DEFAULT_ADM) - .crid(DEFAULT_CRID) - .w(sizes.isEmpty() ? 0 : sizes.get(0).getW()) - .h(sizes.isEmpty() ? 0 : sizes.get(0).getH()) - .build() - : null; - } - - private List getLineItemSizes(Imp imp) { - return imp.getPmp().getDeals().stream() - .map(Deal::getExt) - .filter(Objects::nonNull) - .map(this::getExtDeal) - .filter(Objects::nonNull) - .map(ExtDeal::getLine) - .filter(Objects::nonNull) - .map(ExtDealLine::getSizes) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .toList(); - } - - private ExtDeal getExtDeal(JsonNode extDeal) { - try { - return mapper.mapper().treeToValue(extDeal, ExtDeal.class); - } catch (JsonProcessingException e) { - throw new PreBidException("Error decoding bidRequest.imp.pmp.deal.ext: " + e.getMessage(), e); - } - } - - @Value - @AllArgsConstructor(staticName = "of") - private static class DealInfo { - - String dealId; - - String lineItemId; - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareLineItemService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareLineItemService.java deleted file mode 100644 index 1751ef8abd5..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareLineItemService.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.TargetingService; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.model.MatchLineItemsResult; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.util.HttpUtil; -import org.springframework.beans.factory.annotation.Value; - -import java.time.Clock; - -public class SimulationAwareLineItemService extends LineItemService { - - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - - public SimulationAwareLineItemService(int maxDealsPerBidder, - TargetingService targetingService, - CurrencyConversionService conversionService, - ApplicationEventService applicationEventService, - @Value("${auction.ad-server-currency}}") String adServerCurrency, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - super( - maxDealsPerBidder, - targetingService, - conversionService, - applicationEventService, - adServerCurrency, - clock, - criteriaLogManager); - } - - @Override - public boolean accountHasDeals(AuctionContext auctionContext) { - return accountHasDeals( - auctionContext.getAccount().getId(), - HttpUtil.getDateFromHeader(auctionContext.getHttpRequest().getHeaders(), PG_SIM_TIMESTAMP)); - } - - @Override - public MatchLineItemsResult findMatchingLineItems(BidRequest bidRequest, - Imp imp, - String bidder, - BidderAliases aliases, - AuctionContext auctionContext) { - - return findMatchingLineItems( - bidRequest, - imp, - bidder, - aliases, - auctionContext, - HttpUtil.getDateFromHeader(auctionContext.getHttpRequest().getHeaders(), PG_SIM_TIMESTAMP)); - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java deleted file mode 100644 index 2009f94e63f..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwarePlannerService.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.prebid.server.deals.simulation; - -import io.vertx.core.AsyncResult; -import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.PlannerService; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; - -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.Consumer; - -public class SimulationAwarePlannerService extends PlannerService { - - private static final Logger logger = LoggerFactory.getLogger(SimulationAwarePlannerService.class); - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - private static final String PBS_PLANNER_CLIENT_ERROR = "pbs-planner-client-error"; - - private final SimulationAwareLineItemService lineItemService; - private final Metrics metrics; - private final AlertHttpService alertHttpService; - - private List lineItemMetaData; - - public SimulationAwarePlannerService(PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - SimulationAwareLineItemService lineItemService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - JacksonMapper mapper) { - super( - plannerProperties, - deploymentProperties, - lineItemService, - deliveryProgressService, - alertHttpService, - httpClient, - metrics, - clock, - mapper); - - this.lineItemService = Objects.requireNonNull(lineItemService); - this.alertHttpService = Objects.requireNonNull(alertHttpService); - this.metrics = Objects.requireNonNull(metrics); - this.lineItemMetaData = new ArrayList<>(); - } - - public void advancePlans(ZonedDateTime now) { - lineItemService.updateLineItems(lineItemMetaData, isPlannerResponsive.get(), now); - lineItemService.advanceToNextPlan(now); - } - - public void initiateLineItemsFetching(ZonedDateTime now) { - fetchLineItemMetaData(planEndpoint, headers(now)) - .onComplete(this::handleInitializationResult); - } - - /** - * Handles result of initialization process. Sets metadata if request was successful. - */ - @Override - protected void handleInitializationResult(AsyncResult> plannerResponse) { - if (plannerResponse.succeeded()) { - metrics.updatePlannerRequestMetric(true); - isPlannerResponsive.set(true); - lineItemService.updateIsPlannerResponsive(true); - lineItemMetaData = plannerResponse.result(); - } else { - alert(plannerResponse.cause().getMessage(), AlertPriority.HIGH, logger::warn); - logger.warn("Failed to retrieve line items from Planner after retry. Reason: {0}", - plannerResponse.cause().getMessage()); - isPlannerResponsive.set(false); - lineItemService.updateIsPlannerResponsive(false); - metrics.updatePlannerRequestMetric(false); - } - } - - private MultiMap headers(ZonedDateTime now) { - return headers().add(PG_SIM_TIMESTAMP, UTC_MILLIS_FORMATTER.format(now)); - } - - private void alert(String message, AlertPriority alertPriority, Consumer logger) { - alertHttpService.alert(PBS_PLANNER_CLIENT_ERROR, alertPriority, message); - logger.accept(message); - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareRegisterService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareRegisterService.java deleted file mode 100644 index d185285937e..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareRegisterService.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.prebid.server.deals.simulation; - -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.RegisterService; -import org.prebid.server.deals.events.AdminEventService; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.health.HealthMonitor; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.vertx.http.HttpClient; - -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; - -public class SimulationAwareRegisterService extends RegisterService { - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - private static final String PG_SIM_TIMESTAMP = "pg-sim-timestamp"; - - public SimulationAwareRegisterService(PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - AdminEventService adminEventService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HealthMonitor healthMonitor, - CurrencyConversionService currencyConversionService, - HttpClient httpClient, - Vertx vertx, - JacksonMapper mapper) { - super(plannerProperties, - deploymentProperties, - adminEventService, - deliveryProgressService, - alertHttpService, - healthMonitor, - currencyConversionService, - httpClient, - vertx, - mapper); - } - - @Override - public void initialize() { - // disable timer initialization for simulation mode - } - - public void performRegistration(ZonedDateTime now) { - register(headers(now)); - } - - private MultiMap headers(ZonedDateTime now) { - return headers().add(PG_SIM_TIMESTAMP, UTC_MILLIS_FORMATTER.format(now)); - } -} diff --git a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareUserService.java b/src/main/java/org/prebid/server/deals/simulation/SimulationAwareUserService.java deleted file mode 100644 index 78d9f8ae409..00000000000 --- a/src/main/java/org/prebid/server/deals/simulation/SimulationAwareUserService.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.prebid.server.deals.simulation; - -import io.vertx.core.Future; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.UserService; -import org.prebid.server.deals.model.SimulationProperties; -import org.prebid.server.deals.model.UserDetails; -import org.prebid.server.deals.model.UserDetailsProperties; -import org.prebid.server.execution.Timeout; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; - -import java.time.Clock; - -public class SimulationAwareUserService extends UserService { - - private final boolean winEventsEnabled; - private final boolean userDetailsEnabled; - - public SimulationAwareUserService(UserDetailsProperties userDetailsProperties, - SimulationProperties simulationProperties, - String dataCenterRegion, - LineItemService lineItemService, - HttpClient httpClient, - Clock clock, - Metrics metrics, - JacksonMapper mapper) { - super( - userDetailsProperties, - dataCenterRegion, - lineItemService, - httpClient, - clock, - metrics, - mapper); - - this.winEventsEnabled = simulationProperties.isWinEventsEnabled(); - this.userDetailsEnabled = simulationProperties.isUserDetailsEnabled(); - } - - @Override - public Future getUserDetails(AuctionContext context, Timeout timeout) { - return userDetailsEnabled - ? super.getUserDetails(context, timeout) - : Future.succeededFuture(UserDetails.empty()); - } - - @Override - public void processWinEvent(String lineItemId, String bidId, UidsCookie uids) { - if (winEventsEnabled) { - super.processWinEvent(lineItemId, bidId, uids); - } - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/RequestContext.java b/src/main/java/org/prebid/server/deals/targeting/RequestContext.java deleted file mode 100644 index 8aef7c152c0..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/RequestContext.java +++ /dev/null @@ -1,422 +0,0 @@ -package org.prebid.server.deals.targeting; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Data; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Geo; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Publisher; -import com.iab.openrtb.request.Segment; -import com.iab.openrtb.request.Site; -import com.iab.openrtb.request.User; -import com.iab.openrtb.request.Video; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.targeting.model.GeoLocation; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; -import org.prebid.server.exception.TargetingSyntaxException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.FlexibleExtension; -import org.prebid.server.proto.openrtb.ext.request.ExtApp; -import org.prebid.server.proto.openrtb.ext.request.ExtSite; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.request.ExtUserTime; -import org.prebid.server.util.StreamUtil; - -import java.beans.BeanInfo; -import java.beans.FeatureDescriptor; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class RequestContext { - - private static final String EXT_BIDDER = "bidder."; - private static final String EXT_CONTEXT_DATA = "context.data."; - private static final String EXT_DATA = "data."; - - private final BidRequest bidRequest; - private final Imp imp; - private final TxnLog txnLog; - - private final AttributeReader impReader; - private final AttributeReader geoReader; - private final AttributeReader deviceReader; - private final AttributeReader userReader; - private final AttributeReader siteReader; - private final AttributeReader appReader; - - public RequestContext(BidRequest bidRequest, - Imp imp, - TxnLog txnLog, - JacksonMapper mapper) { - - this.bidRequest = Objects.requireNonNull(bidRequest); - this.imp = Objects.requireNonNull(imp); - this.txnLog = Objects.requireNonNull(txnLog); - - impReader = AttributeReader.forImp(); - geoReader = AttributeReader.forGeo(getExtNode( - bidRequest.getDevice(), - device -> getIfNotNull(getIfNotNull(device, Device::getGeo), Geo::getExt), - mapper)); - deviceReader = AttributeReader.forDevice(getExtNode(bidRequest.getDevice(), Device::getExt, mapper)); - userReader = AttributeReader.forUser(); - siteReader = AttributeReader.forSite(); - appReader = AttributeReader.forApp(); - } - - private static ObjectNode getExtNode(T target, - Function extExtractor, - JacksonMapper mapper) { - - final FlexibleExtension ext = target != null ? extExtractor.apply(target) : null; - return ext != null ? (ObjectNode) mapper.mapper().valueToTree(ext) : null; - } - - public LookupResult lookupString(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - final String path = category.path(); - - return switch (type) { - case domain -> lookupResult( - getIfNotNull(bidRequest.getSite(), Site::getDomain), - getIfNotNull(getIfNotNull(bidRequest.getSite(), Site::getPublisher), Publisher::getDomain)); - case publisherDomain -> lookupResult(getIfNotNull( - getIfNotNull(bidRequest.getSite(), Site::getPublisher), Publisher::getDomain)); - case referrer -> lookupResult(getIfNotNull(bidRequest.getSite(), Site::getPage)); - case appBundle -> lookupResult(getIfNotNull(bidRequest.getApp(), App::getBundle)); - case adslot -> lookupResult( - imp.getTagid(), - impReader.readFromExt(imp, "gpid", RequestContext::nodeToString), - impReader.readFromExt(imp, "data.pbadslot", RequestContext::nodeToString), - impReader.readFromExt(imp, "data.adserver.adslot", RequestContext::nodeToString)); - case deviceGeoExt -> lookupResult(geoReader.readFromExt( - getIfNotNull(bidRequest.getDevice(), Device::getGeo), path, RequestContext::nodeToString)); - case deviceExt -> lookupResult( - deviceReader.readFromExt(bidRequest.getDevice(), path, RequestContext::nodeToString)); - case bidderParam -> lookupResult( - impReader.readFromExt(imp, EXT_BIDDER + path, RequestContext::nodeToString)); - case userFirstPartyData -> - userReader.read(bidRequest.getUser(), path, RequestContext::nodeToString, String.class); - case siteFirstPartyData -> getSiteFirstPartyData(path, RequestContext::nodeToString); - default -> LookupResult.empty(); - }; - } - - public LookupResult lookupInteger(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - final String path = category.path(); - - return switch (type) { - case pagePosition -> lookupResult(getIfNotNull(getIfNotNull(imp, Imp::getBanner), Banner::getPos)); - case dow -> lookupResult(getIfNotNull( - getIfNotNull(getIfNotNull(bidRequest.getUser(), User::getExt), ExtUser::getTime), - ExtUserTime::getUserdow)); - case hour -> lookupResult(getIfNotNull( - getIfNotNull(getIfNotNull(bidRequest.getUser(), User::getExt), ExtUser::getTime), - ExtUserTime::getUserhour)); - case deviceGeoExt -> lookupResult(geoReader.readFromExt( - getIfNotNull(bidRequest.getDevice(), Device::getGeo), path, RequestContext::nodeToInteger)); - case bidderParam -> lookupResult( - impReader.readFromExt(imp, EXT_BIDDER + path, RequestContext::nodeToInteger)); - case userFirstPartyData -> - userReader.read(bidRequest.getUser(), path, RequestContext::nodeToInteger, Integer.class); - case siteFirstPartyData -> getSiteFirstPartyData(path, RequestContext::nodeToInteger); - default -> LookupResult.empty(); - }; - } - - public LookupResult> lookupStrings(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - final String path = category.path(); - final User user = bidRequest.getUser(); - - return switch (type) { - case mediaType -> lookupResult(getMediaTypes()); - case bidderParam -> lookupResult( - impReader.readFromExt(imp, EXT_BIDDER + path, RequestContext::nodeToListOfStrings)); - case userSegment -> lookupResult(getSegments(category)); - case userFirstPartyData -> lookupResult( - listOfNonNulls(userReader.readFromObject(user, path, String.class)), - userReader.readFromExt(user, path, RequestContext::nodeToListOfStrings)); - case siteFirstPartyData -> getSiteFirstPartyData(path, RequestContext::nodeToListOfStrings); - default -> LookupResult.empty(); - }; - } - - public LookupResult> lookupIntegers(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - final String path = category.path(); - final User user = bidRequest.getUser(); - - return switch (type) { - case bidderParam -> lookupResult( - impReader.readFromExt(imp, EXT_BIDDER + path, RequestContext::nodeToListOfIntegers)); - case userFirstPartyData -> lookupResult( - listOfNonNulls(userReader.readFromObject(user, path, Integer.class)), - userReader.readFromExt(user, path, RequestContext::nodeToListOfIntegers)); - case siteFirstPartyData -> getSiteFirstPartyData(path, RequestContext::nodeToListOfIntegers); - default -> LookupResult.empty(); - }; - } - - public LookupResult> lookupSizes(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - if (type != TargetingCategory.Type.size) { - throw new TargetingSyntaxException("Unexpected category for fetching sizes for: " + type); - } - - final List sizes = ListUtils.union(sizesFromBanner(imp), sizesFromVideo(imp)); - - return !sizes.isEmpty() ? LookupResult.ofValue(sizes) : LookupResult.empty(); - } - - private static List sizesFromBanner(Imp imp) { - final List formats = getIfNotNull(imp.getBanner(), Banner::getFormat); - return ListUtils.emptyIfNull(formats).stream() - .map(format -> Size.of(format.getW(), format.getH())) - .toList(); - } - - private static List sizesFromVideo(Imp imp) { - final Video video = imp.getVideo(); - final Integer width = video != null ? video.getW() : null; - final Integer height = video != null ? video.getH() : null; - - return width != null && height != null - ? Collections.singletonList(Size.of(width, height)) - : Collections.emptyList(); - } - - public GeoLocation lookupGeoLocation(TargetingCategory category) { - final TargetingCategory.Type type = category.type(); - if (type != TargetingCategory.Type.location) { - throw new TargetingSyntaxException("Unexpected category for fetching geo location for: " + type); - } - - final Geo geo = getIfNotNull(getIfNotNull(bidRequest, BidRequest::getDevice), Device::getGeo); - final Float lat = getIfNotNull(geo, Geo::getLat); - final Float lon = getIfNotNull(geo, Geo::getLon); - - return lat != null && lon != null ? GeoLocation.of(lat, lon) : null; - } - - public TxnLog txnLog() { - return txnLog; - } - - @SafeVarargs - private static LookupResult lookupResult(T... candidates) { - return LookupResult.of(listOfNonNulls(candidates)); - } - - @SafeVarargs - private static List listOfNonNulls(T... candidates) { - return Stream.of(candidates) - .filter(Objects::nonNull) - .toList(); - } - - private static T getIfNotNull(S source, Function getter) { - return source != null ? getter.apply(source) : null; - } - - private List getMediaTypes() { - final List mediaTypes = new ArrayList<>(); - if (imp.getBanner() != null) { - mediaTypes.add("banner"); - } - if (imp.getVideo() != null) { - mediaTypes.add("video"); - } - if (imp.getXNative() != null) { - mediaTypes.add("native"); - } - return mediaTypes; - } - - private LookupResult getSiteFirstPartyData(String path, Function valueExtractor) { - return lookupResult( - impReader.readFromExt(imp, EXT_CONTEXT_DATA + path, valueExtractor), - impReader.readFromExt(imp, EXT_DATA + path, valueExtractor), - siteReader.readFromExt(bidRequest.getSite(), path, valueExtractor), - appReader.readFromExt(bidRequest.getApp(), path, valueExtractor)); - } - - private List getSegments(TargetingCategory category) { - final List userData = getIfNotNull(bidRequest.getUser(), User::getData); - - final List segments = ListUtils.emptyIfNull(userData) - .stream() - .filter(Objects::nonNull) - .filter(data -> Objects.equals(data.getId(), category.path())) - .flatMap(data -> ListUtils.emptyIfNull(data.getSegment()).stream()) - .map(Segment::getId) - .filter(Objects::nonNull) - .toList(); - - return !segments.isEmpty() ? segments : null; - } - - private static String toJsonPointer(String path) { - return Arrays.stream(path.split("\\.")) - .collect(Collectors.joining("/", "/", StringUtils.EMPTY)); - } - - private static String nodeToString(JsonNode node) { - return node.isTextual() ? node.asText() : null; - } - - private static Integer nodeToInteger(JsonNode node) { - return node.isInt() ? node.asInt() : null; - } - - private static List nodeToListOfStrings(JsonNode node) { - final Function valueExtractor = RequestContext::nodeToString; - return node.isTextual() - ? Collections.singletonList(valueExtractor.apply(node)) - : nodeToList(node, valueExtractor); - } - - private static List nodeToListOfIntegers(JsonNode node) { - final Function valueExtractor = RequestContext::nodeToInteger; - return node.isInt() - ? Collections.singletonList(valueExtractor.apply(node)) - : nodeToList(node, valueExtractor); - } - - private static List nodeToList(JsonNode node, Function valueExtractor) { - if (!node.isArray()) { - return null; - } - - return StreamUtil.asStream(node.spliterator()) - .map(valueExtractor) - .filter(Objects::nonNull) - .toList(); - } - - private static class AttributeReader { - - private static final Set> SUPPORTED_PROPERTY_TYPES = Set.of(String.class, Integer.class, int.class); - - private final Map properties; - private final Function extPathExtractor; - - private AttributeReader(Class type, Function extPathExtractor) { - this.properties = supportedBeanProperties(type); - this.extPathExtractor = extPathExtractor; - } - - public static AttributeReader forImp() { - return new AttributeReader<>( - Imp.class, - imp -> getIfNotNull(imp, Imp::getExt)); - } - - public static AttributeReader forGeo(ObjectNode geoExt) { - return new AttributeReader<>( - Geo.class, - ignored -> geoExt); - } - - public static AttributeReader forDevice(ObjectNode deviceExt) { - return new AttributeReader<>( - Device.class, - ignored -> deviceExt); - } - - public static AttributeReader forUser() { - return new AttributeReader<>( - User.class, - user -> getIfNotNull(getIfNotNull(user, User::getExt), ExtUser::getData)); - } - - public static AttributeReader forSite() { - return new AttributeReader<>( - Site.class, - site -> getIfNotNull(getIfNotNull(site, Site::getExt), ExtSite::getData)); - } - - public static AttributeReader forApp() { - return new AttributeReader<>( - App.class, - app -> getIfNotNull(getIfNotNull(app, App::getExt), ExtApp::getData)); - } - - public LookupResult read(T target, - String path, - Function valueExtractor, - Class attributeType) { - - return lookupResult( - // look in the object itself - readFromObject(target, path, attributeType), - // then examine ext if value not found on top level or if it is nested attribute - readFromExt(target, path, valueExtractor)); - } - - public A readFromObject(T target, String path, Class attributeType) { - return isTopLevelAttribute(path) - ? getIfNotNull(target, user -> readProperty(user, path, attributeType)) - : null; - } - - public A readFromExt(T target, String path, Function valueExtractor) { - final JsonNode extPath = getIfNotNull(target, extPathExtractor); - final JsonNode value = getIfNotNull(extPath, node -> node.at(toJsonPointer(path))); - return getIfNotNull(value, valueExtractor); - } - - private boolean isTopLevelAttribute(String path) { - return !path.contains("."); - } - - private static Map supportedBeanProperties(Class beanClass) { - try { - final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass, Object.class); - return Arrays.stream(beanInfo.getPropertyDescriptors()) - .filter(descriptor -> SUPPORTED_PROPERTY_TYPES.contains(descriptor.getPropertyType())) - .collect(Collectors.toMap(FeatureDescriptor::getName, Function.identity())); - } catch (IntrospectionException e) { - return ExceptionUtils.rethrow(e); - } - } - - @SuppressWarnings("unchecked") - private A readProperty(T target, String path, Class attributeType) { - final PropertyDescriptor descriptor = properties.get(path); - - if (descriptor != null && descriptor.getPropertyType().equals(attributeType)) { - try { - return (A) descriptor.getReadMethod().invoke(target); - } catch (IllegalAccessException | InvocationTargetException e) { - // just ignore - } - } - - return null; - } - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/TargetingDefinition.java b/src/main/java/org/prebid/server/deals/targeting/TargetingDefinition.java deleted file mode 100644 index ec1cb8683af..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/TargetingDefinition.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.prebid.server.deals.targeting; - -import lombok.Value; -import org.prebid.server.deals.targeting.interpret.Expression; - -@Value(staticConstructor = "of") -public class TargetingDefinition { - - Expression rootExpression; -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/And.java b/src/main/java/org/prebid/server/deals/targeting/interpret/And.java deleted file mode 100644 index bfe69b2882a..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/And.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; - -import java.util.Collections; -import java.util.List; - -@EqualsAndHashCode -public class And implements NonTerminalExpression { - - private final List expressions; - - public And(List expressions) { - this.expressions = Collections.unmodifiableList(expressions); - } - - @Override - public boolean matches(RequestContext context) { - for (final Expression expression : expressions) { - if (!expression.matches(context)) { - return false; - } - } - return true; - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/DomainMetricAwareExpression.java b/src/main/java/org/prebid/server/deals/targeting/interpret/DomainMetricAwareExpression.java deleted file mode 100644 index 9d682256384..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/DomainMetricAwareExpression.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; - -@EqualsAndHashCode -public class DomainMetricAwareExpression implements Expression { - - private final Expression domainFunction; - private final String lineItemId; - - public DomainMetricAwareExpression(Expression domainFunction, String lineItemId) { - this.domainFunction = domainFunction; - this.lineItemId = lineItemId; - } - - @Override - public boolean matches(RequestContext requestContext) { - final boolean matches = domainFunction.matches(requestContext); - if (matches) { - requestContext.txnLog().lineItemsMatchedDomainTargeting().add(lineItemId); - } - return matches; - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Expression.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Expression.java deleted file mode 100644 index 332e6a2a2eb..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Expression.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.prebid.server.deals.targeting.RequestContext; - -public interface Expression { - - boolean matches(RequestContext context); -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/In.java b/src/main/java/org/prebid/server/deals/targeting/interpret/In.java deleted file mode 100644 index 299a74e254f..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/In.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -@EqualsAndHashCode -public abstract class In implements TerminalExpression { - - protected final TargetingCategory category; - - protected List values; - - public In(TargetingCategory category, List values) { - this.category = Objects.requireNonNull(category); - this.values = Collections.unmodifiableList(values); - } - - @Override - public boolean matches(RequestContext context) { - return lookupActualValue(context).anyMatch(values::contains); - } - - protected abstract LookupResult lookupActualValue(RequestContext context); -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/InIntegers.java b/src/main/java/org/prebid/server/deals/targeting/interpret/InIntegers.java deleted file mode 100644 index 99511bf484b..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/InIntegers.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.List; - -@EqualsAndHashCode(callSuper = true) -public class InIntegers extends In { - - public InIntegers(TargetingCategory category, List values) { - super(category, values); - } - - @Override - public LookupResult lookupActualValue(RequestContext context) { - return context.lookupInteger(category); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/InStrings.java b/src/main/java/org/prebid/server/deals/targeting/interpret/InStrings.java deleted file mode 100644 index 185d2069074..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/InStrings.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Stream; - -@EqualsAndHashCode(callSuper = true) -public class InStrings extends In { - - public InStrings(TargetingCategory category, List values) { - super(category, toLowerCase(values)); - } - - @Override - public LookupResult lookupActualValue(RequestContext context) { - final List actualValue = firstNonEmpty( - () -> context.lookupString(category).getValues(), - () -> lookupIntegerAsString(context)); - - return actualValue != null - ? LookupResult.of(actualValue.stream().map(String::toLowerCase).toList()) - : LookupResult.empty(); - } - - private List lookupIntegerAsString(RequestContext context) { - final List actualValue = context.lookupInteger(category).getValues(); - return actualValue.stream().map(Object::toString).toList(); - } - - private static List toLowerCase(List values) { - return values.stream().map(String::toLowerCase).toList(); - } - - @SafeVarargs - private static List firstNonEmpty(Supplier>... suppliers) { - return Stream.of(suppliers) - .map(Supplier::get) - .filter(CollectionUtils::isNotEmpty) - .findFirst() - .orElse(null); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Intersects.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Intersects.java deleted file mode 100644 index e1113947683..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Intersects.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -@EqualsAndHashCode -public abstract class Intersects implements TerminalExpression { - - protected final TargetingCategory category; - - protected List values; - - public Intersects(TargetingCategory category, List values) { - this.category = Objects.requireNonNull(category); - this.values = Collections.unmodifiableList(values); - } - - @Override - public boolean matches(RequestContext context) { - return lookupActualValues(context) - .anyMatch(actualValues -> !Collections.disjoint(values, actualValues)); - } - - protected abstract LookupResult> lookupActualValues(RequestContext context); -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegers.java b/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegers.java deleted file mode 100644 index fd3b0f618cf..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegers.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.List; - -@EqualsAndHashCode(callSuper = true) -public class IntersectsIntegers extends Intersects { - - public IntersectsIntegers(TargetingCategory category, List values) { - super(category, values); - } - - @Override - public LookupResult> lookupActualValues(RequestContext context) { - return context.lookupIntegers(category); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsSizes.java b/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsSizes.java deleted file mode 100644 index 444bfdcc356..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsSizes.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.List; - -@EqualsAndHashCode(callSuper = true) -public class IntersectsSizes extends Intersects { - - public IntersectsSizes(TargetingCategory category, List values) { - super(category, values); - } - - @Override - public LookupResult> lookupActualValues(RequestContext context) { - return context.lookupSizes(category); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsStrings.java b/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsStrings.java deleted file mode 100644 index dd6d9dff2d8..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/IntersectsStrings.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.List; - -@EqualsAndHashCode(callSuper = true) -public class IntersectsStrings extends Intersects { - - public IntersectsStrings(TargetingCategory category, List values) { - super(category, toLowerCase(values)); - } - - @Override - public LookupResult> lookupActualValues(RequestContext context) { - return LookupResult.of( - context.lookupStrings(category).getValues().stream() - .map(IntersectsStrings::toLowerCase) - .toList()); - } - - private static List toLowerCase(List values) { - return values.stream().map(String::toLowerCase).toList(); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Matches.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Matches.java deleted file mode 100644 index 4d5394eeedf..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Matches.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.Objects; -import java.util.function.BiFunction; - -@EqualsAndHashCode -public class Matches implements TerminalExpression { - - private static final String WILDCARD = "*"; - - private final TargetingCategory category; - - private final BiFunction method; - - private final String value; - - public Matches(TargetingCategory category, String value) { - this.category = Objects.requireNonNull(category); - this.method = resolveMethod(Objects.requireNonNull(value)); - this.value = value.replaceAll("\\*", "").toLowerCase(); - } - - @Override - public boolean matches(RequestContext context) { - return context.lookupString(category) - .anyMatch(valueToMatch -> method.apply(valueToMatch.toLowerCase(), value)); - } - - private static BiFunction resolveMethod(String value) { - if (value.startsWith(WILDCARD) && value.endsWith(WILDCARD)) { - return String::contains; - } else if (value.startsWith(WILDCARD)) { - return String::endsWith; - } else if (value.endsWith(WILDCARD)) { - return String::startsWith; - } else { - return String::equals; - } - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/NonTerminalExpression.java b/src/main/java/org/prebid/server/deals/targeting/interpret/NonTerminalExpression.java deleted file mode 100644 index ee9f4235a3d..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/NonTerminalExpression.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -public interface NonTerminalExpression extends Expression { -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Not.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Not.java deleted file mode 100644 index ed8f1a35875..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Not.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; - -import java.util.Objects; - -@EqualsAndHashCode -public class Not implements NonTerminalExpression { - - private final Expression expression; - - public Not(Expression expression) { - this.expression = Objects.requireNonNull(expression); - } - - @Override - public boolean matches(RequestContext context) { - return !expression.matches(context); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Or.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Or.java deleted file mode 100644 index a4740f889ad..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Or.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; - -import java.util.Collections; -import java.util.List; - -@EqualsAndHashCode -public class Or implements NonTerminalExpression { - - private final List expressions; - - public Or(List expressions) { - this.expressions = Collections.unmodifiableList(expressions); - } - - @Override - public boolean matches(RequestContext context) { - for (final Expression expression : expressions) { - if (expression.matches(context)) { - return true; - } - } - return false; - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/TerminalExpression.java b/src/main/java/org/prebid/server/deals/targeting/interpret/TerminalExpression.java deleted file mode 100644 index 7c89885cc49..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/TerminalExpression.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -public interface TerminalExpression extends Expression { -} diff --git a/src/main/java/org/prebid/server/deals/targeting/interpret/Within.java b/src/main/java/org/prebid/server/deals/targeting/interpret/Within.java deleted file mode 100644 index 7a4da8f30c6..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/interpret/Within.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import lombok.EqualsAndHashCode; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.GeoLocation; -import org.prebid.server.deals.targeting.model.GeoRegion; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import java.util.Objects; - -@EqualsAndHashCode -public class Within implements TerminalExpression { - - private static final int EARTH_RADIUS_MI = 3959; - - private final TargetingCategory category; - - private final GeoRegion value; - - public Within(TargetingCategory category, GeoRegion value) { - this.category = Objects.requireNonNull(category); - this.value = Objects.requireNonNull(value); - } - - @Override - public boolean matches(RequestContext context) { - final GeoLocation location = context.lookupGeoLocation(category); - - return location != null && isLocationWithinRegion(location); - } - - private boolean isLocationWithinRegion(GeoLocation location) { - final double distance = calculateDistance(location.getLat(), location.getLon(), value.getLat(), value.getLon()); - - return value.getRadiusMiles() > distance; - } - - private static double calculateDistance(double startLat, double startLong, double endLat, double endLong) { - final double dLat = Math.toRadians(endLat - startLat); - final double dLong = Math.toRadians(endLong - startLong); - - final double a = Math.pow(Math.sin(dLat / 2), 2) - + Math.cos(Math.toRadians(startLat)) * Math.cos(Math.toRadians(endLat)) - * Math.pow(Math.sin(dLong / 2), 2); - final double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - - return EARTH_RADIUS_MI * c; - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/model/GeoLocation.java b/src/main/java/org/prebid/server/deals/targeting/model/GeoLocation.java deleted file mode 100644 index 4918d500e13..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/model/GeoLocation.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.targeting.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class GeoLocation { - - Float lat; - - Float lon; -} diff --git a/src/main/java/org/prebid/server/deals/targeting/model/GeoRegion.java b/src/main/java/org/prebid/server/deals/targeting/model/GeoRegion.java deleted file mode 100644 index f7ae09c5ffd..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/model/GeoRegion.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.deals.targeting.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class GeoRegion { - - Float lat; - - Float lon; - - @JsonProperty("radiusMiles") - Float radiusMiles; -} diff --git a/src/main/java/org/prebid/server/deals/targeting/model/LookupResult.java b/src/main/java/org/prebid/server/deals/targeting/model/LookupResult.java deleted file mode 100644 index 557fa98ec4a..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/model/LookupResult.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.prebid.server.deals.targeting.model; - -import lombok.Value; -import org.apache.commons.collections4.ListUtils; - -import java.util.Collections; -import java.util.List; -import java.util.function.Predicate; - -@Value(staticConstructor = "of") -public class LookupResult { - - private static final LookupResult EMPTY = LookupResult.of(Collections.emptyList()); - - List values; - - @SuppressWarnings("unchecked") - public static LookupResult empty() { - return (LookupResult) EMPTY; - } - - public static LookupResult ofValue(T value) { - return LookupResult.of(Collections.singletonList(value)); - } - - public boolean anyMatch(Predicate matcher) { - return values.stream().anyMatch(matcher); - } - - public LookupResult orElse(List orValues) { - return LookupResult.of(ListUtils.union(values, orValues)); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/model/Size.java b/src/main/java/org/prebid/server/deals/targeting/model/Size.java deleted file mode 100644 index 5b54b220596..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/model/Size.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.deals.targeting.model; - -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor(staticName = "of") -public class Size { - - Integer w; - - Integer h; -} diff --git a/src/main/java/org/prebid/server/deals/targeting/syntax/BooleanOperator.java b/src/main/java/org/prebid/server/deals/targeting/syntax/BooleanOperator.java deleted file mode 100644 index 534ed8f4fc8..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/syntax/BooleanOperator.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import java.util.Arrays; - -public enum BooleanOperator { - - AND("$and"), - OR("$or"), - NOT("$not"); - - private final String value; - - BooleanOperator(String value) { - this.value = value; - } - - public static boolean isBooleanOperator(String candidate) { - return Arrays.stream(BooleanOperator.values()).anyMatch(op -> op.value.equals(candidate)); - } - - public static BooleanOperator fromString(String candidate) { - for (final BooleanOperator op : values()) { - if (op.value.equals(candidate)) { - return op; - } - } - throw new IllegalArgumentException("Unrecognized boolean operator: " + candidate); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/syntax/MatchingFunction.java b/src/main/java/org/prebid/server/deals/targeting/syntax/MatchingFunction.java deleted file mode 100644 index 54bb4a78fb7..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/syntax/MatchingFunction.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import java.util.Arrays; - -public enum MatchingFunction { - - MATCHES("$matches"), - IN("$in"), - INTERSECTS("$intersects"), - WITHIN("$within"); - - private final String value; - - MatchingFunction(String value) { - this.value = value; - } - - public String value() { - return value; - } - - public static boolean isMatchingFunction(String candidate) { - return Arrays.stream(MatchingFunction.values()).anyMatch(op -> op.value.equals(candidate)); - } - - public static MatchingFunction fromString(String candidate) { - for (final MatchingFunction op : values()) { - if (op.value.equals(candidate)) { - return op; - } - } - throw new IllegalArgumentException("Unrecognized matching function: " + candidate); - } -} diff --git a/src/main/java/org/prebid/server/deals/targeting/syntax/TargetingCategory.java b/src/main/java/org/prebid/server/deals/targeting/syntax/TargetingCategory.java deleted file mode 100644 index b7461807420..00000000000 --- a/src/main/java/org/prebid/server/deals/targeting/syntax/TargetingCategory.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import lombok.EqualsAndHashCode; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.exception.TargetingSyntaxException; - -import java.util.Arrays; -import java.util.EnumSet; -import java.util.Objects; - -@EqualsAndHashCode -public class TargetingCategory { - - private static final String BIDDER_PARAM_PATH_PATTERN = "\\w+(\\.\\w+)+"; - - private static final EnumSet DYNAMIC_TYPES = EnumSet.of( - Type.deviceGeoExt, - Type.deviceExt, - Type.bidderParam, - Type.userSegment, - Type.userFirstPartyData, - Type.siteFirstPartyData); - - private static final EnumSet STATIC_TYPES = EnumSet.complementOf(DYNAMIC_TYPES); - - private final Type type; - private final String path; - - public TargetingCategory(Type type) { - this(type, null); - } - - public TargetingCategory(Type type, String path) { - this.type = Objects.requireNonNull(type); - this.path = path; - } - - public static boolean isTargetingCategory(String candidate) { - final boolean isSimpleCategory = STATIC_TYPES.stream().anyMatch(op -> op.attribute().equals(candidate)); - return isSimpleCategory || DYNAMIC_TYPES.stream().anyMatch(op -> candidate.startsWith(op.attribute())); - } - - public static TargetingCategory fromString(String candidate) { - for (final Type type : STATIC_TYPES) { - if (type.attribute().equals(candidate)) { - return new TargetingCategory(type); - } - } - - for (final Type type : DYNAMIC_TYPES) { - if (candidate.startsWith(type.attribute())) { - return parseDynamicCategory(candidate, type); - } - } - - throw new IllegalArgumentException("Unrecognized targeting category: " + candidate); - } - - private static TargetingCategory parseDynamicCategory(String candidate, Type type) { - return switch (type) { - case deviceGeoExt, deviceExt, userSegment, userFirstPartyData, siteFirstPartyData -> - parseByTypeAttribute(candidate, type); - case bidderParam -> parseBidderParam(candidate, type); - default -> throw new IllegalStateException("Unexpected dynamic targeting category type " + type); - }; - } - - private static TargetingCategory parseByTypeAttribute(String candidate, Type type) { - final String candidatePath = StringUtils.substringAfter(candidate, type.attribute()); - return new TargetingCategory(type, candidatePath); - } - - private static TargetingCategory parseBidderParam(String candidate, Type type) { - final String candidatePath = StringUtils.substringAfter(candidate, type.attribute()); - if (candidatePath.matches(BIDDER_PARAM_PATH_PATTERN)) { - return new TargetingCategory(type, dropBidderName(candidatePath)); - } else { - throw new TargetingSyntaxException("BidderParam path is incorrect: " + candidatePath); - } - } - - private static String dropBidderName(String path) { - final int index = path.indexOf('.'); - return path.substring(index + 1); - } - - public Type type() { - return type; - } - - public String path() { - return path; - } - - public enum Type { - size("adunit.size"), - mediaType("adunit.mediatype"), - adslot("adunit.adslot"), - domain("site.domain"), - publisherDomain("site.publisher.domain"), - referrer("site.referrer"), - appBundle("app.bundle"), - deviceGeoExt("device.geo.ext."), - deviceExt("device.ext."), - pagePosition("pos"), - location("geo.distance"), - bidderParam("bidp."), - userSegment("segment."), - userFirstPartyData("ufpd."), - siteFirstPartyData("sfpd."), - dow("user.ext.time.userdow"), - hour("user.ext.time.userhour"); - - private final String attribute; - - Type(String attribute) { - this.attribute = attribute; - } - - public String attribute() { - return attribute; - } - - public static Type fromString(String attribute) { - return Arrays.stream(values()) - .filter(value -> value.attribute.equals(attribute)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException( - "Unrecognized targeting category type: " + attribute)); - } - } -} diff --git a/src/main/java/org/prebid/server/events/EventRequest.java b/src/main/java/org/prebid/server/events/EventRequest.java index 59ee222c82b..64e430e3945 100644 --- a/src/main/java/org/prebid/server/events/EventRequest.java +++ b/src/main/java/org/prebid/server/events/EventRequest.java @@ -28,8 +28,6 @@ public class EventRequest { Analytics analytics; - String lineItemId; - public enum Type { win, imp diff --git a/src/main/java/org/prebid/server/events/EventUtil.java b/src/main/java/org/prebid/server/events/EventUtil.java index efb9f4137f9..864892e6725 100644 --- a/src/main/java/org/prebid/server/events/EventUtil.java +++ b/src/main/java/org/prebid/server/events/EventUtil.java @@ -37,8 +37,6 @@ public class EventUtil { private static final String ENABLED_ANALYTICS = "1"; // default private static final String DISABLED_ANALYTICS = "0"; - private static final String LINE_ITEM_ID_PARAMETER = "l"; - private EventUtil() { } @@ -142,7 +140,6 @@ public static EventRequest from(RoutingContext routingContext) { .format(format) .analytics(analytics) .integration(queryParams.get(INTEGRATION_PARAMETER)) - .lineItemId(queryParams.get(LINE_ITEM_ID_PARAMETER)) .build(); } @@ -192,10 +189,6 @@ private static String optionalParameters(EventRequest eventRequest) { result.append(nameValueAsQueryString(ANALYTICS_PARAMETER, DISABLED_ANALYTICS)); } - result.append(StringUtils.isNotEmpty(eventRequest.getLineItemId()) - ? nameValueAsQueryString(LINE_ITEM_ID_PARAMETER, eventRequest.getLineItemId()) - : StringUtils.EMPTY); // skip parameter - return result.toString(); } diff --git a/src/main/java/org/prebid/server/events/EventsService.java b/src/main/java/org/prebid/server/events/EventsService.java index 59accc7037e..819dfeb0e0a 100644 --- a/src/main/java/org/prebid/server/events/EventsService.java +++ b/src/main/java/org/prebid/server/events/EventsService.java @@ -19,16 +19,15 @@ public EventsService(String externalUrl) { public Events createEvent(String bidId, String bidder, String accountId, - String lineItemId, boolean analyticsEnabled, EventsContext eventsContext) { + return Events.of( eventUrl( EventRequest.Type.win, bidId, bidder, accountId, - lineItemId, analytics(analyticsEnabled), EventRequest.Format.image, eventsContext), @@ -37,7 +36,6 @@ public Events createEvent(String bidId, bidId, bidder, accountId, - lineItemId, analytics(analyticsEnabled), EventRequest.Format.image, eventsContext)); @@ -46,14 +44,17 @@ public Events createEvent(String bidId, /** * Returns url for win tracking. */ - public String winUrl(String bidId, String bidder, String accountId, String lineItemId, - boolean analyticsEnabled, EventsContext eventsContext) { + public String winUrl(String bidId, + String bidder, + String accountId, + boolean analyticsEnabled, + EventsContext eventsContext) { + return eventUrl( EventRequest.Type.win, bidId, bidder, accountId, - lineItemId, analytics(analyticsEnabled), EventRequest.Format.image, eventsContext); @@ -65,13 +66,12 @@ public String winUrl(String bidId, String bidder, String accountId, String lineI public String vastUrlTracking(String bidId, String bidder, String accountId, - String lineItemId, EventsContext eventsContext) { + return eventUrl(EventRequest.Type.imp, bidId, bidder, accountId, - lineItemId, null, EventRequest.Format.blank, eventsContext); @@ -81,7 +81,6 @@ private String eventUrl(EventRequest.Type type, String bidId, String bidder, String accountId, - String lineItemId, EventRequest.Analytics analytics, EventRequest.Format format, EventsContext eventsContext) { @@ -95,7 +94,6 @@ private String eventUrl(EventRequest.Type type, .timestamp(eventsContext.getAuctionTimestamp()) .format(format) .integration(eventsContext.getIntegration()) - .lineItemId(lineItemId) .analytics(analytics) .build(); diff --git a/src/main/java/org/prebid/server/exception/TargetingSyntaxException.java b/src/main/java/org/prebid/server/exception/TargetingSyntaxException.java deleted file mode 100644 index b5fbd75b47d..00000000000 --- a/src/main/java/org/prebid/server/exception/TargetingSyntaxException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.prebid.server.exception; - -public class TargetingSyntaxException extends RuntimeException { - - public TargetingSyntaxException(String message) { - super(message); - } - - public TargetingSyntaxException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/main/java/org/prebid/server/handler/DealsStatusHandler.java b/src/main/java/org/prebid/server/handler/DealsStatusHandler.java deleted file mode 100644 index 15a9dc066dd..00000000000 --- a/src/main/java/org/prebid/server/handler/DealsStatusHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.prebid.server.handler; - -import io.netty.handler.codec.http.HttpHeaderValues; -import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.ext.web.RoutingContext; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.HttpUtil; - -import java.util.Objects; - -public class DealsStatusHandler implements Handler { - - private static final Logger logger = LoggerFactory.getLogger(DealsStatusHandler.class); - - private final DeliveryProgressService deliveryProgressService; - private final JacksonMapper mapper; - - public DealsStatusHandler(DeliveryProgressService deliveryProgressService, JacksonMapper mapper) { - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public void handle(RoutingContext routingContext) { - final DeliveryProgressReport deliveryProgressReport = deliveryProgressService - .getOverallDeliveryProgressReport(); - final String body = mapper.encodeToString(deliveryProgressReport); - - // don't send the response if client has gone - if (routingContext.response().closed()) { - logger.warn("The client already closed connection, response will be skipped"); - return; - } - - routingContext.response() - .putHeader(HttpUtil.CONTENT_TYPE_HEADER, HttpHeaderValues.APPLICATION_JSON) - .exceptionHandler(this::handleResponseException) - .end(body); - } - - private void handleResponseException(Throwable throwable) { - logger.warn("Failed to send deals status response: {0}", throwable.getMessage()); - } -} diff --git a/src/main/java/org/prebid/server/handler/ForceDealsUpdateHandler.java b/src/main/java/org/prebid/server/handler/ForceDealsUpdateHandler.java deleted file mode 100644 index 942b4953147..00000000000 --- a/src/main/java/org/prebid/server/handler/ForceDealsUpdateHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.prebid.server.handler; - -import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; -import io.vertx.ext.web.RoutingContext; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.PlannerService; -import org.prebid.server.deals.RegisterService; -import org.prebid.server.exception.InvalidRequestException; -import org.prebid.server.util.HttpUtil; - -import java.time.ZonedDateTime; -import java.util.Objects; - -public class ForceDealsUpdateHandler implements Handler { - - private static final String ACTION_NAME_PARAM = "action_name"; - - private final DeliveryStatsService deliveryStatsService; - private final PlannerService plannerService; - private final RegisterService registerService; - private final AlertHttpService alertHttpService; - private final DeliveryProgressService deliveryProgressService; - private final LineItemService lineItemService; - private final String endpoint; - - public ForceDealsUpdateHandler(DeliveryStatsService deliveryStatsService, - PlannerService plannerService, - RegisterService registerService, - AlertHttpService alertHttpService, - DeliveryProgressService deliveryProgressService, - LineItemService lineItemService, - String endpoint) { - - this.deliveryStatsService = Objects.requireNonNull(deliveryStatsService); - this.plannerService = Objects.requireNonNull(plannerService); - this.registerService = Objects.requireNonNull(registerService); - this.alertHttpService = Objects.requireNonNull(alertHttpService); - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.lineItemService = Objects.requireNonNull(lineItemService); - this.endpoint = Objects.requireNonNull(endpoint); - } - - @Override - public void handle(RoutingContext routingContext) { - try { - handleDealsAction(dealsActionFrom(routingContext)); - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.NO_CONTENT.code()) - .end()); - } catch (InvalidRequestException e) { - respondWithError(routingContext, HttpResponseStatus.BAD_REQUEST, e); - } catch (Exception e) { - respondWithError(routingContext, HttpResponseStatus.INTERNAL_SERVER_ERROR, e); - } - } - - private static DealsAction dealsActionFrom(RoutingContext routingContext) { - final String actionName = routingContext.request().getParam(ACTION_NAME_PARAM); - if (StringUtils.isEmpty(actionName)) { - throw new InvalidRequestException("Parameter '%s' is required and can't be empty" - .formatted(ACTION_NAME_PARAM)); - } - - try { - return DealsAction.valueOf(actionName.toUpperCase()); - } catch (IllegalArgumentException ignored) { - throw new InvalidRequestException("Given '%s' parameter value '%s' is not among possible actions" - .formatted(ACTION_NAME_PARAM, actionName)); - } - } - - private void handleDealsAction(DealsAction dealsAction) { - switch (dealsAction) { - case UPDATE_LINE_ITEMS -> plannerService.updateLineItemMetaData(); - case SEND_REPORT -> deliveryStatsService.sendDeliveryProgressReports(); - case REGISTER_INSTANCE -> registerService.performRegistration(); - case RESET_ALERT_COUNT -> { - alertHttpService.resetAlertCount("pbs-register-client-error"); - alertHttpService.resetAlertCount("pbs-planner-client-error"); - alertHttpService.resetAlertCount("pbs-planner-empty-response-error"); - alertHttpService.resetAlertCount("pbs-delivery-stats-client-error"); - } - case CREATE_REPORT -> deliveryProgressService.createDeliveryProgressReports(ZonedDateTime.now()); - case INVALIDATE_LINE_ITEMS -> lineItemService.invalidateLineItems(); - } - } - - private void respondWithError(RoutingContext routingContext, HttpResponseStatus statusCode, Exception exception) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(statusCode.code()) - .end(exception.getMessage())); - } - - enum DealsAction { - UPDATE_LINE_ITEMS, SEND_REPORT, REGISTER_INSTANCE, RESET_ALERT_COUNT, CREATE_REPORT, INVALIDATE_LINE_ITEMS - } -} diff --git a/src/main/java/org/prebid/server/handler/LineItemStatusHandler.java b/src/main/java/org/prebid/server/handler/LineItemStatusHandler.java deleted file mode 100644 index e43a543025a..00000000000 --- a/src/main/java/org/prebid/server/handler/LineItemStatusHandler.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.prebid.server.handler; - -import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.ext.web.RoutingContext; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.proto.report.LineItemStatusReport; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.util.HttpUtil; - -import java.util.Objects; - -public class LineItemStatusHandler implements Handler { - - private static final Logger logger = LoggerFactory.getLogger(LineItemStatusHandler.class); - - private static final String ID_PARAM = "id"; - - private final DeliveryProgressService deliveryProgressService; - private final JacksonMapper mapper; - private final String endpoint; - - public LineItemStatusHandler(DeliveryProgressService deliveryProgressService, JacksonMapper mapper, - String endpoint) { - this.deliveryProgressService = Objects.requireNonNull(deliveryProgressService); - this.mapper = Objects.requireNonNull(mapper); - this.endpoint = Objects.requireNonNull(endpoint); - } - - @Override - public void handle(RoutingContext routingContext) { - routingContext.response() - .exceptionHandler(LineItemStatusHandler::handleResponseException); - - final String lineItemId = lineItemIdFrom(routingContext); - if (StringUtils.isEmpty(lineItemId)) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) - .end(ID_PARAM + " parameter is required")); - return; - } - - try { - final LineItemStatusReport report = deliveryProgressService.getLineItemStatusReport(lineItemId); - - HttpUtil.headers().forEach(entry -> routingContext.response().putHeader(entry.getKey(), entry.getValue())); - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.OK.code()) - .end(mapper.encodeToString(report))); - } catch (PreBidException e) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) - .end(e.getMessage())); - } catch (Exception e) { - HttpUtil.executeSafely(routingContext, endpoint, - response -> response - .setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code()) - .end(e.getMessage())); - } - } - - private static String lineItemIdFrom(RoutingContext routingContext) { - return routingContext.request().getParam(ID_PARAM); - } - - private static void handleResponseException(Throwable exception) { - logger.warn("Failed to send line item status response: {0}", exception.getMessage()); - } -} diff --git a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java index 383b0cf7455..ef26b9d09da 100644 --- a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java +++ b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java @@ -10,7 +10,6 @@ import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; -import lombok.AllArgsConstructor; import lombok.Value; import org.prebid.server.activity.infrastructure.ActivityInfrastructure; import org.prebid.server.activity.infrastructure.creator.ActivityInfrastructureCreator; @@ -18,9 +17,6 @@ import org.prebid.server.analytics.model.NotificationEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; import org.prebid.server.auction.gpp.model.GppContextCreator; -import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.deals.UserService; -import org.prebid.server.deals.events.ApplicationEventService; import org.prebid.server.events.EventRequest; import org.prebid.server.events.EventUtil; import org.prebid.server.exception.PreBidException; @@ -48,36 +44,24 @@ public class NotificationEventHandler implements Handler { private static final String TRACKING_PIXEL_PNG = "static/tracking-pixel.png"; private static final String PNG_CONTENT_TYPE = "image/png"; - private final UidsCookieService uidsCookieService; - private final ApplicationEventService applicationEventService; - private final UserService userService; private final ActivityInfrastructureCreator activityInfrastructureCreator; private final AnalyticsReporterDelegator analyticsDelegator; private final TimeoutFactory timeoutFactory; private final ApplicationSettings applicationSettings; private final long defaultTimeoutMillis; - private final boolean dealsEnabled; private final TrackingPixel trackingPixel; - public NotificationEventHandler(UidsCookieService uidsCookieService, - ApplicationEventService applicationEventService, - UserService userService, - ActivityInfrastructureCreator activityInfrastructureCreator, + public NotificationEventHandler(ActivityInfrastructureCreator activityInfrastructureCreator, AnalyticsReporterDelegator analyticsDelegator, TimeoutFactory timeoutFactory, ApplicationSettings applicationSettings, - long defaultTimeoutMillis, - boolean dealsEnabled) { + long defaultTimeoutMillis) { - this.uidsCookieService = Objects.requireNonNull(uidsCookieService); - this.applicationEventService = applicationEventService; - this.userService = userService; this.activityInfrastructureCreator = Objects.requireNonNull(activityInfrastructureCreator); this.analyticsDelegator = Objects.requireNonNull(analyticsDelegator); this.timeoutFactory = Objects.requireNonNull(timeoutFactory); this.applicationSettings = Objects.requireNonNull(applicationSettings); this.defaultTimeoutMillis = defaultTimeoutMillis; - this.dealsEnabled = dealsEnabled; trackingPixel = createTrackingPixel(); } @@ -144,45 +128,35 @@ private static Future handleAccountExceptionOrFallback(Throwable except private void handleEvent(AsyncResult async, EventRequest eventRequest, RoutingContext routingContext) { if (async.failed()) { - respondWithServerError(routingContext, "Error occurred while fetching account", async.cause()); - } else { - final Account account = async.result(); - - final String lineItemId = eventRequest.getLineItemId(); - final String bidId = eventRequest.getBidId(); - if (dealsEnabled && lineItemId != null) { - applicationEventService.publishLineItemWinEvent(lineItemId); - userService.processWinEvent(lineItemId, bidId, uidsCookieService.parseFromRequest(routingContext)); - } - - final boolean eventsEnabledForAccount = Objects.equals(accountEventsEnabled(account), true); - final boolean eventsEnabledForRequest = eventRequest.getAnalytics() == EventRequest.Analytics.enabled; - - if (!eventsEnabledForAccount && eventsEnabledForRequest) { - respondWithUnauthorized(routingContext, - "Account '%s' doesn't support events".formatted(account.getId())); - return; - } - - final EventRequest.Type eventType = eventRequest.getType(); - if (eventsEnabledForRequest) { - final NotificationEvent notificationEvent = NotificationEvent.builder() - .type(eventType == EventRequest.Type.win - ? NotificationEvent.Type.win : NotificationEvent.Type.imp) - .bidId(eventRequest.getBidId()) - .account(account) - .bidder(eventRequest.getBidder()) - .timestamp(eventRequest.getTimestamp()) - .integration(eventRequest.getIntegration()) - .httpContext(HttpRequestContext.from(routingContext)) - .lineItemId(lineItemId) - .activityInfrastructure(activityInfrastructure(account)) - .build(); - - analyticsDelegator.processEvent(notificationEvent); - } - respondWithOk(routingContext, eventRequest.getFormat() == EventRequest.Format.image); + respondWithAccountError(routingContext, async.cause()); + return; + } + + final Account account = async.result(); + final boolean eventsEnabledForAccount = Objects.equals(accountEventsEnabled(account), true); + final boolean eventsEnabledForRequest = eventRequest.getAnalytics() == EventRequest.Analytics.enabled; + + if (!eventsEnabledForAccount && eventsEnabledForRequest) { + respondWithUnauthorized(routingContext, "Account '%s' doesn't support events".formatted(account.getId())); + return; + } + + final EventRequest.Type eventType = eventRequest.getType(); + if (eventsEnabledForRequest) { + final NotificationEvent notificationEvent = NotificationEvent.builder() + .type(eventType == EventRequest.Type.win ? NotificationEvent.Type.win : NotificationEvent.Type.imp) + .bidId(eventRequest.getBidId()) + .account(account) + .bidder(eventRequest.getBidder()) + .timestamp(eventRequest.getTimestamp()) + .integration(eventRequest.getIntegration()) + .httpContext(HttpRequestContext.from(routingContext)) + .activityInfrastructure(activityInfrastructure(account)) + .build(); + + analyticsDelegator.processEvent(notificationEvent); } + respondWithOk(routingContext, eventRequest.getFormat() == EventRequest.Format.image); } private static Boolean accountEventsEnabled(Account account) { @@ -202,13 +176,14 @@ private ActivityInfrastructure activityInfrastructure(Account account) { private void respondWithOk(RoutingContext routingContext, boolean respondWithPixel) { if (respondWithPixel) { - HttpUtil.executeSafely(routingContext, Endpoint.event, + HttpUtil.executeSafely( + routingContext, + Endpoint.event, response -> response .putHeader(HttpHeaders.CONTENT_TYPE, trackingPixel.getContentType()) .end(Buffer.buffer(trackingPixel.getContent()))); } else { - HttpUtil.executeSafely(routingContext, Endpoint.event, - HttpServerResponse::end); + HttpUtil.executeSafely(routingContext, Endpoint.event, HttpServerResponse::end); } } @@ -220,14 +195,16 @@ private static void respondWithUnauthorized(RoutingContext routingContext, Strin respondWith(routingContext, HttpResponseStatus.UNAUTHORIZED, message); } - private static void respondWithServerError(RoutingContext routingContext, String message, Throwable exception) { - logger.warn(message, exception); - final String body = "%s: %s".formatted(message, exception.getMessage()); + private static void respondWithAccountError(RoutingContext routingContext, Throwable exception) { + logger.warn("Error occurred while fetching account", exception); + final String body = "Error occurred while fetching account: " + exception.getMessage(); respondWith(routingContext, HttpResponseStatus.INTERNAL_SERVER_ERROR, body); } private static void respondWith(RoutingContext routingContext, HttpResponseStatus status, String body) { - HttpUtil.executeSafely(routingContext, Endpoint.event, + HttpUtil.executeSafely( + routingContext, + Endpoint.event, response -> response .setStatusCode(status.code()) .end(body)); @@ -236,8 +213,7 @@ private static void respondWith(RoutingContext routingContext, HttpResponseStatu /** * Internal class for holding pixels content type to its value. */ - @AllArgsConstructor(staticName = "of") - @Value + @Value(staticConstructor = "of") private static class TrackingPixel { String contentType; diff --git a/src/main/java/org/prebid/server/handler/TracerLogHandler.java b/src/main/java/org/prebid/server/handler/TracerLogHandler.java index ae0412860ae..53064a59264 100644 --- a/src/main/java/org/prebid/server/handler/TracerLogHandler.java +++ b/src/main/java/org/prebid/server/handler/TracerLogHandler.java @@ -13,7 +13,6 @@ public class TracerLogHandler implements Handler { private static final String ACCOUNT_PARAMETER = "account"; - private static final String LINE_ITEM_PARAMETER = "lineItemId"; private static final String BIDDER_CODE_PARAMETER = "bidderCode"; private static final String LOG_LEVEL_PARAMETER = "level"; private static final String DURATION_IN_SECONDS = "duration"; @@ -29,11 +28,11 @@ public void handle(RoutingContext routingContext) { final MultiMap parameters = routingContext.request().params(); final String accountId = parameters.get(ACCOUNT_PARAMETER); final String bidderCode = parameters.get(BIDDER_CODE_PARAMETER); - final String lineItemId = parameters.get(LINE_ITEM_PARAMETER); - if (StringUtils.isBlank(accountId) && StringUtils.isBlank(lineItemId) && StringUtils.isBlank(bidderCode)) { - routingContext.response().setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) - .end("At least one parameter should ne defined: account, bidderCode, lineItemId"); + if (StringUtils.isBlank(accountId) && StringUtils.isBlank(bidderCode)) { + routingContext.response() + .setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) + .end("At least one parameter should be defined: account, bidderCode"); return; } @@ -42,14 +41,17 @@ public void handle(RoutingContext routingContext) { try { duration = parseDuration(parameters.get(DURATION_IN_SECONDS)); } catch (InvalidRequestException e) { - routingContext.response().setStatusCode(HttpResponseStatus.BAD_REQUEST.code()).end(e.getMessage()); + routingContext.response() + .setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) + .end(e.getMessage()); return; } try { - criteriaManager.addCriteria(accountId, bidderCode, lineItemId, loggerLevel, duration); + criteriaManager.addCriteria(accountId, bidderCode, loggerLevel, duration); } catch (IllegalArgumentException e) { - routingContext.response().setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) + routingContext.response() + .setStatusCode(HttpResponseStatus.BAD_REQUEST.code()) .end("Invalid parameter: " + e.getMessage()); return; } @@ -67,6 +69,5 @@ private static int parseDuration(String rawDuration) { throw new InvalidRequestException( "duration parameter should be defined as integer, but was " + rawDuration); } - } } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index d2f94d27e67..55f61a554f7 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -370,8 +370,13 @@ private static String originFrom(RoutingContext routingContext) { return origin; } - private void respondWith(RoutingContext routingContext, HttpResponseStatus status, String body, long startTime, - MetricName metricRequestStatus, AmpEvent event, TcfContext tcfContext) { + private void respondWith(RoutingContext routingContext, + HttpResponseStatus status, + String body, + long startTime, + MetricName metricRequestStatus, + AmpEvent event, + TcfContext tcfContext) { final boolean responseSent = HttpUtil.executeSafely(routingContext, Endpoint.openrtb2_amp, response -> response diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index 043890ae86b..a7c036a1f4c 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -127,6 +127,7 @@ private void handleResult(AsyncResult responseResult, AuctionEvent.AuctionEventBuilder auctionEventBuilder, RoutingContext routingContext, long startTime) { + final boolean responseSucceeded = responseResult.succeeded(); final AuctionContext auctionContext = responseSucceeded ? responseResult.result() : null; @@ -175,7 +176,8 @@ private void handleResult(AsyncResult responseResult, } else if (exception instanceof BlacklistedAppException || exception instanceof BlacklistedAccountException) { metricRequestStatus = exception instanceof BlacklistedAccountException - ? MetricName.blacklisted_account : MetricName.blacklisted_app; + ? MetricName.blacklisted_account + : MetricName.blacklisted_app; final String message = "Blacklisted: " + exception.getMessage(); logger.debug(message); @@ -205,17 +207,31 @@ private void handleResult(AsyncResult responseResult, final AuctionEvent auctionEvent = auctionEventBuilder.status(status.code()).errors(errorMessages).build(); final PrivacyContext privacyContext = auctionContext != null ? auctionContext.getPrivacyContext() : null; final TcfContext tcfContext = privacyContext != null ? privacyContext.getTcfContext() : TcfContext.empty(); - respondWith(routingContext, status, body, startTime, requestType, metricRequestStatus, auctionEvent, - tcfContext); + respondWith( + routingContext, + status, + body, + startTime, + requestType, + metricRequestStatus, + auctionEvent, + tcfContext); httpInteractionLogger.maybeLogOpenrtb2Auction(auctionContext, routingContext, status.code(), body); } - private void respondWith(RoutingContext routingContext, HttpResponseStatus status, String body, long startTime, - MetricName requestType, MetricName metricRequestStatus, AuctionEvent event, + private void respondWith(RoutingContext routingContext, + HttpResponseStatus status, + String body, + long startTime, + MetricName requestType, + MetricName metricRequestStatus, + AuctionEvent event, TcfContext tcfContext) { - final boolean responseSent = HttpUtil.executeSafely(routingContext, Endpoint.openrtb2_auction, + final boolean responseSent = HttpUtil.executeSafely( + routingContext, + Endpoint.openrtb2_auction, response -> response .exceptionHandler(throwable -> handleResponseException(throwable, requestType)) .setStatusCode(status.code()) diff --git a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java index 144338430ba..a68eb39eb45 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java @@ -66,6 +66,7 @@ public VideoHandler(VideoRequestFactory videoRequestFactory, Clock clock, PrebidVersionProvider prebidVersionProvider, JacksonMapper mapper) { + this.videoRequestFactory = Objects.requireNonNull(videoRequestFactory); this.videoResponseFactory = Objects.requireNonNull(videoResponseFactory); this.exchangeService = Objects.requireNonNull(exchangeService); diff --git a/src/main/java/org/prebid/server/log/Criteria.java b/src/main/java/org/prebid/server/log/Criteria.java index f98a45c2500..7ad5c3039fd 100644 --- a/src/main/java/org/prebid/server/log/Criteria.java +++ b/src/main/java/org/prebid/server/log/Criteria.java @@ -1,48 +1,32 @@ package org.prebid.server.log; import io.vertx.core.logging.Logger; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Value; +import org.apache.commons.lang3.StringUtils; import java.util.Objects; import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; -@Value -@Builder -@AllArgsConstructor public class Criteria { private static final String TAG_SEPARATOR = "-"; - private static final String TAGGED_MESSAGE_PATTERN = "[%s]: %s"; private static final String TAGGED_RESPONSE_PATTERN = "[%s]: %s - %s"; public static final String BID_RESPONSE = "BidResponse"; public static final String RESOLVED_BID_REQUEST = "Resolved BidRequest"; - String account; + private final String account; + private final String bidder; + private final String tag; + private final BiConsumer loggerLevel; - String bidder; - - String lineItemId; - - String tag; - - BiConsumer loggerLevel; - - public static Criteria create(String account, String bidder, String lineItemId, - BiConsumer loggerLevel) { - return new Criteria(account, bidder, lineItemId, makeTag(account, bidder, lineItemId), loggerLevel); + private Criteria(String account, String bidder, BiConsumer loggerLevel) { + this.account = account; + this.bidder = bidder; + this.tag = makeTag(account, bidder); + this.loggerLevel = Objects.requireNonNull(loggerLevel); } - public void log(Criteria criteria, Logger logger, Object message, Consumer defaultLogger) { - if (isMatched(criteria)) { - loggerLevel.accept(logger, TAGGED_MESSAGE_PATTERN.formatted(tag, message)); - } else { - defaultLogger.accept(message); - } + public static Criteria create(String account, String bidder, BiConsumer loggerLevel) { + return new Criteria(account, bidder, loggerLevel); } public void logResponse(String bidResponse, Logger logger) { @@ -58,23 +42,19 @@ public void logResponseAndRequest(String bidResponse, String bidRequest, Logger } } - private boolean isMatched(Criteria criteria) { - return criteria != null - && (account == null || account.equals(criteria.account)) - && (bidder == null || bidder.equals(criteria.bidder)) - && (lineItemId == null || lineItemId.equals(criteria.lineItemId)); - } - private boolean isMatchedToString(String value) { return (account == null || value.contains(account)) - && (bidder == null || value.contains(bidder)) - && (lineItemId == null || value.contains(lineItemId)); + && (bidder == null || value.contains(bidder)); } - private static String makeTag(String account, String bidder, String lineItemId) { - return Stream.of(account, bidder, lineItemId) - .filter(Objects::nonNull) - .collect(Collectors.joining(TAG_SEPARATOR)); - } + private static String makeTag(String account, String bidder) { + if (account == null) { + return StringUtils.defaultString(bidder); + } + if (bidder == null) { + return account; + } + return account + TAG_SEPARATOR + bidder; + } } diff --git a/src/main/java/org/prebid/server/log/CriteriaLogManager.java b/src/main/java/org/prebid/server/log/CriteriaLogManager.java index b8e5801d436..20344901a31 100644 --- a/src/main/java/org/prebid/server/log/CriteriaLogManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaLogManager.java @@ -10,7 +10,6 @@ import java.util.Objects; import java.util.Set; -import java.util.function.Consumer; public class CriteriaLogManager { @@ -24,25 +23,11 @@ public CriteriaLogManager(JacksonMapper mapper) { this.mapper = Objects.requireNonNull(mapper); } - public void log(Logger logger, Criteria criteria, Object message, Consumer defaultLogger) { - if (criterias.isEmpty()) { - defaultLogger.accept(message); - } - criterias.forEach(cr -> cr.log(criteria, logger, message, defaultLogger)); - } - - public void log(Logger logger, String account, Object message, Consumer defaultLogger) { - log(logger, Criteria.builder().account(account).build(), message, defaultLogger); - } - - public void log(Logger logger, String account, String bidder, String lineItemId, Object message, - Consumer defaultLogger) { - log(logger, Criteria.builder().account(account).bidder(bidder).lineItemId(lineItemId).build(), - message, defaultLogger); - } - - public BidResponse traceResponse(Logger logger, BidResponse bidResponse, BidRequest bidRequest, + public BidResponse traceResponse(Logger logger, + BidResponse bidResponse, + BidRequest bidRequest, boolean debugEnabled) { + if (criterias.isEmpty()) { return bidResponse; } diff --git a/src/main/java/org/prebid/server/log/CriteriaManager.java b/src/main/java/org/prebid/server/log/CriteriaManager.java index e5cde95a392..e55087ce50a 100644 --- a/src/main/java/org/prebid/server/log/CriteriaManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaManager.java @@ -2,18 +2,13 @@ import io.vertx.core.Vertx; import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.prebid.server.deals.model.LogCriteriaFilter; -import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; public class CriteriaManager { private static final long MAX_CRITERIA_DURATION = 300000L; - private static final Logger logger = LoggerFactory.getLogger(CriteriaManager.class); - private final CriteriaLogManager criteriaLogManager; private final Vertx vertx; @@ -22,24 +17,16 @@ public CriteriaManager(CriteriaLogManager criteriaLogManager, Vertx vertx) { this.vertx = vertx; } - public void addCriteria(String accountId, String bidderCode, String lineItemId, String loggerLevel, + public void addCriteria(String accountId, + String bidderCode, + String loggerLevel, Integer durationMillis) { - final Criteria criteria = Criteria.create(accountId, bidderCode, lineItemId, resolveLogLevel(loggerLevel)); + + final Criteria criteria = Criteria.create(accountId, bidderCode, resolveLogLevel(loggerLevel)); criteriaLogManager.addCriteria(criteria); vertx.setTimer(limitDuration(durationMillis), ignored -> criteriaLogManager.removeCriteria(criteria)); } - public void addCriteria(LogCriteriaFilter filter, Long durationSeconds) { - if (filter != null) { - final Criteria criteria = Criteria.create(filter.getAccountId(), filter.getBidderCode(), - filter.getLineItemId(), Logger::error); - criteriaLogManager.addCriteria(criteria); - logger.info("Logger was updated with new criteria {0}", criteria); - vertx.setTimer(limitDuration(TimeUnit.SECONDS.toMillis(durationSeconds)), - ignored -> criteriaLogManager.removeCriteria(criteria)); - } - } - public void stop() { criteriaLogManager.removeAllCriteria(); } @@ -49,21 +36,18 @@ private long limitDuration(long durationMillis) { } private BiConsumer resolveLogLevel(String rawLogLevel) { - final LogLevel logLevel; try { - logLevel = LogLevel.valueOf(rawLogLevel.toLowerCase()); + return switch (LogLevel.valueOf(rawLogLevel.toLowerCase())) { + case info -> Logger::info; + case warn -> Logger::warn; + case trace -> Logger::trace; + case error -> Logger::error; + case fatal -> Logger::fatal; + case debug -> Logger::debug; + }; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid LoggingLevel: " + rawLogLevel); } - - return switch (logLevel) { - case info -> Logger::info; - case warn -> Logger::warn; - case trace -> Logger::trace; - case error -> Logger::error; - case fatal -> Logger::fatal; - case debug -> Logger::debug; - }; } private enum LogLevel { diff --git a/src/main/java/org/prebid/server/metric/MetricName.java b/src/main/java/org/prebid/server/metric/MetricName.java index 09467050ff7..dec0f38534a 100644 --- a/src/main/java/org/prebid/server/metric/MetricName.java +++ b/src/main/java/org/prebid/server/metric/MetricName.java @@ -147,32 +147,6 @@ public enum MetricName { // price-floors price_floors("price-floors"), - // win notifications - win_notifications, - win_requests, - win_request_preparation_failed, - win_request_time, - win_request_failed, - win_request_successful, - - // user details - user_details_requests, - user_details_request_preparation_failed, - user_details_request_time, - user_details_request_failed, - user_details_request_successful, - - // pg - planner_lineitems_received, - planner_requests, - planner_request_failed, - planner_request_successful, - planner_request_time, - delivery_requests, - delivery_request_failed, - delivery_request_successful, - delivery_request_time, - // activity disallowed_count("disallowed.count"), processed_rules_count("processedrules.count"); diff --git a/src/main/java/org/prebid/server/metric/Metrics.java b/src/main/java/org/prebid/server/metric/Metrics.java index 8ce8e1b4936..65c4b71e7f1 100644 --- a/src/main/java/org/prebid/server/metric/Metrics.java +++ b/src/main/java/org/prebid/server/metric/Metrics.java @@ -58,7 +58,6 @@ public class Metrics extends UpdatableMetrics { private final CurrencyRatesMetrics currencyRatesMetrics; private final Map settingsCacheMetrics; private final HooksMetrics hooksMetrics; - private final PgMetrics pgMetrics; public Metrics(MetricRegistry metricRegistry, CounterType counterType, @@ -97,7 +96,6 @@ public Metrics(MetricRegistry metricRegistry, currencyRatesMetrics = new CurrencyRatesMetrics(metricRegistry, counterType); settingsCacheMetrics = new HashMap<>(); hooksMetrics = new HooksMetrics(metricRegistry, counterType); - pgMetrics = new PgMetrics(metricRegistry, counterType); } RequestsMetrics requests() { @@ -140,10 +138,6 @@ UserSyncMetrics userSync() { return userSyncMetrics; } - PgMetrics pgMetrics() { - return pgMetrics; - } - CookieSyncMetrics cookieSync() { return cookieSyncMetrics; } @@ -509,58 +503,6 @@ public void createHttpClientCircuitBreakerNumberGauge(LongSupplier numberSupplie forCircuitBreakerType(MetricName.http).createGauge(MetricName.existing, numberSupplier); } - public void updatePlannerRequestMetric(boolean successful) { - pgMetrics().incCounter(MetricName.planner_requests); - if (successful) { - pgMetrics().incCounter(MetricName.planner_request_successful); - } else { - pgMetrics().incCounter(MetricName.planner_request_failed); - } - } - - public void updateDeliveryRequestMetric(boolean successful) { - pgMetrics().incCounter(MetricName.delivery_requests); - if (successful) { - pgMetrics().incCounter(MetricName.delivery_request_successful); - } else { - pgMetrics().incCounter(MetricName.delivery_request_failed); - } - } - - public void updateWinEventRequestMetric(boolean successful) { - incCounter(MetricName.win_requests); - if (successful) { - incCounter(MetricName.win_request_successful); - } else { - incCounter(MetricName.win_request_failed); - } - } - - public void updateUserDetailsRequestMetric(boolean successful) { - incCounter(MetricName.user_details_requests); - if (successful) { - incCounter(MetricName.user_details_request_successful); - } else { - incCounter(MetricName.user_details_request_failed); - } - } - - public void updateWinRequestTime(long millis) { - updateTimer(MetricName.win_request_time, millis); - } - - public void updateLineItemsNumberMetric(long count) { - pgMetrics().incCounter(MetricName.planner_lineitems_received, count); - } - - public void updatePlannerRequestTime(long millis) { - pgMetrics().updateTimer(MetricName.planner_request_time, millis); - } - - public void updateDeliveryRequestTime(long millis) { - pgMetrics().updateTimer(MetricName.delivery_request_time, millis); - } - public void updateGeoLocationMetric(boolean successful) { incCounter(MetricName.geolocation_requests); if (successful) { @@ -700,18 +642,6 @@ static MetricName fromAction(ExecutionAction action) { } } - public void updateWinNotificationMetric() { - incCounter(MetricName.win_notifications); - } - - public void updateWinRequestPreparationFailed() { - incCounter(MetricName.win_request_preparation_failed); - } - - public void updateUserDetailsRequestPreparationFailed() { - incCounter(MetricName.user_details_request_preparation_failed); - } - public void updateRequestsActivityDisallowedCount(Activity activity) { requests().activities().forActivity(activity).incCounter(MetricName.disallowed_count); } diff --git a/src/main/java/org/prebid/server/metric/PgMetrics.java b/src/main/java/org/prebid/server/metric/PgMetrics.java deleted file mode 100644 index a7aca3a35a4..00000000000 --- a/src/main/java/org/prebid/server/metric/PgMetrics.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.prebid.server.metric; - -import com.codahale.metrics.MetricRegistry; - -public class PgMetrics extends UpdatableMetrics { - - PgMetrics(MetricRegistry metricRegistry, CounterType counterType) { - super(metricRegistry, counterType, metricName -> "pg." + metricName); - } -} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugPgmetrics.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugPgmetrics.java deleted file mode 100644 index bf87b233962..00000000000 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugPgmetrics.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.proto.openrtb.ext.response; - -import lombok.Builder; -import lombok.Value; - -import java.util.Map; -import java.util.Set; - -/** - * Defines the contract for bidresponse.ext.debug.pgmetrics - */ -@Builder -@Value -public class ExtDebugPgmetrics { - - public static final ExtDebugPgmetrics EMPTY = ExtDebugPgmetrics.builder().build(); - - Set sentToClient; - - Set sentToClientAsTopMatch; - - Set matchedDomainTargeting; - - Set matchedWholeTargeting; - - Set matchedTargetingFcapped; - - Set matchedTargetingFcapLookupFailed; - - Set readyToServe; - - Set pacingDeferred; - - Map> sentToBidder; - - Map> sentToBidderAsTopMatch; - - Map> receivedFromBidder; - - Set responseInvalidated; -} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugTrace.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugTrace.java index e1b047beac1..f17c2c9cf16 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugTrace.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtDebugTrace.java @@ -1,11 +1,9 @@ package org.prebid.server.proto.openrtb.ext.response; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Value; import java.util.List; -import java.util.Map; /** * Defines the contract for bidresponse.ext.debug.trace @@ -14,17 +12,5 @@ @Value public class ExtDebugTrace { - /** - * Defines the contract for bidresponse.ext.debug.trace.deals - */ - List deals; - - /** - * Defines the contract for bidresponse.ext.debug.trace.lineItems - */ - - @JsonProperty("lineitems") - Map> lineItems; - List activityInfrastructure; } diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtResponseDebug.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtResponseDebug.java index 253a6d9f7ea..7d1a5f4c499 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtResponseDebug.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtResponseDebug.java @@ -24,11 +24,6 @@ public class ExtResponseDebug { */ BidRequest resolvedrequest; - /** - * Defines the contract for bidresponse.ext.debug.pgmetrics - */ - ExtDebugPgmetrics pgmetrics; - /** * Defines the contract for bidresponse.ext.debug.trace */ diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtTraceDeal.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtTraceDeal.java deleted file mode 100644 index 1187ef36757..00000000000 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtTraceDeal.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.prebid.server.proto.openrtb.ext.response; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.time.ZonedDateTime; - -/** - * Defines the contract for bidresponse.ext.debug.trace.deals[] - */ -@AllArgsConstructor(staticName = "of") -@Value -public class ExtTraceDeal { - - /** - * Defines the contract for bidresponse.ext.debug.trace.deals[].lineitemid - */ - @JsonProperty("lineitemid") - String lineItemId; - - /** - * Defines the contract for bidresponse.ext.debug.trace.deals[].time - */ - ZonedDateTime time; - - /** - * Defines the contract for bidresponse.ext.debug.trace.deals[].category - */ - Category category; - - /** - * Defines the contract for bidresponse.ext.debug.trace.deals[].message - */ - String message; - - public enum Category { - targeting, pacing, cleanup, post_processing - } -} diff --git a/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java b/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java index 1bd29c31a3d..93c8b1f61b4 100644 --- a/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java @@ -5,21 +5,11 @@ import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.PlannerService; -import org.prebid.server.deals.RegisterService; -import org.prebid.server.deals.simulation.DealsSimulationAdminHandler; import org.prebid.server.handler.AccountCacheInvalidationHandler; import org.prebid.server.handler.CollectedMetricsHandler; import org.prebid.server.handler.CurrencyRatesHandler; import org.prebid.server.handler.CustomizedAdminEndpoint; -import org.prebid.server.handler.DealsStatusHandler; -import org.prebid.server.handler.ForceDealsUpdateHandler; import org.prebid.server.handler.HttpInteractionLogHandler; -import org.prebid.server.handler.LineItemStatusHandler; import org.prebid.server.handler.LoggerControlKnobHandler; import org.prebid.server.handler.SettingsCacheNotificationHandler; import org.prebid.server.handler.TracerLogHandler; @@ -192,89 +182,6 @@ CustomizedAdminEndpoint tracerLogEndpoint( .withCredentials(adminEndpointCredentials); } - @Bean - @ConditionalOnExpression("${deals.enabled} == true and ${admin-endpoints.deals-status.enabled} == true") - CustomizedAdminEndpoint dealsStatusEndpoint( - DeliveryProgressService deliveryProgressService, - JacksonMapper mapper, - @Value("${admin-endpoints.deals-status.path}") String path, - @Value("${admin-endpoints.deals-status.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.deals-status.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { - - return new CustomizedAdminEndpoint( - path, - new DealsStatusHandler(deliveryProgressService, mapper), - isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); - } - - @Bean - @ConditionalOnExpression("${deals.enabled} == true and ${admin-endpoints.lineitem-status.enabled} == true") - CustomizedAdminEndpoint lineItemStatusEndpoint( - DeliveryProgressService deliveryProgressService, - JacksonMapper mapper, - @Value("${admin-endpoints.lineitem-status.path}") String path, - @Value("${admin-endpoints.lineitem-status.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.lineitem-status.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { - - return new CustomizedAdminEndpoint( - path, - new LineItemStatusHandler(deliveryProgressService, mapper, path), - isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); - } - - @Bean - @ConditionalOnExpression("${deals.enabled} == true and ${admin-endpoints.force-deals-update.enabled} == true") - CustomizedAdminEndpoint forceDealsUpdateEndpoint( - DeliveryStatsService deliveryStatsService, - PlannerService plannerService, - RegisterService registerService, - AlertHttpService alertHttpService, - DeliveryProgressService deliveryProgressService, - LineItemService lineItemService, - @Value("${admin-endpoints.force-deals-update.path}") String path, - @Value("${admin-endpoints.force-deals-update.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.force-deals-update.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { - - return new CustomizedAdminEndpoint( - path, - new ForceDealsUpdateHandler( - deliveryStatsService, - plannerService, - registerService, - alertHttpService, - deliveryProgressService, - lineItemService, - path), - isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); - } - - @Bean - @ConditionalOnExpression("${deals.enabled} == true and ${deals.simulation.enabled} == true" - + " and ${admin-endpoints.e2eadmin.enabled} == true") - CustomizedAdminEndpoint dealsSimulationAdminEndpoint( - DealsSimulationAdminHandler dealsSimulationAdminHandler, - @Value("${admin-endpoints.e2eadmin.path}") String path, - @Value("${admin-endpoints.e2eadmin.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.e2eadmin.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { - - return new CustomizedAdminEndpoint( - path, - dealsSimulationAdminHandler, - isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); - } - @Bean @ConditionalOnExpression("${admin-endpoints.collected-metrics.enabled} == true") CustomizedAdminEndpoint collectedMetricsAdminEndpoint( diff --git a/src/main/java/org/prebid/server/spring/config/DealsConfiguration.java b/src/main/java/org/prebid/server/spring/config/DealsConfiguration.java deleted file mode 100644 index 5b935ca1602..00000000000 --- a/src/main/java/org/prebid/server/spring/config/DealsConfiguration.java +++ /dev/null @@ -1,914 +0,0 @@ -package org.prebid.server.spring.config; - -import io.vertx.core.Vertx; -import io.vertx.core.eventbus.EventBus; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.commons.lang3.ObjectUtils; -import org.prebid.server.bidder.BidderErrorNotifier; -import org.prebid.server.bidder.BidderRequestCompletionTrackerFactory; -import org.prebid.server.bidder.DealsBidderRequestCompletionTrackerFactory; -import org.prebid.server.bidder.HttpBidderRequestEnricher; -import org.prebid.server.bidder.HttpBidderRequester; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.AdminCentralService; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DealsService; -import org.prebid.server.deals.DeliveryProgressReportFactory; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.PlannerService; -import org.prebid.server.deals.RegisterService; -import org.prebid.server.deals.Suspendable; -import org.prebid.server.deals.TargetingService; -import org.prebid.server.deals.UserAdditionalInfoService; -import org.prebid.server.deals.UserService; -import org.prebid.server.deals.deviceinfo.DeviceInfoService; -import org.prebid.server.deals.events.AdminEventProcessor; -import org.prebid.server.deals.events.AdminEventService; -import org.prebid.server.deals.events.ApplicationEventProcessor; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.events.EventServiceInitializer; -import org.prebid.server.deals.simulation.DealsSimulationAdminHandler; -import org.prebid.server.deals.simulation.SimulationAwareDeliveryProgressService; -import org.prebid.server.deals.simulation.SimulationAwareDeliveryStatsService; -import org.prebid.server.deals.simulation.SimulationAwareHttpBidderRequester; -import org.prebid.server.deals.simulation.SimulationAwareLineItemService; -import org.prebid.server.deals.simulation.SimulationAwarePlannerService; -import org.prebid.server.deals.simulation.SimulationAwareRegisterService; -import org.prebid.server.deals.simulation.SimulationAwareUserService; -import org.prebid.server.geolocation.GeoLocationService; -import org.prebid.server.health.HealthMonitor; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.log.CriteriaManager; -import org.prebid.server.metric.Metrics; -import org.prebid.server.settings.CachingApplicationSettings; -import org.prebid.server.settings.SettingsCache; -import org.prebid.server.vertx.ContextRunner; -import org.prebid.server.vertx.http.HttpClient; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.time.Clock; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Configuration -public class DealsConfiguration { - - @Configuration - @ConditionalOnExpression("${deals.enabled} == true and ${deals.simulation.enabled} == false") - public static class ProductionConfiguration { - - @Bean - PlannerService plannerService( - PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - DeliveryProgressService deliveryProgressService, - LineItemService lineItemService, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - JacksonMapper mapper) { - - return new PlannerService( - plannerProperties.toComponentProperties(), - deploymentProperties.toComponentProperties(), - lineItemService, - deliveryProgressService, - alertHttpService, - httpClient, - metrics, - clock, - mapper); - } - - @Bean - RegisterService registerService( - PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - AdminEventService adminEventService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HealthMonitor healthMonitor, - CurrencyConversionService currencyConversionService, - HttpClient httpClient, - Vertx vertx, - JacksonMapper mapper) { - - return new RegisterService( - plannerProperties.toComponentProperties(), - deploymentProperties.toComponentProperties(), - adminEventService, - deliveryProgressService, - alertHttpService, - healthMonitor, - currencyConversionService, - httpClient, - vertx, - mapper); - } - - @Bean - DeliveryStatsService deliveryStatsService( - DeliveryStatsProperties deliveryStatsProperties, - DeliveryProgressReportFactory deliveryProgressReportFactory, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - Vertx vertx, - JacksonMapper mapper) { - - return new DeliveryStatsService( - deliveryStatsProperties.toComponentProperties(), - deliveryProgressReportFactory, - alertHttpService, - httpClient, - metrics, - clock, - vertx, - mapper); - } - - @Bean - LineItemService lineItemService( - @Value("${deals.max-deals-per-bidder}") int maxDealsPerBidder, - TargetingService targetingService, - CurrencyConversionService conversionService, - ApplicationEventService applicationEventService, - @Value("${auction.ad-server-currency}") String adServerCurrency, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - return new LineItemService(maxDealsPerBidder, - targetingService, - conversionService, - applicationEventService, - adServerCurrency, - clock, - criteriaLogManager); - } - - @Bean - DeliveryProgressService deliveryProgressService( - DeliveryProgressProperties deliveryProgressProperties, - LineItemService lineItemService, - DeliveryStatsService deliveryStatsService, - DeliveryProgressReportFactory deliveryProgressReportFactory, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - return new DeliveryProgressService( - deliveryProgressProperties.toComponentProperties(), - lineItemService, - deliveryStatsService, - deliveryProgressReportFactory, - clock, - criteriaLogManager); - } - - @Bean - UserService userService( - UserDetailsProperties userDetailsProperties, - @Value("${datacenter-region}") String dataCenterRegion, - LineItemService lineItemService, - HttpClient httpClient, - Clock clock, - Metrics metrics, - JacksonMapper mapper) { - - return new UserService( - userDetailsProperties.toComponentProperties(), - dataCenterRegion, - lineItemService, - httpClient, - clock, - metrics, - mapper); - } - } - - @Configuration - @ConditionalOnExpression("${deals.enabled} == true and ${deals.simulation.enabled} == false") - @EnableScheduling - public static class SchedulerConfiguration { - - @Bean - GeneralPlannerScheduler generalPlannerScheduler(PlannerService plannerService, - ContextRunner contextRunner) { - return new GeneralPlannerScheduler(plannerService, contextRunner); - } - - @Bean - @ConditionalOnExpression( - "'${deals.delivery-stats.delivery-period}'" - + ".equals('${deals.delivery-progress.report-reset-period}')") - ImmediateDeliveryScheduler immediateDeliveryScheduler(DeliveryProgressService deliveryProgressService, - DeliveryStatsService deliveryStatsService, - Clock clock, - ContextRunner contextRunner) { - return new ImmediateDeliveryScheduler(deliveryProgressService, deliveryStatsService, clock, - contextRunner); - } - - @Bean - @ConditionalOnExpression( - "not '${deals.delivery-stats.delivery-period}'" - + ".equals('${deals.delivery-progress.report-reset-period}')") - DeliveryScheduler deliveryScheduler(DeliveryProgressService deliveryProgressService, - DeliveryStatsService deliveryStatsService, - Clock clock, - ContextRunner contextRunner) { - return new DeliveryScheduler(deliveryProgressService, deliveryStatsService, clock, - contextRunner); - } - - @Bean - AdvancePlansScheduler advancePlansScheduler(LineItemService lineItemService, - ContextRunner contextRunner, - Clock clock) { - return new AdvancePlansScheduler(lineItemService, contextRunner, clock); - } - - private static class GeneralPlannerScheduler { - - private final PlannerService plannerService; - private final ContextRunner contextRunner; - - GeneralPlannerScheduler(PlannerService plannerService, ContextRunner contextRunner) { - this.plannerService = plannerService; - this.contextRunner = contextRunner; - } - - @Scheduled(cron = "${deals.planner.update-period}") - public void fetchPlansFromGeneralPlanner() { - contextRunner.runOnServiceContext(future -> { - plannerService.updateLineItemMetaData(); - future.complete(); - }); - } - } - - private static class AdvancePlansScheduler { - private final LineItemService lineItemService; - private final ContextRunner contextRunner; - private final Clock clock; - - AdvancePlansScheduler(LineItemService lineItemService, ContextRunner contextRunner, Clock clock) { - this.lineItemService = lineItemService; - this.contextRunner = contextRunner; - this.clock = clock; - } - - @Scheduled(cron = "${deals.planner.plan-advance-period}") - public void advancePlans() { - contextRunner.runOnServiceContext(future -> { - lineItemService.advanceToNextPlan(ZonedDateTime.now(clock)); - future.complete(); - }); - } - } - - private static class ImmediateDeliveryScheduler { - - private final DeliveryProgressService deliveryProgressService; - private final DeliveryStatsService deliveryStatsService; - private final Clock clock; - private final ContextRunner contextRunner; - - ImmediateDeliveryScheduler(DeliveryProgressService deliveryProgressService, - DeliveryStatsService deliveryStatsService, - Clock clock, - ContextRunner contextRunner) { - this.deliveryProgressService = deliveryProgressService; - this.deliveryStatsService = deliveryStatsService; - this.clock = clock; - this.contextRunner = contextRunner; - } - - @Scheduled(cron = "${deals.delivery-stats.delivery-period}") - public void createAndSendDeliveryReport() { - contextRunner.runOnServiceContext(future -> { - final ZonedDateTime now = ZonedDateTime.now(clock); - deliveryProgressService.createDeliveryProgressReports(now); - deliveryStatsService.sendDeliveryProgressReports(now); - future.complete(); - }); - } - } - } - - private static class DeliveryScheduler { - - private final DeliveryProgressService deliveryProgressService; - private final DeliveryStatsService deliveryStatsService; - private final Clock clock; - private final ContextRunner contextRunner; - - DeliveryScheduler(DeliveryProgressService deliveryProgressService, - DeliveryStatsService deliveryStatsService, - Clock clock, - ContextRunner contextRunner) { - this.deliveryProgressService = deliveryProgressService; - this.deliveryStatsService = deliveryStatsService; - this.clock = clock; - this.contextRunner = contextRunner; - } - - @Scheduled(cron = "${deals.delivery-progress.report-reset-period}") - public void createDeliveryReport() { - contextRunner.runOnServiceContext(future -> { - deliveryProgressService.createDeliveryProgressReports(ZonedDateTime.now(clock)); - future.complete(); - }); - } - - @Scheduled(cron = "${deals.delivery-stats.delivery-period}") - public void sendDeliveryReport() { - contextRunner.runOnServiceContext(future -> { - deliveryStatsService.sendDeliveryProgressReports(ZonedDateTime.now(clock)); - future.complete(); - }); - } - } - - @Configuration - @ConditionalOnExpression("${deals.enabled} == true and ${deals.simulation.enabled} == true") - public static class SimulationConfiguration { - - @Bean - @ConditionalOnProperty(prefix = "deals", name = "call-real-bidders-in-simulation", havingValue = "false", - matchIfMissing = true) - SimulationAwareHttpBidderRequester simulationAwareHttpBidderRequester( - HttpClient httpClient, - BidderRequestCompletionTrackerFactory completionTrackerFactory, - BidderErrorNotifier bidderErrorNotifier, - HttpBidderRequestEnricher requestEnricher, - LineItemService lineItemService, - JacksonMapper mapper) { - - return new SimulationAwareHttpBidderRequester( - httpClient, completionTrackerFactory, bidderErrorNotifier, requestEnricher, lineItemService, - mapper); - } - - @Bean - SimulationAwarePlannerService plannerService( - PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - DeliveryProgressService deliveryProgressService, - SimulationAwareLineItemService lineItemService, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - JacksonMapper mapper) { - - return new SimulationAwarePlannerService( - plannerProperties.toComponentProperties(), - deploymentProperties.toComponentProperties(), - lineItemService, - deliveryProgressService, - alertHttpService, - httpClient, - metrics, - clock, - mapper); - } - - @Bean - SimulationAwareRegisterService registerService( - PlannerProperties plannerProperties, - DeploymentProperties deploymentProperties, - AdminEventService adminEventService, - DeliveryProgressService deliveryProgressService, - AlertHttpService alertHttpService, - HealthMonitor healthMonitor, - CurrencyConversionService currencyConversionService, - HttpClient httpClient, - Vertx vertx, - JacksonMapper mapper) { - - return new SimulationAwareRegisterService( - plannerProperties.toComponentProperties(), - deploymentProperties.toComponentProperties(), - adminEventService, - deliveryProgressService, - alertHttpService, - healthMonitor, - currencyConversionService, - httpClient, - vertx, - mapper); - } - - @Bean - SimulationAwareDeliveryStatsService deliveryStatsService( - DeliveryStatsProperties deliveryStatsProperties, - DeliveryProgressReportFactory deliveryProgressReportFactory, - AlertHttpService alertHttpService, - HttpClient httpClient, - Metrics metrics, - Clock clock, - Vertx vertx, - JacksonMapper mapper) { - - return new SimulationAwareDeliveryStatsService( - deliveryStatsProperties.toComponentProperties(), - deliveryProgressReportFactory, - alertHttpService, - httpClient, - metrics, - clock, - vertx, - mapper); - } - - @Bean - SimulationAwareLineItemService lineItemService( - @Value("${deals.max-deals-per-bidder}") int maxDealsPerBidder, - TargetingService targetingService, - CurrencyConversionService conversionService, - ApplicationEventService applicationEventService, - @Value("${auction.ad-server-currency}") String adServerCurrency, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - return new SimulationAwareLineItemService( - maxDealsPerBidder, - targetingService, - conversionService, - applicationEventService, - adServerCurrency, - clock, - criteriaLogManager); - } - - @Bean - SimulationAwareDeliveryProgressService deliveryProgressService( - DeliveryProgressProperties deliveryProgressProperties, - LineItemService lineItemService, - DeliveryStatsService deliveryStatsService, - DeliveryProgressReportFactory deliveryProgressReportFactory, - @Value("${deals.simulation.ready-at-adjustment-ms}") long readyAtAdjustment, - Clock clock, - CriteriaLogManager criteriaLogManager) { - - return new SimulationAwareDeliveryProgressService( - deliveryProgressProperties.toComponentProperties(), - lineItemService, - deliveryStatsService, - deliveryProgressReportFactory, - readyAtAdjustment, - clock, - criteriaLogManager); - } - - @Bean - SimulationAwareUserService userService( - UserDetailsProperties userDetailsProperties, - SimulationProperties simulationProperties, - @Value("${datacenter-region}") String dataCenterRegion, - LineItemService lineItemService, - HttpClient httpClient, - Clock clock, - Metrics metrics, - JacksonMapper mapper) { - - return new SimulationAwareUserService( - userDetailsProperties.toComponentProperties(), - simulationProperties.toComponentProperties(), - dataCenterRegion, - lineItemService, - httpClient, - clock, - metrics, - mapper); - } - - @Bean - DealsSimulationAdminHandler dealsSimulationAdminHandler( - SimulationAwareRegisterService registerService, - SimulationAwarePlannerService plannerService, - SimulationAwareDeliveryProgressService deliveryProgressService, - SimulationAwareDeliveryStatsService deliveryStatsService, - @Autowired(required = false) SimulationAwareHttpBidderRequester httpBidderRequester, - JacksonMapper mapper, - @Value("${admin-endpoints.e2eadmin.path}") String path) { - - return new DealsSimulationAdminHandler( - registerService, - plannerService, - deliveryProgressService, - deliveryStatsService, - httpBidderRequester, - mapper, - path); - } - - @Bean - BeanPostProcessor simulationCustomizationBeanPostProcessor( - @Autowired(required = false) SimulationAwareHttpBidderRequester httpBidderRequester) { - - return new BeanPostProcessor() { - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - // there are HttpBidderRequester and SimulationAwareHttpBidderRequester in context by now, we would - // like to replace former with latter everywhere - if (httpBidderRequester != null && bean.getClass().isAssignableFrom(HttpBidderRequester.class) - && !(bean instanceof SimulationAwareHttpBidderRequester)) { - return httpBidderRequester; - } - - return bean; - } - }; - } - } - - @Configuration - @ConditionalOnExpression("${deals.enabled} == true") - public static class DealsMainConfiguration { - - @Bean - @ConfigurationProperties - DeploymentProperties deploymentProperties() { - return new DeploymentProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.planner") - PlannerProperties plannerProperties() { - return new PlannerProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.delivery-stats") - DeliveryStatsProperties deliveryStatsProperties() { - return new DeliveryStatsProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.delivery-progress") - DeliveryProgressProperties deliveryProgressProperties() { - return new DeliveryProgressProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.user-data") - UserDetailsProperties userDetailsProperties() { - return new UserDetailsProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.alert-proxy") - AlertProxyProperties alertProxyProperties() { - return new AlertProxyProperties(); - } - - @Bean - @ConfigurationProperties(prefix = "deals.simulation") - SimulationProperties simulationProperties() { - return new SimulationProperties(); - } - - @Bean - BidderRequestCompletionTrackerFactory bidderRequestCompletionTrackerFactory() { - return new DealsBidderRequestCompletionTrackerFactory(); - } - - @Bean - UserAdditionalInfoService userAdditionalInfoService( - LineItemService lineItemService, - @Autowired(required = false) DeviceInfoService deviceInfoService, - @Autowired(required = false) GeoLocationService geoLocationService, - UserService userService, - Clock clock, - JacksonMapper mapper, - CriteriaLogManager criteriaLogManager) { - - return new UserAdditionalInfoService( - lineItemService, - deviceInfoService, - geoLocationService, - userService, - clock, - mapper, - criteriaLogManager); - } - - @Bean - DealsService dealsService(LineItemService lineItemService, - JacksonMapper mapper, - CriteriaLogManager criteriaLogManager) { - - return new DealsService(lineItemService, mapper, criteriaLogManager); - } - - @Bean - DeliveryProgressReportFactory deliveryProgressReportFactory( - DeploymentProperties deploymentProperties, - @Value("${deals.delivery-progress-report.competitors-number}") int competitorsNumber, - LineItemService lineItemService) { - - return new DeliveryProgressReportFactory( - deploymentProperties.toComponentProperties(), competitorsNumber, lineItemService); - } - - @Bean - AlertHttpService alertHttpService(JacksonMapper mapper, - HttpClient httpClient, - Clock clock, - DeploymentProperties deploymentProperties, - AlertProxyProperties alertProxyProperties) { - - return new AlertHttpService( - mapper, - httpClient, - clock, - deploymentProperties.toComponentProperties(), - alertProxyProperties.toComponentProperties()); - } - - @Bean - TargetingService targetingService(JacksonMapper mapper) { - return new TargetingService(mapper); - } - - @Bean - AdminCentralService adminCentralService( - CriteriaManager criteriaManager, - LineItemService lineItemService, - DeliveryProgressService deliveryProgressService, - @Autowired(required = false) @Qualifier("settingsCache") SettingsCache settingsCache, - @Autowired(required = false) @Qualifier("ampSettingsCache") SettingsCache ampSettingsCache, - @Autowired(required = false) CachingApplicationSettings cachingApplicationSettings, - JacksonMapper mapper, - List suspendables) { - - return new AdminCentralService( - criteriaManager, - lineItemService, - deliveryProgressService, - settingsCache, - ampSettingsCache, - cachingApplicationSettings, - mapper, - suspendables); - } - - @Bean - ApplicationEventService applicationEventService(EventBus eventBus) { - return new ApplicationEventService(eventBus); - } - - @Bean - AdminEventService adminEventService(EventBus eventBus) { - return new AdminEventService(eventBus); - } - - @Bean - EventServiceInitializer eventServiceInitializer(List applicationEventProcessors, - List adminEventProcessors, - EventBus eventBus) { - - return new EventServiceInitializer(applicationEventProcessors, adminEventProcessors, eventBus); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class DeploymentProperties { - - @NotBlank - private String hostId; - - @NotBlank - private String datacenterRegion; - - @NotBlank - private String vendor; - - @NotBlank - private String profile; - - @NotBlank - private String infra; - - @NotBlank - private String dataCenter; - - @NotBlank - private String system; - - @NotBlank - private String subSystem; - - public org.prebid.server.deals.model.DeploymentProperties toComponentProperties() { - return org.prebid.server.deals.model.DeploymentProperties.builder() - .pbsHostId(getHostId()).pbsRegion(getDatacenterRegion()).pbsVendor(getVendor()) - .profile(getProfile()).infra(getInfra()).dataCenter(getDataCenter()).system(getSystem()) - .subSystem(getSubSystem()).build(); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class PlannerProperties { - - @NotBlank - private String planEndpoint; - @NotBlank - private String registerEndpoint; - @NotNull - private Long timeoutMs; - @NotNull - private Long registerPeriodSec; - @NotBlank - private String username; - @NotBlank - private String password; - - public org.prebid.server.deals.model.PlannerProperties toComponentProperties() { - return org.prebid.server.deals.model.PlannerProperties.builder() - .planEndpoint(getPlanEndpoint()) - .registerEndpoint(getRegisterEndpoint()) - .timeoutMs(getTimeoutMs()) - .registerPeriodSeconds(getRegisterPeriodSec()) - .username(getUsername()) - .password(getPassword()) - .build(); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class DeliveryStatsProperties { - - @NotBlank - private String endpoint; - @NotNull - private Integer cachedReportsNumber; - @NotNull - private Long timeoutMs; - @NotNull - private Integer lineItemsPerReport; - @NotNull - private Integer reportsIntervalMs; - @NotNull - private Integer batchesIntervalMs; - @NotNull - private Boolean requestCompressionEnabled; - @NotBlank - private String username; - @NotBlank - private String password; - - public org.prebid.server.deals.model.DeliveryStatsProperties toComponentProperties() { - return org.prebid.server.deals.model.DeliveryStatsProperties.builder() - .endpoint(getEndpoint()) - .cachedReportsNumber(getCachedReportsNumber()) - .timeoutMs(getTimeoutMs()) - .lineItemsPerReport(getLineItemsPerReport()) - .reportsIntervalMs(getReportsIntervalMs()) - .batchesIntervalMs(getBatchesIntervalMs()) - .requestCompressionEnabled(getRequestCompressionEnabled()) - .username(getUsername()) - .password(getPassword()) - .build(); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class DeliveryProgressProperties { - - @NotNull - private Long lineItemStatusTtlSec; - @NotNull - private Integer cachedPlansNumber; - - public org.prebid.server.deals.model.DeliveryProgressProperties toComponentProperties() { - return org.prebid.server.deals.model.DeliveryProgressProperties.of(getLineItemStatusTtlSec(), - getCachedPlansNumber()); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class UserDetailsProperties { - - @NotBlank - private String userDetailsEndpoint; - @NotBlank - private String winEventEndpoint; - @NotNull - private Long timeout; - @NotNull - private List userIds; - - public org.prebid.server.deals.model.UserDetailsProperties toComponentProperties() { - final List componentUserIds = getUserIds().stream() - .map(DealsConfiguration.UserIdRule::toComponentProperties) - .toList(); - - return org.prebid.server.deals.model.UserDetailsProperties.of( - getUserDetailsEndpoint(), getWinEventEndpoint(), getTimeout(), componentUserIds); - } - } - - @Validated - @Data - @NoArgsConstructor - private static class AlertProxyProperties { - - @NotNull - private boolean enabled; - - @NotBlank - private String url; - - @NotNull - private Integer timeoutSec; - - Map alertTypes; - - @NotBlank - private String username; - - @NotBlank - private String password; - - public org.prebid.server.deals.model.AlertProxyProperties toComponentProperties() { - return org.prebid.server.deals.model.AlertProxyProperties.builder() - .enabled(isEnabled()).url(getUrl()).timeoutSec(getTimeoutSec()) - .alertTypes(ObjectUtils.defaultIfNull(getAlertTypes(), new HashMap<>())) - .username(getUsername()) - .password(getPassword()).build(); - } - } - - @Validated - @NoArgsConstructor - @Data - private static class UserIdRule { - - @NotBlank - private String type; - - @NotBlank - private String source; - - @NotBlank - private String location; - - org.prebid.server.deals.model.UserIdRule toComponentProperties() { - return org.prebid.server.deals.model.UserIdRule.of(getType(), getSource(), getLocation()); - } - } - - @Validated - @NoArgsConstructor - @Data - private static class SimulationProperties { - - @NotNull - boolean enabled; - - Boolean winEventsEnabled; - - Boolean userDetailsEnabled; - - org.prebid.server.deals.model.SimulationProperties toComponentProperties() { - return org.prebid.server.deals.model.SimulationProperties.builder() - .enabled(isEnabled()) - .winEventsEnabled(getWinEventsEnabled() != null ? getWinEventsEnabled() : false) - .userDetailsEnabled(getUserDetailsEnabled() != null ? getUserDetailsEnabled() : false) - .build(); - } - } -} diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index a258f09827b..1180f622661 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -79,9 +79,6 @@ import org.prebid.server.cookie.PrioritizedCoopSyncProvider; import org.prebid.server.cookie.UidsCookieService; import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.DealsService; -import org.prebid.server.deals.UserAdditionalInfoService; -import org.prebid.server.deals.events.ApplicationEventService; import org.prebid.server.events.EventsService; import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.floors.PriceFloorAdjuster; @@ -369,11 +366,9 @@ Ortb2RequestFactory openRtb2RequestFactory( ApplicationSettings applicationSettings, IpAddressHelper ipAddressHelper, HookStageExecutor hookStageExecutor, - @Autowired(required = false) UserAdditionalInfoService userAdditionalInfoService, CountryCodeMapper countryCodeMapper, PriceFloorProcessor priceFloorProcessor, - Metrics metrics, - Clock clock) { + Metrics metrics) { final List blacklistedAccounts = splitToList(blacklistedAccountsString); @@ -390,11 +385,9 @@ Ortb2RequestFactory openRtb2RequestFactory( applicationSettings, ipAddressHelper, hookStageExecutor, - userAdditionalInfoService, priceFloorProcessor, countryCodeMapper, - metrics, - clock); + metrics); } @Bean @@ -811,7 +804,6 @@ ExchangeService exchangeService( @Value("${logging.sampling-rate:0.01}") double logSamplingRate, BidderCatalog bidderCatalog, StoredResponseProcessor storedResponseProcessor, - @Autowired(required = false) DealsService dealsService, PrivacyEnforcementService privacyEnforcementService, FpdResolver fpdResolver, SupplyChainResolver supplyChainResolver, @@ -827,7 +819,6 @@ ExchangeService exchangeService( BidResponseCreator bidResponseCreator, BidResponsePostProcessor bidResponsePostProcessor, HookStageExecutor hookStageExecutor, - @Autowired(required = false) ApplicationEventService applicationEventService, HttpInteractionLogger httpInteractionLogger, PriceFloorAdjuster priceFloorAdjuster, PriceFloorEnforcer priceFloorEnforcer, @@ -843,7 +834,6 @@ ExchangeService exchangeService( logSamplingRate, bidderCatalog, storedResponseProcessor, - dealsService, privacyEnforcementService, fpdResolver, supplyChainResolver, @@ -859,7 +849,6 @@ ExchangeService exchangeService( bidResponseCreator, bidResponsePostProcessor, hookStageExecutor, - applicationEventService, httpInteractionLogger, priceFloorAdjuster, priceFloorEnforcer, @@ -1022,16 +1011,12 @@ BidderParamValidator bidderParamValidator(BidderCatalog bidderCatalog, JacksonMa ResponseBidValidator responseValidator( @Value("${auction.validations.banner-creative-max-size}") BidValidationEnforcement bannerMaxSizeEnforcement, @Value("${auction.validations.secure-markup}") BidValidationEnforcement secureMarkupEnforcement, - Metrics metrics, - JacksonMapper mapper, - @Value("${deals.enabled}") boolean dealsEnabled) { + Metrics metrics) { return new ResponseBidValidator( bannerMaxSizeEnforcement, secureMarkupEnforcement, metrics, - mapper, - dealsEnabled, logSamplingRate); } diff --git a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java index 4636a056783..5dc0f08fc19 100644 --- a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java @@ -2,7 +2,6 @@ import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; -import io.vertx.core.eventbus.EventBus; import io.vertx.core.file.FileSystem; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; @@ -12,7 +11,6 @@ import io.vertx.ext.web.handler.BodyHandler; import org.prebid.server.spring.config.metrics.MetricsConfiguration; import org.prebid.server.vertx.ContextRunner; -import org.prebid.server.vertx.LocalMessageCodec; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -44,14 +42,6 @@ Vertx vertx(@Value("${vertx.worker-pool-size}") int workerPoolSize, return vertx; } - @Bean - EventBus eventBus(Vertx vertx) { - final EventBus eventBus = vertx.eventBus(); - eventBus.registerCodec(LocalMessageCodec.create()); - - return eventBus; - } - @Bean FileSystem fileSystem(Vertx vertx) { return vertx.fileSystem(); diff --git a/src/main/java/org/prebid/server/spring/config/WebConfiguration.java b/src/main/java/org/prebid/server/spring/config/WebConfiguration.java index c6244306b97..fd5e6b95ee3 100644 --- a/src/main/java/org/prebid/server/spring/config/WebConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/WebConfiguration.java @@ -27,8 +27,6 @@ import org.prebid.server.cookie.CookieDeprecationService; import org.prebid.server.cookie.CookieSyncService; import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.deals.UserService; -import org.prebid.server.deals.events.ApplicationEventService; import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.handler.BidderParamHandler; import org.prebid.server.handler.CookieSyncHandler; @@ -403,27 +401,18 @@ BidderDetailsHandler bidderDetailsHandler(BidderCatalog bidderCatalog, JacksonMa } @Bean - NotificationEventHandler notificationEventHandler( - UidsCookieService uidsCookieService, - @Autowired(required = false) ApplicationEventService applicationEventService, - @Autowired(required = false) UserService userService, - ActivityInfrastructureCreator activityInfrastructureCreator, - AnalyticsReporterDelegator analyticsReporterDelegator, - TimeoutFactory timeoutFactory, - ApplicationSettings applicationSettings, - @Value("${event.default-timeout-ms}") long defaultTimeoutMillis, - @Value("${deals.enabled}") boolean dealsEnabled) { + NotificationEventHandler notificationEventHandler(ActivityInfrastructureCreator activityInfrastructureCreator, + AnalyticsReporterDelegator analyticsReporterDelegator, + TimeoutFactory timeoutFactory, + ApplicationSettings applicationSettings, + @Value("${event.default-timeout-ms}") long defaultTimeoutMillis) { return new NotificationEventHandler( - uidsCookieService, - applicationEventService, - userService, activityInfrastructureCreator, analyticsReporterDelegator, timeoutFactory, applicationSettings, - defaultTimeoutMillis, - dealsEnabled); + defaultTimeoutMillis); } @Bean diff --git a/src/main/java/org/prebid/server/util/HttpUtil.java b/src/main/java/org/prebid/server/util/HttpUtil.java index 767d326b0a7..b848f1a4d41 100644 --- a/src/main/java/org/prebid/server/util/HttpUtil.java +++ b/src/main/java/org/prebid/server/util/HttpUtil.java @@ -10,9 +10,7 @@ import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; -import org.prebid.server.exception.PreBidException; import org.prebid.server.log.ConditionalLogger; -import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.model.Endpoint; import org.prebid.server.model.HttpRequestContext; @@ -21,15 +19,12 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.time.ZonedDateTime; import java.util.Arrays; -import java.util.Base64; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,7 +42,6 @@ public final class HttpUtil { public static final CharSequence X_FORWARDED_FOR_HEADER = HttpHeaders.createOptimized("X-Forwarded-For"); public static final CharSequence X_REAL_IP_HEADER = HttpHeaders.createOptimized("X-Real-Ip"); public static final CharSequence DNT_HEADER = HttpHeaders.createOptimized("DNT"); - public static final CharSequence X_REQUEST_AGENT_HEADER = HttpHeaders.createOptimized("X-Request-Agent"); public static final CharSequence ORIGIN_HEADER = HttpHeaders.createOptimized("Origin"); public static final CharSequence ACCEPT_HEADER = HttpHeaders.createOptimized("Accept"); public static final CharSequence SEC_GPC_HEADER = HttpHeaders.createOptimized("Sec-GPC"); @@ -65,19 +59,15 @@ public final class HttpUtil { public static final CharSequence ACCEPT_LANGUAGE_HEADER = HttpHeaders.createOptimized("Accept-Language"); public static final CharSequence SET_COOKIE_HEADER = HttpHeaders.createOptimized("Set-Cookie"); public static final CharSequence AUTHORIZATION_HEADER = HttpHeaders.createOptimized("Authorization"); - public static final CharSequence DATE_HEADER = HttpHeaders.createOptimized("Date"); public static final CharSequence CACHE_CONTROL_HEADER = HttpHeaders.createOptimized("Cache-Control"); public static final CharSequence EXPIRES_HEADER = HttpHeaders.createOptimized("Expires"); public static final CharSequence PRAGMA_HEADER = HttpHeaders.createOptimized("Pragma"); public static final CharSequence LOCATION_HEADER = HttpHeaders.createOptimized("Location"); public static final CharSequence CONNECTION_HEADER = HttpHeaders.createOptimized("Connection"); - public static final CharSequence ACCEPT_ENCODING_HEADER = HttpHeaders.createOptimized("Accept-Encoding"); public static final CharSequence CONTENT_ENCODING_HEADER = HttpHeaders.createOptimized("Content-Encoding"); public static final CharSequence X_OPENRTB_VERSION_HEADER = HttpHeaders.createOptimized("x-openrtb-version"); public static final CharSequence X_PREBID_HEADER = HttpHeaders.createOptimized("x-prebid"); private static final Set SENSITIVE_HEADERS = Set.of(AUTHORIZATION_HEADER.toString()); - public static final CharSequence PG_TRX_ID = HttpHeaders.createOptimized("pg-trx-id"); - public static final CharSequence PG_IGNORE_PACING = HttpHeaders.createOptimized("X-Prebid-PG-ignore-pacing"); //the low-entropy client hints public static final CharSequence SAVE_DATA = HttpHeaders.createOptimized("Save-Data"); @@ -85,8 +75,6 @@ public final class HttpUtil { public static final CharSequence SEC_CH_UA_MOBILE = HttpHeaders.createOptimized("Sec-CH-UA-Mobile"); public static final CharSequence SEC_CH_UA_PLATFORM = HttpHeaders.createOptimized("Sec-CH-UA-Platform"); - private static final String BASIC_AUTH_PATTERN = "Basic %s"; - private HttpUtil() { } @@ -138,28 +126,6 @@ public static void addHeaderIfValueIsNotEmpty(MultiMap headers, CharSequence hea } } - public static ZonedDateTime getDateFromHeader(MultiMap headers, String header) { - return getDateFromHeader(headers::get, header); - } - - public static ZonedDateTime getDateFromHeader(CaseInsensitiveMultiMap headers, String header) { - return getDateFromHeader(headers::get, header); - } - - private static ZonedDateTime getDateFromHeader(Function headerGetter, String header) { - final String isoTimeStamp = headerGetter.apply(header); - if (isoTimeStamp == null) { - return null; - } - - try { - return ZonedDateTime.parse(isoTimeStamp); - } catch (Exception e) { - throw new PreBidException( - "%s header is not compatible to ISO-8601 format: %s".formatted(header, isoTimeStamp)); - } - } - public static String getHostFromUrl(String url) { if (StringUtils.isBlank(url)) { return null; @@ -196,20 +162,22 @@ public static String createCookiesHeader(RoutingContext routingContext) { .collect(Collectors.joining("; ")); } - public static boolean executeSafely(RoutingContext routingContext, Endpoint endpoint, + public static boolean executeSafely(RoutingContext routingContext, + Endpoint endpoint, Consumer responseConsumer) { + return executeSafely(routingContext, endpoint.value(), responseConsumer); } - public static boolean executeSafely(RoutingContext routingContext, String endpoint, + public static boolean executeSafely(RoutingContext routingContext, + String endpoint, Consumer responseConsumer) { final HttpServerResponse response = routingContext.response(); if (response.closed()) { - conditionalLogger.warn( - "Client already closed connection, response to %s will be skipped".formatted(endpoint), - 0.01); + conditionalLogger + .warn("Client already closed connection, response to %s will be skipped".formatted(endpoint), 0.01); return false; } @@ -222,14 +190,6 @@ public static boolean executeSafely(RoutingContext routingContext, String endpoi } } - /** - * Creates standart basic auth header value - */ - public static String makeBasicAuthHeaderValue(String username, String password) { - return BASIC_AUTH_PATTERN - .formatted(Base64.getEncoder().encodeToString((username + ':' + password).getBytes())); - } - /** * Converts {@link MultiMap} headers format to Map, where keys are headers names and values are lists * of header's values diff --git a/src/main/java/org/prebid/server/util/LineItemUtil.java b/src/main/java/org/prebid/server/util/LineItemUtil.java deleted file mode 100644 index 37d89040e3c..00000000000 --- a/src/main/java/org/prebid/server/util/LineItemUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.prebid.server.util; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; -import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; - -import java.util.List; -import java.util.Objects; - -public class LineItemUtil { - - private static final Logger logger = LoggerFactory.getLogger(LineItemUtil.class); - - private LineItemUtil() { - } - - /** - * Extracts line item ID from the given {@link Bid}. - */ - public static String lineItemIdFrom(Bid bid, List imps, JacksonMapper mapper) { - if (StringUtils.isEmpty(bid.getDealid())) { - return null; - } - final ExtDealLine extDealLine = extDealLineFrom(bid, imps, mapper); - return extDealLine != null ? extDealLine.getLineItemId() : null; - } - - private static ExtDealLine extDealLineFrom(Bid bid, List imps, JacksonMapper mapper) { - final Imp correspondingImp = imps.stream() - .filter(imp -> Objects.equals(imp.getId(), bid.getImpid())) - .findFirst() - .orElse(null); - return correspondingImp != null ? extDealLineFrom(bid, correspondingImp, mapper) : null; - } - - public static ExtDealLine extDealLineFrom(Bid bid, Imp imp, JacksonMapper mapper) { - if (StringUtils.isEmpty(bid.getDealid())) { - return null; - } - - final Pmp pmp = imp.getPmp(); - final List deals = pmp != null ? pmp.getDeals() : null; - return CollectionUtils.isEmpty(deals) - ? null - : deals.stream() - .filter(Objects::nonNull) - .filter(deal -> Objects.equals(deal.getId(), bid.getDealid())) // find deal by ID - .map(Deal::getExt) - .filter(Objects::nonNull) - .map((ObjectNode ext) -> dealExt(ext, mapper)) - .filter(Objects::nonNull) - .map(ExtDeal::getLine) - .findFirst() - .orElse(null); - } - - private static ExtDeal dealExt(JsonNode ext, JacksonMapper mapper) { - try { - return mapper.mapper().treeToValue(ext, ExtDeal.class); - } catch (JsonProcessingException e) { - logger.warn("Error decoding deal.ext: {0}", e, e.getMessage()); - return null; - } - } -} diff --git a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java index 353f4389a14..e3e405cb710 100644 --- a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java +++ b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java @@ -1,30 +1,22 @@ package org.prebid.server.validation; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; import com.iab.openrtb.request.Site; import com.iab.openrtb.response.Bid; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.BidderAliases; import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountAuctionConfig; @@ -33,15 +25,11 @@ import org.prebid.server.validation.model.ValidationResult; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Currency; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Validator for response {@link Bid} object. @@ -58,31 +46,21 @@ public class ResponseBidValidator { private static final String[] INSECURE_MARKUP_MARKERS = {"http:", "http%3A"}; private static final String[] SECURE_MARKUP_MARKERS = {"https:", "https%3A"}; - private static final String PREBID_EXT = "prebid"; - private static final String BIDDER_EXT = "bidder"; - private static final String DEALS_ONLY = "dealsonly"; - private final BidValidationEnforcement bannerMaxSizeEnforcement; private final BidValidationEnforcement secureMarkupEnforcement; private final Metrics metrics; - private final JacksonMapper mapper; - private final boolean dealsEnabled; private final double logSamplingRate; public ResponseBidValidator(BidValidationEnforcement bannerMaxSizeEnforcement, BidValidationEnforcement secureMarkupEnforcement, Metrics metrics, - JacksonMapper mapper, - boolean dealsEnabled, double logSamplingRate) { this.bannerMaxSizeEnforcement = Objects.requireNonNull(bannerMaxSizeEnforcement); this.secureMarkupEnforcement = Objects.requireNonNull(secureMarkupEnforcement); this.metrics = Objects.requireNonNull(metrics); - this.mapper = Objects.requireNonNull(mapper); - this.dealsEnabled = dealsEnabled; this.logSamplingRate = logSamplingRate; } @@ -106,10 +84,6 @@ public ValidationResult validate(BidderBid bidderBid, warnings.addAll(validateBannerFields(bid, bidder, bidRequest, account, correspondingImp, aliases)); } - if (dealsEnabled) { - validateDealsFor(bidderBid, bidRequest, bidder, aliases, warnings); - } - warnings.addAll(validateSecureMarkup(bid, bidder, bidRequest, account, correspondingImp, aliases)); } catch (ValidationException e) { return ValidationResult.error(warnings, e.getMessage()); @@ -280,9 +254,9 @@ private static boolean markupIsNotSecure(String adm) { } private List singleWarningOrValidationException(BidValidationEnforcement enforcement, - Consumer metricsRecorder, - ConditionalLogger conditionalLogger, - String message) throws ValidationException { + Consumer metricsRecorder, + ConditionalLogger conditionalLogger, + String message) throws ValidationException { return switch (enforcement) { case enforce -> { metricsRecorder.accept(MetricName.err); @@ -302,165 +276,4 @@ private static String getReferer(BidRequest bidRequest) { final Site site = bidRequest.getSite(); return site != null ? site.getPage() : "unknown"; } - - private void validateDealsFor(BidderBid bidderBid, - BidRequest bidRequest, - String bidder, - BidderAliases aliases, - List warnings) throws ValidationException { - - final Bid bid = bidderBid.getBid(); - final String bidId = bid.getId(); - - final Imp imp = bidRequest.getImp().stream() - .filter(curImp -> Objects.equals(curImp.getId(), bid.getImpid())) - .findFirst() - .orElseThrow(() -> new ValidationException("Bid \"%s\" has no corresponding imp in request", bidId)); - - final String dealId = bid.getDealid(); - - if (isDealsOnlyImp(imp, bidder) && dealId == null) { - throw new ValidationException("Bid \"%s\" missing required field 'dealid'", bidId); - } - - if (dealId != null) { - final Set dealIdsFromImp = getDealIdsFromImp(imp, bidder, aliases); - if (CollectionUtils.isNotEmpty(dealIdsFromImp) && !dealIdsFromImp.contains(dealId)) { - warnings.add(""" - WARNING: Bid "%s" has 'dealid' not present in corresponding imp in request. \ - 'dealid' in bid: '%s', deal Ids in imp: '%s'""" - .formatted(bidId, dealId, String.join(",", dealIdsFromImp))); - } - if (bidderBid.getType() == BidType.banner) { - if (imp.getBanner() == null) { - throw new ValidationException(""" - Bid "%s" has banner media type but corresponding imp \ - in request is missing 'banner' object""", - bidId); - } - - final List bannerFormats = getBannerFormats(imp); - if (bidSizeNotInFormats(bid, bannerFormats)) { - throw new ValidationException(""" - Bid "%s" has 'w' and 'h' not supported by corresponding imp in \ - request. Bid dimensions: '%dx%d', formats in imp: '%s'""", - bidId, - bid.getW(), - bid.getH(), - formatSizes(bannerFormats)); - } - - if (isPgDeal(imp, dealId)) { - validateIsInLineItemSizes(bid, bidId, dealId, imp); - } - } - } - } - - private void validateIsInLineItemSizes(Bid bid, String bidId, String dealId, Imp imp) throws ValidationException { - final List lineItemSizes = getLineItemSizes(imp, dealId); - if (lineItemSizes.isEmpty()) { - throw new ValidationException( - "Line item sizes were not found for bidId %s and dealId %s", bid.getId(), dealId); - } - - if (bidSizeNotInFormats(bid, lineItemSizes)) { - throw new ValidationException( - """ - Bid "%s" has 'w' and 'h' not matched to Line Item. \ - Bid dimensions: '%dx%d', Line Item sizes: '%s'""", - bidId, bid.getW(), bid.getH(), formatSizes(lineItemSizes)); - } - } - - private static boolean isDealsOnlyImp(Imp imp, String bidder) { - final JsonNode dealsOnlyNode = bidderParamsFromImp(imp).path(bidder).path(DEALS_ONLY); - return dealsOnlyNode.isBoolean() && dealsOnlyNode.asBoolean(); - } - - private static JsonNode bidderParamsFromImp(Imp imp) { - return imp.getExt().path(PREBID_EXT).path(BIDDER_EXT); - } - - private Set getDealIdsFromImp(Imp imp, String bidder, BidderAliases aliases) { - return getDeals(imp) - .filter(Objects::nonNull) - .filter(deal -> isBidderHasDeal(bidder, dealExt(deal.getExt()), aliases)) - .map(Deal::getId) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); - } - - private static Stream getDeals(Imp imp) { - final Pmp pmp = imp.getPmp(); - return pmp != null ? pmp.getDeals().stream() : Stream.empty(); - } - - private static boolean isBidderHasDeal(String bidder, ExtDeal extDeal, BidderAliases aliases) { - final ExtDealLine extDealLine = extDeal != null ? extDeal.getLine() : null; - final String dealLineBidder = extDealLine != null ? extDealLine.getBidder() : null; - return dealLineBidder == null || aliases.isSame(bidder, dealLineBidder); - } - - private static boolean bidSizeNotInFormats(Bid bid, List formats) { - return formats.stream() - .noneMatch(format -> sizesEqual(bid, format)); - } - - private static boolean sizesEqual(Bid bid, Format format) { - return Objects.equals(format.getH(), bid.getH()) && Objects.equals(format.getW(), bid.getW()); - } - - private static List getBannerFormats(Imp imp) { - return ListUtils.emptyIfNull(imp.getBanner().getFormat()); - } - - private List getLineItemSizes(Imp imp, String dealId) { - return getDeals(imp) - .filter(deal -> dealId.equals(deal.getId())) - .map(Deal::getExt) - .filter(Objects::nonNull) - .map(this::dealExt) - .filter(Objects::nonNull) - .map(ExtDeal::getLine) - .filter(Objects::nonNull) - .map(ExtDealLine::getSizes) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .toList(); - } - - private boolean isPgDeal(Imp imp, String dealId) { - return getDeals(imp) - .filter(Objects::nonNull) - .filter(deal -> Objects.equals(deal.getId(), dealId)) - .map(Deal::getExt) - .filter(Objects::nonNull) - .map(this::dealExt) - .filter(Objects::nonNull) - .map(ExtDeal::getLine) - .filter(Objects::nonNull) - .map(ExtDealLine::getLineItemId) - .anyMatch(Objects::nonNull); - } - - private ExtDeal dealExt(JsonNode ext) { - try { - return mapper.mapper().treeToValue(ext, ExtDeal.class); - } catch (JsonProcessingException e) { - logger.warn("Error decoding deal.ext: {0}", e, e.getMessage()); - return null; - } - } - - private static String formatSizes(List lineItemSizes) { - return lineItemSizes.stream() - .map(ResponseBidValidator::formatSize) - .collect(Collectors.joining(",")); - } - - private static String formatSize(Format lineItemSize) { - return "%dx%d".formatted(lineItemSize.getW(), lineItemSize.getH()); - } } diff --git a/src/main/java/org/prebid/server/vast/VastModifier.java b/src/main/java/org/prebid/server/vast/VastModifier.java index d5896db41af..51721bf9627 100644 --- a/src/main/java/org/prebid/server/vast/VastModifier.java +++ b/src/main/java/org/prebid/server/vast/VastModifier.java @@ -60,7 +60,6 @@ public JsonNode modifyVastXml(Boolean isEventsEnabled, putObject.getBidid(), bidder, accountId, - null, eventsContext); try { return new TextNode(appendTrackingUrlToVastXml(value.asText(), vastUrlTracking, bidder)); @@ -78,8 +77,8 @@ public String createBidVastXml(String bidder, String eventBidId, String accountId, EventsContext eventsContext, - List debugWarnings, - String lineItemId) { + List debugWarnings) { + if (!bidderCatalog.isModifyingVastXmlAllowed(bidder)) { return bidAdm; } @@ -89,8 +88,7 @@ public String createBidVastXml(String bidder, return vastXml; } - final String vastUrl = eventsService.vastUrlTracking(eventBidId, bidder, - accountId, lineItemId, eventsContext); + final String vastUrl = eventsService.vastUrlTracking(eventBidId, bidder, accountId, eventsContext); try { return appendTrackingUrlToVastXml(vastXml, vastUrl, bidder); } catch (PreBidException e) { diff --git a/src/main/java/org/prebid/server/vertx/LocalMessageCodec.java b/src/main/java/org/prebid/server/vertx/LocalMessageCodec.java deleted file mode 100644 index 302dcb11eff..00000000000 --- a/src/main/java/org/prebid/server/vertx/LocalMessageCodec.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.prebid.server.vertx; - -import io.vertx.core.buffer.Buffer; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.MessageCodec; - -/** - * Message codec intended for use with objects passed around via {@link EventBus} only locally, i.e. within one JVM. - */ -public class LocalMessageCodec implements MessageCodec { - - private static final String CODEC_NAME = "LocalMessageCodec"; - - public static MessageCodec create() { - return new LocalMessageCodec(); - } - - @Override - public void encodeToWire(Buffer buffer, Object source) { - throw new UnsupportedOperationException("Serialization is not supported by this message codec"); - } - - @Override - public Object decodeFromWire(int pos, Buffer buffer) { - throw new UnsupportedOperationException("Deserialization is not supported by this message codec"); - } - - @Override - public Object transform(Object source) { - return source; - } - - @Override - public String name() { - return codecName(); - } - - @Override - public byte systemCodecID() { - return -1; - } - - public static String codecName() { - return CODEC_NAME; - } -} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 14b64b0cb1e..af936e77b8a 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -67,21 +67,6 @@ admin-endpoints: path: /pbs-admin/tracelog on-application-port: false protected: true - deals-status: - enabled: false - path: /pbs-admin/deals-status - on-application-port: false - protected: true - lineitem-status: - enabled: false - path: /pbs-admin/lineitem-status - on-application-port: false - protected: true - force-deals-update: - enabled: false - path: /pbs-admin/force-deals-update - on-application-port: false - protected: true e2eadmin: enabled: false path: /pbs-admin/e2eAdmin/* diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/alert/Action.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/alert/Action.groovy deleted file mode 100644 index 8760760c00a..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/alert/Action.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.functional.model.deals.alert - -enum Action { - - RAISE -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertEvent.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertEvent.groovy deleted file mode 100644 index 596b7221c46..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertEvent.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.prebid.server.functional.model.deals.alert - -import com.fasterxml.jackson.databind.PropertyNamingStrategies -import com.fasterxml.jackson.databind.annotation.JsonNaming -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy) -class AlertEvent { - - String id - Action action - AlertPriority priority - ZonedDateTime updatedAt - String name - String details - AlertSource source -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertPriority.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertPriority.groovy deleted file mode 100644 index 502b2d5eb25..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertPriority.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.functional.model.deals.alert - -enum AlertPriority { - - HIGH, MEDIUM, LOW -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertSource.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertSource.groovy deleted file mode 100644 index 3175711c4be..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/alert/AlertSource.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.functional.model.deals.alert - -import com.fasterxml.jackson.databind.PropertyNamingStrategies -import com.fasterxml.jackson.databind.annotation.JsonNaming -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy) -class AlertSource { - - String env - String dataCenter - String region - String system - String subSystem - String hostId -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/DeliverySchedule.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/DeliverySchedule.groovy deleted file mode 100644 index 8b59632171b..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/DeliverySchedule.groovy +++ /dev/null @@ -1,37 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonFormat -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static org.prebid.server.functional.model.deals.lineitem.LineItem.TIME_PATTERN - -@ToString(includeNames = true, ignoreNulls = true) -class DeliverySchedule { - - String planId - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime startTimeStamp - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime endTimeStamp - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime updatedTimeStamp - - Set tokens - - static getDefaultDeliverySchedule() { - new DeliverySchedule(planId: PBSUtils.randomString, - startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusDays(1), - updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - tokens: [Token.defaultToken] - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/FrequencyCap.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/FrequencyCap.groovy deleted file mode 100644 index 995ae1b9309..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/FrequencyCap.groovy +++ /dev/null @@ -1,23 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -import static PeriodType.DAY - -@ToString(includeNames = true, ignoreNulls = true) -class FrequencyCap { - - String fcapId - Integer count - Integer periods - String periodType - - static getDefaultFrequencyCap() { - new FrequencyCap(count: 1, - fcapId: PBSUtils.randomString, - periods: 1, - periodType: DAY - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItem.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItem.groovy deleted file mode 100644 index 43051f0ab50..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItem.groovy +++ /dev/null @@ -1,74 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonFormat -import groovy.transform.ToString -import org.prebid.server.functional.model.deals.lineitem.targeting.Targeting -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static LineItemStatus.ACTIVE -import static java.time.ZoneOffset.UTC -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_HIGH - -@ToString(includeNames = true, ignoreNulls = true) -class LineItem { - - public static final String TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'" - - String lineItemId - - String extLineItemId - - String dealId - - List sizes - - String accountId - - String source - - Price price - - RelativePriority relativePriority - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime startTimeStamp - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime endTimeStamp - - @JsonFormat(pattern = TIME_PATTERN) - ZonedDateTime updatedTimeStamp - - LineItemStatus status - - List frequencyCaps - - List deliverySchedules - - Targeting targeting - - static LineItem getDefaultLineItem(String accountId) { - int plannerAdapterLineItemId = PBSUtils.randomNumber - String plannerAdapterName = PBSUtils.randomString - new LineItem(lineItemId: "${plannerAdapterName}-$plannerAdapterLineItemId", - extLineItemId: plannerAdapterLineItemId, - dealId: PBSUtils.randomString, - sizes: [LineItemSize.defaultLineItemSize], - accountId: accountId, - source: GENERIC.name().toLowerCase(), - price: Price.defaultPrice, - relativePriority: VERY_HIGH, - startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusMonths(1), - updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - status: ACTIVE, - frequencyCaps: [], - deliverySchedules: [DeliverySchedule.defaultDeliverySchedule], - targeting: Targeting.defaultTargeting - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemSize.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemSize.groovy deleted file mode 100644 index 2ff7af18dec..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemSize.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import groovy.transform.ToString - -@ToString(includeNames = true) -class LineItemSize { - - Integer w - Integer h - - static getDefaultLineItemSize() { - new LineItemSize(w: 300, - h: 250 - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemStatus.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemStatus.groovy deleted file mode 100644 index c2dded2d3d2..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/LineItemStatus.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonValue - -enum LineItemStatus { - - ACTIVE("active"), - DELETED("deleted"), - PAUSED("paused") - - @JsonValue - final String value - - private LineItemStatus(String value) { - this.value = value - } - - @Override - String toString() { - value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/MediaType.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/MediaType.groovy deleted file mode 100644 index 949da3d9b53..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/MediaType.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonValue - -enum MediaType { - - BANNER("banner") - - @JsonValue - final String value - - private MediaType(String value) { - this.value = value - } - - @Override - String toString() { - value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/PeriodType.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/PeriodType.groovy deleted file mode 100644 index 10ca6f59d9c..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/PeriodType.groovy +++ /dev/null @@ -1,24 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonValue - -enum PeriodType { - - HOUR("hour"), - DAY("day"), - WEEK("week"), - MONTH("month"), - CAMPAIGN("campaign") - - @JsonValue - final String value - - private PeriodType(String value) { - this.value = value - } - - @Override - String toString() { - value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Price.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Price.groovy deleted file mode 100644 index 5c0bb616ed6..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Price.groovy +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -@ToString(includeNames = true, ignoreNulls = true) -class Price { - - BigDecimal cpm - String currency - - static getDefaultPrice() { - new Price(cpm: PBSUtils.randomPrice, currency: "USD") - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/RelativePriority.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/RelativePriority.groovy deleted file mode 100644 index 911da0b365f..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/RelativePriority.groovy +++ /dev/null @@ -1,24 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonValue - -enum RelativePriority { - - VERY_HIGH(1), - HIGH(2), - MEDIUM(3), - LOW(4), - VERY_LOW(5) - - @JsonValue - final Integer value - - private RelativePriority(Integer value) { - this.value = value - } - - @Override - String toString() { - value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Token.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Token.groovy deleted file mode 100644 index e7dd3f2fc5d..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/Token.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem - -import com.fasterxml.jackson.annotation.JsonProperty -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class Token { - - @JsonProperty("class") - Integer priorityClass - - Integer total - - static getDefaultToken() { - new Token(priorityClass: 1, - total: 1000 - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/BooleanOperator.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/BooleanOperator.groovy deleted file mode 100644 index 0e4a4740e53..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/BooleanOperator.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue - -enum BooleanOperator { - - AND('$and'), - OR('$or'), - NOT('$not'), - - INVALID('$invalid'), - UPPERCASE_AND('$AND') - - @JsonValue - final String value - - private BooleanOperator(String value) { - this.value = value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunction.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunction.groovy deleted file mode 100644 index 54a1353808e..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunction.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue - -enum MatchingFunction { - - MATCHES('$matches'), - IN('$in'), - INTERSECTS('$intersects'), - WITHIN('$within') - - @JsonValue - final String value - - private MatchingFunction(String value) { - this.value = value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunctionNode.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunctionNode.groovy deleted file mode 100644 index 6e639fe4383..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/MatchingFunctionNode.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue -import groovy.transform.PackageScope - -@PackageScope -class MatchingFunctionNode { - - Map> matchingFunctionMultipleValuesNode - - Map matchingFunctionSingleValueNode - - @JsonValue - def getMatchingFunctionNode() { - matchingFunctionMultipleValuesNode ?: matchingFunctionSingleValueNode - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/Targeting.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/Targeting.groovy deleted file mode 100644 index 12c9633cbaf..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/Targeting.groovy +++ /dev/null @@ -1,92 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue -import org.prebid.server.functional.model.deals.lineitem.LineItemSize - -import static BooleanOperator.AND -import static MatchingFunction.INTERSECTS -import static TargetingType.AD_UNIT_MEDIA_TYPE -import static TargetingType.AD_UNIT_SIZE -import static org.prebid.server.functional.model.deals.lineitem.MediaType.BANNER -import static org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator.NOT -import static org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator.OR - -class Targeting { - - private final Map> rootNode - - private final Map singleTargetingRootNode - - @JsonValue - def getSerializableRootNode() { - rootNode ?: singleTargetingRootNode - } - - private Targeting(Builder builder) { - rootNode = [(builder.rootOperator): builder.targetingNodes] - } - - private Targeting(Builder builder, TargetingNode targetingNode) { - singleTargetingRootNode = [(builder.rootOperator): targetingNode] - } - - Map> getTargetingRootNode() { - rootNode.asImmutable() - } - - static Targeting getDefaultTargeting() { - defaultTargetingBuilder.build() - } - - static Builder getDefaultTargetingBuilder() { - new Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [BANNER]) - } - - static Targeting getInvalidTwoRootNodesTargeting() { - defaultTargeting.tap { rootNode.put(OR, []) } - } - - static class Builder { - - private BooleanOperator rootOperator - private List targetingNodes = [] - - Builder(BooleanOperator rootOperator = AND) { - this.rootOperator = rootOperator - } - - Builder addTargeting(TargetingType targetingType, - MatchingFunction matchingFunction, - List targetingValues) { - MatchingFunctionNode matchingFunctionNode = new MatchingFunctionNode(matchingFunctionMultipleValuesNode: [(matchingFunction): targetingValues]) - addTargetingNode(targetingType, matchingFunctionNode) - this - } - - Builder addTargeting(TargetingType targetingType, - MatchingFunction matchingFunction, - Object targetingValue) { - MatchingFunctionNode matchingFunctionNode = new MatchingFunctionNode(matchingFunctionSingleValueNode: [(matchingFunction): targetingValue]) - addTargetingNode(targetingType, matchingFunctionNode) - this - } - - private void addTargetingNode(TargetingType targetingType, - MatchingFunctionNode matchingFunctionNode) { - targetingNodes << new TargetingNode([(targetingType): matchingFunctionNode]) - } - - Targeting build() { - new Targeting(this) - } - - Targeting buildNotBooleanOperatorTargeting(TargetingType targetingType, - MatchingFunction matchingFunction, - List targetingValues) { - rootOperator = NOT - MatchingFunctionNode matchingFunctionNode = new MatchingFunctionNode(matchingFunctionSingleValueNode: [(matchingFunction): targetingValues]) - new Targeting(this, new TargetingNode([(targetingType): matchingFunctionNode])) - } - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingNode.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingNode.groovy deleted file mode 100644 index 4e8ccecd318..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingNode.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue -import groovy.transform.PackageScope -import groovy.transform.TupleConstructor - -@PackageScope -@TupleConstructor -class TargetingNode { - - @JsonValue - Map targetingNode -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingType.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingType.groovy deleted file mode 100644 index 5434d38a59a..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/lineitem/targeting/TargetingType.groovy +++ /dev/null @@ -1,46 +0,0 @@ -package org.prebid.server.functional.model.deals.lineitem.targeting - -import com.fasterxml.jackson.annotation.JsonValue - -enum TargetingType { - - AD_UNIT_SIZE("adunit.size"), - AD_UNIT_MEDIA_TYPE("adunit.mediatype"), - AD_UNIT_AD_SLOT("adunit.adslot"), - SITE_DOMAIN("site.domain"), - SITE_PUBLISHER_DOMAIN("site.publisher.domain"), - REFERRER("site.referrer"), - APP_BUNDLE("app.bundle"), - DEVICE_COUNTRY("device.geo.ext.geoprovider.country"), - DEVICE_TYPE("device.ext.deviceinfoprovider.type"), - DEVICE_OS("device.ext.deviceinfoprovider.osfamily"), - DEVICE_REGION("device.geo.ext.geoprovider.region"), - DEVICE_METRO("device.geo.ext.geoprovider.metro"), - PAGE_POSITION("pos"), - LOCATION("geo.distance"), - BIDP("bidp."), - BIDP_ACCOUNT_ID(BIDP.value + "rubicon.accountId"), - USER_SEGMENT("segment."), - USER_SEGMENT_NAME(USER_SEGMENT.value + "name"), - UFPD("ufpd."), - UFPD_KEYWORDS(UFPD.value + "keywords"), - UFPD_BUYER_UID(UFPD.value + "buyeruid"), - UFPD_BUYER_UIDS(UFPD.value + "buyeruids"), - UFPD_YOB(UFPD.value + "yob"), - SFPD("sfpd."), - SFPD_AMP(SFPD.value + "amp"), - SFPD_LANGUAGE(SFPD.value + "language"), - SFPD_KEYWORDS(SFPD.value + "keywords"), - SFPD_BUYER_ID(SFPD.value + "buyerid"), - SFPD_BUYER_IDS(SFPD.value + "buyerids"), - DOW("user.ext.time.userdow"), - HOUR("user.ext.time.userhour"), - INVALID("invalid.targeting.type") - - @JsonValue - final String value - - private TargetingType(String value) { - this.value = value - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/register/CurrencyServiceState.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/register/CurrencyServiceState.groovy deleted file mode 100644 index 4c0db24acd3..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/register/CurrencyServiceState.groovy +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.functional.model.deals.register - -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class CurrencyServiceState { - - ZonedDateTime lastUpdate -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/register/RegisterRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/register/RegisterRequest.groovy deleted file mode 100644 index 75daf33adc3..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/register/RegisterRequest.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.functional.model.deals.register - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class RegisterRequest { - - BigDecimal healthIndex - Status status - String hostInstanceId - String region - String vendor -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/register/Status.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/register/Status.groovy deleted file mode 100644 index ad065e9ac4a..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/register/Status.groovy +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.functional.model.deals.register - -import groovy.transform.ToString -import org.prebid.server.functional.model.deals.report.DeliveryStatisticsReport - -@ToString(includeNames = true, ignoreNulls = true) -class Status { - - CurrencyServiceState currencyRates - DeliveryStatisticsReport dealsStatus -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliverySchedule.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliverySchedule.groovy deleted file mode 100644 index 5701757e569..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliverySchedule.groovy +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class DeliverySchedule { - - String planId - ZonedDateTime planStartTimeStamp - ZonedDateTime planExpirationTimeStamp - ZonedDateTime planUpdatedTimeStamp - Set tokens -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliveryStatisticsReport.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliveryStatisticsReport.groovy deleted file mode 100644 index 5ee7340c3dd..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/DeliveryStatisticsReport.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class DeliveryStatisticsReport { - - String reportId - String instanceId - String vendor - String region - Long clientAuctions - Set lineItemStatus - ZonedDateTime reportTimeStamp - ZonedDateTime dataWindowStartTimeStamp - ZonedDateTime dataWindowEndTimeStamp -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/Event.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/Event.groovy deleted file mode 100644 index 495bfaf673e..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/Event.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class Event { - - String type - Long count -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatus.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatus.groovy deleted file mode 100644 index a68029852c6..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatus.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class LineItemStatus { - - String lineItemSource - String lineItemId - String dealId - String extLineItemId - Long accountAuctions - Long domainMatched - Long targetMatched - Long targetMatchedButFcapped - Long targetMatchedButFcapLookupFailed - Long pacingDeferred - Long sentToBidder - Long sentToBidderAsTopMatch - Long receivedFromBidder - Long receivedFromBidderInvalidated - Long sentToClient - Long sentToClientAsTopMatch - Set lostToLineItems - Set events - Set deliverySchedule - String readyAt - Long spentTokens - Long pacingFrequency -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatusReport.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatusReport.groovy deleted file mode 100644 index 6fb1766c534..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/LineItemStatusReport.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class LineItemStatusReport { - - String lineItemId - DeliverySchedule deliverySchedule - Long spentTokens - ZonedDateTime readyToServeTimestamp - Long pacingFrequency - String accountId - Map target -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/LostToLineItem.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/LostToLineItem.groovy deleted file mode 100644 index 58567ffc974..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/LostToLineItem.groovy +++ /dev/null @@ -1,11 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class LostToLineItem { - - String lineItemSource - String lineItemId - Long count -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/report/Token.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/report/Token.groovy deleted file mode 100644 index 89310a5d73e..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/report/Token.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package org.prebid.server.functional.model.deals.report - -import com.fasterxml.jackson.annotation.JsonProperty -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class Token { - - @JsonProperty("class") - Integer priorityClass - - Integer total - - Long spent - - Long totalSpent -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/Segment.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/Segment.groovy deleted file mode 100644 index f11d8f32ff1..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/Segment.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -@ToString(includeNames = true, ignoreNulls = true) -class Segment { - - String id - - static getDefaultSegment() { - new Segment(id: PBSUtils.randomString) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/User.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/User.groovy deleted file mode 100644 index 6d2e527a0e6..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/User.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class User { - - List data - UserExt ext - - static getDefaultUser() { - new User(data: [UserData.defaultUserData], - ext: UserExt.defaultUserExt - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserData.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserData.groovy deleted file mode 100644 index 5687d89285e..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserData.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -@ToString(includeNames = true, ignoreNulls = true) -class UserData { - - String id - String name - List segment - - static UserData getDefaultUserData() { - new UserData(id: PBSUtils.randomString, - name: PBSUtils.randomString, - segment: [Segment.defaultSegment] - ) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetails.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetails.groovy deleted file mode 100644 index 780ec674b24..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetails.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class UserDetails { - - List userData - List fcapIds -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsRequest.groovy deleted file mode 100644 index 74985c5808f..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsRequest.groovy +++ /dev/null @@ -1,12 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class UserDetailsRequest { - - ZonedDateTime time - List ids -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsResponse.groovy deleted file mode 100644 index 143aee234d9..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserDetailsResponse.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString -import org.prebid.server.functional.model.ResponseModel - -@ToString(includeNames = true, ignoreNulls = true) -class UserDetailsResponse implements ResponseModel { - - User user - - static UserDetailsResponse getDefaultUserResponse(User user = User.defaultUser) { - new UserDetailsResponse(user: user) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserExt.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserExt.groovy deleted file mode 100644 index 53a89aa97e2..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserExt.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString -import org.prebid.server.functional.util.PBSUtils - -@ToString(includeNames = true, ignoreNulls = true) -class UserExt { - - List fcapIds - - static getDefaultUserExt() { - new UserExt(fcapIds: [PBSUtils.randomString]) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserId.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserId.groovy deleted file mode 100644 index 8edeac5336d..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/UserId.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString - -@ToString(includeNames = true, ignoreNulls = true) -class UserId { - - String type - String id -} diff --git a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/WinEventNotification.groovy b/src/test/groovy/org/prebid/server/functional/model/deals/userdata/WinEventNotification.groovy deleted file mode 100644 index bea8f7c296b..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/deals/userdata/WinEventNotification.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.functional.model.deals.userdata - -import groovy.transform.ToString -import org.prebid.server.functional.model.deals.lineitem.FrequencyCap - -import java.time.ZonedDateTime - -@ToString(includeNames = true, ignoreNulls = true) -class WinEventNotification { - - String bidderCode - String bidId - String lineItemId - String region - List userIds - ZonedDateTime winEventDateTime - ZonedDateTime lineUpdatedDateTime - List frequencyCaps -} diff --git a/src/test/groovy/org/prebid/server/functional/model/mock/services/generalplanner/PlansResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/mock/services/generalplanner/PlansResponse.groovy deleted file mode 100644 index f9a9d4548e7..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/mock/services/generalplanner/PlansResponse.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package org.prebid.server.functional.model.mock.services.generalplanner - -import com.fasterxml.jackson.annotation.JsonValue -import org.prebid.server.functional.model.ResponseModel -import org.prebid.server.functional.model.deals.lineitem.LineItem - -class PlansResponse implements ResponseModel { - - List lineItems - - static PlansResponse getDefaultPlansResponse(String accountId) { - new PlansResponse(lineItems: [LineItem.getDefaultLineItem(accountId)]) - } - - @JsonValue - List getLineItems() { - lineItems - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/dealsupdate/ForceDealsUpdateRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/request/dealsupdate/ForceDealsUpdateRequest.groovy deleted file mode 100644 index aaa1c0b2ece..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/request/dealsupdate/ForceDealsUpdateRequest.groovy +++ /dev/null @@ -1,48 +0,0 @@ -package org.prebid.server.functional.model.request.dealsupdate - -import com.fasterxml.jackson.databind.PropertyNamingStrategies -import com.fasterxml.jackson.databind.annotation.JsonNaming -import groovy.transform.ToString - -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.CREATE_REPORT -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.INVALIDATE_LINE_ITEMS -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.REGISTER_INSTANCE -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.RESET_ALERT_COUNT -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.SEND_REPORT -import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.UPDATE_LINE_ITEMS - -@ToString(includeNames = true, ignoreNulls = true) -@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy) -class ForceDealsUpdateRequest { - - String actionName - - static ForceDealsUpdateRequest getUpdateLineItemsRequest() { - new ForceDealsUpdateRequest(actionName: UPDATE_LINE_ITEMS.name()) - } - - static ForceDealsUpdateRequest getSendReportRequest() { - new ForceDealsUpdateRequest(actionName: SEND_REPORT.name()) - } - - static ForceDealsUpdateRequest getRegisterInstanceRequest() { - new ForceDealsUpdateRequest(actionName: REGISTER_INSTANCE.name()) - } - - static ForceDealsUpdateRequest getResetAlertCountRequest() { - new ForceDealsUpdateRequest(actionName: RESET_ALERT_COUNT.name()) - } - - static ForceDealsUpdateRequest getCreateReportRequest() { - new ForceDealsUpdateRequest(actionName: CREATE_REPORT.name()) - } - - static ForceDealsUpdateRequest getInvalidateLineItemsRequest() { - new ForceDealsUpdateRequest(actionName: INVALIDATE_LINE_ITEMS.name()) - } - - private enum Action { - - UPDATE_LINE_ITEMS, SEND_REPORT, REGISTER_INSTANCE, RESET_ALERT_COUNT, CREATE_REPORT, INVALIDATE_LINE_ITEMS - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/event/EventRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/request/event/EventRequest.groovy index 9d7000cb7b3..6ed94f08161 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/event/EventRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/event/EventRequest.groovy @@ -24,8 +24,6 @@ class EventRequest { Integer analytics @JsonProperty("ts") Long timestamp - @JsonProperty("l") - String lineItemId static EventRequest getDefaultEventRequest() { def request = new EventRequest() diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy index caae943a322..99e37de76ab 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy @@ -5,7 +5,6 @@ import groovy.transform.ToString import org.prebid.server.functional.model.Currency import org.prebid.server.functional.model.ResponseModel import org.prebid.server.functional.model.bidder.BidderName -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse import org.prebid.server.functional.model.request.auction.BidRequest import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -29,16 +28,4 @@ class BidResponse implements ResponseModel { bidResponse.seatbid = [seatBid] bidResponse } - - static BidResponse getDefaultPgBidResponse(BidRequest bidRequest, PlansResponse plansResponse) { - def bidResponse = getDefaultBidResponse(bidRequest) - def bid = bidResponse.seatbid[0].bid[0] - def lineItem = plansResponse.lineItems[0] - bid.dealid = lineItem.dealId - if (lineItem.sizes) { - bid.w = lineItem.sizes[0].w - bid.h = lineItem.sizes[0].h - } - bidResponse - } } diff --git a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy index 8a1eceb6f87..ca9efffb62a 100644 --- a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy +++ b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy @@ -8,12 +8,10 @@ import io.restassured.response.Response import io.restassured.specification.RequestSpecification import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.model.bidder.BidderName -import org.prebid.server.functional.model.deals.report.LineItemStatusReport import org.prebid.server.functional.model.mock.services.prebidcache.response.PrebidCacheResponse import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest import org.prebid.server.functional.model.request.event.EventRequest import org.prebid.server.functional.model.request.logging.httpinteraction.HttpInteractionRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest @@ -58,8 +56,6 @@ class PrebidServerService implements ObjectMapperWrapper { static final String CURRENCY_RATES_ENDPOINT = "/currency/rates" static final String HTTP_INTERACTION_ENDPOINT = "/logging/httpinteraction" static final String COLLECTED_METRICS_ENDPOINT = "/collected-metrics" - static final String FORCE_DEALS_UPDATE_ENDPOINT = "/pbs-admin/force-deals-update" - static final String LINE_ITEM_STATUS_ENDPOINT = "/pbs-admin/lineitem-status" static final String PROMETHEUS_METRICS_ENDPOINT = "/metrics" static final String UIDS_COOKIE_NAME = "uids" @@ -267,24 +263,6 @@ class PrebidServerService implements ObjectMapperWrapper { decode(response.asString(), new TypeReference>() {}) } - void sendForceDealsUpdateRequest(ForceDealsUpdateRequest forceDealsUpdateRequest) { - def response = given(adminRequestSpecification).queryParams(toMap(forceDealsUpdateRequest)) - .get(FORCE_DEALS_UPDATE_ENDPOINT) - - checkResponseStatusCode(response, 204) - } - - LineItemStatusReport sendLineItemStatusRequest(String lineItemId) { - def request = given(adminRequestSpecification) - if (lineItemId != null) { - request.queryParam("id", lineItemId) - } - - def response = request.get(LINE_ITEM_STATUS_ENDPOINT) - - checkResponseStatusCode(response) - decode(response.body.asString(), LineItemStatusReport) - } String sendPrometheusMetricsRequest() { def response = given(prometheusRequestSpecification).get(PROMETHEUS_METRICS_ENDPOINT) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsPgConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsPgConfig.groovy deleted file mode 100644 index 47de3679541..00000000000 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsPgConfig.groovy +++ /dev/null @@ -1,135 +0,0 @@ -package org.prebid.server.functional.testcontainers - -import org.prebid.server.functional.model.Currency -import org.prebid.server.functional.testcontainers.container.NetworkServiceContainer -import org.prebid.server.functional.util.PBSUtils - -import java.time.LocalDate - -import static org.prebid.server.functional.testcontainers.scaffolding.pg.Alert.ALERT_ENDPOINT_PATH -import static org.prebid.server.functional.testcontainers.scaffolding.pg.DeliveryStatistics.REPORT_DELIVERY_ENDPOINT_PATH -import static org.prebid.server.functional.testcontainers.scaffolding.pg.GeneralPlanner.PLANS_ENDPOINT_PATH -import static org.prebid.server.functional.testcontainers.scaffolding.pg.GeneralPlanner.REGISTER_ENDPOINT_PATH -import static org.prebid.server.functional.testcontainers.scaffolding.pg.UserData.USER_DETAILS_ENDPOINT_PATH -import static org.prebid.server.functional.testcontainers.scaffolding.pg.UserData.WIN_EVENT_ENDPOINT_PATH - -class PbsPgConfig { - - public static final String PG_ENDPOINT_USERNAME = "pg" - public static final String PG_ENDPOINT_PASSWORD = "pg" - - private static final int NEXT_MONTH = LocalDate.now().plusMonths(1).monthValue - - final Map properties - final String env - final String dataCenter - final String region - final String system - final String subSystem - final String hostId - final String vendor - final Currency currency - final String userIdType - final int maxDealsPerBidder - final int lineItemsPerReport - - PbsPgConfig(NetworkServiceContainer networkServiceContainer) { - properties = getPgConfig(networkServiceContainer.rootUri).asImmutable() - env = properties.get("profile") - dataCenter = properties.get("data-center") - region = properties.get("datacenter-region") - system = properties.get("system") - subSystem = properties.get("sub-system") - hostId = properties.get("host-id") - vendor = properties.get("vendor") - currency = properties.get("auction.ad-server-currency") - userIdType = properties.get("deals.user-data.user-ids[0].type") - maxDealsPerBidder = getIntProperty(properties, "deals.max-deals-per-bidder") - lineItemsPerReport = getIntProperty(properties, "deals.delivery-stats.line-items-per-report") - } - - private static Map getPgConfig(String networkServiceContainerUri) { - pbsGeneralSettings() + adminDealsUpdateEndpoint() + deals() + deliveryProgress() + - planner(networkServiceContainerUri) + deliveryStatistics(networkServiceContainerUri) + - alert(networkServiceContainerUri) + userData(networkServiceContainerUri) + adminLineItemStatusEndpoint() - } - - private static Map pbsGeneralSettings() { - ["host-id" : PBSUtils.randomString, - "datacenter-region" : PBSUtils.randomString, - "vendor" : PBSUtils.randomString, - "profile" : PBSUtils.randomString, - "system" : PBSUtils.randomString, - "sub-system" : PBSUtils.randomString, - "data-center" : PBSUtils.randomString, - "auction.ad-server-currency": "USD", - ] - } - - private static Map adminDealsUpdateEndpoint() { - ["admin-endpoints.force-deals-update.enabled": "true"] - } - - private static Map adminLineItemStatusEndpoint() { - ["admin-endpoints.lineitem-status.enabled": "true"] - } - - private static Map deals() { - ["deals.enabled" : "true", - "deals.simulation.enabled" : "false", - "deals.max-deals-per-bidder": "3" - ] - } - - private static Map planner(String networkServiceContainerUri) { - ["deals.planner.plan-endpoint" : networkServiceContainerUri + PLANS_ENDPOINT_PATH, - "deals.planner.register-endpoint" : networkServiceContainerUri + REGISTER_ENDPOINT_PATH, - "deals.planner.update-period" : "0 15 10 15 $NEXT_MONTH ?" as String, - "deals.planner.plan-advance-period": "0 15 10 15 $NEXT_MONTH ?" as String, - "deals.planner.timeout-ms" : "5000", - "deals.planner.username" : PG_ENDPOINT_USERNAME, - "deals.planner.password" : PG_ENDPOINT_PASSWORD, - "deals.planner.register-period-sec": "3600" - ] - } - - private static Map deliveryStatistics(String networkServiceContainerUri) { - ["deals.delivery-stats.endpoint" : networkServiceContainerUri + - REPORT_DELIVERY_ENDPOINT_PATH, - "deals.delivery-stats.username" : PG_ENDPOINT_USERNAME, - "deals.delivery-stats.password" : PG_ENDPOINT_PASSWORD, - "deals.delivery-stats.delivery-period" : "0 15 10 15 $NEXT_MONTH ?" as String, - "deals.delivery-stats.timeout-ms" : "10000", - "deals.delivery-stats.request-compression-enabled": "false", - "deals.delivery-stats.line-items-per-report" : "5" - ] - } - - private static Map deliveryProgress() { - ["deals.delivery-progress.report-reset-period": "0 15 10 15 $NEXT_MONTH ?" as String] - } - - private static Map alert(String networkServiceContainerUri) { - ["deals.alert-proxy.enabled" : "true", - "deals.alert-proxy.url" : networkServiceContainerUri + ALERT_ENDPOINT_PATH, - "deals.alert-proxy.username" : PG_ENDPOINT_USERNAME, - "deals.alert-proxy.password" : PG_ENDPOINT_PASSWORD, - "deals.alert-proxy.timeout-sec": "10" - ] - } - - private static Map userData(String networkServiceContainerUri) { - ["deals.user-data.user-details-endpoint": networkServiceContainerUri + USER_DETAILS_ENDPOINT_PATH, - "deals.user-data.win-event-endpoint" : networkServiceContainerUri + WIN_EVENT_ENDPOINT_PATH, - "deals.user-data.timeout" : "1000", - "deals.user-data.user-ids[0].type" : "autotest", - "deals.user-data.user-ids[0].source" : "uid", - "deals.user-data.user-ids[0].location" : "generic" - ] - } - - private static getIntProperty(Map properties, String propertyName) { - def property = properties.get(propertyName) - property ? property as int : -1 - } -} diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/Alert.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/Alert.groovy deleted file mode 100644 index 49efd6b3441..00000000000 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/Alert.groovy +++ /dev/null @@ -1,50 +0,0 @@ -package org.prebid.server.functional.testcontainers.scaffolding.pg - -import com.fasterxml.jackson.core.type.TypeReference -import org.mockserver.model.HttpRequest -import org.prebid.server.functional.model.deals.alert.AlertEvent -import org.prebid.server.functional.testcontainers.scaffolding.NetworkScaffolding -import org.testcontainers.containers.MockServerContainer - -import static org.mockserver.model.HttpRequest.request -import static org.mockserver.model.HttpResponse.response -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.mockserver.model.JsonPathBody.jsonPath - -class Alert extends NetworkScaffolding { - - static final String ALERT_ENDPOINT_PATH = "/deals/alert" - - Alert(MockServerContainer mockServerContainer) { - super(mockServerContainer, ALERT_ENDPOINT_PATH) - } - - AlertEvent getRecordedAlertRequest() { - def body = getRecordedRequestsBody(request).last() - // 0 index element is returned after deserialization as PBS responses with SingletonList - decode(body, new TypeReference>() {})[0] - } - - Map> getLastRecordedAlertRequestHeaders() { - getLastRecordedRequestHeaders(request) - } - - @Override - void setResponse() { - mockServerClient.when(request().withPath(endpoint)) - .respond(response().withStatusCode(OK_200.code())) - } - - @Override - protected HttpRequest getRequest(String alertId) { - request().withMethod("POST") - .withPath(ALERT_ENDPOINT_PATH) - .withBody(jsonPath("\$[?(@.id == '$alertId')]")) - } - - @Override - protected HttpRequest getRequest() { - request().withMethod("POST") - .withPath(ALERT_ENDPOINT_PATH) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/DeliveryStatistics.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/DeliveryStatistics.groovy deleted file mode 100644 index 32f8f26b4d3..00000000000 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/DeliveryStatistics.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package org.prebid.server.functional.testcontainers.scaffolding.pg - -import org.mockserver.model.HttpRequest -import org.mockserver.model.HttpStatusCode -import org.prebid.server.functional.model.deals.report.DeliveryStatisticsReport -import org.prebid.server.functional.testcontainers.scaffolding.NetworkScaffolding -import org.testcontainers.containers.MockServerContainer - -import static org.mockserver.model.ClearType.ALL -import static org.mockserver.model.HttpRequest.request -import static org.mockserver.model.HttpResponse.response -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.mockserver.model.JsonPathBody.jsonPath - -class DeliveryStatistics extends NetworkScaffolding { - - static final String REPORT_DELIVERY_ENDPOINT_PATH = "/deals/report/delivery" - - DeliveryStatistics(MockServerContainer mockServerContainer) { - super(mockServerContainer, REPORT_DELIVERY_ENDPOINT_PATH) - } - - Map> getLastRecordedDeliveryRequestHeaders() { - getLastRecordedRequestHeaders(request) - } - - DeliveryStatisticsReport getLastRecordedDeliveryStatisticsReportRequest() { - recordedDeliveryStatisticsReportRequests.last() - } - - void resetRecordedRequests() { - reset(REPORT_DELIVERY_ENDPOINT_PATH, ALL) - } - - void setResponse(HttpStatusCode statusCode = OK_200) { - mockServerClient.when(request().withPath(endpoint)) - .respond(response().withStatusCode(statusCode.code())) - } - - List getRecordedDeliveryStatisticsReportRequests() { - def body = getRecordedRequestsBody(request) - body.collect { decode(it, DeliveryStatisticsReport) } - } - - @Override - protected HttpRequest getRequest(String reportId) { - request().withMethod("POST") - .withPath(REPORT_DELIVERY_ENDPOINT_PATH) - .withBody(jsonPath("\$[?(@.reportId == '$reportId')]")) - } - - @Override - protected HttpRequest getRequest() { - request().withMethod("POST") - .withPath(REPORT_DELIVERY_ENDPOINT_PATH) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/GeneralPlanner.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/GeneralPlanner.groovy deleted file mode 100644 index be27be483f6..00000000000 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/GeneralPlanner.groovy +++ /dev/null @@ -1,96 +0,0 @@ -package org.prebid.server.functional.testcontainers.scaffolding.pg - -import org.mockserver.matchers.Times -import org.mockserver.model.HttpRequest -import org.mockserver.model.HttpStatusCode -import org.prebid.server.functional.model.deals.register.RegisterRequest -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.testcontainers.scaffolding.NetworkScaffolding -import org.testcontainers.containers.MockServerContainer - -import static org.mockserver.model.HttpRequest.request -import static org.mockserver.model.HttpResponse.response -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.mockserver.model.JsonPathBody.jsonPath - -class GeneralPlanner extends NetworkScaffolding { - - static final String PLANS_ENDPOINT_PATH = "/deals/plans" - static final String REGISTER_ENDPOINT_PATH = "/deals/register" - - GeneralPlanner(MockServerContainer mockServerContainer) { - super(mockServerContainer, REGISTER_ENDPOINT_PATH) - } - - void initRegisterResponse(HttpStatusCode statusCode = OK_200) { - reset() - setResponse(statusCode) - } - - void initPlansResponse(PlansResponse plansResponse, - HttpStatusCode statusCode = OK_200, - Times times = Times.exactly(1)) { - resetPlansEndpoint() - setPlansResponse(plansResponse, statusCode, times) - } - - void resetPlansEndpoint() { - reset(PLANS_ENDPOINT_PATH) - } - - int getRecordedPlansRequestCount() { - getRequestCount(plansRequest) - } - - RegisterRequest getLastRecordedRegisterRequest() { - recordedRegisterRequests.last() - } - - List getRecordedRegisterRequests() { - def body = getRecordedRequestsBody(request) - body.collect { decode(it, RegisterRequest) } - } - - void setResponse(HttpStatusCode statusCode = OK_200) { - mockServerClient.when(request().withPath(endpoint)) - .respond(response().withStatusCode(statusCode.code())) - } - - Map> getLastRecordedRegisterRequestHeaders() { - getLastRecordedRequestHeaders(request) - } - - Map> getLastRecordedPlansRequestHeaders() { - getLastRecordedRequestHeaders(plansRequest) - } - - @Override - void reset() { - super.reset(PLANS_ENDPOINT_PATH) - super.reset(REGISTER_ENDPOINT_PATH) - } - - private void setPlansResponse(PlansResponse plansResponse, - HttpStatusCode statusCode, - Times times = Times.exactly(1)) { - setResponse(plansRequest, plansResponse, statusCode, times) - } - - @Override - protected HttpRequest getRequest(String hostInstanceId) { - request().withMethod("POST") - .withPath(REGISTER_ENDPOINT_PATH) - .withBody(jsonPath("\$[?(@.hostInstanceId == '$hostInstanceId')]")) - } - - @Override - protected HttpRequest getRequest() { - request().withMethod("POST") - .withPath(REGISTER_ENDPOINT_PATH) - } - - private static HttpRequest getPlansRequest() { - request().withMethod("GET") - .withPath(PLANS_ENDPOINT_PATH) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/UserData.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/UserData.groovy deleted file mode 100644 index 9a0caafa140..00000000000 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/pg/UserData.groovy +++ /dev/null @@ -1,77 +0,0 @@ -package org.prebid.server.functional.testcontainers.scaffolding.pg - -import org.mockserver.model.HttpRequest -import org.mockserver.model.HttpStatusCode -import org.prebid.server.functional.model.deals.userdata.UserDetailsRequest -import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse -import org.prebid.server.functional.model.deals.userdata.WinEventNotification -import org.prebid.server.functional.testcontainers.scaffolding.NetworkScaffolding -import org.testcontainers.containers.MockServerContainer - -import static org.mockserver.model.HttpRequest.request -import static org.mockserver.model.HttpResponse.response -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.mockserver.model.JsonPathBody.jsonPath - -class UserData extends NetworkScaffolding { - - static final String USER_DETAILS_ENDPOINT_PATH = "/deals/user-details" - static final String WIN_EVENT_ENDPOINT_PATH = "/deals/win-event" - - UserData(MockServerContainer mockServerContainer) { - super(mockServerContainer, WIN_EVENT_ENDPOINT_PATH) - } - - UserDetailsRequest getRecordedUserDetailsRequest() { - def body = getRecordedRequestsBody(userDetailsRequest).last() - decode(body, UserDetailsRequest) - } - - WinEventNotification getRecordedWinEventRequest() { - def body = getRecordedRequestsBody(request).last() - decode(body, WinEventNotification) - } - - void setUserDataResponse(UserDetailsResponse userDataResponse, HttpStatusCode httpStatusCode = OK_200) { - resetUserDetailsEndpoint() - setResponse(userDetailsRequest, userDataResponse, httpStatusCode) - } - - int getRecordedUserDetailsRequestCount() { - getRequestCount(userDetailsRequest) - } - - void resetUserDetailsEndpoint() { - reset(USER_DETAILS_ENDPOINT_PATH) - } - - @Override - void reset() { - super.reset(USER_DETAILS_ENDPOINT_PATH) - super.reset(WIN_EVENT_ENDPOINT_PATH) - } - - @Override - void setResponse() { - mockServerClient.when(request().withPath(endpoint)) - .respond(response().withStatusCode(OK_200.code())) - } - - @Override - protected HttpRequest getRequest(String bidId) { - request().withMethod("POST") - .withPath(WIN_EVENT_ENDPOINT_PATH) - .withBody(jsonPath("\$[?(@.bidId == '$bidId')]")) - } - - @Override - protected HttpRequest getRequest() { - request().withMethod("POST") - .withPath(WIN_EVENT_ENDPOINT_PATH) - } - - private static HttpRequest getUserDetailsRequest() { - request().withMethod("POST") - .withPath(USER_DETAILS_ENDPOINT_PATH) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/AlertSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/AlertSpec.groovy deleted file mode 100644 index bae95e69d96..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/AlertSpec.groovy +++ /dev/null @@ -1,281 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.mockserver.matchers.Times -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Retry - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static org.mockserver.model.HttpStatusCode.INTERNAL_SERVER_ERROR_500 -import static org.mockserver.model.HttpStatusCode.NOT_FOUND_404 -import static org.mockserver.model.HttpStatusCode.NO_CONTENT_204 -import static org.prebid.server.functional.model.deals.alert.Action.RAISE -import static org.prebid.server.functional.model.deals.alert.AlertPriority.LOW -import static org.prebid.server.functional.model.deals.alert.AlertPriority.MEDIUM -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_PASSWORD -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_USERNAME -import static org.prebid.server.functional.util.HttpUtil.AUTHORIZATION_HEADER -import static org.prebid.server.functional.util.HttpUtil.CONTENT_TYPE_HEADER -import static org.prebid.server.functional.util.HttpUtil.CONTENT_TYPE_HEADER_VALUE -import static org.prebid.server.functional.util.HttpUtil.PG_TRX_ID_HEADER -import static org.prebid.server.functional.util.HttpUtil.UUID_REGEX - -class AlertSpec extends BasePgSpec { - - private static final String PBS_REGISTER_CLIENT_ERROR = "pbs-register-client-error" - private static final String PBS_PLANNER_CLIENT_ERROR = "pbs-planner-client-error" - private static final String PBS_PLANNER_EMPTY_RESPONSE = "pbs-planner-empty-response-error" - private static final String PBS_DELIVERY_CLIENT_ERROR = "pbs-delivery-stats-client-error" - private static final Integer DEFAULT_ALERT_PERIOD = 15 - - @Retry(exceptions = [IllegalStateException.class]) - def "PBS should send alert request when the threshold is reached"() { - given: "Changed Planner Register endpoint response to return bad status code" - generalPlanner.initRegisterResponse(NOT_FOUND_404) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - when: "Initiating PBS to register its instance through the bad Planner for the first time" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "PBS sends an alert request to the Alert Service for the first time" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - when: "Initiating PBS to register its instance through the bad Planner until the period threshold of alerts is reached" - (2..DEFAULT_ALERT_PERIOD).forEach { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - } - - then: "PBS sends an alert request to the Alert Service for the second time" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 2 } - - and: "Request has the right number of failed register attempts" - def alertRequest = alert.recordedAlertRequest - assert alertRequest.details.startsWith("Service register failed to send request $DEFAULT_ALERT_PERIOD " + - "time(s) with error message") - - cleanup: "Return initial Planner response status code" - generalPlanner.initRegisterResponse() - } - - def "PBS should send an alert request with appropriate headers"() { - given: "Changed Planner Register endpoint response to return bad status code" - generalPlanner.initRegisterResponse(NOT_FOUND_404) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - when: "Initiating PBS to register its instance through the bad Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - and: "PBS sends an alert request to the Alert Service" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - then: "Request headers correspond to the payload" - def alertRequestHeaders = alert.lastRecordedAlertRequestHeaders - assert alertRequestHeaders - - and: "Request has an authorization header with a basic auth token" - def basicAuthToken = HttpUtil.makeBasicAuthHeaderValue(PG_ENDPOINT_USERNAME, PG_ENDPOINT_PASSWORD) - assert alertRequestHeaders.get(AUTHORIZATION_HEADER) == [basicAuthToken] - - and: "Request has a header with uuid value" - def uuidHeaderValue = alertRequestHeaders.get(PG_TRX_ID_HEADER) - assert uuidHeaderValue?.size() == 1 - assert (uuidHeaderValue[0] =~ UUID_REGEX).matches() - - and: "Request has a content type header" - assert alertRequestHeaders.get(CONTENT_TYPE_HEADER) == [CONTENT_TYPE_HEADER_VALUE] - - cleanup: "Return initial Planner response status code" - generalPlanner.initRegisterResponse() - } - - def "PBS should send an alert when fetching line items response status wasn't OK ('#httpStatusCode')"() { - given: "Changed Planner line items endpoint response to return bad status code" - // PBS will make 2 requests to the planner: 1 normal, 2 - recovery request - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString), httpStatusCode, Times.exactly(2)) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - when: "Initiating PBS to fetch line items through the bad Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - - then: "PBS sends an alert request to the Alert Service" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - and: "Alert request should correspond to the payload" - verifyAll(alert.recordedAlertRequest) { alertRequest -> - (alertRequest.id =~ UUID_REGEX).matches() - alertRequest.action == RAISE - alertRequest.priority == MEDIUM - alertRequest.updatedAt.isBefore(ZonedDateTime.now(ZoneId.from(UTC))) - alertRequest.name == PBS_PLANNER_CLIENT_ERROR - alertRequest.details == "Service planner failed to send request 1 time(s) with error message :" + - " Failed to retrieve line items from GP. Reason: Failed to fetch data from Planner, HTTP status code ${httpStatusCode.code()}" - - alertRequest.source.env == pgConfig.env - alertRequest.source.dataCenter == pgConfig.dataCenter - alertRequest.source.region == pgConfig.region - alertRequest.source.system == pgConfig.system - alertRequest.source.subSystem == pgConfig.subSystem - alertRequest.source.hostId == pgConfig.hostId - } - - cleanup: "Return initial Planner response status code" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString)) - - where: "Bad status codes" - httpStatusCode << [NO_CONTENT_204, NOT_FOUND_404, INTERNAL_SERVER_ERROR_500] - } - - def "PBS should send an alert when register PBS instance response status wasn't OK ('#httpStatusCode')"() { - given: "Changed Planner register endpoint response to return bad status code" - generalPlanner.initRegisterResponse(httpStatusCode) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - when: "Initiating PBS to register its instance through the bad Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "PBS sends an alert request to the Alert Service" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - and: "Alert request should correspond to the payload" - verifyAll(alert.recordedAlertRequest) { alertRequest -> - (alertRequest.id =~ UUID_REGEX).matches() - alertRequest.action == RAISE - alertRequest.priority == MEDIUM - alertRequest.updatedAt.isBefore(ZonedDateTime.now(ZoneId.from(UTC))) - alertRequest.name == PBS_REGISTER_CLIENT_ERROR - alertRequest.details.startsWith("Service register failed to send request 1 time(s) with error message :" + - " Planner responded with non-successful code ${httpStatusCode.code()}") - - alertRequest.source.env == pgConfig.env - alertRequest.source.dataCenter == pgConfig.dataCenter - alertRequest.source.region == pgConfig.region - alertRequest.source.system == pgConfig.system - alertRequest.source.subSystem == pgConfig.subSystem - alertRequest.source.hostId == pgConfig.hostId - } - - cleanup: "Return initial Planner response status code" - generalPlanner.initRegisterResponse() - - where: "Bad status codes" - httpStatusCode << [NOT_FOUND_404, INTERNAL_SERVER_ERROR_500] - } - - def "PBS should send an alert when send delivery statistics report response status wasn't OK ('#httpStatusCode')"() { - given: "Changed Delivery Statistics endpoint response to return bad status code" - deliveryStatistics.reset() - deliveryStatistics.setResponse(httpStatusCode) - - and: "Set line items response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString)) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - and: "Report to send is generated by PBS" - updateLineItemsAndWait() - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - when: "Initiating PBS to send delivery statistics report through the bad Delivery Statistics Service" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends an alert request to the Alert Service" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - and: "Alert request should correspond to the payload" - verifyAll(alert.recordedAlertRequest) { alertRequest -> - (alertRequest.id =~ UUID_REGEX).matches() - alertRequest.action == RAISE - alertRequest.priority == MEDIUM - alertRequest.updatedAt.isBefore(ZonedDateTime.now(ZoneId.from(UTC))) - alertRequest.name == PBS_DELIVERY_CLIENT_ERROR - alertRequest.details.startsWith("Service deliveryStats failed to send request 1 time(s) with error message : " + - "Report was not send to delivery stats service with a reason: Delivery stats service responded with " + - "status code = ${httpStatusCode.code()} for report with id = ") - - alertRequest.source.env == pgConfig.env - alertRequest.source.dataCenter == pgConfig.dataCenter - alertRequest.source.region == pgConfig.region - alertRequest.source.system == pgConfig.system - alertRequest.source.subSystem == pgConfig.subSystem - alertRequest.source.hostId == pgConfig.hostId - } - - cleanup: "Return initial Delivery Statistics response status code" - deliveryStatistics.reset() - deliveryStatistics.setResponse() - - and: "Report to delivery statistics is sent" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - where: "Bad status codes" - httpStatusCode << [NOT_FOUND_404, INTERNAL_SERVER_ERROR_500] - } - - def "PBS should send an alert when Planner returns empty response"() { - given: "Changed Planner get plans response to return no plans" - generalPlanner.initPlansResponse(new PlansResponse(lineItems: [])) - - and: "PBS alert counter is reset" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.resetAlertCountRequest) - - and: "Initial Alert Service request count is taken" - def initialRequestCount = alert.requestCount - - when: "Initiating PBS to fetch line items through the Planner" - updateLineItemsAndWait() - - then: "PBS sends an alert request to the Alert Service" - PBSUtils.waitUntil { alert.requestCount == initialRequestCount + 1 } - - and: "Alert request should correspond to the payload" - verifyAll(alert.recordedAlertRequest) { alertRequest -> - (alertRequest.id =~ UUID_REGEX).matches() - alertRequest.action == RAISE - alertRequest.priority == LOW - alertRequest.updatedAt.isBefore(ZonedDateTime.now(ZoneId.from(UTC))) - alertRequest.name == PBS_PLANNER_EMPTY_RESPONSE - alertRequest.details.startsWith("Service planner failed to send request 1 time(s) with error message : " + - "Response without line items was received from planner") - - alertRequest.source.env == pgConfig.env - alertRequest.source.dataCenter == pgConfig.dataCenter - alertRequest.source.region == pgConfig.region - alertRequest.source.system == pgConfig.system - alertRequest.source.subSystem == pgConfig.subSystem - alertRequest.source.hostId == pgConfig.hostId - } - - cleanup: "Return initial Planner response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString)) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/BasePgSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/BasePgSpec.groovy deleted file mode 100644 index 9159bba8bb0..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/BasePgSpec.groovy +++ /dev/null @@ -1,60 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.service.PrebidServerService -import org.prebid.server.functional.testcontainers.Dependencies -import org.prebid.server.functional.testcontainers.PbsPgConfig -import org.prebid.server.functional.testcontainers.PbsServiceFactory -import org.prebid.server.functional.testcontainers.scaffolding.Bidder -import org.prebid.server.functional.testcontainers.scaffolding.pg.Alert -import org.prebid.server.functional.testcontainers.scaffolding.pg.DeliveryStatistics -import org.prebid.server.functional.testcontainers.scaffolding.pg.GeneralPlanner -import org.prebid.server.functional.testcontainers.scaffolding.pg.UserData -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Retry -import spock.lang.Shared -import spock.lang.Specification - -@Retry(mode = Retry.Mode.SETUP_FEATURE_CLEANUP) -abstract class BasePgSpec extends Specification { - - protected static final PbsServiceFactory pbsServiceFactory = new PbsServiceFactory(Dependencies.networkServiceContainer) - - protected static final GeneralPlanner generalPlanner = new GeneralPlanner(Dependencies.networkServiceContainer) - protected static final DeliveryStatistics deliveryStatistics = new DeliveryStatistics(Dependencies.networkServiceContainer) - protected static final Alert alert = new Alert(Dependencies.networkServiceContainer) - protected static final UserData userData = new UserData(Dependencies.networkServiceContainer) - - protected static final PbsPgConfig pgConfig = new PbsPgConfig(Dependencies.networkServiceContainer) - protected static final Bidder bidder = new Bidder(Dependencies.networkServiceContainer) - - @Shared - protected final PrebidServerService pgPbsService = pbsServiceFactory.getService(pgConfig.properties) - - def setupSpec() { - bidder.setResponse() - generalPlanner.setResponse() - deliveryStatistics.setResponse() - alert.setResponse() - userData.setResponse() - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - } - - def cleanupSpec() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - generalPlanner.reset() - deliveryStatistics.reset() - alert.reset() - userData.reset() - bidder.reset() - } - - protected void updateLineItemsAndWait() { - def initialPlansRequestCount = generalPlanner.recordedPlansRequestCount - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - PBSUtils.waitUntil { generalPlanner.recordedPlansRequestCount == initialPlansRequestCount + 1 } - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/CurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/CurrencySpec.groovy deleted file mode 100644 index 9f2d6a3f540..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/CurrencySpec.groovy +++ /dev/null @@ -1,98 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.lineitem.Price -import org.prebid.server.functional.model.mock.services.currencyconversion.CurrencyConversionRatesResponse -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.service.PrebidServerService -import org.prebid.server.functional.testcontainers.scaffolding.CurrencyConversion -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Shared - -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer - -class CurrencySpec extends BasePgSpec { - - private static final CurrencyConversion currencyConversion = new CurrencyConversion(networkServiceContainer).tap { - setCurrencyConversionRatesResponse(CurrencyConversionRatesResponse.defaultCurrencyConversionRatesResponse) - } - - private static final Map pgCurrencyConverterPbsConfig = externalCurrencyConverterConfig + pgConfig.properties - private static final PrebidServerService pgCurrencyConverterPbsService = pbsServiceFactory.getService(pgCurrencyConverterPbsConfig) - - @Shared - BidRequest bidRequest - - def setup() { - bidRequest = BidRequest.defaultBidRequest - bidder.setResponse(bidRequest.id, BidResponse.getDefaultBidResponse(bidRequest)) - pgCurrencyConverterPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should convert non-default line item currency to the default one during the bidder auction"() { - given: "Planner Mock line items with the same CPM but different currencies" - def accountId = bidRequest.site.publisher.id - def defaultCurrency = Price.defaultPrice.currency - def nonDefaultCurrency = "EUR" - def defaultCurrencyLineItem = [LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 1, currency: defaultCurrency) }] - def nonDefaultCurrencyLineItems = [LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 1, currency: nonDefaultCurrency) }, - LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 1, currency: nonDefaultCurrency) }, - LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 1, currency: nonDefaultCurrency) }] - def lineItems = defaultCurrencyLineItem + nonDefaultCurrencyLineItems - def plansResponse = new PlansResponse(lineItems: lineItems) - generalPlanner.initPlansResponse(plansResponse) - def nonDefaultCurrencyLineItemIds = nonDefaultCurrencyLineItems.collect { it.lineItemId } - - and: "Line items are fetched by PBS" - def initialPlansRequestCount = generalPlanner.recordedPlansRequestCount - pgCurrencyConverterPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - PBSUtils.waitUntil { generalPlanner.recordedPlansRequestCount == initialPlansRequestCount + 1 } - - when: "Auction is requested" - def auctionResponse = pgCurrencyConverterPbsService.sendAuctionRequest(bidRequest) - - then: "All line items are ready to be served" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == plansResponse.lineItems.size() - - and: "Line Item with EUR defaultCurrency was sent to bidder as EUR defaultCurrency rate > than USD" - assert auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value)?.sort() == - nonDefaultCurrencyLineItemIds.sort() - } - - def "PBS should invalidate line item with an unknown for the conversion rate currency"() { - given: "Planner Mock line items with a default currency and unknown currency" - def defaultCurrency = Price.defaultPrice.currency - def unknownCurrency = "UAH" - def defaultCurrencyLineItem = [LineItem.getDefaultLineItem(bidRequest.site.publisher.id).tap { price = new Price(cpm: 1, currency: defaultCurrency) }] - def unknownCurrencyLineItem = [LineItem.getDefaultLineItem(bidRequest.site.publisher.id).tap { price = new Price(cpm: 1, currency: unknownCurrency) }] - def lineItems = defaultCurrencyLineItem + unknownCurrencyLineItem - def plansResponse = new PlansResponse(lineItems: lineItems) - generalPlanner.initPlansResponse(plansResponse) - def defaultCurrencyLineItemId = defaultCurrencyLineItem.collect { it.lineItemId } - - and: "Line items are fetched by PBS" - def initialPlansRequestCount = generalPlanner.recordedPlansRequestCount - pgCurrencyConverterPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - PBSUtils.waitUntil { generalPlanner.recordedPlansRequestCount == initialPlansRequestCount + 1 } - - when: "Auction is requested" - def auctionResponse = pgCurrencyConverterPbsService.sendAuctionRequest(bidRequest) - - then: "Only line item with the default currency is ready to be served and was sent to bidder" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe == defaultCurrencyLineItemId as Set - assert auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) == - defaultCurrencyLineItemId as Set - } - - private static Map getExternalCurrencyConverterConfig() { - ["currency-converter.external-rates.enabled" : "true", - "currency-converter.external-rates.url" : "$networkServiceContainer.rootUri/currency".toString(), - "currency-converter.external-rates.default-timeout-ms": "4000", - "currency-converter.external-rates.refresh-period-ms" : "900000" - ] - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/LineItemStatusSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/LineItemStatusSpec.groovy deleted file mode 100644 index 77f2c31f603..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/LineItemStatusSpec.groovy +++ /dev/null @@ -1,193 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.DeliverySchedule -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.lineitem.Token -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.service.PrebidServerException -import org.prebid.server.functional.util.ObjectMapperWrapper -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime -import java.time.temporal.ChronoUnit - -import static java.time.ZoneOffset.UTC - -class LineItemStatusSpec extends BasePgSpec implements ObjectMapperWrapper { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should return a bad request exception when no 'id' query parameter is provided"() { - when: "Requesting endpoint without 'id' parameter" - pgPbsService.sendLineItemStatusRequest(null) - - then: "PBS throws an exception" - def exception = thrown(PrebidServerException) - assert exception.statusCode == 400 - assert exception.responseBody.contains("id parameter is required") - } - - def "PBS should return a bad request exception when endpoint is requested with not existing line item id"() { - given: "Not existing line item id" - def notExistingLineItemId = PBSUtils.randomString - - when: "Requesting endpoint" - pgPbsService.sendLineItemStatusRequest(notExistingLineItemId) - - then: "PBS throws an exception" - def exception = thrown(PrebidServerException) - assert exception.statusCode == 400 - assert exception.responseBody.contains("LineItem not found: $notExistingLineItemId") - } - - def "PBS should return an empty line item status response when line item doesn't have a scheduled delivery"() { - given: "Line item with no delivery schedule" - def plansResponse = PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].deliverySchedules = null - } - def lineItemId = plansResponse.lineItems[0].lineItemId - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Requesting endpoint" - def lineItemStatusReport = pgPbsService.sendLineItemStatusRequest(lineItemId) - - then: "Empty line item status report is returned" - verifyAll(lineItemStatusReport) { - it.lineItemId == lineItemId - !it.deliverySchedule - !it.spentTokens - !it.readyToServeTimestamp - !it.pacingFrequency - !it.accountId - !it.target - } - } - - def "PBS should return filled line item status report when line item has a scheduled delivery"() { - given: "Line item with a scheduled delivery" - def plansResponse = new PlansResponse(lineItems: [LineItem.getDefaultLineItem(PBSUtils.randomString).tap { - deliverySchedules = [DeliverySchedule.defaultDeliverySchedule] - }]) - generalPlanner.initPlansResponse(plansResponse) - def lineItemId = plansResponse.lineItems[0].lineItemId - def lineItem = plansResponse.lineItems[0] - def deliverySchedule = lineItem.deliverySchedules[0] - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Requesting endpoint" - def lineItemStatusReport = pgPbsService.sendLineItemStatusRequest(lineItemId) - - then: "Line item status report is returned" - def reportTimeZone = lineItemStatusReport.deliverySchedule?.planStartTimeStamp?.zone - assert reportTimeZone - - verifyAll(lineItemStatusReport) { - it.lineItemId == lineItemId - it.deliverySchedule?.planId == deliverySchedule.planId - - it.deliverySchedule.planStartTimeStamp == - timeToReportFormat(deliverySchedule.startTimeStamp, reportTimeZone) - it.deliverySchedule?.planExpirationTimeStamp == - timeToReportFormat(deliverySchedule.endTimeStamp, reportTimeZone) - it.deliverySchedule?.planUpdatedTimeStamp == - timeToReportFormat(deliverySchedule.updatedTimeStamp, reportTimeZone) - - it.deliverySchedule?.tokens?.size() == deliverySchedule.tokens.size() - it.deliverySchedule?.tokens?.first()?.priorityClass == deliverySchedule.tokens[0].priorityClass - it.deliverySchedule?.tokens?.first()?.total == deliverySchedule.tokens[0].total - !it.deliverySchedule?.tokens?.first()?.spent - !it.deliverySchedule?.tokens?.first()?.totalSpent - - it.spentTokens == 0 - it.readyToServeTimestamp.isBefore(ZonedDateTime.now()) - it.pacingFrequency == getDeliveryRateMs(deliverySchedule) - it.accountId == lineItem.accountId - encode(it.target) == encode(lineItem.targeting) - } - } - - def "PBS should return line item status report with an active scheduled delivery"() { - given: "Line item with an active and expired scheduled deliveries" - def inactiveDeliverySchedule = DeliverySchedule.defaultDeliverySchedule.tap { - startTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusHours(12) - updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusHours(12) - endTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusHours(6) - } - def activeDeliverySchedule = DeliverySchedule.defaultDeliverySchedule.tap { - startTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)) - updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)) - endTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).plusHours(12) - } - def plansResponse = new PlansResponse(lineItems: [LineItem.getDefaultLineItem(PBSUtils.randomString).tap { - deliverySchedules = [inactiveDeliverySchedule, activeDeliverySchedule] - }]) - generalPlanner.initPlansResponse(plansResponse) - def lineItemId = plansResponse.lineItems[0].lineItemId - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Requesting endpoint" - def lineItemStatusReport = pgPbsService.sendLineItemStatusRequest(lineItemId) - - then: "Line item status report is returned with an active delivery" - assert lineItemStatusReport.lineItemId == lineItemId - assert lineItemStatusReport.deliverySchedule?.planId == activeDeliverySchedule.planId - } - - def "PBS should return line item status report with increased spent token number when PG auction has happened"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Line item with a scheduled delivery" - def plansResponse = new PlansResponse(lineItems: [LineItem.getDefaultLineItem(bidRequest.site.publisher.id).tap { - deliverySchedules = [DeliverySchedule.defaultDeliverySchedule.tap { - tokens = [Token.defaultToken] - }] - }]) - generalPlanner.initPlansResponse(plansResponse) - def lineItemId = plansResponse.lineItems[0].lineItemId - def spentTokensNumber = 1 - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "PG bid response is set" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "PBS PG auction is requested" - pgPbsService.sendAuctionRequest(bidRequest) - - when: "Requesting line item status endpoint" - def lineItemStatusReport = pgPbsService.sendLineItemStatusRequest(lineItemId) - - then: "Spent token number in line item status report is increased" - assert lineItemStatusReport.lineItemId == lineItemId - assert lineItemStatusReport.spentTokens == spentTokensNumber - assert lineItemStatusReport.deliverySchedule?.tokens?.first()?.spent == spentTokensNumber - } - - private ZonedDateTime timeToReportFormat(ZonedDateTime givenTime, ZoneId reportTimeZone) { - givenTime.truncatedTo(ChronoUnit.MILLIS).withZoneSameInstant(reportTimeZone) - } - - private Integer getDeliveryRateMs(DeliverySchedule deliverySchedule) { - deliverySchedule.tokens[0].total > 0 - ? (deliverySchedule.endTimeStamp.toInstant().toEpochMilli() - - deliverySchedule.startTimeStamp.toInstant().toEpochMilli()) / - deliverySchedule.tokens[0].total - : null - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/PgAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/PgAuctionSpec.groovy deleted file mode 100644 index 4d7ffec88af..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/PgAuctionSpec.groovy +++ /dev/null @@ -1,520 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.UidsCookie -import org.prebid.server.functional.model.bidder.Generic -import org.prebid.server.functional.model.deals.lineitem.FrequencyCap -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.lineitem.LineItemSize -import org.prebid.server.functional.model.deals.lineitem.Price -import org.prebid.server.functional.model.deals.lineitem.RelativePriority -import org.prebid.server.functional.model.deals.lineitem.targeting.Targeting -import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.BidRequestExt -import org.prebid.server.functional.model.request.auction.Bidder -import org.prebid.server.functional.model.request.auction.Imp -import org.prebid.server.functional.model.request.auction.Prebid -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.deals.lineitem.LineItemStatus.DELETED -import static org.prebid.server.functional.model.deals.lineitem.LineItemStatus.PAUSED -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.HIGH -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.LOW -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.MEDIUM -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_HIGH -import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_LOW -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.IN -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.INTERSECTS -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_MEDIA_TYPE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_SIZE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.DEVICE_REGION -import static org.prebid.server.functional.model.response.auction.MediaType.BANNER -import static org.prebid.server.functional.util.HttpUtil.UUID_REGEX - -class PgAuctionSpec extends BasePgSpec { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should return base response after PG auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Auction response contains values according to the payload" - verifyAll(auctionResponse) { - auctionResponse.id == bidRequest.id - auctionResponse.cur == pgConfig.currency - !auctionResponse.bidid - !auctionResponse.customdata - !auctionResponse.nbr - } - - and: "Seat bid corresponds to the request seat bid" - assert auctionResponse.seatbid?.size() == bidRequest.imp.size() - def seatBid = auctionResponse.seatbid[0] - assert seatBid.seat == GENERIC - - assert seatBid.bid?.size() == 1 - - verifyAll(seatBid.bid[0]) { bid -> - (bid.id =~ UUID_REGEX).matches() - bid.impid == bidRequest.imp[0].id - bid.price == bidResponse.seatbid[0].bid[0].price - bid.crid == bidResponse.seatbid[0].bid[0].crid - bid.ext?.prebid?.type == BANNER - bid.ext?.origbidcpm == bidResponse.seatbid[0].bid[0].price - } - } - - def "PBS shouldn't process line item with #reason"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock non matched line item" - generalPlanner.initPlansResponse(plansResponse.tap { - it.lineItems[0].accountId = bidRequest.site.publisher.id - }) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start processing PG deals" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - reason | plansResponse - - "non matched targeting" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].targeting = new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [BANNER]) - .addTargeting(DEVICE_REGION, IN, [14]) - .build() - } - - "empty targeting" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].targeting = null - } - - "non matched bidder" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].source = PBSUtils.randomString - } - - "inactive status" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].status = DELETED - } - - "paused status" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].status = PAUSED - } - - "expired lifetime" | PlansResponse.getDefaultPlansResponse(PBSUtils.randomString).tap { - lineItems[0].startTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusMinutes(2) - lineItems[0].endTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusMinutes(1) - lineItems[0].updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusMinutes(2) - } - } - - def "PBS shouldn't process line item with non matched publisher account id"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock non matched publisher account id line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(PBSUtils.randomNumber as String) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start processing PG deals" - assert !auctionResponse.ext?.debug?.pgmetrics - } - - def "PBS shouldn't start processing PG deals when there is no any line item"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock no line items" - generalPlanner.initPlansResponse(new PlansResponse(lineItems: [])) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start processing PG deals" - assert !auctionResponse.ext?.debug?.pgmetrics - } - - def "PBS shouldn't allow line item with #reason delivery plan take part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line item with expired delivery schedule" - def plansResponse = plansResponseClosure(bidRequest) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't allow line item take part in auction" - assert auctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == - plansResponse.lineItems.collect { it.lineItemId } as Set - - where: - reason | plansResponseClosure - - "expired" | { BidRequest bidReq -> - PlansResponse.getDefaultPlansResponse(bidReq.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].startTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusDays(2) - lineItems[0].deliverySchedules[0].updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusDays(2) - lineItems[0].deliverySchedules[0].endTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).minusDays(1) - } - } - - "not set" | { BidRequest bidReq -> - PlansResponse.getDefaultPlansResponse(bidReq.site.publisher.id).tap { - lineItems[0].deliverySchedules = [] - } - } - } - - def "PBS should process only first #maxDealsPerBidder line items among the matched ones"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Publisher account id" - def accountId = bidRequest.site.publisher.id - - and: "Planner Mock line items to return #maxDealsPerBidder + 1 line items" - def maxLineItemsToProcess = pgConfig.maxDealsPerBidder - def plansResponse = new PlansResponse(lineItems: (1..maxLineItemsToProcess + 1).collect { - LineItem.getDefaultLineItem(accountId) - }) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "There are #maxLineItemsToProcess + 1 line items are matched and ready to serve" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == maxLineItemsToProcess + 1 - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == maxLineItemsToProcess + 1 - - and: "Only #maxLineItemsToProcess were sent to the bidder" - assert auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value)?.size() == maxLineItemsToProcess - } - - def "PBS should send to bidder only the first line item among line items with identical deal ids"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Deal id" - def dealId = PBSUtils.randomString - - and: "Planner Mock line items with identical deal ids" - def plansResponse = new PlansResponse(lineItems: (1..2).collect { - LineItem.getDefaultLineItem(bidRequest.site.publisher.id).tap { it.dealId = dealId } - }) - generalPlanner.initPlansResponse(plansResponse) - def lineItemsNumber = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "There are 2 matched and ready to serve line items" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemsNumber - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItemsNumber - - and: "Only 1 line item was sent to the bidder" - assert auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value)?.size() == lineItemsNumber - 1 - } - - def "PBS should allow line item with matched to the request bidder alias take part in auction"() { - given: "Bid request with set bidder alias" - def lineItemSource = PBSUtils.randomString - def bidRequest = BidRequest.defaultBidRequest.tap { - def prebid = new Prebid(aliases: [(lineItemSource): GENERIC], debug: 1) - ext = new BidRequestExt(prebid: prebid) - } - - and: "Planner Mock line items with changed line item source" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].source = lineItemSource - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemCount = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Line item was matched by alias bidder and took part in auction" - def pgMetrics = auctionResponse.ext?.debug?.pgmetrics - assert pgMetrics - assert pgMetrics.sentToBidder?.get(lineItemSource)?.size() == lineItemCount - assert pgMetrics.readyToServe?.size() == lineItemCount - assert pgMetrics.matchedWholeTargeting?.size() == lineItemCount - } - - def "PBS should abandon line items with matched user frequency capped ids take part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items with added frequency cap" - def fcapId = PBSUtils.randomNumber as String - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].frequencyCaps = [FrequencyCap.defaultFrequencyCap.tap { it.fcapId = fcapId }] - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "User Service Response is set to return frequency capped id identical to the line item fcapId" - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse.tap { - user.ext.fcapIds = [fcapId] - }) - - and: "Cookies header" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS hasn't started processing PG deals as line item was recognized as frequency capped" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedTargetingFcapped?.size() == plansResponse.lineItems.size() - - cleanup: - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - } - - def "PBS should allow line items with unmatched user frequency capped ids take part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items with added frequency cap" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].frequencyCaps = [FrequencyCap.defaultFrequencyCap.tap { fcapId = PBSUtils.randomNumber as String }] - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "User Service Response is set to return frequency capped id not identical to the line item fcapId" - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse.tap { - user.ext.fcapIds = [PBSUtils.randomNumber as String] - }) - - and: "Cookies header" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS hasn't started processing PG deals as line item was recognized as frequency capped" - assert !auctionResponse.ext?.debug?.pgmetrics?.matchedTargetingFcapped - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe - - cleanup: - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - } - - def "PBS shouldn't use already matched line items by the same bidder during one auction"() { - given: "Bid request with two impressions" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].ext.prebid.bidder = new Bidder(generic: new Generic()) - imp << Imp.defaultImpression - imp[1].ext.prebid.bidder = new Bidder(generic: new Generic()) - } - def accountId = bidRequest.site.publisher.id - - and: "Planner Mock with two line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(accountId).tap { - lineItems << LineItem.getDefaultLineItem(accountId) - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemCount = plansResponse.lineItems.size() - def lineItemIds = plansResponse.lineItems.collect { it.lineItemId } as Set - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Two line items are ready to be served" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItemCount - - and: "Two (as the number of imps) different line items were sent to the bidder" - def sentToBidder = auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == lineItemCount - assert sentToBidder.sort() == lineItemIds.sort() - - def sentToBidderAsTopMatch = auctionResponse.ext?.debug?.pgmetrics?.sentToBidderAsTopMatch?.get(GENERIC.value) - assert sentToBidderAsTopMatch?.size() == lineItemCount - assert sentToBidderAsTopMatch.sort() == lineItemIds.sort() - } - - def "PBS should send line items with the highest priority to the bidder during auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Planner Mock line items with different priorities" - def lowerPriorityLineItems = [LineItem.getDefaultLineItem(accountId).tap { relativePriority = VERY_LOW }, - LineItem.getDefaultLineItem(accountId).tap { relativePriority = LOW }] - def higherPriorityLineItems = [LineItem.getDefaultLineItem(accountId).tap { relativePriority = MEDIUM }, - LineItem.getDefaultLineItem(accountId).tap { relativePriority = HIGH }, - LineItem.getDefaultLineItem(accountId).tap { relativePriority = VERY_HIGH }] - def lineItems = lowerPriorityLineItems + higherPriorityLineItems - def plansResponse = new PlansResponse(lineItems: lineItems) - def higherPriorityLineItemIds = higherPriorityLineItems.collect { it.lineItemId } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "All line items are ready to be served" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItems.size() - - and: "#maxDealsPerBidder[3] line items were send to bidder" - def sentToBidder = auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == pgConfig.maxDealsPerBidder - - and: "Those line items with the highest priority were sent" - assert sentToBidder.sort() == higherPriorityLineItemIds.sort() - } - - def "PBS should send line items with the highest CPM to the bidder during auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Planner Mock line items with different CPMs" - def currency = Price.defaultPrice.currency - def lowerCpmLineItems = [LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 1, currency: currency) }, - LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 2, currency: currency) }] - def higherCpmLineItems = [LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 3, currency: currency) }, - LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 4, currency: currency) }, - LineItem.getDefaultLineItem(accountId).tap { price = new Price(cpm: 5, currency: currency) }] - def lineItems = lowerCpmLineItems + higherCpmLineItems - def plansResponse = new PlansResponse(lineItems: lineItems) - def higherCpmLineItemIds = higherCpmLineItems.collect { it.lineItemId } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "All line items are ready to be served" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItems.size() - - and: "#maxDealsPerBidder[3] line items were send to bidder" - def sentToBidder = auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == pgConfig.maxDealsPerBidder - - and: "Those line items with the highest CPM were sent" - assert sentToBidder.sort() == higherCpmLineItemIds.sort() - } - - def "PBS should send line items with the highest priority to the bidder during auction despite the price"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Planner Mock line items with different priorities and CPMs" - def lineItems = RelativePriority.values().collect { relativePriority -> - LineItem.getDefaultLineItem(accountId).tap { - it.relativePriority = relativePriority - it.price = Price.defaultPrice - } - } - - def plansResponse = new PlansResponse(lineItems: lineItems) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "All line items are ready to be served" - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItems.size() - - and: "#maxDealsPerBidder[3] line items were send to bidder" - def sentToBidder = auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - def dealsPerBidder = pgConfig.maxDealsPerBidder - assert sentToBidder?.size() == dealsPerBidder - - and: "Those line items with the highest priority were sent" - def prioritizedLineItems = lineItems.sort { it.relativePriority.value } - .take(dealsPerBidder) - assert sentToBidder.sort() == prioritizedLineItems.collect { it.lineItemId }.sort() - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidResponseSpec.groovy deleted file mode 100644 index 2978fb91e0f..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidResponseSpec.groovy +++ /dev/null @@ -1,211 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.LineItemSize -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.Format -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.PBSUtils - -import static org.prebid.server.functional.model.response.auction.ErrorType.GENERIC - -class PgBidResponseSpec extends BasePgSpec { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should allow valid bidder response with deals info continue taking part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - def lineItemCount = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder returned valid response with deals info during auction" - assert auctionResponse.ext?.debug?.pgmetrics?.sentToClient?.size() == lineItemCount - assert auctionResponse.ext?.debug?.pgmetrics?.sentToClientAsTopMatch?.size() == lineItemCount - } - - def "PBS should invalidate bidder response when bid id doesn't match to the bid request bid id"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse).tap { - seatbid[0].bid[0].impid = PBSUtils.randomNumber as String - } - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder response is invalid" - def bidderErrors = auctionResponse.ext?.errors?.get(GENERIC) - def bidId = bidResponse.seatbid[0].bid[0].id - - assert bidderErrors?.size() == 1 - assert bidderErrors[0].message ==~ - /BidId `$bidId` validation messages:.* Error: Bid \"$bidId\" has no corresponding imp in request.*/ - } - - def "PBS should invalidate bidder response when deal id doesn't match to the bid request deal id"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse).tap { - seatbid[0].bid[0].dealid = PBSUtils.randomNumber as String - } - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder response is invalid" - def bidderErrors = auctionResponse.ext?.errors?.get(GENERIC) - def bidId = bidResponse.seatbid[0].bid[0].id - - assert bidderErrors?.size() == 1 - assert bidderErrors[0].message ==~ /BidId `$bidId` validation messages:.* Warning: / + - /WARNING: Bid "$bidId" has 'dealid' not present in corresponding imp in request.*/ - } - - def "PBS should invalidate bidder response when non-matched to the bid request size is returned"() { - given: "Bid request with set sizes" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].banner.format = [Format.defaultFormat] - } - def impFormat = bidRequest.imp[0].banner.format[0] - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response with unmatched to the bid request size" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse).tap { - seatbid[0].bid[0].w = PBSUtils.randomNumber - } - def bid = bidResponse.seatbid[0].bid[0] - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder response is invalid" - assert auctionResponse.ext?.debug?.pgmetrics?.responseInvalidated?.size() == plansResponse.lineItems.size() - - and: "PBS invalidated response as unmatched by size" - def bidderErrors = auctionResponse.ext?.errors?.get(GENERIC) - - assert bidderErrors?.size() == 1 - assert bidderErrors[0].message ==~ /BidId `$bid.id` validation messages:.* Error: / + - /Bid "$bid.id" has 'w' and 'h' not supported by corresponding imp in request\. / + - /Bid dimensions: '${bid.w}x$bid.h', formats in imp: '${impFormat.w}x$impFormat.h'.*/ - } - - def "PBS should invalidate bidder response when non-matched to the PBS line item size response is returned"() { - given: "Bid request" - def newFormat = new Format(w: PBSUtils.randomNumber, h: PBSUtils.randomNumber) - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].banner.format = [Format.defaultFormat, newFormat] - } - - and: "Planner Mock line items with a default size" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].sizes = [LineItemSize.defaultLineItemSize] - } - def lineItemSize = plansResponse.lineItems[0].sizes[0] - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response with non-matched to the line item size" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse).tap { - seatbid[0].bid[0].w = newFormat.w - seatbid[0].bid[0].h = newFormat.h - } - def bid = bidResponse.seatbid[0].bid[0] - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder response is invalid" - assert auctionResponse.ext?.debug?.pgmetrics?.responseInvalidated?.size() == plansResponse.lineItems.size() - - and: "PBS invalidated response as not matched by size" - def bidderErrors = auctionResponse.ext?.errors?.get(GENERIC) - - assert bidderErrors?.size() == 1 - assert bidderErrors[0].message ==~ /BidId `$bid.id` validation messages:.* Error: / + - /Bid "$bid.id" has 'w' and 'h' not matched to Line Item\. / + - /Bid dimensions: '${bid.w}x$bid.h', Line Item sizes: '${lineItemSize.w}x$lineItemSize.h'.*/ - } - - def "PBS should invalidate bidder response when line items sizes empty"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].banner.format = [Format.defaultFormat] - } - - and: "Planner Mock line items with a empty sizes" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].sizes = [] - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Set bid response without line items sizes 'h' and 'w' " - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - def bid = bidResponse.seatbid[0].bid[0] - bidder.setResponse(bidRequest.id, bidResponse) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder response is invalid" - assert auctionResponse.ext?.debug?.pgmetrics?.responseInvalidated?.size() == plansResponse.lineItems.size() - - and: "PBS invalidated response as line items sizes empty" - def bidderErrors = auctionResponse.ext?.errors?.get(GENERIC) - - assert bidderErrors?.size() == 1 - assert bidderErrors[0].message == "BidId `${bid.id}` validation messages: " + - "Error: Line item sizes were not found for " + - "bidId ${bid.id} and dealId ${plansResponse.getLineItems()[0].dealId}" - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidderRequestSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidderRequestSpec.groovy deleted file mode 100644 index 0a0219d34ee..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/PgBidderRequestSpec.groovy +++ /dev/null @@ -1,167 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.UidsCookie -import org.prebid.server.functional.model.bidder.Generic -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.Bidder -import org.prebid.server.functional.model.request.auction.Device -import org.prebid.server.functional.model.request.auction.Imp -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Ignore - -class PgBidderRequestSpec extends BasePgSpec { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should be able to add given device info to the bidder request"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - device = new Device(ua: PBSUtils.randomString, - make: PBSUtils.randomString, - model: PBSUtils.randomString) - } - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "User Service response is set" - def userResponse = UserDetailsResponse.defaultUserResponse - userData.setUserDataResponse(userResponse) - - and: "Cookies with user ids" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS sent a request to the bidder with added device info" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { bidderRequest -> - bidderRequest.user?.ext?.fcapids == userResponse.user.ext.fcapIds - bidderRequest.user.data?.size() == userResponse.user.data.size() - bidderRequest.user.data[0].id == userResponse.user.data[0].name - bidderRequest.user.data[0].segment?.size() == userResponse.user.data[0].segment.size() - bidderRequest.user.data[0].segment[0].id == userResponse.user.data[0].segment[0].id - } - } - - def "PBS should be able to add pmp deals part to the bidder request when PG is enabled"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def accountId = bidRequest.site.publisher.id - def plansResponse = new PlansResponse(lineItems: [LineItem.getDefaultLineItem(accountId), LineItem.getDefaultLineItem(accountId)]) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS sent a request to the bidder with added deals" - def bidderRequest = bidder.getBidderRequest(bidRequest.id) - - assert bidderRequest.imp?.size() == bidRequest.imp.size() - assert bidderRequest.imp[0].pmp?.deals?.size() == plansResponse.lineItems.size() - assert bidderRequest.imp[0].pmp?.deals - assert plansResponse.lineItems.each { lineItem -> - def deal = bidderRequest.imp[0]?.pmp?.deals?.find { it.id == lineItem.dealId } - - assert deal - verifyAll(deal) { - deal?.ext?.line?.lineItemId == lineItem.lineItemId - deal?.ext?.line?.extLineItemId == lineItem.extLineItemId - deal?.ext?.line?.sizes?.size() == lineItem.sizes.size() - deal?.ext?.line?.sizes[0].w == lineItem.sizes[0].w - deal?.ext?.line?.sizes[0].h == lineItem.sizes[0].h - } - } - } - - @Ignore - def "PBS shouldn't add already top matched line item by first impression to the second impression deals bidder request section"() { - given: "Bid request with two impressions" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].ext.prebid.bidder = new Bidder(generic: new Generic()) - imp << Imp.defaultImpression - imp[1].ext.prebid.bidder = new Bidder(generic: new Generic()) - } - - and: "Planner Mock line items" - def accountId = bidRequest.site.publisher.id - def plansResponse = new PlansResponse(lineItems: [LineItem.getDefaultLineItem(accountId), LineItem.getDefaultLineItem(accountId)]) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS sent a request to the bidder with two impressions" - def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest.imp?.size() == bidRequest.imp.size() - - and: "First impression contains 2 deals according to the line items" - def firstRequestImp = bidderRequest.imp.find { it.id == bidRequest.imp[0].id } - assert firstRequestImp?.pmp?.deals?.size() == plansResponse.lineItems.size() - assert plansResponse.lineItems.each { lineItem -> - def deal = firstRequestImp.pmp.deals.find { it.id == lineItem.dealId } - - assert deal - verifyAll(deal) { - deal?.ext?.line?.lineItemId == lineItem.lineItemId - deal?.ext?.line?.extLineItemId == lineItem.extLineItemId - deal?.ext?.line?.sizes?.size() == lineItem.sizes.size() - deal?.ext?.line?.sizes[0].w == lineItem.sizes[0].w - deal?.ext?.line?.sizes[0].h == lineItem.sizes[0].h - } - } - - def topMatchLineItemId = firstRequestImp.pmp.deals.first().ext.line.lineItemId - def secondRequestImp = bidderRequest.imp.find { it.id == bidRequest.imp[1].id } - - and: "Second impression contains only 1 deal excluding already top matched line items by the first impression" - assert secondRequestImp.pmp.deals.size() == plansResponse.lineItems.size() - 1 - assert !(secondRequestImp.pmp.deals.collect { it.ext.line.lineItemId } in topMatchLineItemId) - - assert plansResponse.lineItems.findAll { it.lineItemId != topMatchLineItemId }.each { lineItem -> - def deal = secondRequestImp.pmp.deals.find { it.id == lineItem.dealId } - - assert deal - verifyAll(deal) { - deal?.ext?.line?.lineItemId == lineItem.lineItemId - deal?.ext?.line?.extLineItemId == lineItem.extLineItemId - deal?.ext?.line?.sizes?.size() == lineItem.sizes.size() - deal?.ext?.line?.sizes[0].w == lineItem.sizes[0].w - deal?.ext?.line?.sizes[0].h == lineItem.sizes[0].h - } - } - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/PgDealsOnlySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/PgDealsOnlySpec.groovy deleted file mode 100644 index d5677d963cf..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/PgDealsOnlySpec.groovy +++ /dev/null @@ -1,190 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.bidder.BidderName -import org.prebid.server.functional.model.bidder.Generic -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.BidRequestExt -import org.prebid.server.functional.model.request.auction.Prebid -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.PBSUtils - -import static org.prebid.server.functional.model.response.auction.ErrorType.GENERIC -import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID - -class PgDealsOnlySpec extends BasePgSpec { - - def "PBS shouldn't call bidder when bidder pgdealsonly flag is set to true and no available PG line items"() { - given: "Bid request with set pgdealsonly flag" - def bidRequest = BidRequest.defaultBidRequest - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(pgDealsOnly: true) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(new PlansResponse(lineItems: [])) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't called bidder during auction" - assert initialBidderRequestCount == bidder.requestCount - - and: "PBS returns a not calling bidder warning" - def auctionWarnings = auctionResponse.ext?.warnings?.get(PREBID) - assert auctionWarnings.size() == 1 - assert auctionWarnings[0].code == 999 - assert auctionWarnings[0].message == - "Not calling $GENERIC.value bidder for impressions ${bidRequest.imp[0].id}" + - " due to pgdealsonly flag and no available PG line items." - } - - def "PBS shouldn't call bidder when bidder alias is set, bidder pgdealsonly flag is set to true and no available PG line items"() { - given: "Bid request with set bidder alias and pgdealsonly flag" - def bidderAliasName = PBSUtils.randomString - def bidRequest = BidRequest.defaultBidRequest.tap { - def prebid = new Prebid(aliases: [(bidderAliasName): BidderName.GENERIC], debug: 1) - ext = new BidRequestExt(prebid: prebid) - } - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(pgDealsOnly: true) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(new PlansResponse(lineItems: [])) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't called bidder during auction" - assert initialBidderRequestCount == bidder.requestCount - - and: "PBS returns a not calling bidder warning" - def auctionWarnings = auctionResponse.ext?.warnings?.get(PREBID) - assert auctionWarnings.size() == 1 - assert auctionWarnings[0].code == 999 - assert auctionWarnings[0].message == - "Not calling $GENERIC.value bidder for impressions ${bidRequest.imp[0].id}" + - " due to pgdealsonly flag and no available PG line items." - } - - def "PBS should call bidder when bidder pgdealsonly flag is set to false and no available PG line items"() { - given: "Bid request with set pgdealsonly flag" - def bidRequest = BidRequest.defaultBidRequest - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(pgDealsOnly: false) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(new PlansResponse(lineItems: [])) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS has called bidder during auction" - assert initialBidderRequestCount + 1 == bidder.requestCount - assert !auctionResponse.ext?.warnings - } - - def "PBS should return an error when bidder dealsonly flag is set to true, no available PG line items and bid response misses 'dealid' field"() { - given: "Bid request with set dealsonly flag" - def bidRequest = BidRequest.defaultBidRequest - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(dealsOnly: true) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id)) - - and: "Bid response with missing 'dealid' field" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidResponse.seatbid[0].bid[0].dealid = null - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder was requested" - assert initialBidderRequestCount + 1 == bidder.requestCount - - and: "PBS returns an error of missing 'dealid' field in bid" - def bidErrors = auctionResponse.ext?.errors?.get(GENERIC) - def bidId = bidResponse.seatbid[0].bid[0].id - - assert bidErrors?.size() == 1 - assert bidErrors[0].code == 5 - assert bidErrors[0].message ==~ /BidId `$bidId` validation messages:.* Error: / + - /Bid "$bidId" missing required field 'dealid'.*/ - } - - def "PBS should add dealsonly flag when it is not specified and pgdealsonly flag is set to true"() { - given: "Bid request with set pgdealsonly flag, dealsonly is not specified" - def bidRequest = BidRequest.defaultBidRequest - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(pgDealsOnly: true) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id)) - - and: "Bid response with missing 'dealid' field to check dealsonly flag was added and worked" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidResponse.seatbid[0].bid[0].dealid = null - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder was requested" - assert initialBidderRequestCount + 1 == bidder.requestCount - - and: "PBS added dealsonly flag to the bidder request" - assert auctionResponse.ext?.debug?.resolvedRequest?.imp?.first()?.ext?.prebid?.bidder?.generic?.dealsOnly - - and: "PBS returns an error of missing 'dealid' field in bid" - def bidErrors = auctionResponse.ext?.errors?.get(GENERIC) - def bidId = bidResponse.seatbid[0].bid[0].id - - assert bidErrors?.size() == 1 - assert bidErrors[0].code == 5 - assert bidErrors[0].message ==~ /BidId `$bidId` validation messages:.* Error: / + - /Bid "$bidId" missing required field 'dealid'.*/ - } - - def "PBS shouldn't return an error when bidder dealsonly flag is set to true, no available PG line items and bid response misses 'dealid' field"() { - given: "Bid request with set dealsonly flag" - def bidRequest = BidRequest.defaultBidRequest - bidRequest.imp.first().ext.prebid.bidder.generic = new Generic(dealsOnly: false) - def initialBidderRequestCount = bidder.requestCount - - and: "No line items response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id)) - - and: "Bid response with missing 'dealid' field" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidResponse.seatbid[0].bid[0].dealid = null - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "Bidder was requested" - assert initialBidderRequestCount + 1 == bidder.requestCount - - and: "PBS hasn't returned an error" - !auctionResponse.ext?.errors - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/PlansSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/PlansSpec.groovy deleted file mode 100644 index 6d277034751..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/PlansSpec.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils - -import static org.mockserver.model.HttpStatusCode.INTERNAL_SERVER_ERROR_500 -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_PASSWORD -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_USERNAME -import static org.prebid.server.functional.util.HttpUtil.AUTHORIZATION_HEADER -import static org.prebid.server.functional.util.HttpUtil.PG_TRX_ID_HEADER -import static org.prebid.server.functional.util.HttpUtil.UUID_REGEX - -class PlansSpec extends BasePgSpec { - - def "PBS should be able to send a request to General Planner"() { - given: "General Planner response is set" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString), OK_200) - - when: "PBS sends request to General Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - - then: "Request is sent" - PBSUtils.waitUntil { generalPlanner.recordedPlansRequestCount == 1 } - } - - def "PBS should retry request to General Planner when first request fails"() { - given: "Bad General Planner response" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString), INTERNAL_SERVER_ERROR_500) - - when: "PBS sends request to General Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - - then: "Request is sent two times" - PBSUtils.waitUntil { generalPlanner.recordedPlansRequestCount == 2 } - } - - def "PBS should send appropriate headers when requests plans from General Planner"() { - when: "PBS sends request to General Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - - then: "Request with headers is sent" - def plansRequestHeaders = generalPlanner.lastRecordedPlansRequestHeaders - assert plansRequestHeaders - - and: "Request has an authorization header with a basic auth token" - def basicAuthToken = HttpUtil.makeBasicAuthHeaderValue(PG_ENDPOINT_USERNAME, PG_ENDPOINT_PASSWORD) - assert plansRequestHeaders.get(AUTHORIZATION_HEADER) == [basicAuthToken] - - and: "Request has a header with uuid value" - def uuidHeader = plansRequestHeaders.get(PG_TRX_ID_HEADER) - assert uuidHeader?.size() == 1 - assert (uuidHeader[0] =~ UUID_REGEX).matches() - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/RegisterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/RegisterSpec.groovy deleted file mode 100644 index a62a10cd594..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/RegisterSpec.groovy +++ /dev/null @@ -1,229 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_PASSWORD -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_USERNAME -import static org.prebid.server.functional.util.HttpUtil.AUTHORIZATION_HEADER -import static org.prebid.server.functional.util.HttpUtil.PG_TRX_ID_HEADER -import static org.prebid.server.functional.util.HttpUtil.UUID_REGEX - -class RegisterSpec extends BasePgSpec { - - def setupSpec() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should be able to register its instance in Planner on demand"() { - given: "Properties values from PBS config" - def host = pgConfig.hostId - def vendor = pgConfig.vendor - def region = pgConfig.region - - and: "Initial Planner request count" - def initialRequestCount = generalPlanner.requestCount - - when: "PBS sends request to Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "Request counter is increased" - PBSUtils.waitUntil { generalPlanner.requestCount == initialRequestCount + 1 } - - and: "PBS instance is healthy" - def registerRequest = generalPlanner.lastRecordedRegisterRequest - assert registerRequest.healthIndex >= 0 && registerRequest.healthIndex <= 1 - - and: "Host, vendor and region are appropriate to the config" - assert registerRequest.hostInstanceId == host - assert registerRequest.vendor == vendor - assert registerRequest.region == region - - and: "Delivery Statistics Report doesn't have delivery specific data" - verifyAll(registerRequest.status.dealsStatus) { delStatsReport -> - (delStatsReport.reportId =~ UUID_REGEX).matches() - delStatsReport.instanceId == host - delStatsReport.vendor == vendor - delStatsReport.region == region - !delStatsReport.lineItemStatus - !delStatsReport.dataWindowStartTimeStamp - !delStatsReport.dataWindowEndTimeStamp - delStatsReport.reportTimeStamp.isBefore(ZonedDateTime.now(ZoneId.from(UTC))) - } - } - - def "PBS should send a register request with appropriate headers"() { - when: "Initiating PBS to register its instance" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "Request with headers is sent" - def registerRequestHeaders = generalPlanner.lastRecordedRegisterRequestHeaders - assert registerRequestHeaders - - and: "Request has an authorization header with a basic auth token" - def basicAuthToken = HttpUtil.makeBasicAuthHeaderValue(PG_ENDPOINT_USERNAME, PG_ENDPOINT_PASSWORD) - assert registerRequestHeaders.get(AUTHORIZATION_HEADER) == [basicAuthToken] - - and: "Request has a header with uuid value" - def uuidHeader = registerRequestHeaders.get(PG_TRX_ID_HEADER) - assert uuidHeader?.size() == 1 - assert (uuidHeader[0] =~ UUID_REGEX).matches() - } - - def "PBS should be able to register its instance in Planner providing active PBS line items info"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - def lineItem = plansResponse.lineItems[0] - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial Planner request count" - def initialRequestCount = generalPlanner.requestCount - - when: "PBS sends request to Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "Request counter is increased" - PBSUtils.waitUntil { generalPlanner.requestCount == initialRequestCount + 1 } - - and: "Delivery Statistics Report has active line item data" - def registerRequest = generalPlanner.lastRecordedRegisterRequest - def delStatsReport = registerRequest.status?.dealsStatus - assert delStatsReport - def lineItemStatus = delStatsReport.lineItemStatus - - assert lineItemStatus?.size() == plansResponse.lineItems.size() - verifyAll(lineItemStatus) { - lineItemStatus[0].lineItemSource == lineItem.source - lineItemStatus[0].lineItemId == lineItem.lineItemId - lineItemStatus[0].dealId == lineItem.dealId - lineItemStatus[0].extLineItemId == lineItem.extLineItemId - } - - and: "Line item wasn't used in auction" - verifyAll(lineItemStatus) { - !lineItemStatus[0].accountAuctions - !lineItemStatus[0].targetMatched - !lineItemStatus[0].sentToBidder - !lineItemStatus[0].spentTokens - } - - cleanup: - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should be able to register its instance in Planner providing line items status after auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - def lineItem = plansResponse.lineItems[0] - def lineItemCount = plansResponse.lineItems.size() as Long - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial Planner request count" - def initialRequestCount = generalPlanner.requestCount - - and: "Auction is requested" - pgPbsService.sendAuctionRequest(bidRequest) - - when: "PBS sends request to Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "Request counter is increased" - PBSUtils.waitUntil { generalPlanner.requestCount == initialRequestCount + 1 } - - and: "Delivery Statistics Report has info about auction" - def registerRequest = generalPlanner.lastRecordedRegisterRequest - def delStatsReport = registerRequest.status.dealsStatus - assert delStatsReport - - and: "Delivery Statistics Report has correct line item status data" - def lineItemStatus = delStatsReport.lineItemStatus - - assert lineItemStatus?.size() as Long == lineItemCount - verifyAll(lineItemStatus) { - lineItemStatus[0].lineItemSource == lineItem.source - lineItemStatus[0].lineItemId == lineItem.lineItemId - lineItemStatus[0].dealId == lineItem.dealId - lineItemStatus[0].extLineItemId == lineItem.extLineItemId - } - - and: "Line item was used in auction" - verifyAll(lineItemStatus) { - lineItemStatus[0].accountAuctions == lineItemCount - lineItemStatus[0].targetMatched == lineItemCount - lineItemStatus[0].sentToBidder == lineItemCount - lineItemStatus[0].spentTokens == lineItemCount - } - - cleanup: - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should update auction count when register its instance in Planner after auction"() { - given: "Initial auction count" - def initialRequestCount = generalPlanner.requestCount - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - PBSUtils.waitUntil { generalPlanner.requestCount == initialRequestCount + 1 } - def initialAuctionCount = generalPlanner.lastRecordedRegisterRequest?.status?.dealsStatus?.clientAuctions - - and: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial Planner request count" - initialRequestCount = generalPlanner.requestCount - - and: "Auction is requested" - pgPbsService.sendAuctionRequest(bidRequest) - - when: "PBS sends request to Planner" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.registerInstanceRequest) - - then: "Request counter is increased" - PBSUtils.waitUntil { generalPlanner.requestCount == initialRequestCount + 1 } - - and: "Delivery Statistics Report has info about auction" - def registerRequest = generalPlanner.lastRecordedRegisterRequest - assert registerRequest.status?.dealsStatus?.clientAuctions == initialAuctionCount + 1 - - cleanup: - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/ReportSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/ReportSpec.groovy deleted file mode 100644 index 75c73d0f534..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/ReportSpec.groovy +++ /dev/null @@ -1,559 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.DeliverySchedule -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.lineitem.Token -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils - -import java.time.ZoneId -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatter - -import static java.time.ZoneOffset.UTC -import static org.mockserver.model.HttpStatusCode.CONFLICT_409 -import static org.mockserver.model.HttpStatusCode.INTERNAL_SERVER_ERROR_500 -import static org.mockserver.model.HttpStatusCode.OK_200 -import static org.prebid.server.functional.model.deals.lineitem.LineItem.TIME_PATTERN -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_PASSWORD -import static org.prebid.server.functional.testcontainers.PbsPgConfig.PG_ENDPOINT_USERNAME -import static org.prebid.server.functional.util.HttpUtil.AUTHORIZATION_HEADER -import static org.prebid.server.functional.util.HttpUtil.CHARSET_HEADER_VALUE -import static org.prebid.server.functional.util.HttpUtil.CONTENT_TYPE_HEADER -import static org.prebid.server.functional.util.HttpUtil.CONTENT_TYPE_HEADER_VALUE -import static org.prebid.server.functional.util.HttpUtil.PG_TRX_ID_HEADER -import static org.prebid.server.functional.util.HttpUtil.UUID_REGEX - -class ReportSpec extends BasePgSpec { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS shouldn't send delivery statistics when PBS doesn't have reports to send"() { - given: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "Delivery Statistics Service request count is not changed" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount } - } - - def "PBS shouldn't send delivery statistics when delivery report batch is created but doesn't have reports to send"() { - given: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "Delivery Statistics Service request count is not changed" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount } - } - - def "PBS should send a report request with appropriate headers"() { - given: "Initial report sent request count is taken" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Line items are fetched" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(PBSUtils.randomString)) - updateLineItemsAndWait() - - and: "Delivery report batch is created" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - and: "PBS sends a report request to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - then: "Request headers corresponds to the payload" - def deliveryRequestHeaders = deliveryStatistics.lastRecordedDeliveryRequestHeaders - assert deliveryRequestHeaders - - and: "Request has an authorization header with a basic auth token" - def basicAuthToken = HttpUtil.makeBasicAuthHeaderValue(PG_ENDPOINT_USERNAME, PG_ENDPOINT_PASSWORD) - assert deliveryRequestHeaders.get(AUTHORIZATION_HEADER) == [basicAuthToken] - - and: "Request has a header with uuid value" - def uuidHeader = deliveryRequestHeaders.get(PG_TRX_ID_HEADER) - assert uuidHeader?.size() == 1 - assert (uuidHeader[0] =~ UUID_REGEX).matches() - - and: "Request has a content type header" - assert deliveryRequestHeaders.get(CONTENT_TYPE_HEADER) == ["$CONTENT_TYPE_HEADER_VALUE;$CHARSET_HEADER_VALUE"] - } - - def "PBS should send delivery statistics report when delivery progress report with one line item is created"() { - given: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Time before report is sent" - def startTime = ZonedDateTime.now(UTC) - - and: "Set Planner response to return one line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(PBSUtils.randomString) - def lineItem = plansResponse.lineItems[0] - generalPlanner.initPlansResponse(plansResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report request to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "Report request should correspond to the payload" - def reportRequest = deliveryStatistics.lastRecordedDeliveryStatisticsReportRequest - def endTime = ZonedDateTime.now(ZoneId.from(UTC)) - - verifyAll(reportRequest) { - (reportRequest.reportId =~ UUID_REGEX).matches() - reportRequest.instanceId == pgConfig.hostId - reportRequest.vendor == pgConfig.vendor - reportRequest.region == pgConfig.region - !reportRequest.clientAuctions - - reportRequest.reportTimeStamp.isBefore(endTime) - reportRequest.dataWindowStartTimeStamp.isBefore(startTime) - reportRequest.dataWindowEndTimeStamp.isAfter(startTime) - reportRequest.dataWindowEndTimeStamp.isBefore(endTime) - reportRequest.reportTimeStamp.isAfter(reportRequest.dataWindowEndTimeStamp) - } - - and: "Report line items should have an appropriate to the initially set line items info" - assert reportRequest.lineItemStatus?.size() == 1 - def lineItemStatus = reportRequest.lineItemStatus[0] - - verifyAll(lineItemStatus) { - lineItemStatus.lineItemSource == lineItem.source - lineItemStatus.lineItemId == lineItem.lineItemId - lineItemStatus.dealId == lineItem.dealId - lineItemStatus.extLineItemId == lineItem.extLineItemId - !lineItemStatus.accountAuctions - !lineItemStatus.domainMatched - !lineItemStatus.targetMatched - !lineItemStatus.targetMatchedButFcapped - !lineItemStatus.targetMatchedButFcapLookupFailed - !lineItemStatus.pacingDeferred - !lineItemStatus.sentToBidder - !lineItemStatus.sentToBidderAsTopMatch - !lineItemStatus.receivedFromBidder - !lineItemStatus.receivedFromBidderInvalidated - !lineItemStatus.sentToClient - !lineItemStatus.sentToClientAsTopMatch - !lineItemStatus.lostToLineItems - !lineItemStatus.events - !lineItemStatus.readyAt - !lineItemStatus.spentTokens - !lineItemStatus.pacingFrequency - - lineItemStatus.deliverySchedule?.size() == 1 - } - - def timeFormatter = DateTimeFormatter.ofPattern(TIME_PATTERN) - def deliverySchedule = lineItemStatus.deliverySchedule[0] - - verifyAll(deliverySchedule) { - deliverySchedule.planId == lineItem.deliverySchedules[0].planId - timeFormatter.format(deliverySchedule.planStartTimeStamp) == - timeFormatter.format(lineItem.deliverySchedules[0].startTimeStamp) - timeFormatter.format(deliverySchedule.planUpdatedTimeStamp) == - timeFormatter.format(lineItem.deliverySchedules[0].updatedTimeStamp) - timeFormatter.format(deliverySchedule.planExpirationTimeStamp) == - timeFormatter.format(lineItem.deliverySchedules[0].endTimeStamp) - - deliverySchedule.tokens?.size() == 1 - } - - verifyAll(deliverySchedule.tokens[0]) { tokens -> - tokens.priorityClass == lineItem.deliverySchedules[0].tokens[0].priorityClass - tokens.total == lineItem.deliverySchedules[0].tokens[0].total - tokens.spent == 0 - tokens.totalSpent == 0 - } - } - - def "PBS should send a correct delivery statistics report when auction with one line item is happened"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Time before report is sent" - def startTime = ZonedDateTime.now(UTC) - - and: "Set Planner response to return one line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - def lineItem = plansResponse.lineItems[0] - def lineItemCount = plansResponse.lineItems.size() as Long - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - when: "Auction request to PBS is sent" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report request to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "Report request should be sent after the test start" - def reportRequest = deliveryStatistics.lastRecordedDeliveryStatisticsReportRequest - assert reportRequest.reportTimeStamp.isAfter(startTime) - - and: "Request should contain correct number of client auctions made" - assert reportRequest.clientAuctions == 1 - - and: "Report line items should have an appropriate to the initially set line item info" - assert reportRequest.lineItemStatus?.size() == 1 - def lineItemStatus = reportRequest.lineItemStatus[0] - - verifyAll(lineItemStatus) { - lineItemStatus.lineItemSource == lineItem.source - lineItemStatus.lineItemId == lineItem.lineItemId - lineItemStatus.dealId == lineItem.dealId - lineItemStatus.extLineItemId == lineItem.extLineItemId - } - - and: "Report should have the right PG metrics info" - verifyAll(lineItemStatus) { - lineItemStatus?.accountAuctions == lineItemCount - lineItemStatus?.targetMatched == lineItemCount - lineItemStatus?.sentToBidder == lineItemCount - lineItemStatus?.sentToBidderAsTopMatch == lineItemCount - } - - and: "Report line item should have a delivery schedule" - assert lineItemStatus.deliverySchedule?.size() == 1 - assert lineItemStatus.deliverySchedule[0].planId == lineItem.deliverySchedules[0].planId - } - - def "PBS should use line item token with the highest priority"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Time before report is sent" - def startTime = ZonedDateTime.now(UTC) - - and: "Set Planner response to return one line item" - def highestPriorityToken = new Token(priorityClass: 1, total: 2) - def lowerPriorityToken = new Token(priorityClass: 3, total: 2) - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - def tokens = [highestPriorityToken, lowerPriorityToken] - lineItems[0].deliverySchedules[0].tokens = tokens - } - def tokens = plansResponse.lineItems[0].deliverySchedules[0].tokens - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - when: "Auction request to PBS is sent" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report request to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "Report request should be sent after the test start" - def reportRequest = deliveryStatistics.lastRecordedDeliveryStatisticsReportRequest - assert reportRequest.reportTimeStamp.isAfter(startTime) - - and: "Token with the highest priority was used" - def reportTokens = reportRequest.lineItemStatus?.first()?.deliverySchedule?.first()?.tokens - assert reportTokens - assert reportTokens.size() == tokens.size() - def usedToken = reportTokens.find { it.priorityClass == highestPriorityToken.priorityClass } - assert usedToken?.total == highestPriorityToken.total - assert usedToken?.spent == 1 - assert usedToken?.totalSpent == 1 - - and: "Token with a lower priority wasn't used" - def notUsedToken = reportTokens.find { it.priorityClass == lowerPriorityToken.priorityClass } - assert notUsedToken?.total == lowerPriorityToken.total - assert notUsedToken?.spent == 0 - assert notUsedToken?.totalSpent == 0 - } - - def "PBS shouldn't consider line item as used when bidder responds with non-deals specific info"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Time before report is sent" - def startTime = ZonedDateTime.now(UTC) - - and: "Set Planner response to return one line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Non-deals bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - when: "Auction request to PBS is sent" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report request to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "Report request should be sent after the test start" - def reportRequest = deliveryStatistics.lastRecordedDeliveryStatisticsReportRequest - assert reportRequest.reportTimeStamp.isAfter(startTime) - - and: "Line item token wasn't used" - def reportTokens = reportRequest.lineItemStatus?.first()?.deliverySchedule?.first()?.tokens - assert reportTokens?.size() == plansResponse.lineItems[0].deliverySchedules[0].tokens.size() - assert reportTokens[0].spent == 0 - assert reportTokens[0].totalSpent == 0 - } - - def "PBS should send additional report when line items number exceeds PBS 'line-items-per-report' property"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Already recorded request count is reset" - deliveryStatistics.resetRecordedRequests() - deliveryStatistics.setResponse() - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - and: "Set Planner response to return #lineItemsPerReport + 1 line items" - def lineItemsPerReport = pgConfig.lineItemsPerReport - def plansResponse = new PlansResponse(lineItems: (1..lineItemsPerReport + 1).collect { - LineItem.getDefaultLineItem(accountId) - }) - generalPlanner.initPlansResponse(plansResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - when: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends two report requests to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 2 } - - and: "Two reports are sent" - def reportRequests = deliveryStatistics.recordedDeliveryStatisticsReportRequests - assert reportRequests.size() == 2 - - and: "Two reports were sent with #lineItemsPerReport and 1 number of line items" - assert [reportRequests[-2].lineItemStatus.size(), reportRequests[-1].lineItemStatus.size()].sort() == - [lineItemsPerReport, 1].sort() - } - - def "PBS should save reports for later sending when response from Delivery Statistics was unsuccessful"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Set Planner response to return 1 line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(accountId) - generalPlanner.initPlansResponse(plansResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "Delivery Statistics Service response is set to return a bad status code" - deliveryStatistics.reset() - deliveryStatistics.setResponse(INTERNAL_SERVER_ERROR_500) - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report to Delivery Statistics" - PBSUtils.waitUntil { deliveryStatistics.requestCount == 1 } - - when: "Delivery Statistics Service response is set to return a success response" - deliveryStatistics.reset() - deliveryStatistics.setResponse(OK_200) - - and: "PBS is requested to send a report to Delivery Statistics for the second time" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS for the second time sends the same report to the Delivery Statistics Service" - PBSUtils.waitUntil { deliveryStatistics.requestCount == 1 } - } - - def "PBS shouldn't save reports for later sending when Delivery Statistics response is Conflict 409"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Set Planner response to return 1 line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(accountId) - generalPlanner.initPlansResponse(plansResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "Delivery Statistics Service response is set to return a Conflict status code" - deliveryStatistics.reset() - deliveryStatistics.setResponse(CONFLICT_409) - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - - when: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report to Delivery Statistics" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "PBS is requested to send a report to Delivery Statistics for the second time" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS doesn't request Delivery Statistics Service for the second time" - assert deliveryStatistics.requestCount == initialRequestCount + 1 - } - - def "PBS should change active delivery plan when the current plan lifetime expires"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - def accountId = bidRequest.site.publisher.id - - and: "Initial Delivery Statistics Service request count" - def initialRequestCount = deliveryStatistics.requestCount - def auctionCount = 2 - - and: "Current delivery plan which expires in 2 seconds" - def currentPlanTimeToLive = 2 - def currentDeliverySchedule = new DeliverySchedule(planId: PBSUtils.randomNumber as String, - startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)), - endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusSeconds(currentPlanTimeToLive), - tokens: [new Token(priorityClass: 1, total: 1000)]) - - and: "Next delivery plan" - def nextDeliverySchedule = new DeliverySchedule(planId: PBSUtils.randomNumber as String, - startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusSeconds(currentPlanTimeToLive), - updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusSeconds(currentPlanTimeToLive), - endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusHours(1), - tokens: [new Token(priorityClass: 1, total: 500)]) - - and: "Set Planner response to return line item with two delivery plans" - def plansResponse = PlansResponse.getDefaultPlansResponse(accountId).tap { - lineItems[0].deliverySchedules = [currentDeliverySchedule, nextDeliverySchedule] - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "PBS requests Planner line items" - updateLineItemsAndWait() - - and: "Auction request to PBS is sent for the first time" - pgPbsService.sendAuctionRequest(bidRequest) - - when: "Current delivery plan lifetime is expired" - PBSUtils.waitUntil({ ZonedDateTime.now(ZoneId.from(UTC)).isAfter(currentDeliverySchedule.endTimeStamp) }, - (currentPlanTimeToLive * 1000) + 1000) - - and: "PBS requests Planner line items which also forces current PBS line items to be updated" - generalPlanner.initPlansResponse(plansResponse) - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest) - - and: "Auction request to PBS is sent for the second time" - bidder.setResponse(bidRequest.id, bidResponse) - pgPbsService.sendAuctionRequest(bidRequest) - - and: "PBS generates delivery report batch" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.createReportRequest) - - and: "PBS is requested to send a report to Delivery Statistics" - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.sendReportRequest) - - then: "PBS sends a report to Delivery Statistics" - PBSUtils.waitUntil { deliveryStatistics.requestCount == initialRequestCount + 1 } - - and: "Report has info about 2 happened auctions" - def reportRequest = deliveryStatistics.lastRecordedDeliveryStatisticsReportRequest - assert reportRequest.clientAuctions == auctionCount - assert reportRequest.lineItemStatus?.size() == plansResponse.lineItems.size() - assert reportRequest.lineItemStatus[0].accountAuctions == auctionCount - - and: "One line item during each auction was sent to the bidder" - assert reportRequest.lineItemStatus[0].sentToBidder == auctionCount - - and: "Report contains two delivery plans info" - def reportDeliverySchedules = reportRequest.lineItemStatus[0].deliverySchedule - assert reportDeliverySchedules?.size() == plansResponse.lineItems[0].deliverySchedules.size() - - and: "One token was used during the first auction by the first delivery plan" - assert reportDeliverySchedules.find { it.planId == currentDeliverySchedule.planId }?.tokens[0].spent == 1 - - and: "One token was used from another delivery plan during the second auction after first delivery plan lifetime expired" - assert reportDeliverySchedules.find { it.planId == nextDeliverySchedule.planId }?.tokens[0].spent == 1 - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingFirstPartyDataSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingFirstPartyDataSpec.groovy deleted file mode 100644 index a1552071a8d..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingFirstPartyDataSpec.groovy +++ /dev/null @@ -1,707 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.targeting.Targeting -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.AppExt -import org.prebid.server.functional.model.request.auction.AppExtData -import org.prebid.server.functional.model.request.auction.Banner -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.BidRequestExt -import org.prebid.server.functional.model.request.auction.BidderConfig -import org.prebid.server.functional.model.request.auction.BidderConfigOrtb -import org.prebid.server.functional.model.request.auction.DoohExt -import org.prebid.server.functional.model.request.auction.DoohExtData -import org.prebid.server.functional.model.request.auction.ExtPrebidBidderConfig -import org.prebid.server.functional.model.request.auction.Imp -import org.prebid.server.functional.model.request.auction.ImpExtContext -import org.prebid.server.functional.model.request.auction.ImpExtContextData -import org.prebid.server.functional.model.request.auction.Prebid -import org.prebid.server.functional.model.request.auction.Site -import org.prebid.server.functional.model.request.auction.SiteExt -import org.prebid.server.functional.model.request.auction.SiteExtData -import org.prebid.server.functional.model.request.auction.User -import org.prebid.server.functional.model.request.auction.UserExt -import org.prebid.server.functional.model.request.auction.UserExtData -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.service.PrebidServerException -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Shared - -import static org.prebid.server.functional.model.bidder.BidderName.APPNEXUS -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC_CAMEL_CASE -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.IN -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.INTERSECTS -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.MATCHES -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.SFPD_BUYER_ID -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.SFPD_BUYER_IDS -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.SFPD_KEYWORDS -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.SFPD_LANGUAGE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.UFPD_BUYER_UID -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.UFPD_BUYER_UIDS -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.UFPD_KEYWORDS -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.UFPD_YOB -import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP -import static org.prebid.server.functional.model.request.auction.DistributionChannel.DOOH -import static org.prebid.server.functional.model.request.auction.DistributionChannel.SITE - -class TargetingFirstPartyDataSpec extends BasePgSpec { - - @Shared - String stringTargetingValue = PBSUtils.randomString - @Shared - Integer integerTargetingValue = PBSUtils.randomNumber - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should support both scalar and array String inputs by '#ufpdTargetingType' for INTERSECTS matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - ext = new UserExt(data: userExtData) - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(ufpdTargetingType, INTERSECTS, [stringTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - ufpdTargetingType | userExtData - UFPD_BUYER_UID | new UserExtData(buyeruid: stringTargetingValue) - UFPD_KEYWORDS | new UserExtData(keywords: [stringTargetingValue]) - } - - def "PBS should support both scalar and array Integer inputs by '#ufpdTargetingType' for INTERSECTS matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - ext = new UserExt(data: userExtData) - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(ufpdTargetingType, INTERSECTS, [stringTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - ufpdTargetingType | userExtData - UFPD_BUYER_UID | new UserExtData(buyeruid: stringTargetingValue) - UFPD_BUYER_UIDS | new UserExtData(buyeruids: [stringTargetingValue]) - } - - def "PBS should support taking Site First Party Data from #place source"() { - given: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.getAccountId()).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, INTERSECTS, [stringTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - place | bidRequest - "imp[].ext.context" | BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - ext.context = new ImpExtContext(data: new ImpExtContextData(language: stringTargetingValue)) - }] - } - "site" | BidRequest.defaultBidRequest.tap { - site = Site.defaultSite.tap { - ext = new SiteExt(data: new SiteExtData(language: stringTargetingValue)) - } - } - "imp[].ext.data" | BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - ext.data = new ImpExtContextData(language: stringTargetingValue) - }] - } - } - - def "PBS should support String array input for Site First Party Data to be matched by INTERSECTS matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - banner = Banner.defaultBanner - ext.context = new ImpExtContext(data: new ImpExtContextData(keywords: [stringTargetingValue])) - }] - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_KEYWORDS, INTERSECTS, [stringTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should support both scalar and array Integer inputs in Site First Party Data ('#targetingType') by INTERSECTS matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - banner = Banner.defaultBanner - ext.context = new ImpExtContext(data: impExtContextData) - }] - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(targetingType, INTERSECTS, [integerTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - targetingType | impExtContextData - SFPD_BUYER_ID | new ImpExtContextData(buyerId: integerTargetingValue) - SFPD_BUYER_IDS | new ImpExtContextData(buyerIds: [integerTargetingValue]) - } - - def "PBS shouldn't throw a NPE for Site First Party Data when its Ext is absent and targeting INTERSECTS matching type is selected"() { - given: "Bid request with set site first party data in bidRequest.site" - def bidRequest = BidRequest.defaultBidRequest.tap { - site = Site.defaultSite.tap { - keywords = stringTargetingValue - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_KEYWORDS, INTERSECTS, [stringTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS successfully processed request" - notThrown(PrebidServerException) - - and: "PBS hasn't had PG auction as request targeting is not specified in the right place" - assert !auctionResponse.ext?.debug?.pgmetrics - } - - def "PBS should support taking User FPD from bidRequest.user by #matchingFunction matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - updateUserFieldGeneric(it) - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(ufpdTargetingType, matchingFunction, [targetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - ufpdTargetingType | updateUserFieldGeneric | targetingValue | matchingFunction - UFPD_BUYER_UID | { it.buyeruid = stringTargetingValue } | stringTargetingValue | INTERSECTS - UFPD_BUYER_UID | { it.buyeruid = stringTargetingValue } | stringTargetingValue | IN - UFPD_YOB | { it.yob = integerTargetingValue } | integerTargetingValue | INTERSECTS - UFPD_YOB | { it.yob = integerTargetingValue } | integerTargetingValue | IN - } - - def "PBS should support taking User FPD from bidRequest.user by MATCHES matching function"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - it.buyeruid = stringTargetingValue - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should be able to match site FPD targeting taken from different sources by INTERSECTS matching function"() { - given: "Bid request with set site FPD in different request places" - def bidRequest = getSiteFpdBidRequest(siteLanguage, appLanguage, doohLanguage, impLanguage) - - and: "Planner response with INTERSECTS 1 of site FPD values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.getAccountId()).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, INTERSECTS, [stringTargetingValue, PBSUtils.randomString]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - siteLanguage | appLanguage | doohLanguage | impLanguage - stringTargetingValue | null | null | PBSUtils.randomString - null | stringTargetingValue | null | PBSUtils.randomString - null | null | stringTargetingValue | stringTargetingValue - } - - def "PBS should be able to match site FPD targeting taken from different sources by MATCHES matching function"() { - given: "Bid request with set site FPD in different request places" - def bidRequest = getSiteFpdBidRequest(siteLanguage, appLanguage, doohLanguage, impLanguage) - - and: "Planner response with MATCHES 1 of site FPD values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.getAccountId()).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - siteLanguage | appLanguage | doohLanguage | impLanguage - stringTargetingValue | null | null | PBSUtils.randomString - null | stringTargetingValue | null | PBSUtils.randomString - null | null | stringTargetingValue | stringTargetingValue - } - - def "PBS should be able to match site FPD targeting taken from different sources by IN matching function"() { - given: "Bid request with set site FPD in different request places" - def siteLanguage = PBSUtils.randomString - def appLanguage = PBSUtils.randomString - def doohLanguage = PBSUtils.randomString - def impLanguage = PBSUtils.randomString - def bidRequest = getSiteFpdBidRequest(siteLanguage, appLanguage, doohLanguage, impLanguage) - - and: "Planner response with IN all of site FPD values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, IN, [siteLanguage, appLanguage, impLanguage, PBSUtils.randomString]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should be able to match user FPD targeting taken from different sources by MATCHES matching function"() { - given: "Bid request with set user FPD in different request places" - def bidRequest = getUserFpdBidRequest(userBuyerUid, userExtDataBuyerUid) - - and: "Planner response with MATCHES 1 of user FPD values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - - where: - userBuyerUid | userExtDataBuyerUid - stringTargetingValue | PBSUtils.randomString - PBSUtils.randomString | stringTargetingValue - } - - def "PBS should be able to match user FPD targeting taken from different sources by IN matching function"() { - given: "Bid request with set user FPD in different request places" - def userBuyerUid = PBSUtils.randomString - def userExtDataBuyerUid = PBSUtils.randomString - def bidRequest = getUserFpdBidRequest(userBuyerUid, userExtDataBuyerUid) - - and: "Planner response with IN all of user FPD values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, IN, [userBuyerUid, userExtDataBuyerUid, PBSUtils.randomString]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - } - - def "PBS should support targeting by SITE First Party Data when request ext prebid bidder config is given"() { - given: "Bid request with set Site specific bidder config" - def bidRequest = BidRequest.defaultBidRequest.tap { - def site = new Site().tap { - ext = new SiteExt(data: new SiteExtData(language: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [GENERIC], - config: new BidderConfig(ortb2: new BidderConfigOrtb(site: site))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS should support targeting by USER First Party Data when request ext prebid bidder config is given"() { - given: "Bid request with set User specific bidder config" - def bidRequest = BidRequest.defaultBidRequest.tap { - def user = new User().tap { - ext = new UserExt(data: new UserExtData(buyeruid: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [GENERIC], - config: new BidderConfig(ortb2: new BidderConfigOrtb(user: user))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS shouldn't target by SITE First Party Data when request ext prebid bidder config with not matched bidder is given"() { - given: "Bid request with request not matched bidder" - def notMatchedBidder = APPNEXUS - def bidRequest = BidRequest.defaultBidRequest.tap { - def site = new Site().tap { - ext = new SiteExt(data: new SiteExtData(language: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [notMatchedBidder], - config: new BidderConfig(ortb2: new BidderConfigOrtb(site: site))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't had PG auction" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS shouldn't target by USER First Party Data when request ext prebid bidder config with not matched bidder is given"() { - given: "Bid request with request not matched bidder" - def notMatchedBidder = APPNEXUS - def bidRequest = BidRequest.defaultBidRequest.tap { - def user = new User().tap { - ext = new UserExt(data: new UserExtData(buyeruid: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [notMatchedBidder], - config: new BidderConfig(ortb2: new BidderConfigOrtb(user: user))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't had PG auction" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS should support targeting by SITE First Party Data when a couple of request ext prebid bidder configs are given"() { - given: "Bid request with 1 not matched Site specific bidder config and 1 matched" - def bidRequest = BidRequest.defaultBidRequest.tap { - def bidderConfigSite = new Site().tap { - ext = new SiteExt(data: new SiteExtData(language: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [GENERIC], - config: new BidderConfig(ortb2: new BidderConfigOrtb(site: bidderConfigSite))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SFPD_LANGUAGE, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS should support targeting by USER First Party Data when a couple of request ext prebid bidder configs are given"() { - given: "Bid request with 1 not matched User specific bidder config and 1 matched" - def bidRequest = BidRequest.defaultBidRequest.tap { - def bidderConfigUser = new User().tap { - ext = new UserExt(data: new UserExtData(buyeruid: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [GENERIC], - config: new BidderConfig(ortb2: new BidderConfigOrtb(user: bidderConfigUser))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, matchingFunction, matchingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - matchingFunction | matchingValue - INTERSECTS | [stringTargetingValue, PBSUtils.randomString] - MATCHES | stringTargetingValue - } - - def "PBS shouldn't rely on bidder name case strategy when bidder name in another case stately"() { - given: "Bid request with 1 not matched User specific bidder config and 1 matched" - def bidRequest = BidRequest.defaultBidRequest.tap { - def bidderConfigUser = new User().tap { - ext = new UserExt(data: new UserExtData(buyeruid: stringTargetingValue)) - } - def bidderConfig = new ExtPrebidBidderConfig(bidders: [bidders], - config: new BidderConfig(ortb2: new BidderConfigOrtb(user: bidderConfigUser))) - ext = new BidRequestExt(prebid: new Prebid(debug: 1, bidderConfig: [bidderConfig])) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(UFPD_BUYER_UID, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - bidders << [GENERIC, GENERIC_CAMEL_CASE] - } - - private BidRequest getSiteFpdBidRequest(String siteLanguage, String appLanguage, String doohLanguage, String impLanguage) { - def bidRequest - if (siteLanguage != null) { - bidRequest = BidRequest.getDefaultBidRequest(SITE).tap { - site.ext = new SiteExt(data: new SiteExtData(language: siteLanguage)) - } - } else if (appLanguage != null) { - bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.ext = new AppExt(data: new AppExtData(language: appLanguage)) - } - } else { - bidRequest = BidRequest.getDefaultBidRequest(DOOH).tap { - dooh.ext = new DoohExt(data: new DoohExtData(language: doohLanguage)) - } - } - bidRequest.imp[0].tap { - ext.context = new ImpExtContext(data: new ImpExtContextData(language: impLanguage)) - } - bidRequest - } - - private BidRequest getUserFpdBidRequest(String userBuyerUid, String userExtDataBuyerUid) { - BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - buyeruid = userBuyerUid - ext = new UserExt(data: new UserExtData(buyeruid: userExtDataBuyerUid)) - } - } - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingSpec.groovy deleted file mode 100644 index 882860a9e5b..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/TargetingSpec.groovy +++ /dev/null @@ -1,560 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.bidder.Rubicon -import org.prebid.server.functional.model.deals.lineitem.LineItemSize -import org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator -import org.prebid.server.functional.model.deals.lineitem.targeting.Targeting -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.App -import org.prebid.server.functional.model.request.auction.Banner -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.Bidder -import org.prebid.server.functional.model.request.auction.Device -import org.prebid.server.functional.model.request.auction.Geo -import org.prebid.server.functional.model.request.auction.GeoExt -import org.prebid.server.functional.model.request.auction.GeoExtGeoProvider -import org.prebid.server.functional.model.request.auction.Imp -import org.prebid.server.functional.model.request.auction.ImpExt -import org.prebid.server.functional.model.request.auction.ImpExtContext -import org.prebid.server.functional.model.request.auction.ImpExtContextData -import org.prebid.server.functional.model.request.auction.ImpExtContextDataAdServer -import org.prebid.server.functional.model.request.auction.Publisher -import org.prebid.server.functional.model.request.auction.User -import org.prebid.server.functional.model.request.auction.UserExt -import org.prebid.server.functional.model.request.auction.UserTime -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Shared - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static java.time.temporal.WeekFields.SUNDAY_START -import static org.prebid.server.functional.model.bidder.BidderName.RUBICON -import static org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator.NOT -import static org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator.OR -import static org.prebid.server.functional.model.deals.lineitem.targeting.BooleanOperator.UPPERCASE_AND -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.IN -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.INTERSECTS -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.MATCHES -import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.WITHIN -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_AD_SLOT -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_MEDIA_TYPE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_SIZE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.APP_BUNDLE -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.BIDP_ACCOUNT_ID -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.DEVICE_METRO -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.DEVICE_REGION -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.DOW -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.HOUR -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.INVALID -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.PAGE_POSITION -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.REFERRER -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.SITE_DOMAIN -import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.UFPD_BUYER_UID -import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP -import static org.prebid.server.functional.model.response.auction.MediaType.BANNER -import static org.prebid.server.functional.model.response.auction.MediaType.VIDEO - -class TargetingSpec extends BasePgSpec { - - @Shared - String stringTargetingValue = PBSUtils.randomString - @Shared - Integer integerTargetingValue = PBSUtils.randomNumber - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should invalidate line items when targeting has #reason"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = targeting - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't had PG deals auction as line item hasn't passed validation" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - reason | targeting - - "two root nodes" | Targeting.invalidTwoRootNodesTargeting - - "invalid boolean operator" | new Targeting.Builder(BooleanOperator.INVALID).addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [BANNER]) - .build() - - "uppercase boolean operator" | new Targeting.Builder(UPPERCASE_AND).addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [BANNER]) - .build() - - "invalid targeting type" | Targeting.defaultTargetingBuilder - .addTargeting(INVALID, INTERSECTS, [PBSUtils.randomString]) - .build() - - "'in' matching type value as not list" | new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, IN, BANNER) - .build() - - "'intersects' matching type value as not list" | new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, BANNER) - .build() - - "'within' matching type value as not list" | new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, WITHIN, BANNER) - .build() - - "'matches' matching type value as list" | new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, MATCHES, [BANNER]) - .build() - - "null targeting height and width" | new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [new LineItemSize(w: null, h: null)]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [BANNER]) - .build() - } - - def "PBS should invalidate line items with not supported '#matchingFunction' matching function by '#targetingType' targeting type"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(targetingType, matchingFunction, [PBSUtils.randomString]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't had PG deals auction as line item hasn't passed validation" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - matchingFunction | targetingType - INTERSECTS | SITE_DOMAIN - WITHIN | SITE_DOMAIN - INTERSECTS | REFERRER - WITHIN | REFERRER - INTERSECTS | APP_BUNDLE - WITHIN | APP_BUNDLE - INTERSECTS | AD_UNIT_AD_SLOT - WITHIN | AD_UNIT_AD_SLOT - } - - def "PBS should support line item targeting by string '#targetingType' targeting type"() { - given: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.getAccountId()).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(targetingType, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - targetingType | bidRequest - - REFERRER | BidRequest.defaultBidRequest.tap { - site.page = stringTargetingValue - } - - APP_BUNDLE | BidRequest.getDefaultBidRequest(APP).tap { - app = App.defaultApp.tap { - bundle = stringTargetingValue - } - } - - UFPD_BUYER_UID | BidRequest.defaultBidRequest.tap { - user = User.defaultUser.tap { - buyeruid = stringTargetingValue - } - } - } - - def "PBS should support targeting matching by bidder parameters"() { - given: "Bid request with specified bidder parameter" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - banner = Banner.defaultBanner - ext = ImpExt.defaultImpExt - ext.prebid.bidder = new Bidder(rubicon: Rubicon.defaultRubicon.tap { accountId = integerTargetingValue }) - }] - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].source = RUBICON.name().toLowerCase() - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(BIDP_ACCOUNT_ID, INTERSECTS, [integerTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should support line item targeting by page position targeting type"() { - given: "Bid request and bid response" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].banner.pos = integerTargetingValue - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(PAGE_POSITION, IN, [integerTargetingValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should support line item targeting by userdow targeting type"() { - given: "Bid request and bid response" - def bidRequest = BidRequest.defaultBidRequest.tap { - def weekDay = ZonedDateTime.now(ZoneId.from(UTC)).dayOfWeek.get(SUNDAY_START.dayOfWeek()) - user = User.defaultUser.tap { - ext = new UserExt(time: new UserTime(userdow: weekDay)) - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(DOW, IN, [ZonedDateTime.now(ZoneId.from(UTC)).dayOfWeek.get(SUNDAY_START.dayOfWeek())]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should support line item targeting by userhour targeting type"() { - given: "Bid request and bid response" - def bidRequest = BidRequest.defaultBidRequest.tap { - def hour = ZonedDateTime.now(ZoneId.from(UTC)).hour - user = User.defaultUser.tap { - ext = new UserExt(time: new UserTime(userhour: hour)) - } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(HOUR, IN, [ZonedDateTime.now(ZoneId.from(UTC)).hour]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } - - def "PBS should support line item targeting by '#targetingType' targeting type"() { - given: "Bid request and bid response" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(HOUR, IN, [ZonedDateTime.now(ZoneId.from(UTC)).hour]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - - where: - targetingType | targetingValue - - "'\$or' root node with one match" | new Targeting.Builder(OR).addTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [VIDEO]) - .build() - - "'\$not' root node without matches" | new Targeting.Builder(NOT).buildNotBooleanOperatorTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [VIDEO]) - } - - def "PBS should support line item domain targeting by #domainTargetingType"() { - given: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SITE_DOMAIN, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - - and: "Targeting recorded as matched" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedDomainTargeting?.size() == lineItemSize - - where: - domainTargetingType | bidRequest - - "site domain" | BidRequest.defaultBidRequest.tap { - site.domain = stringTargetingValue - } - - "site publisher domain" | BidRequest.defaultBidRequest.tap { - site.publisher = Publisher.defaultPublisher.tap { domain = stringTargetingValue } - } - } - - def "PBS should support line item domain targeting"() { - given: "Bid response" - def bidRequest = BidRequest.defaultBidRequest.tap { - site.domain = siteDomain - site.publisher = Publisher.defaultPublisher.tap { domain = sitePublisherDomain } - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(SITE_DOMAIN, IN, [siteDomain]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - - and: "Targeting recorded as matched" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedDomainTargeting?.size() == lineItemSize - - where: - siteDomain | sitePublisherDomain - "www.example.com" | null - "https://www.example.com" | null - "www.example.com" | "example.com" - } - - def "PBS should appropriately match '\$or', '\$not' line items targeting root node rules"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = targeting - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't had PG deals auction as targeting differs" - assert !auctionResponse.ext?.debug?.pgmetrics - - where: - targeting << [new Targeting.Builder(OR).addTargeting(AD_UNIT_SIZE, INTERSECTS, [new LineItemSize(w: PBSUtils.randomNumber, h: PBSUtils.randomNumber)]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [VIDEO]) - .build(), - new Targeting.Builder(NOT).buildNotBooleanOperatorTargeting(AD_UNIT_SIZE, INTERSECTS, [LineItemSize.defaultLineItemSize])] - } - - def "PBS should support line item targeting by device geo region, metro when request region, metro as int or str value are given"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest.tap { - device = new Device(geo: new Geo(ext: new GeoExt(geoProvider: new GeoExtGeoProvider(region: requestValue, - metro: requestValue)))) - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(DEVICE_REGION, IN, [lineItemValue]) - .addTargeting(DEVICE_METRO, IN, [lineItemValue]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - assert auctionResponse.ext.debug.pgmetrics.matchedWholeTargeting.first() == plansResponse.lineItems.first().lineItemId - - where: - requestValue | lineItemValue - stringTargetingValue | stringTargetingValue - integerTargetingValue | integerTargetingValue as String - } - - def "PBS should be able to match Ad Slot targeting taken from different sources by MATCHES matching function"() { - given: "Bid request with set ad slot info in different request places" - def bidRequest = BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - tagId = impTagId - ext.gpid = impExtGpid - ext.data = new ImpExtContextData(pbAdSlot: adSlot, - adServer: new ImpExtContextDataAdServer(adSlot: adServerAdSlot)) - }] - } - - and: "Planner response with MATCHES one of Ad Slot values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(AD_UNIT_AD_SLOT, MATCHES, stringTargetingValue) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - - where: - impTagId | impExtGpid | adSlot | adServerAdSlot - stringTargetingValue | PBSUtils.randomString | PBSUtils.randomString | PBSUtils.randomString - PBSUtils.randomString | stringTargetingValue | PBSUtils.randomString | PBSUtils.randomString - null | null | stringTargetingValue | PBSUtils.randomString - null | null | PBSUtils.randomString | stringTargetingValue - } - - def "PBS should be able to match Ad Slot targeting taken from different sources by IN matching function"() { - given: "Bid request with set ad slot info in different request places" - def contextAdSlot = PBSUtils.randomString - def contextAdServerAdSlot = PBSUtils.randomString - def adSlot = PBSUtils.randomString - def adServerAdSlot = PBSUtils.randomString - def bidRequest = BidRequest.defaultBidRequest.tap { - imp = [Imp.defaultImpression.tap { - ext.context = new ImpExtContext(data: new ImpExtContextData(pbAdSlot: contextAdSlot, - adServer: new ImpExtContextDataAdServer(adSlot: contextAdServerAdSlot))) - ext.data = new ImpExtContextData(pbAdSlot: adSlot, - adServer: new ImpExtContextDataAdServer(adSlot: adServerAdSlot)) - }] - } - - and: "Planner response with IN all of Ad Slot values" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = Targeting.defaultTargetingBuilder - .addTargeting(AD_UNIT_AD_SLOT, IN, [contextAdSlot, contextAdServerAdSlot, adSlot, adServerAdSlot, PBSUtils.randomString]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - def lineItemSize = plansResponse.lineItems.size() - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == lineItemSize - } - - def "PBS should be able to match video size targeting taken from imp[].video sources by INTERSECTS matching function"() { - given: "Default video bid request" - def lineItemSize = LineItemSize.defaultLineItemSize - def bidRequest = BidRequest.defaultVideoRequest.tap { - imp[0].video.w = lineItemSize.w - imp[0].video.h = lineItemSize.h - } - - and: "Planner response" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].targeting = new Targeting.Builder().addTargeting(AD_UNIT_SIZE, INTERSECTS, [lineItemSize]) - .addTargeting(AD_UNIT_MEDIA_TYPE, INTERSECTS, [VIDEO]) - .build() - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS had PG auction" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedWholeTargeting?.size() == plansResponse.lineItems.size() - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/TokenSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/TokenSpec.groovy deleted file mode 100644 index 672db59e438..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/TokenSpec.groovy +++ /dev/null @@ -1,317 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.deals.lineitem.LineItem -import org.prebid.server.functional.model.deals.lineitem.Token -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.util.HttpUtil - -import java.time.ZoneId -import java.time.ZonedDateTime - -import static java.time.ZoneOffset.UTC -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC - -class TokenSpec extends BasePgSpec { - - def cleanup() { - pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.invalidateLineItemsRequest) - } - - def "PBS should start using line item in auction when its expired tokens number is increased"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock zero tokens line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 0 - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested" - def firstAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start processing PG deals" - assert firstAuctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == - [plansResponse.lineItems[0].lineItemId] as Set - assert !firstAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder - - when: "Line item tokens are updated" - plansResponse.lineItems[0].deliverySchedules[0].tokens[0].total = 1 - plansResponse.lineItems[0].deliverySchedules[0].updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).plusSeconds(1) - generalPlanner.initPlansResponse(plansResponse) - - and: "Updated line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Auction is requested for the second time" - bidder.setResponse(bidRequest.id, bidResponse) - def secondAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS should process PG deals" - def sentToBidder = secondAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == plansResponse.lineItems.size() - assert sentToBidder[0] == plansResponse.lineItems[0].lineItemId - } - - def "PBS shouldn't allow line items with zero token number take part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock zero tokens line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 0 - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS should recognize line items with pacing deferred" - assert auctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == [plansResponse.lineItems[0].lineItemId] as Set - } - - def "PBS should allow line item take part in auction when it has at least one unspent token among all expired tokens"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line item with zero and 1 available tokens" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - def deliverySchedules = lineItems[0].deliverySchedules[0] - deliverySchedules.tokens[0].total = 0 - deliverySchedules.tokens << new Token(priorityClass: 2, total: 0) - deliverySchedules.tokens << new Token(priorityClass: 3, total: 1) - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - def lineItemCount = plansResponse.lineItems.size() - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS should process PG deals" - assert !auctionResponse.ext?.debug?.pgmetrics?.pacingDeferred - assert auctionResponse.ext?.debug?.pgmetrics?.readyToServe?.size() == lineItemCount - def sentToBidder = auctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == lineItemCount - assert sentToBidder[0] == plansResponse.lineItems[0].lineItemId - } - - def "PBS shouldn't allow line item take part in auction when all its tokens are spent"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock with 1 token to spend line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 1 - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Auction is happened for the first time" - pgPbsService.sendAuctionRequest(bidRequest) - - when: "Requesting auction for the second time" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start PG processing" - assert auctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == [plansResponse.lineItems[0].lineItemId] as Set - } - - def "PBS should take only the first token among tokens with the same priority class"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line item with 2 tokens of the same priority but the first has zero total number" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - def tokens = [new Token(priorityClass: 1, total: 0), new Token(priorityClass: 1, total: 1)] - lineItems[0].deliverySchedules[0].tokens = tokens - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is happened" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start PG processing as it was processed only the first token with 0 total number" - assert auctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == [plansResponse.lineItems[0].lineItemId] as Set - } - - def "PBS shouldn't allow line item take part in auction when its number of available impressions is ahead of the scheduled time"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line item to have max 2 impressions during one week" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 2 - lineItems[0].startTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)) - lineItems[0].updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)) - lineItems[0].endTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)).plusWeeks(1) - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested for the first time" - def firstAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS processed PG deals" - def sentToBidder = firstAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == plansResponse.lineItems.size() - assert sentToBidder[0] == plansResponse.lineItems[0].lineItemId - - when: "Auction is requested for the second time" - def secondAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS hasn't allowed line item take part in auction as it has only one impression left to be shown during the week" - assert secondAuctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == - [plansResponse.lineItems[0].lineItemId] as Set - assert !secondAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder - } - - def "PBS should abandon line item with updated zero available token number take part in auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock with not null tokens number line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 2 - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - when: "Auction is requested" - def firstAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS processed PG deals" - def sentToBidder = firstAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder?.get(GENERIC.value) - assert sentToBidder?.size() == plansResponse.lineItems.size() - assert sentToBidder[0] == plansResponse.lineItems[0].lineItemId - - when: "Line item tokens are updated to have no available tokens" - plansResponse.lineItems[0].deliverySchedules[0].tokens[0].total = 0 - plansResponse.lineItems[0].deliverySchedules[0].updatedTimeStamp = ZonedDateTime.now(ZoneId.from(UTC)) - - generalPlanner.initPlansResponse(plansResponse) - - and: "Updated line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Auction is requested for the second time" - def secondAuctionResponse = pgPbsService.sendAuctionRequest(bidRequest) - - then: "PBS shouldn't start processing PG deals" - assert secondAuctionResponse.ext?.debug?.pgmetrics?.pacingDeferred == - [plansResponse.lineItems[0].lineItemId] as Set - assert !secondAuctionResponse.ext?.debug?.pgmetrics?.sentToBidder - } - - def "PBS should ignore line item pacing when ignore pacing header is present in the request"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock zero tokens line item" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].deliverySchedules[0].tokens[0].total = 0 - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Pg ignore pacing header" - def pgIgnorePacingHeader = ["${HttpUtil.PG_IGNORE_PACING_HEADER}": "1"] - - when: "Auction is requested" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, pgIgnorePacingHeader) - - then: "PBS should process PG deals" - def pgMetrics = auctionResponse.ext?.debug?.pgmetrics - def sentToBidder = pgMetrics?.sentToBidder[GENERIC.value] - assert sentToBidder?.size() == plansResponse.lineItems.size() - assert sentToBidder[0] == plansResponse.lineItems[0].lineItemId - assert pgMetrics.readyToServe == [plansResponse.lineItems[0].lineItemId] as Set - } - - def "PBS should prioritize line item when pg ignore pacing and #reason"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock with additional lineItem" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems.add(updateLineItem(bidRequest.site.publisher.id)) - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Pg ignore pacing header" - def pgIgnorePacingHeader = ["${HttpUtil.PG_IGNORE_PACING_HEADER}": "1"] - - when: "Auction is requested" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, pgIgnorePacingHeader) - - then: "PBS should process PG deals" - def pgMetrics = auctionResponse.ext?.debug?.pgmetrics - assert pgMetrics?.readyToServe?.size() == plansResponse.lineItems.size() - assert pgMetrics.readyToServe.eachWithIndex { id, index -> - id == plansResponse.lineItems[index].lineItemId } - - where: - reason | updateLineItem - "cpm is null" | {siteId -> LineItem.getDefaultLineItem(siteId).tap { - price.cpm = null - }} - "relative priority is null" | {siteId -> LineItem.getDefaultLineItem(siteId).tap { - relativePriority = null - }} - "no tokens unspent" | {siteId -> LineItem.getDefaultLineItem(siteId).tap { - deliverySchedules[0].tokens[0].total = 0 - }} - "delivery plan is null" | {siteId -> LineItem.getDefaultLineItem(siteId).tap { - deliverySchedules = null - }} - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pg/UserDetailsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pg/UserDetailsSpec.groovy deleted file mode 100644 index a61907af8ae..00000000000 --- a/src/test/groovy/org/prebid/server/functional/tests/pg/UserDetailsSpec.groovy +++ /dev/null @@ -1,343 +0,0 @@ -package org.prebid.server.functional.tests.pg - -import org.prebid.server.functional.model.UidsCookie -import org.prebid.server.functional.model.deals.lineitem.FrequencyCap -import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse -import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse -import org.prebid.server.functional.model.mock.services.httpsettings.HttpAccountsResponse -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.event.EventRequest -import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.testcontainers.Dependencies -import org.prebid.server.functional.testcontainers.scaffolding.HttpSettings -import org.prebid.server.functional.util.HttpUtil -import org.prebid.server.functional.util.PBSUtils -import spock.lang.Shared - -import java.time.format.DateTimeFormatter - -import static org.mockserver.model.HttpStatusCode.INTERNAL_SERVER_ERROR_500 -import static org.mockserver.model.HttpStatusCode.NOT_FOUND_404 -import static org.mockserver.model.HttpStatusCode.NO_CONTENT_204 -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.deals.lineitem.LineItem.TIME_PATTERN - -class UserDetailsSpec extends BasePgSpec { - - private static final String USER_SERVICE_NAME = "userservice" - - @Shared - HttpSettings httpSettings = new HttpSettings(Dependencies.networkServiceContainer) - - def "PBS should send user details request to the User Service during deals auction"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id)) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial user details request count is taken" - def initialRequestCount = userData.recordedUserDetailsRequestCount - - and: "Cookies with user ids" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS sends a request to the User Service" - def updatedRequestCount = userData.recordedUserDetailsRequestCount - assert updatedRequestCount == initialRequestCount + 1 - - and: "Request corresponds to the payload" - def userDetailsRequest = userData.recordedUserDetailsRequest - assert userDetailsRequest.ids?.size() == 1 - assert userDetailsRequest.ids[0].id == uidsCookie.tempUIDs.get(GENERIC).uid - assert userDetailsRequest.ids[0].type == pgConfig.userIdType - } - - def "PBS should validate bad user details response status code #statusCode"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "User Service response is set" - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse, statusCode) - - and: "Initial user details request count is taken" - def initialRequestCount = userData.recordedUserDetailsRequestCount - - and: "Cookies with user ids" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS sends a request to the User Service during auction" - assert userData.recordedUserDetailsRequestCount == initialRequestCount + 1 - def userServiceCall = auctionResponse.ext?.debug?.httpcalls?.get(USER_SERVICE_NAME) - assert userServiceCall?.size() == 1 - - assert !userServiceCall[0].status - assert !userServiceCall[0].responseBody - - cleanup: - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - - where: - statusCode << [NO_CONTENT_204, NOT_FOUND_404, INTERNAL_SERVER_ERROR_500] - } - - def "PBS should invalidate user details response body when response has absent #fieldName field"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial user details request count is taken" - def initialRequestCount = userData.recordedUserDetailsRequestCount - - and: "User Service response is set" - userData.setUserDataResponse(userDataResponse) - - and: "Cookies with user ids" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS sends a request to the User Service" - assert userData.recordedUserDetailsRequestCount == initialRequestCount + 1 - - and: "Call to the user service was made" - assert auctionResponse.ext?.debug?.httpcalls?.get(USER_SERVICE_NAME)?.size() == 1 - - and: "Data from the user service response wasn't added to the bid request by PBS" - assert !auctionResponse.ext?.debug?.resolvedRequest?.user?.data - assert !auctionResponse.ext?.debug?.resolvedRequest?.user?.ext?.fcapids - - cleanup: - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - - where: - fieldName | userDataResponse - "user" | new UserDetailsResponse(user: null) - "user.data" | UserDetailsResponse.defaultUserResponse.tap { user.data = null } - "user.ext" | UserDetailsResponse.defaultUserResponse.tap { user.ext = null } - } - - def "PBS should abandon line items with user fCap ids take part in auction when user details response failed"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Planner Mock line items with added frequency cap" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id).tap { - lineItems[0].frequencyCaps = [FrequencyCap.defaultFrequencyCap.tap { fcapId = PBSUtils.randomNumber as String }] - } - generalPlanner.initPlansResponse(plansResponse) - - and: "Bid response" - def bidResponse = BidResponse.getDefaultPgBidResponse(bidRequest, plansResponse) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Bad User Service Response is set" - userData.setUserDataResponse(new UserDetailsResponse(user: null)) - - and: "Cookies header" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS" - def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest, cookieHeader) - - then: "PBS hasn't started processing PG deals as line item targeting frequency capped lookup failed" - assert auctionResponse.ext?.debug?.pgmetrics?.matchedTargetingFcapLookupFailed?.size() == - plansResponse.lineItems.size() - - cleanup: - userData.setUserDataResponse(UserDetailsResponse.defaultUserResponse) - } - - def "PBS should send win notification request to the User Service on bidder wins"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - def lineItemId = plansResponse.lineItems[0].lineItemId - def lineItemUpdateTime = plansResponse.lineItems[0].updatedTimeStamp - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial win notification request count" - def initialRequestCount = userData.requestCount - - and: "Enabled event request" - def winEventRequest = EventRequest.defaultEventRequest.tap { - it.lineItemId = lineItemId - analytics = 0 - } - - and: "Default account response" - def httpSettingsResponse = HttpAccountsResponse.getDefaultHttpAccountsResponse(winEventRequest.accountId.toString()) - httpSettings.setResponse(winEventRequest.accountId.toString(), httpSettingsResponse) - - and: "Cookies header" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS where the winner is instantiated" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "Sending event request to PBS" - pgPbsService.sendEventRequest(winEventRequest, cookieHeader) - - then: "PBS sends a win notification to the User Service" - PBSUtils.waitUntil { userData.requestCount == initialRequestCount + 1 } - - and: "Win request corresponds to the payload" - def timeFormatter = DateTimeFormatter.ofPattern(TIME_PATTERN) - - verifyAll(userData.recordedWinEventRequest) { winNotificationRequest -> - winNotificationRequest.bidderCode == GENERIC.value - winNotificationRequest.bidId == winEventRequest.bidId - winNotificationRequest.lineItemId == lineItemId - winNotificationRequest.region == pgConfig.region - winNotificationRequest.userIds?.size() == 1 - winNotificationRequest.userIds[0].id == uidsCookie.tempUIDs.get(GENERIC).uid - winNotificationRequest.userIds[0].type == pgConfig.userIdType - timeFormatter.format(winNotificationRequest.lineUpdatedDateTime) == timeFormatter.format(lineItemUpdateTime) - winNotificationRequest.winEventDateTime.isAfter(winNotificationRequest.lineUpdatedDateTime) - !winNotificationRequest.frequencyCaps - } - } - - def "PBS shouldn't send win notification request to the User Service when #reason line item id is given"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - generalPlanner.initPlansResponse(PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id)) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial win notification request count" - def initialRequestCount = userData.requestCount - - and: "Enabled event request" - def eventRequest = EventRequest.defaultEventRequest.tap { - it.lineItemId = lineItemId - analytics = 0 - } - - and: "Default account response" - def httpSettingsResponse = HttpAccountsResponse.getDefaultHttpAccountsResponse(eventRequest.accountId.toString()) - httpSettings.setResponse(eventRequest.accountId.toString(), httpSettingsResponse) - - and: "Cookies header" - def uidsCookie = UidsCookie.defaultUidsCookie - def cookieHeader = HttpUtil.getCookieHeader(uidsCookie) - - when: "Sending auction request to PBS where the winner is instantiated" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "Sending event request to PBS" - pgPbsService.sendEventRequest(eventRequest, cookieHeader) - - then: "PBS hasn't sent a win notification to the User Service" - assert userData.requestCount == initialRequestCount - - where: - reason | lineItemId - "null" | null - "non-existent" | PBSUtils.randomNumber as String - } - - def "PBS shouldn't send win notification request to the User Service when #reason cookies header was given"() { - given: "Bid request" - def bidRequest = BidRequest.defaultBidRequest - - and: "Bid response" - def bidResponse = BidResponse.getDefaultBidResponse(bidRequest) - bidder.setResponse(bidRequest.id, bidResponse) - - and: "Planner Mock line items" - def plansResponse = PlansResponse.getDefaultPlansResponse(bidRequest.site.publisher.id) - def lineItemId = plansResponse.lineItems[0].lineItemId - generalPlanner.initPlansResponse(plansResponse) - - and: "Line items are fetched by PBS" - updateLineItemsAndWait() - - and: "Initial win notification request count" - def initialRequestCount = userData.requestCount - - and: "Enabled event request" - def eventRequest = EventRequest.defaultEventRequest.tap { - it.lineItemId = lineItemId - analytics = 0 - } - - and: "Default account response" - def httpSettingsResponse = HttpAccountsResponse.getDefaultHttpAccountsResponse(eventRequest.accountId.toString()) - httpSettings.setResponse(eventRequest.accountId.toString(), httpSettingsResponse) - - when: "Sending auction request to PBS where the winner is instantiated" - pgPbsService.sendAuctionRequest(bidRequest) - - and: "Sending event request to PBS" - pgPbsService.sendEventRequest(eventRequest, HttpUtil.getCookieHeader(uidsCookie)) - - then: "PBS hasn't sent a win notification to the User Service" - assert userData.requestCount == initialRequestCount - - where: - reason | uidsCookie - - "empty cookie" | new UidsCookie() - - "empty uids cookie" | UidsCookie.defaultUidsCookie.tap { - uids = null - tempUIDs = null - } - } -} diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index cf487140605..4a8a1d5e68e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -23,7 +23,6 @@ import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.service.PrebidServerService -import org.prebid.server.functional.testcontainers.PbsPgConfig import org.prebid.server.functional.testcontainers.scaffolding.VendorList import org.prebid.server.functional.tests.BaseSpec import org.prebid.server.functional.util.PBSUtils @@ -57,13 +56,13 @@ abstract class PrivacyBaseSpec extends BaseSpec { private static final int GEO_PRECISION = 2 protected static final Map GENERIC_COOKIE_SYNC_CONFIG = ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : "$networkServiceContainer.rootUri/generic-usersync".toString(), - "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": false.toString()] + "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": false.toString()] private static final Map OPENX_COOKIE_SYNC_CONFIG = ["adaptrs.${OPENX.value}.enabled" : "true", "adapters.${OPENX.value}.usersync.cookie-family-name": OPENX.value] private static final Map OPENX_CONFIG = ["adapters.${OPENX.value}.endpoint": "$networkServiceContainer.rootUri/auction".toString(), "adapters.${OPENX.value}.enabled" : 'true'] protected static final Map GDPR_VENDOR_LIST_CONFIG = ["gdpr.vendorlist.v2.http-endpoint-template": "$networkServiceContainer.rootUri/v2/vendor-list.json".toString(), - "gdpr.vendorlist.v3.http-endpoint-template": "$networkServiceContainer.rootUri/v3/vendor-list.json".toString()] + "gdpr.vendorlist.v3.http-endpoint-template": "$networkServiceContainer.rootUri/v3/vendor-list.json".toString()] protected static final Map SETTING_CONFIG = ["settings.enforce-valid-account": 'true'] protected static final Map GENERIC_VENDOR_CONFIG = ["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String, "gdpr.host-vendor-id" : GENERIC_VENDOR_ID as String, @@ -88,8 +87,6 @@ abstract class PrivacyBaseSpec extends BaseSpec { "gdpr.vendorlist.v3.retry-policy.exponential-backoff.max-delay-millis": EXPONENTIAL_BACKOFF_MAX_DELAY as String, "gdpr.vendorlist.v3.retry-policy.exponential-backoff.factor" : Long.MAX_VALUE as String] - private static final PbsPgConfig pgConfig = new PbsPgConfig(networkServiceContainer) - protected static final String VENDOR_LIST_PATH = "/app/prebid-server/data/vendorlist-v{VendorVersion}/{VendorVersion}.json" protected static final String VALID_VALUE_FOR_GPC_HEADER = "1" protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UspNatV1Consent.Builder().setGpc(true).build() @@ -100,7 +97,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { GENERIC_COOKIE_SYNC_CONFIG + GENERIC_VENDOR_CONFIG + RETRY_POLICY_EXPONENTIAL_CONFIG) protected static final Map PBS_CONFIG = OPENX_CONFIG + OPENX_COOKIE_SYNC_CONFIG + - GENERIC_COOKIE_SYNC_CONFIG + pgConfig.properties + GDPR_VENDOR_LIST_CONFIG + SETTING_CONFIG + GENERIC_VENDOR_CONFIG + GENERIC_COOKIE_SYNC_CONFIG + GDPR_VENDOR_LIST_CONFIG + SETTING_CONFIG + GENERIC_VENDOR_CONFIG @Shared protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(PBS_CONFIG) diff --git a/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy b/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy index 2e7d6a2d0a1..c1f60516abf 100644 --- a/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy @@ -7,11 +7,7 @@ import static java.nio.charset.StandardCharsets.UTF_8 class HttpUtil implements ObjectMapperWrapper { - public static final String UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/ - public static final String PG_TRX_ID_HEADER = "pg-trx-id" - public static final String PG_IGNORE_PACING_HEADER = "X-Prebid-PG-ignore-pacing" - public static final String AUTHORIZATION_HEADER = "Authorization" public static final String ACCEPT_HEADER = "Authorization" public static final String CONTENT_TYPE_HEADER = "Content-Type" public static final String COOKIE_HEADER = "cookie" @@ -21,13 +17,6 @@ class HttpUtil implements ObjectMapperWrapper { public static final String SET_COOKIE_HEADER = 'Set-Cookie' public static final String COOKIE_DEPRECATION_HEADER = 'Sec-Cookie-Deprecation' - public static final String CONTENT_TYPE_HEADER_VALUE = "application/json" - public static final String CHARSET_HEADER_VALUE = "charset=utf-8" - - static String makeBasicAuthHeaderValue(String username, String password) { - "Basic ${encodeWithBase64("$username:$password")}" - } - static HashMap getCookieHeader(UidsCookie uidsCookie) { [(COOKIE_HEADER): makeUidsCookieHeaderValue(encode(uidsCookie))] } diff --git a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java index 12ee628c670..98fd998571b 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java @@ -17,8 +17,6 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.execution.Timeout; import org.prebid.server.vertx.http.HttpClient; import org.prebid.server.vertx.http.model.HttpClientResponse; @@ -161,8 +159,6 @@ public void handleShouldBeAbleToEncodeAuctionEvent() { .auctionContext(AuctionContext.builder() .uidsCookie(mock(UidsCookie.class)) .timeoutContext(TimeoutContext.of(0, mock(Timeout.class), 0)) - .txnLog(mock(TxnLog.class)) - .deepDebugLog(mock(DeepDebugLog.class)) .build()) .build(); diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index 67d7725c535..58a9386de55 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -58,8 +58,6 @@ import org.prebid.server.cache.model.CacheInfo; import org.prebid.server.cache.model.CacheServiceResult; import org.prebid.server.cache.model.DebugHttpCall; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.events.EventsContext; import org.prebid.server.events.EventsService; import org.prebid.server.exception.InvalidRequestException; @@ -95,7 +93,6 @@ import org.prebid.server.proto.openrtb.ext.response.ExtBidResponse; import org.prebid.server.proto.openrtb.ext.response.ExtBidResponsePrebid; import org.prebid.server.proto.openrtb.ext.response.ExtBidderError; -import org.prebid.server.proto.openrtb.ext.response.ExtDebugPgmetrics; import org.prebid.server.proto.openrtb.ext.response.ExtDebugTrace; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.ExtResponseCache; @@ -105,7 +102,6 @@ import org.prebid.server.proto.openrtb.ext.response.ExtTraceActivityInvocationDefaultResult; import org.prebid.server.proto.openrtb.ext.response.ExtTraceActivityInvocationResult; import org.prebid.server.proto.openrtb.ext.response.ExtTraceActivityRule; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import org.prebid.server.proto.openrtb.ext.response.seatnonbid.NonBid; import org.prebid.server.proto.openrtb.ext.response.seatnonbid.SeatNonBid; @@ -122,7 +118,6 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -136,7 +131,6 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; -import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static java.util.function.UnaryOperator.identity; @@ -162,8 +156,6 @@ import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; import static org.prebid.server.proto.openrtb.ext.response.BidType.video; import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; -import static org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category.pacing; -import static org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category.targeting; public class BidResponseCreatorTest extends VertxTest { @@ -551,7 +543,7 @@ public void shouldRequestCacheServiceWithVideoBidsToModify() { .with(toAuctionParticipant(bidderResponses)); final String modifiedAdm = "modifiedAdm"; - given(vastModifier.createBidVastXml(any(), any(), any(), any(), any(), any(), any(), any())) + given(vastModifier.createBidVastXml(any(), any(), any(), any(), any(), any(), any())) .willReturn(modifiedAdm); // just a stub to get through method call chain @@ -569,8 +561,14 @@ public void shouldRequestCacheServiceWithVideoBidsToModify() { .build(); verify(vastModifier) - .createBidVastXml(eq(bidder1), eq(null), eq(BID_NURL), eq(bidId1), - eq(accountId), eq(expectedEventContext), eq(emptyList()), eq(null)); + .createBidVastXml( + eq(bidder1), + eq(null), + eq(BID_NURL), + eq(bidId1), + eq(accountId), + eq(expectedEventContext), + eq(emptyList())); final ArgumentCaptor> bidInfoCaptor = ArgumentCaptor.forClass(List.class); verify(cacheService).cacheBidsOpenrtb( @@ -609,8 +607,7 @@ public void shouldModifyBidAdmWhenBidVideoAndVastModifierReturnValue() { final String modifiedVast = "modifiedVast"; given(vastModifier - .createBidVastXml(anyString(), anyString(), anyString(), - anyString(), anyString(), any(), any(), any())) + .createBidVastXml(anyString(), anyString(), anyString(), anyString(), anyString(), any(), any())) .willReturn(modifiedVast); // when @@ -623,8 +620,7 @@ public void shouldModifyBidAdmWhenBidVideoAndVastModifierReturnValue() { .containsOnly(modifiedVast); verify(vastModifier) - .createBidVastXml(eq(bidder), eq(BID_ADM), eq(BID_NURL), eq(bidId), eq("accountId"), any(), any(), - any()); + .createBidVastXml(eq(bidder), eq(BID_ADM), eq(BID_NURL), eq(bidId), eq("accountId"), any(), any()); } @SuppressWarnings("unchecked") @@ -840,14 +836,18 @@ public void shouldUseGeneratedBidIdForEventAndCacheWhenIdGeneratorIsUUIDAndEvent final BidRequestCacheInfo cacheInfo = BidRequestCacheInfo.builder().doCaching(true).build(); givenCacheServiceResult(singletonList(CacheInfo.of("id", null, null, null))); final Events events = Events.of("http://event-type-win", "http://event-type-view"); - given(eventsService.createEvent(anyString(), anyString(), anyString(), anyString(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(events); // when bidResponseCreator.create(auctionContext, cacheInfo, MULTI_BIDS).result(); // then - final ExtBidPrebid extBidPrebid = ExtBidPrebid.builder().bidid(generatedBidId).type(banner).build(); + final ExtBidPrebid extBidPrebid = ExtBidPrebid.builder() + .bidid(generatedBidId) + .type(banner) + .events(events) + .build(); final Bid expectedBid = bid.toBuilder() .ext(mapper.createObjectNode().set("prebid", mapper.valueToTree(extBidPrebid))) .build(); @@ -855,7 +855,7 @@ public void shouldUseGeneratedBidIdForEventAndCacheWhenIdGeneratorIsUUIDAndEvent final BidInfo expectedBidInfo = toBidInfo(expectedBid, imp, bidder, banner, true); verify(cacheService).cacheBidsOpenrtb(eq(singletonList(expectedBidInfo)), any(), any(), any()); - verify(eventsService).createEvent(eq(generatedBidId), anyString(), anyString(), any(), anyBoolean(), any()); + verify(eventsService).createEvent(eq(generatedBidId), anyString(), anyString(), anyBoolean(), any()); } @SuppressWarnings("unchecked") @@ -1920,88 +1920,6 @@ public void shouldPopulateTargetingKeywordsForWinningBidsAndWinningBidsByBidder( verify(cacheService, never()).cacheBidsOpenrtb(anyList(), any(), any(), any()); } - @Test - public void shouldPopulateAuctionLostToMetricByWinningDealBid() { - // given - final String dealId1 = "dealId1"; - final String dealId2 = "dealId2"; - final String lineItemId1 = "lineItemId1"; - final String lineItemId2 = "lineItemId2"; - final BidRequest bidRequest = givenBidRequest( - identity(), - extBuilder -> extBuilder.targeting(givenTargeting()), - Imp.builder() - .id(IMP_ID) - .pmp(Pmp.builder() - // Order defines winning bid - .deals(asList( - Deal.builder().id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId1", null, null, null)))).build(), - Deal.builder().id("dealId2") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId2", null, null, null)))).build())) - .build()) - .build()); - - final Bid firstBid = Bid.builder().id("bidId1").impid(IMP_ID).price(BigDecimal.valueOf(5.67)) - .dealid(dealId1).build(); - final Bid secondBid = Bid.builder().id("bidId2").impid(IMP_ID).price(BigDecimal.valueOf(4.98)) - .dealid(dealId2).build(); - - final List bidderResponses = asList( - BidderResponse.of("bidder1", givenSeatBid(BidderBid.of(firstBid, banner, null)), 100), - BidderResponse.of("bidder2", givenSeatBid(BidderBid.of(secondBid, banner, null)), 100)); - - final AuctionContext auctionContext = givenAuctionContext( - bidRequest, - contextBuilder -> contextBuilder.auctionParticipations(toAuctionParticipant(bidderResponses))); - - // when - bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); - - // then - assertThat(auctionContext.getTxnLog().lostAuctionToLineItems().entrySet()) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .containsOnly(tuple(lineItemId2, singleton(lineItemId1))); - } - - @Test - public void shouldIncreaseLineItemSentToClientAsTopMatchMetricInTransactionLog() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - extBuilder -> extBuilder.targeting(givenTargeting()), - givenImp(Collections.singletonMap("dealId", "lineItemId1"))); - - final Bid bid = Bid.builder() - .id("bidId1") - .impid(IMP_ID) - .price(BigDecimal.valueOf(5.67)) - .dealid("dealId") - .build(); - final List bidderResponses = singletonList( - BidderResponse.of("bidder1", givenSeatBid(BidderBid.of(bid, banner, null)), 100)); - - final AuctionContext auctionContext = givenAuctionContext( - bidRequest, - context -> context - .debugContext(DebugContext.of(true, true, null)) - .auctionParticipations(toAuctionParticipant(bidderResponses))); - - // when - final BidResponse bidResponse = bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); - - // then - final ExtBidResponse responseExt = bidResponse.getExt(); - - assertThat(responseExt.getDebug()).isNotNull(); - assertThat(responseExt.getDebug().getPgmetrics()).isNotNull(); - assertThat(singletonList(responseExt.getDebug().getPgmetrics())) - .flatExtracting(ExtDebugPgmetrics::getSentToClientAsTopMatch) - .containsOnly("lineItemId1"); - } - @Test public void shouldPopulateTargetingKeywordsFromMediaTypePriceGranularities() { // given @@ -2159,43 +2077,6 @@ public void shouldPopulateTargetingKeywordsIfBidWasCachedAndAdmWasRemoved() { .doesNotContainNull(); } - @Test - public void shouldCallEventsServiceWhenEventsDisabledByRequestButBidWithLineItem() { - // given - final Account account = Account.builder() - .id("accountId") - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build(); - final BidRequest bidRequest = givenBidRequest( - identity(), - extBuilder -> extBuilder.targeting(givenTargeting()), - givenImp(Collections.singletonMap("dealId", "lineItemId"))); - - final Bid bid = Bid.builder() - .id("bidId") - .price(BigDecimal.valueOf(5.67)) - .impid(IMP_ID) - .dealid("dealId") - .build(); - final List bidderResponses = singletonList(BidderResponse.of("bidder1", - givenSeatBid(BidderBid.of(bid, banner, "USD")), 100)); - - final AuctionContext auctionContext = givenAuctionContext( - bidRequest, - contextBuilder -> contextBuilder - .account(account) - .auctionParticipations(toAuctionParticipant(bidderResponses))); - - // when - bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); - - // then - verify(eventsService).createEvent( - anyString(), anyString(), anyString(), eq("lineItemId"), eq(false), any()); - } - @Test public void shouldAddExtPrebidEventsIfEventsAreEnabledAndExtRequestPrebidEventPresent() { // given @@ -2227,7 +2108,7 @@ public void shouldAddExtPrebidEventsIfEventsAreEnabledAndExtRequestPrebidEventPr .auctionParticipations(toAuctionParticipant(bidderResponses))); final Events events = Events.of("http://event-type-win", "http://event-type-view"); - given(eventsService.createEvent(anyString(), anyString(), anyString(), any(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(events); final BidRequestCacheInfo cacheInfo = BidRequestCacheInfo.builder().doCaching(true).build(); @@ -2284,7 +2165,7 @@ public void shouldAddExtPrebidEventsIfEventsAreEnabledAndAccountSupportEventsFor .auctionParticipations(toAuctionParticipant(bidderResponses))); final Events events = Events.of("http://event-type-win", "http://event-type-view"); - given(eventsService.createEvent(anyString(), anyString(), anyString(), any(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(events); // when @@ -2331,7 +2212,7 @@ public void shouldAddExtPrebidEventsIfEventsAreEnabledAndDefaultAccountAnalytics .auctionParticipations(toAuctionParticipant(bidderResponses))); final Events events = Events.of("http://event-type-win", "http://event-type-view"); - given(eventsService.createEvent(anyString(), anyString(), anyString(), any(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(events); // when @@ -3089,7 +2970,7 @@ public void shouldPassIntegrationToCacheServiceAndBidEvents() { givenCacheServiceResult(singletonList(CacheInfo.empty())); - given(eventsService.createEvent(anyString(), anyString(), anyString(), any(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(Events.of( "http://win-url?param=value&int=integration", "http://imp-url?param=value&int=integration")); @@ -3109,41 +2990,6 @@ public void shouldPassIntegrationToCacheServiceAndBidEvents() { "http://imp-url?param=value&int=integration")); } - @Test - public void shouldPopulateExtensionResponseDebugAndDeepDebugLogIfEnabled() { - // given - final DeepDebugLog deepDebugLog = DeepDebugLog.create(true, clock); - deepDebugLog.add("line-item-id-1", pacing, () -> "test-1"); - deepDebugLog.add("line-item-id-2", targeting, () -> "test-2"); - deepDebugLog.add("", targeting, () -> "test-3"); - - final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(5.67)).impid(IMP_ID).build(); - final List bidderResponses = singletonList(BidderResponse.of("bidder1", - givenSeatBid(BidderBid.of(bid, banner, "USD")), 100)); - - final AuctionContext auctionContext = givenAuctionContext( - givenBidRequest(givenImp()), - builder -> builder - .deepDebugLog(deepDebugLog) - .auctionParticipations(toAuctionParticipant(bidderResponses))); - - // when - final BidResponse bidResponse = bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); - - // then - final ExtDebugTrace extDebugTrace = bidResponse.getExt().getDebug().getTrace(); - - assertThat(extDebugTrace.getDeals()) - .containsExactly(ExtTraceDeal.of("", ZonedDateTime.now(clock), targeting, "test-3")); - - assertThat(extDebugTrace.getLineItems()) - .containsExactly( - entry("line-item-id-1", List.of(ExtTraceDeal.of("line-item-id-1", - ZonedDateTime.now(clock), pacing, "test-1"))), - entry("line-item-id-2", List.of(ExtTraceDeal.of("line-item-id-2", - ZonedDateTime.now(clock), targeting, "test-2")))); - } - @Test public void shouldPopulateActivityInfrastructureTraceLogOnSpecifiedTraceLevel() { // given @@ -3184,26 +3030,6 @@ public void shouldPopulateActivityInfrastructureTraceLogOnSpecifiedTraceLevel() .isEqualTo(traceLog); } - @Test - public void shouldBidResponseDebugReturnNullIfDeepDebugLogIsEnabledAndNotPopulated() { - // given - final Bid bid = Bid.builder().id("bidId1").price(BigDecimal.valueOf(5.67)).impid(IMP_ID).build(); - final List bidderResponses = singletonList(BidderResponse.of("bidder1", - givenSeatBid(BidderBid.of(bid, banner, "USD")), 100)); - - final AuctionContext auctionContext = givenAuctionContext( - givenBidRequest(givenImp()), - builder -> builder - .deepDebugLog(DeepDebugLog.create(true, clock)) - .auctionParticipations(toAuctionParticipant(bidderResponses))); - - // when - final BidResponse bidResponse = bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); - - // then - assertThat(bidResponse.getExt().getDebug()).isNull(); - } - @Test public void shouldPopulateBidResponseExtErrorIfImpExtIsInvalid() { // given @@ -3398,7 +3224,7 @@ public void shouldPopulateEventsContextForRequestIfEventsEnabledForRequest() { final Events givenEvents = Events.of( "http://win-url?auctionId=123×tamp=1000", "http://imp-url?auctionId=123×tamp=1000"); - given(eventsService.createEvent(anyString(), anyString(), anyString(), any(), anyBoolean(), any())) + given(eventsService.createEvent(anyString(), anyString(), anyString(), anyBoolean(), any())) .willReturn(givenEvents); // when @@ -3767,18 +3593,13 @@ public void shouldPopulateBidExtWhenExtMediaTypePriceGranularityHasValidxNativeE .includebidderkeys(true) .build(); - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemsSentToBidder(); - final Bid bid = Bid.builder().id("bidId").price(BigDecimal.valueOf(5.67)).impid(IMP_ID).build(); final List bidderResponses = singletonList(BidderResponse.of("bidder1", givenSeatBid(BidderBid.of(bid, banner, "USD")), 100)); - final AuctionContext auctionContext = givenAuctionContext(givenBidRequest( - identity(), extBuilder -> extBuilder.targeting(targeting), givenImp()), - auctionContextBuilder -> auctionContextBuilder - .txnLog(txnLog) - .auctionParticipations(toAuctionParticipant(bidderResponses))); + final AuctionContext auctionContext = givenAuctionContext( + givenBidRequest(identity(), extBuilder -> extBuilder.targeting(targeting), givenImp()), + context -> context.auctionParticipations(toAuctionParticipant(bidderResponses))); // when final BidResponse bidResponse = bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); @@ -3880,10 +3701,8 @@ private AuctionContext givenAuctionContext(BidRequest bidRequest, final AuctionContext.AuctionContextBuilder auctionContextBuilder = AuctionContext.builder() .account(Account.empty("accountId")) .bidRequest(bidRequest) - .txnLog(TxnLog.create()) .timeoutContext(TimeoutContext.of(0, timeout, 0)) .debugContext(DebugContext.empty()) - .deepDebugLog(DeepDebugLog.create(false, clock)) .debugHttpCalls(new HashMap<>()) .debugWarnings(emptyList()) .auctionParticipations(emptyList()) diff --git a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java index 8477f0fa112..7194b1d70ea 100644 --- a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java +++ b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java @@ -1,7 +1,6 @@ package org.prebid.server.auction; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import com.iab.openrtb.request.App; @@ -32,7 +31,6 @@ import com.iab.openrtb.response.SeatBid; import io.vertx.core.Future; import org.apache.commons.collections4.MapUtils; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -70,10 +68,6 @@ import org.prebid.server.bidder.model.BidderSeatBid; import org.prebid.server.cookie.UidsCookie; import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.DealsService; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; @@ -110,8 +104,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtAppPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtBidderConfig; import org.prebid.server.proto.openrtb.ext.request.ExtBidderConfigOrtb; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.request.ExtDooh; import org.prebid.server.proto.openrtb.ext.request.ExtGranularityRange; import org.prebid.server.proto.openrtb.ext.request.ExtImpAuctionEnvironment; @@ -198,7 +190,6 @@ import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.same; import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willReturn; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyList; import static org.mockito.Mockito.doAnswer; @@ -225,9 +216,6 @@ public class ExchangeServiceTest extends VertxTest { @Mock private StoredResponseProcessor storedResponseProcessor; - @Mock - private DealsService dealsService; - @Mock private PrivacyEnforcementService privacyEnforcementService; @@ -273,9 +261,6 @@ public class ExchangeServiceTest extends VertxTest { @Mock private HookStageExecutor hookStageExecutor; - @Mock - private ApplicationEventService applicationEventService; - @Mock private HttpInteractionLogger httpInteractionLogger; @@ -395,9 +380,6 @@ public void setUp() { given(storedResponseProcessor.updateStoredBidResponse(any())) .willAnswer(inv -> inv.getArgument(0)); - given(dealsService.matchAndPopulateDeals(any(), any(), any())) - .willAnswer(inv -> inv.getArgument(0)); - given(priceFloorEnforcer.enforce(any(), any(), any(), any())).willAnswer(inv -> inv.getArgument(1)); given(dsaEnforcer.enforce(any(), any(), any())).willAnswer(inv -> inv.getArgument(1)); given(priceFloorAdjuster.adjustForImp(any(), any(), any(), any())) @@ -698,88 +680,6 @@ public void shouldPassRequestModifiedByRawBidderResponseHooks() { .containsOnly(hookChangedBid); } - @Test - public void shouldFilterPgDealsOnlyBiddersWithoutDeals() { - // given - final Bidder bidder1 = mock(Bidder.class); - final Bidder bidder2 = mock(Bidder.class); - givenBidder("bidder1", bidder1, givenEmptySeatBid()); - givenBidder("bidder2", bidder2, givenEmptySeatBid()); - - final BidRequest bidRequest = givenBidRequest(asList( - givenImp( - Map.of( - "bidder1", mapper.valueToTree("traceToken"), - "bidder2", mapper.createObjectNode().set("pgdealsonly", BooleanNode.getTrue())), - imp -> imp.id("imp1")), - givenImp( - singletonMap("bidder2", mapper.createObjectNode().set("pgdealsonly", BooleanNode.getTrue())), - imp -> imp.id("imp2")))); - - // when - final Future result = target.holdAuction(givenRequestContext(bidRequest)); - - // then - final ArgumentCaptor bidRequestCaptor = ArgumentCaptor.forClass(BidderRequest.class); - verify(httpBidderRequester, times(1)) - .requestBids(any(), bidRequestCaptor.capture(), any(), any(), any(), any(), anyBoolean()); - - assertThat(bidRequestCaptor.getValue().getBidRequest().getImp()).hasSize(1) - .extracting(imp -> imp.getExt().get("bidder").asText()) - .containsExactly("traceToken"); - - assertThat(result.result().getDebugWarnings()).containsExactly(""" - Not calling bidder2 bidder for impressions imp1, imp2 \ - due to pgdealsonly flag and no available PG line items."""); - } - - @Test - public void shouldFillAuctionContextWithMatchedDeals() { - // given - final Bidder bidder1 = mock(Bidder.class); - final Bidder bidder2 = mock(Bidder.class); - givenBidder("bidder1", bidder1, givenEmptySeatBid()); - givenBidder("bidder2", bidder2, givenEmptySeatBid()); - - final BidRequest bidRequest = givenBidRequest(asList( - givenImp(singletonMap("bidder1", mapper.createObjectNode()), imp -> imp.id("imp1")), - givenImp(singletonMap("bidder2", mapper.createObjectNode()), imp -> imp.id("imp2")))); - - given(dealsService.matchAndPopulateDeals(any(), any(), any())) - .willAnswer(arguments -> { - final BidderRequest bidderRequest = arguments.getArgument(0); - final Map> impIdToDeals = switch (bidderRequest.getBidder()) { - case "bidder1" -> singletonMap("imp1", singletonList(Deal.builder().id("deal1").build())); - case "bidder2" -> singletonMap("imp2", singletonList(Deal.builder().id("deal2").build())); - default -> null; - }; - - return bidderRequest.toBuilder().impIdToDeals(impIdToDeals).build(); - }); - - // when - final Future result = target.holdAuction(givenRequestContext(bidRequest)); - - // then - assertThat(result.result()) - .extracting(AuctionContext::getBidRequest) - .extracting(BidRequest::getImp) - .satisfies(imps -> { - assertThat(imps.get(0)) - .extracting(Imp::getPmp) - .extracting(Pmp::getDeals) - .asInstanceOf(InstanceOfAssertFactories.list(Deal.class)) - .containsExactly(Deal.builder().id("deal1").build()); - - assertThat(imps.get(1)) - .extracting(Imp::getPmp) - .extracting(Pmp::getDeals) - .asInstanceOf(InstanceOfAssertFactories.list(Deal.class)) - .containsExactly(Deal.builder().id("deal2").build()); - }); - - } - @Test public void shouldPassRequestWithExtPrebidToDefinedBidder() { // given @@ -1383,7 +1283,7 @@ public void shouldOverrideDebugEnabledFlag() { .willReturn(Future.succeededFuture( BidResponse.builder() .ext(ExtBidResponse.builder() - .debug(ExtResponseDebug.of(null, null, null, null)) + .debug(ExtResponseDebug.of(null, null, null)) .build()) .build())); @@ -1413,7 +1313,7 @@ public void shouldAddDebugInfoIfDebugEnabledAndPublisherAndBidderAllowedDebug() .willReturn(Future.succeededFuture( BidResponse.builder() .ext(ExtBidResponse.builder() - .debug(ExtResponseDebug.of(null, null, null, null)) + .debug(ExtResponseDebug.of(null, null, null)) .build()) .build())); @@ -4467,74 +4367,6 @@ public void shouldIncrementHooksGlobalAndAccountMetrics() { verify(metrics).updateAccountModuleDurationMetric(any(), eq("module3"), eq(8L)); } - @Test - public void shouldTolerateBidWithDealThatHasNoLineItemAssociated() { - // given - givenBidder(givenSingleSeatBid(givenBidderBid( - Bid.builder().impid("impId").dealid("dealId").price(BigDecimal.ONE).build()))); - - final BidRequest bidRequest = givenBidRequest(givenSingleImp(singletonMap("someBidder", 1)), identity()); - final AuctionContext auctionContext = givenRequestContext(bidRequest); - - // when - target.holdAuction(auctionContext); - - // then - final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(AuctionContext.class); - verify(applicationEventService).publishAuctionEvent(argumentCaptor.capture()); - final TxnLog txnLog = argumentCaptor.getValue().getTxnLog(); - - assertThat(txnLog).isEqualTo(TxnLog.create()); - } - - @Test - public void shouldRecordLineItemMetricsInTransactionLog() { - // given - givenBidder(givenSeatBid(asList( - givenBidderBid(Bid.builder().impid("impId").dealid("dealId1").price(BigDecimal.ONE).build()), - givenBidderBid(Bid.builder().impid("impId").dealid("dealId2").price(BigDecimal.ONE).build())))); - - willReturn(ValidationResult.success()).given(responseBidValidator) - .validate(argThat(bid -> bid.getBid().getDealid().equals("dealId1")), any(), any(), any()); - willReturn(ValidationResult.error("validation error")).given(responseBidValidator) - .validate(argThat(bid -> bid.getBid().getDealid().equals("dealId2")), any(), any(), any()); - - final List deals = asList( - Deal.builder() - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of( - ExtDealLine.of("lineItemId1", null, null, "someBidder")))) - .build(), - Deal.builder() - .id("dealId2") - .ext(mapper.valueToTree(ExtDeal.of( - ExtDealLine.of("lineItemId2", null, null, "someBidder")))) - .build()); - final Imp imp = givenImp( - singletonMap("someBidder", 1), - builder -> builder - .id("impId") - .pmp(Pmp.builder() - .deals(deals) - .build())); - final BidRequest bidRequest = givenBidRequest(singletonList(imp), identity()); - final AuctionContext auctionContext = givenRequestContext(bidRequest); - - // when - target.holdAuction(auctionContext); - - // then - final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(AuctionContext.class); - verify(applicationEventService).publishAuctionEvent(argumentCaptor.capture()); - final TxnLog txnLog = argumentCaptor.getValue().getTxnLog(); - - final TxnLog expectedTxnLog = TxnLog.create(); - expectedTxnLog.lineItemsReceivedFromBidder().get("someBidder").addAll(asList("lineItemId1", "lineItemId2")); - expectedTxnLog.lineItemsResponseInvalidated().add("lineItemId2"); - - assertThat(txnLog).isEqualTo(expectedTxnLog); - } - @Test public void shouldProperPopulateImpExtPrebidEvenIfInExtImpPrebidContainNotCorrectField() { // given @@ -4622,27 +4454,6 @@ public void shouldReturnsSourceWithCorrespondingRequestExtPrebidSchainsIfSchainI .isEqualTo(givenSourceSchain); } - @Test - public void shouldNotModifyOriginalDealsIfDealsFromLineItemServiceAreMissing() { - // given - final Pmp pmp = Pmp.builder() - .deals(singletonList(Deal.builder().id("dealId1").build())) // deal from prebid request (not from PG) - .build(); - final BidRequest bidRequest = givenBidRequest(singletonList(givenImp(singletonMap("someBidder", 1), - builder -> builder.pmp(pmp))), identity()); - final AuctionContext auctionContext = givenRequestContext(bidRequest).toBuilder() - .build(); - - // when - target.holdAuction(auctionContext); - - // then - final BidRequest capturedBidRequest = captureBidRequest(); - assertThat(capturedBidRequest.getImp()) - .extracting(Imp::getPmp) - .containsExactly(pmp); - } - @Test public void shouldReduceBidsHavingDealIdWithSameImpIdByBidderWithToleratingNotObtainedBidWithTopDeal() { // given @@ -4808,7 +4619,6 @@ private void givenTarget(boolean enabledStrictAppSiteDoohValidation) { 0, bidderCatalog, storedResponseProcessor, - dealsService, privacyEnforcementService, fpdResolver, supplyChainResolver, @@ -4824,7 +4634,6 @@ private void givenTarget(boolean enabledStrictAppSiteDoohValidation) { bidResponseCreator, bidResponsePostProcessor, hookStageExecutor, - applicationEventService, httpInteractionLogger, priceFloorAdjuster, priceFloorEnforcer, @@ -4859,8 +4668,6 @@ private AuctionContext givenRequestContext(BidRequest bidRequest, Account accoun .timeoutContext(TimeoutContext.of(clock.millis(), timeout, 90)) .hookExecutionContext(HookExecutionContext.of(Endpoint.openrtb2_auction)) .debugContext(DebugContext.empty()) - .txnLog(TxnLog.create()) - .deepDebugLog(DeepDebugLog.create(false, clock)) .bidRejectionTrackers(new HashMap<>()) .activityInfrastructure(activityInfrastructure) .build(); diff --git a/src/test/java/org/prebid/server/auction/WinningBidComparatorFactoryTest.java b/src/test/java/org/prebid/server/auction/WinningBidComparatorFactoryTest.java index 57d5ecbea2a..3716bc7b92e 100644 --- a/src/test/java/org/prebid/server/auction/WinningBidComparatorFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/WinningBidComparatorFactoryTest.java @@ -1,18 +1,14 @@ package org.prebid.server.auction; -import com.iab.openrtb.request.Deal; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; import com.iab.openrtb.response.Bid; import org.junit.Test; import org.prebid.server.auction.model.BidInfo; import java.math.BigDecimal; -import java.util.Arrays; import java.util.List; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; +import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; public class WinningBidComparatorFactoryTest { @@ -60,10 +56,10 @@ public void preferDealsComparatorCompareShouldReturnZeroWhenPriceAreEqualForNonD } @Test - public void preferDealsComparatorCompareShouldReturnMoreThanZeroWhenFirstHasNonPgDeal() { + public void preferDealsComparatorCompareShouldReturnMoreThanZeroWhenFirstHasDeal() { // given - final BidInfo dealPriceBidInfo = givenBidInfo(5.0f, "dealId", emptyList()); - final BidInfo higherPriceBidInfo = givenBidInfo(10.0f, null, emptyList()); + final BidInfo dealPriceBidInfo = givenBidInfo(1.0f, "dealId"); + final BidInfo higherPriceBidInfo = givenBidInfo(5.0f); // when final int result = winningBidComparatorFactory.create(true).compare(dealPriceBidInfo, higherPriceBidInfo); @@ -73,10 +69,10 @@ public void preferDealsComparatorCompareShouldReturnMoreThanZeroWhenFirstHasNonP } @Test - public void preferDealsComparatorCompareShouldReturnLessThanZeroWhenFirstHasNoDeal() { + public void preferDealsComparatorCompareShouldReturnLessThanZeroWhenSecondHasDeal() { // given - final BidInfo higherPriceBidInfo = givenBidInfo(10.0f, null, emptyList()); - final BidInfo dealPriceBidInfo = givenBidInfo(5.0f, "dealId", emptyList()); + final BidInfo higherPriceBidInfo = givenBidInfo(5.0f); + final BidInfo dealPriceBidInfo = givenBidInfo(1.0f, "dealId"); // when final int result = winningBidComparatorFactory.create(true).compare(higherPriceBidInfo, dealPriceBidInfo); @@ -86,117 +82,64 @@ public void preferDealsComparatorCompareShouldReturnLessThanZeroWhenFirstHasNoDe } @Test - public void preferDealsComparatorCompareShouldReturnZeroWhenBothHaveNonPgDeals() { - // given - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId", emptyList()); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", emptyList()); - - // when - final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isEqualTo(0); - } - - @Test - public void preferDealsComparatorCompareShouldReturnZeroWhenBothHaveSamePgDealIdAndHasSamePrice() { + public void preferDealsComparatorCompareShouldReturnMoreThanZeroWhenBothHaveDealsAndFirstHasHigherPrice() { // given - final List impDeals = singletonList("dealId"); - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", impDeals); + final BidInfo higherPriceBidInfo = givenBidInfo(5.0f, "dealId1"); + final BidInfo lowerPriceBidInfo = givenBidInfo(1.0f, "dealId2"); // when - final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isEqualTo(0); - } - - @Test - public void preferDealsComparatorCompareShouldReturnMoreThanZeroWhenBothHaveSamePgDealIdAndFirstHasHigherPrice() { - // given - final List impDeals = singletonList("dealId"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", impDeals); - - // when - final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); + final int result = winningBidComparatorFactory.create(true).compare(higherPriceBidInfo, lowerPriceBidInfo); // then assertThat(result).isGreaterThan(0); } @Test - public void preferDealsComparatorShouldReturnLessThanZeroWhenFirstHasHigherPriceAndSecondHasLessImpPgDealIndex() { - // given - final List impDeals = Arrays.asList("dealId1", "dealId2"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId1", impDeals); - - // when - final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isLessThan(0); - } - - @Test - public void preferDealsComparatorShouldReturnLessThanZeroWhenFirstIsNonPgDealWithHigherPriceAndSecondPgDeal() { + public void preferDealsComparatorCompareShouldReturnLessThanZeroWhenBothHaveDealsAndFirstHasLowerPrice() { // given - final List impDeals = singletonList("dealId1"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId1", impDeals); + final BidInfo lowerPriceBidInfo = givenBidInfo(1.0f, "dealId1"); + final BidInfo higherPriceBidInfo = givenBidInfo(5.0f, "dealId2"); // when - final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); + final int result = winningBidComparatorFactory.create(true).compare(lowerPriceBidInfo, higherPriceBidInfo); // then assertThat(result).isLessThan(0); } @Test - public void preferDealsComparatorShouldReturnGreaterThanZeroWhenFirstPgDealAndSecondMonPgDeal() { + public void preferDealsComparatorCompareShouldReturnZeroWhenBothHaveDealsAndPriceAreEqual() { // given - final List impDeals = singletonList("dealId2"); - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(10.0f, "dealId1", impDeals); + final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId1"); + final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId2"); // when final int result = winningBidComparatorFactory.create(true).compare(bidInfo1, bidInfo2); // then - assertThat(result).isGreaterThan(0); + assertThat(result).isEqualTo(0); } @Test public void preferDealsComparatorSortShouldReturnExpectedSortedResultWithDeals() { // given - final String dealId1 = "pgDealId1"; - final String dealId2 = "pgDealId2"; - final List impDeals = Arrays.asList(dealId1, dealId2); - - final BidInfo bidInfo1 = givenBidInfo(1.0f, dealId1, impDeals); // pg deal with lower price - final BidInfo bidInfo2 = givenBidInfo(2.0f, dealId1, impDeals); // pg deal with middle price - final BidInfo bidInfo3 = givenBidInfo(4.1f, dealId2, impDeals); // pg deal with higher price - final BidInfo bidInfo4 = givenBidInfo(5.0f, null, impDeals); // non deal with lower price - final BidInfo bidInfo5 = givenBidInfo(100.1f, null, impDeals); // non deal with higher price - final BidInfo bidInfo6 = givenBidInfo(0.5f, "dealId1", impDeals); // non pg deal with lower price - final BidInfo bidInfo7 = givenBidInfo(1f, "dealId2", impDeals); // non pg deal with middle price - final BidInfo bidInfo8 = givenBidInfo(4.4f, "dealId3", impDeals); // non pg deal with higher price - - final List bidInfos = Arrays.asList(bidInfo5, bidInfo3, bidInfo1, bidInfo2, bidInfo1, bidInfo4, - bidInfo6, bidInfo7, bidInfo8); + final BidInfo bidInfo1 = givenBidInfo(5.0f); // non deal with lower price + final BidInfo bidInfo2 = givenBidInfo(100.1f); // non deal with higher price + final BidInfo bidInfo3 = givenBidInfo(0.5f, "dealId1"); // deal with lower price + final BidInfo bidInfo4 = givenBidInfo(1f, "dealId2"); // deal with middle price + final BidInfo bidInfo5 = givenBidInfo(6f, "dealId3"); // deal with higher price + + final List bidInfos = asList(bidInfo5, bidInfo4, bidInfo2, bidInfo3, bidInfo1, bidInfo2); // when bidInfos.sort(winningBidComparatorFactory.create(true)); // then - assertThat(bidInfos).containsOnly(bidInfo4, bidInfo5, bidInfo6, bidInfo7, bidInfo8, bidInfo3, bidInfo2, - bidInfo1, bidInfo1); + assertThat(bidInfos).containsExactly(bidInfo1, bidInfo2, bidInfo2, bidInfo3, bidInfo4, bidInfo5); } @Test - public void priceComparatorCompareShouldReturnMoreThatZeroWhenFirstHasHigherPriceForNonDealsBids() { + public void priceComparatorCompareShouldReturnMoreThatZeroWhenFirstHasHigherPrice() { // given final BidInfo higherPriceBidInfo = givenBidInfo(5.0f); final BidInfo lowerPriceBidInfo = givenBidInfo(1.0f); @@ -209,7 +152,7 @@ public void priceComparatorCompareShouldReturnMoreThatZeroWhenFirstHasHigherPric } @Test - public void priceComparatorCompareShouldReturnLessThatZeroWhenFirstHasLowerPriceForNonDealsBids() { + public void priceComparatorCompareShouldReturnLessThatZeroWhenFirstHasLowerPrice() { // given final BidInfo lowerPriceBidInfo = givenBidInfo(1.0f); final BidInfo higherPriceBidInfo = givenBidInfo(5.0f); @@ -234,140 +177,22 @@ public void priceComparatorCompareShouldReturnZeroWhenPriceAreEqualForNonDealsBi assertThat(result).isEqualTo(0); } - @Test - public void preferPriceComparatorCompareShouldReturnLessThanZeroWhenFirstHasNonPgDeal() { - // given - final BidInfo dealPriceBidInfo = givenBidInfo(5.0f, "dealId", emptyList()); - final BidInfo higherPriceBidInfo = givenBidInfo(10.0f, null, emptyList()); - - // when - final int result = winningBidComparatorFactory.create(false).compare(dealPriceBidInfo, higherPriceBidInfo); - - // then - assertThat(result).isLessThan(0); - } - - @Test - public void preferPriceComparatorCompareShouldReturnGreaterThanZeroWhenFirstHasNoDeal() { - // given - final BidInfo higherPriceBidInfo = givenBidInfo(10.0f, null, emptyList()); - final BidInfo dealPriceBidInfo = givenBidInfo(5.0f, "dealId", emptyList()); - - // when - final int result = winningBidComparatorFactory.create(false).compare(higherPriceBidInfo, dealPriceBidInfo); - - // then - assertThat(result).isGreaterThan(0); - } - - @Test - public void preferPriceComparatorCompareShouldReturnZeroWhenBothHaveNonPgDeals() { - // given - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId", emptyList()); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", emptyList()); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isEqualTo(0); - } - - @Test - public void preferPriceComparatorCompareShouldReturnZeroWhenBothHaveSamePgDealIdAndHasSamePrice() { - // given - final List impDeals = singletonList("dealId"); - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", impDeals); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isEqualTo(0); - } - - @Test - public void preferPriceComparatorCompareShouldReturnMoreThanZeroWhenBothHaveSamePgDealIdAndFirstHasHigherPrice() { - // given - final List impDeals = singletonList("dealId"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId", impDeals); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isGreaterThan(0); - } - - @Test - public void preferPriceComparatorShouldReturnLessThanZeroWhenFirstHasHigherPriceAndSecondHasLessImpPgDealIndex() { - // given - final List impDeals = Arrays.asList("dealId1", "dealId2"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId1", impDeals); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isLessThan(0); - } - - @Test - public void preferPriceComparatorShouldReturnLessThanZeroWhenFirstIsNonPgDealWithHigherPriceAndSecondPgDeal() { - // given - final List impDeals = singletonList("dealId1"); - final BidInfo bidInfo1 = givenBidInfo(10.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(5.0f, "dealId1", impDeals); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isLessThan(0); - } - - @Test - public void preferPriceComparatorShouldReturnGreaterThanZeroWhenFirstPgDealAndSecondMonPgDeal() { - // given - final List impDeals = singletonList("dealId2"); - final BidInfo bidInfo1 = givenBidInfo(5.0f, "dealId2", impDeals); - final BidInfo bidInfo2 = givenBidInfo(10.0f, "dealId1", impDeals); - - // when - final int result = winningBidComparatorFactory.create(false).compare(bidInfo1, bidInfo2); - - // then - assertThat(result).isGreaterThan(0); - } - @Test public void preferPriceComparatorSortShouldReturnExpectedSortedResultWithDeals() { // given - final String dealId1 = "pgDealId1"; - final String dealId2 = "pgDealId2"; - final List impDeals = Arrays.asList(dealId1, dealId2); - - final BidInfo bidInfo1 = givenBidInfo(1.0f, dealId1, impDeals); // pg deal with lower price - final BidInfo bidInfo2 = givenBidInfo(2.0f, dealId1, impDeals); // pg deal with middle price - final BidInfo bidInfo3 = givenBidInfo(4.1f, dealId2, impDeals); // pg deal with higher price - final BidInfo bidInfo4 = givenBidInfo(5.0f, null, impDeals); // non deal with lower price - final BidInfo bidInfo5 = givenBidInfo(100.1f, null, impDeals); // non deal with higher price - final BidInfo bidInfo6 = givenBidInfo(0.5f, "dealId1", impDeals); // non pg deal with lower price - final BidInfo bidInfo7 = givenBidInfo(1f, "dealId2", impDeals); // non pg deal with middle price - final BidInfo bidInfo8 = givenBidInfo(4.4f, "dealId3", impDeals); // non pg deal with higher price - - final List bidInfos = Arrays.asList(bidInfo5, bidInfo3, bidInfo1, bidInfo2, bidInfo1, bidInfo4, - bidInfo6, bidInfo7, bidInfo8); + final BidInfo bidInfo1 = givenBidInfo(5.0f, null); // non deal with lower price + final BidInfo bidInfo2 = givenBidInfo(100.1f, null); // non deal with higher price + final BidInfo bidInfo3 = givenBidInfo(0.5f, "dealId1"); // deal with lower price + final BidInfo bidInfo4 = givenBidInfo(1f, "dealId2"); // deal with middle price + final BidInfo bidInfo5 = givenBidInfo(6f, "dealId3"); // deal with higher price + + final List bidInfos = asList(bidInfo5, bidInfo4, bidInfo2, bidInfo3, bidInfo1, bidInfo2); // when bidInfos.sort(winningBidComparatorFactory.create(false)); // then - assertThat(bidInfos).containsOnly(bidInfo6, bidInfo7, bidInfo8, bidInfo4, bidInfo5, bidInfo1, - bidInfo1, bidInfo2, bidInfo3); + assertThat(bidInfos).containsExactly(bidInfo3, bidInfo4, bidInfo1, bidInfo5, bidInfo2, bidInfo2); } private static BidInfo givenBidInfo(float price) { @@ -381,16 +206,4 @@ private static BidInfo givenBidInfo(float price, String dealId) { .correspondingImp(Imp.builder().id(IMP_ID).build()) .build(); } - - private static BidInfo givenBidInfo(float price, String dealId, List impDealIds) { - final List impDeals = impDealIds.stream() - .map(impDealId -> Deal.builder().id(impDealId).build()) - .toList(); - final Pmp pmp = Pmp.builder().deals(impDeals).build(); - - return BidInfo.builder() - .bid(Bid.builder().impid(IMP_ID).price(BigDecimal.valueOf(price)).dealid(dealId).build()) - .correspondingImp(Imp.builder().id(IMP_ID).pmp(pmp).build()) - .build(); - } } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/AmpRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/AmpRequestFactoryTest.java index a730e9055cf..cf66cccba0b 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/AmpRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/AmpRequestFactoryTest.java @@ -155,7 +155,7 @@ public void setUp() { given(ortb2RequestFactory.restoreResultFromRejection(any())) .willAnswer(invocation -> Future.failedFuture((Throwable) invocation.getArgument(0))); given(ortb2RequestFactory.enrichWithPriceFloors(any())).willAnswer(invocation -> invocation.getArgument(0)); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())).willAnswer(invocation -> invocation.getArgument(0)); + given(ortb2RequestFactory.updateTimeout(any())).willAnswer(invocation -> invocation.getArgument(0)); given(fpdResolver.resolveApp(any(), any())) .willAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); @@ -164,8 +164,6 @@ public void setUp() { given(fpdResolver.resolveUser(any(), any())) .willAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); given(fpdResolver.resolveImpExt(any(), any())).willAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); - given(ortb2RequestFactory.populateUserAdditionalInfo(any())) - .willAnswer(invocationOnMock -> Future.succeededFuture(invocationOnMock.getArgument(0))); given(ortb2RequestFactory.activityInfrastructureFrom(any())) .willReturn(Future.succeededFuture()); given(geoLocationServiceWrapper.lookup(any())) @@ -1671,7 +1669,7 @@ public void shouldUpdateTimeout() { // given givenBidRequest(); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())) + given(ortb2RequestFactory.updateTimeout(any())) .willAnswer(invocation -> { final AuctionContext auctionContext = invocation.getArgument(0); return auctionContext.with(auctionContext.getBidRequest().toBuilder().tmax(10000L).build()); diff --git a/src/test/java/org/prebid/server/auction/requestfactory/AuctionRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/AuctionRequestFactoryTest.java index babe0ddaa83..085fff44f6a 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/AuctionRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/AuctionRequestFactoryTest.java @@ -161,7 +161,7 @@ public void setUp() { given(ortb2RequestFactory.validateRequest(any(), any(), any())) .willAnswer(invocationOnMock -> Future.succeededFuture((BidRequest) invocationOnMock.getArgument(0))); given(ortb2RequestFactory.enrichWithPriceFloors(any())).willAnswer(invocation -> invocation.getArgument(0)); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())).willAnswer(invocation -> invocation.getArgument(0)); + given(ortb2RequestFactory.updateTimeout(any())).willAnswer(invocation -> invocation.getArgument(0)); given(paramsResolver.resolve(any(), any(), any(), anyBoolean())) .will(invocationOnMock -> invocationOnMock.getArgument(0)); @@ -173,16 +173,14 @@ public void setUp() { .willReturn(Future.succeededFuture(defaultPrivacyContext)); given(ortb2RequestFactory.enrichBidRequestWithAccountAndPrivacyData(any())) - .willAnswer(invocation -> Future.succeededFuture(((AuctionContext) invocation.getArgument(0)) - .getBidRequest())); + .willAnswer(invocation -> Future.succeededFuture( + ((AuctionContext) invocation.getArgument(0)).getBidRequest())); given(ortb2RequestFactory.enrichBidRequestWithGeolocationData(any())) .willAnswer(invocation -> Future.succeededFuture(((AuctionContext) invocation.getArgument(0)) .getBidRequest())); given(ortb2RequestFactory.executeProcessedAuctionRequestHooks(any())) .willAnswer(invocation -> Future.succeededFuture( ((AuctionContext) invocation.getArgument(0)).getBidRequest())); - given(ortb2RequestFactory.populateUserAdditionalInfo(any())) - .willAnswer(invocationOnMock -> Future.succeededFuture(invocationOnMock.getArgument(0))); given(ortb2RequestFactory.restoreResultFromRejection(any())) .willAnswer(invocation -> Future.failedFuture((Throwable) invocation.getArgument(0))); given(ortb2RequestFactory.activityInfrastructureFrom(any())) @@ -744,7 +742,7 @@ public void shouldUpdateTimeout() { // given givenValidBidRequest(); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())) + given(ortb2RequestFactory.updateTimeout(any())) .willAnswer(invocation -> { final AuctionContext auctionContext = invocation.getArgument(0); return auctionContext.with(auctionContext.getBidRequest().toBuilder().tmax(10000L).build()); diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java index 4e16e5b77cb..8791ac5eabf 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java @@ -33,9 +33,6 @@ import org.prebid.server.cookie.UidsCookie; import org.prebid.server.cookie.UidsCookieService; import org.prebid.server.cookie.proto.Uids; -import org.prebid.server.deals.UserAdditionalInfoService; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.TxnLog; import org.prebid.server.exception.BlacklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; @@ -80,7 +77,6 @@ import org.prebid.server.validation.RequestValidator; import org.prebid.server.validation.model.ValidationResult; -import java.time.Clock; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -128,16 +124,12 @@ public class Ortb2RequestFactoryTest extends VertxTest { @Mock private HookStageExecutor hookStageExecutor; @Mock - private UserAdditionalInfoService userAdditionalInfoService; - @Mock private PriceFloorProcessor priceFloorProcessor; @Mock private CountryCodeMapper countryCodeMapper; @Mock private Metrics metrics; - private final Clock clock = Clock.systemDefaultZone(); - private Ortb2RequestFactory target; @Mock @@ -173,9 +165,6 @@ public void setUp() { false, AuctionRequestPayloadImpl.of(invocation.getArgument(0))))); - given(userAdditionalInfoService.populate(any())) - .willAnswer(invocationOnMock -> Future.succeededFuture(invocationOnMock.getArgument(0))); - givenTarget(90); } @@ -598,7 +587,6 @@ public void createAuctionContextShouldReturnExpectedAuctionContext() { .hookExecutionContext(hookExecutionContext) .debugContext(DebugContext.empty()) .requestRejected(false) - .txnLog(TxnLog.create()) .debugHttpCalls(emptyMap()) .bidRejectionTrackers(new HashMap<>()) .build()); @@ -629,7 +617,6 @@ public void enrichAuctionContextShouldReturnExpectedAuctionContext() { .prebidErrors(new ArrayList<>()) .debugWarnings(new ArrayList<>()) .hookExecutionContext(hookExecutionContext) - .txnLog(TxnLog.create()) .debugHttpCalls(emptyMap()) .build(), httpRequest, @@ -651,8 +638,6 @@ public void enrichAuctionContextShouldReturnExpectedAuctionContext() { .prebidErrors(new ArrayList<>()) .debugWarnings(new ArrayList<>()) .hookExecutionContext(hookExecutionContext) - .txnLog(TxnLog.create()) - .deepDebugLog(DeepDebugLog.create(false, clock)) .debugHttpCalls(new HashMap<>()) .build()); } @@ -672,38 +657,6 @@ public void enrichAuctionContextShouldSetDebugOff() { assertThat(result.getDebugContext()).isEqualTo(DebugContext.empty()); } - @Test - public void enrichAuctionContextShouldReturnAuctionContextWithDeepDebugLogWhenDeepDebugIsOff() { - // when - final AuctionContext auctionContext = target.enrichAuctionContext( - AuctionContext.builder().build(), - httpRequest, - BidRequest.builder().build(), - 100); - - // then - assertThat(auctionContext.getDeepDebugLog()).isNotNull().returns(false, DeepDebugLog::isDeepDebugEnabled); - } - - @Test - public void enrichAuctionContextShouldReturnAuctionContextWithDeepDebugLogWhenDeepDebugIsOn() { - // given - final BidRequest bidRequest = BidRequest.builder() - .ext(ExtRequest.of( - ExtRequestPrebid.builder().trace(TraceLevel.verbose).build())) - .build(); - - // when - final AuctionContext auctionContext = target.enrichAuctionContext( - AuctionContext.builder().build(), - httpRequest, - bidRequest, - 100); - - // then - assertThat(auctionContext.getDeepDebugLog()).isNotNull().returns(true, DeepDebugLog::isDeepDebugEnabled); - } - @Test public void validateRequestShouldThrowInvalidRequestExceptionIfRequestIsInvalid() { // given @@ -1072,11 +1025,11 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldAddIpAddressV4FromPri // when final Future result = target.enrichBidRequestWithAccountAndPrivacyData( - AuctionContext.builder() - .bidRequest(bidRequest) - .account(account) - .privacyContext(privacyContext) - .build()); + AuctionContext.builder() + .bidRequest(bidRequest) + .account(account) + .privacyContext(privacyContext) + .build()); // then assertThat(result).isSucceeded().unwrap() @@ -1105,11 +1058,11 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldAddIpAddressV6FromPri // when final Future result = target.enrichBidRequestWithAccountAndPrivacyData( - AuctionContext.builder() - .bidRequest(bidRequest) - .account(account) - .privacyContext(privacyContext) - .build()); + AuctionContext.builder() + .bidRequest(bidRequest) + .account(account) + .privacyContext(privacyContext) + .build()); // then assertThat(result).isSucceeded().unwrap() @@ -1316,7 +1269,7 @@ public void updateTimeoutShouldReturnSameContextIfNoNeedUpdates() { .build(); // when - final AuctionContext result = target.updateTimeout(auctionContext, 0L); + final AuctionContext result = target.updateTimeout(auctionContext); // then assertThat(result).isSameAs(auctionContext); @@ -1339,7 +1292,7 @@ public void updateTimeoutShouldReturnContextWithUpdatedTimeout() { .build(); // when - final AuctionContext result = target.updateTimeout(auctionContext, 0L); + final AuctionContext result = target.updateTimeout(auctionContext); // then assertThat(result.getBidRequest()).isSameAs(auctionContext.getBidRequest()); @@ -1360,7 +1313,7 @@ public void updateTimeoutShouldReturnContextWithUpdatedBidRequestTmax() { .build(); // when - final AuctionContext result = target.updateTimeout(auctionContext, 0L); + final AuctionContext result = target.updateTimeout(auctionContext); // then assertThat(result.getBidRequest()).isEqualTo(givenBidRequest(request -> request.tmax(500L))); @@ -1384,7 +1337,7 @@ public void updateTimeoutShouldReturnContextWithUpdatedTimeoutAndBidRequestTmax( .build(); // when - final AuctionContext result = target.updateTimeout(auctionContext, 0L); + final AuctionContext result = target.updateTimeout(auctionContext); // then assertThat(result.getBidRequest()).isEqualTo(givenBidRequest(request -> request.tmax(500L))); @@ -1670,11 +1623,9 @@ private void givenTarget(int timeoutAdjustmentFactor) { applicationSettings, ipAddressHelper, hookStageExecutor, - userAdditionalInfoService, priceFloorProcessor, countryCodeMapper, - metrics, - clock); + metrics); } private static String bidRequestToString(BidRequest bidRequest) { diff --git a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java index 9d34db0f153..f406293ad38 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java @@ -105,7 +105,7 @@ public void setUp() { given(ortb2RequestFactory.restoreResultFromRejection(any())) .willAnswer(invocation -> Future.failedFuture((Throwable) invocation.getArgument(0))); given(ortb2RequestFactory.enrichWithPriceFloors(any())).willAnswer(invocation -> invocation.getArgument(0)); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())).willAnswer(invocation -> invocation.getArgument(0)); + given(ortb2RequestFactory.updateTimeout(any())).willAnswer(invocation -> invocation.getArgument(0)); given(ortb2RequestFactory.activityInfrastructureFrom(any())) .willReturn(Future.succeededFuture()); @@ -133,9 +133,6 @@ public void setUp() { given(auctionPrivacyContextFactory.contextFrom(any())) .willReturn(Future.succeededFuture(defaultPrivacyContext)); - given(ortb2RequestFactory.populateUserAdditionalInfo(any())) - .willAnswer(invocationOnMock -> Future.succeededFuture(invocationOnMock.getArgument(0))); - target = new VideoRequestFactory( Integer.MAX_VALUE, false, @@ -502,7 +499,7 @@ public void shouldUpdateTimeout() throws JsonProcessingException { // given prepareMinimumSuccessfulConditions(); - given(ortb2RequestFactory.updateTimeout(any(), anyLong())) + given(ortb2RequestFactory.updateTimeout(any())) .willAnswer(invocation -> { final AuctionContext auctionContext = invocation.getArgument(0); return auctionContext.with(auctionContext.getBidRequest().toBuilder().tmax(10000L).build()); diff --git a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java index 88a99caf1bb..222fe74882d 100644 --- a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java +++ b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java @@ -50,6 +50,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.UnaryOperator; import static java.util.Arrays.asList; @@ -459,8 +460,28 @@ public void shouldCompressRequestBodyIfContentEncodingHeaderIsGzip() { @Test public void shouldNotWaitForResponsesWhenAllDealsIsGathered() throws JsonProcessingException { // given - target = new HttpBidderRequester(httpClient, new DealsBidderRequestCompletionTrackerFactory(), - bidderErrorNotifier, requestEnricher, jacksonMapper); + target = new HttpBidderRequester( + httpClient, + bidRequest -> new BidderRequestCompletionTracker() { + + private final AtomicInteger waitAllDeals = new AtomicInteger(2); + private final Promise promise = Promise.promise(); + + @Override + public Future future() { + return promise.future(); + } + + @Override + public void processBids(List bids) { + if (waitAllDeals.decrementAndGet() <= 0) { + promise.complete(); + } + } + }, + bidderErrorNotifier, + requestEnricher, + jacksonMapper); final BidRequest bidRequest = bidRequestWithDeals("deal1", "deal2"); final BidderRequest bidderRequest = BidderRequest.builder() @@ -512,16 +533,15 @@ public void shouldNotWaitForResponsesWhenAllDealsIsGathered() throws JsonProcess CompositeBidderResponse.withBids(singletonList(bidderBidDeal2), emptyList())); // when - final BidderSeatBid bidderSeatBid = - target.requestBids( - bidder, - bidderRequest, - bidRejectionTracker, - timeout, - CaseInsensitiveMultiMap.empty(), - bidderAliases, - false) - .result(); + final BidderSeatBid bidderSeatBid = target.requestBids( + bidder, + bidderRequest, + bidRejectionTracker, + timeout, + CaseInsensitiveMultiMap.empty(), + bidderAliases, + false) + .result(); // then verify(bidder).makeHttpRequests(any()); diff --git a/src/test/java/org/prebid/server/cache/CacheServiceTest.java b/src/test/java/org/prebid/server/cache/CacheServiceTest.java index 74feaf189af..4e4410b7b1c 100644 --- a/src/test/java/org/prebid/server/cache/CacheServiceTest.java +++ b/src/test/java/org/prebid/server/cache/CacheServiceTest.java @@ -232,8 +232,7 @@ public void cacheBidsOpenrtbShouldStoreWinUrl() { .build(); // when cacheService.cacheBidsOpenrtb( - singletonList(givenBidInfo(builder -> builder.id("bidId1"), BidType.banner, "bidder", - "lineItemId")), + singletonList(givenBidInfo(builder -> builder.id("bidId1"), BidType.banner, "bidder")), givenAuctionContext(), CacheContext.builder() .shouldCacheBids(true) @@ -241,9 +240,16 @@ public void cacheBidsOpenrtbShouldStoreWinUrl() { eventsContext); // then - verify(eventsService).winUrl(eq("bidId1"), eq("bidder"), eq("accountId"), eq("lineItemId"), eq(true), - eq(EventsContext.builder().enabledForAccount(true).enabledForRequest(true) - .auctionId("auctionId").build())); + verify(eventsService).winUrl( + eq("bidId1"), + eq("bidder"), + eq("accountId"), + eq(true), + eq(EventsContext.builder() + .enabledForAccount(true) + .enabledForRequest(true) + .auctionId("auctionId") + .build())); } @Test @@ -790,8 +796,8 @@ public void cacheBidsOpenrtbShouldUpdateVastXmlPutObjectWithKeyWhenBidHasCategor // given final Imp imp1 = givenImp(builder -> builder.id("impId1").video(Video.builder().build())); - final BidInfo bidInfo1 = givenBidInfo(builder -> builder.id("bid1").adm("adm"), - BidType.video, "bidder", null) + final BidInfo bidInfo1 = givenBidInfo( + builder -> builder.id("bid1").adm("adm"), BidType.video, "bidder") .toBuilder().category("bid1Category").build(); given(idGenerator.generateId()).willReturn("randomId"); @@ -820,10 +826,10 @@ public void cacheBidsOpenrtbShouldUpdateVastXmlPutObjectWithKeyWhenBidHasCategor public void cacheBidsOpenrtbShouldNotUpdateVastXmlPutObjectWithKeyWhenDoesNotHaveCatDur() throws IOException { // given final Imp imp1 = givenImp(builder -> builder.id("impId1").video(Video.builder().build())); - final BidInfo bidInfo1 = givenBidInfo(builder -> builder.id("bid1").impid("impId1").adm("adm"), - BidType.video, "bidder", null); + final BidInfo bidInfo1 = givenBidInfo( + builder -> builder.id("bid1").impid("impId1").adm("adm"), BidType.video, "bidder"); - given(vastModifier.createBidVastXml(any(), any(), any(), any(), any(), any(), any(), any())).willReturn("adm"); + given(vastModifier.createBidVastXml(any(), any(), any(), any(), any(), any(), any())).willReturn("adm"); // when cacheService.cacheBidsOpenrtb( @@ -1015,16 +1021,6 @@ private static BidInfo givenBidInfo(UnaryOperator bidCustomizer, .build(); } - private static BidInfo givenBidInfo(UnaryOperator bidCustomizer, - BidType bidType, - String bidder, - String lineItemId) { - - return givenBidInfo(bidCustomizer, bidType, bidder).toBuilder() - .lineItemId(lineItemId) - .build(); - } - private static Imp givenImp(UnaryOperator impCustomizer) { return impCustomizer.apply(Imp.builder()).build(); } diff --git a/src/test/java/org/prebid/server/deals/AdminCentralServiceTest.java b/src/test/java/org/prebid/server/deals/AdminCentralServiceTest.java deleted file mode 100644 index 7ff33ff7cd6..00000000000 --- a/src/test/java/org/prebid/server/deals/AdminCentralServiceTest.java +++ /dev/null @@ -1,437 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.model.AdminAccounts; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.deals.model.AdminLineItems; -import org.prebid.server.deals.model.Command; -import org.prebid.server.deals.model.LogCriteriaFilter; -import org.prebid.server.deals.model.LogTracer; -import org.prebid.server.deals.model.ServicesCommand; -import org.prebid.server.log.CriteriaManager; -import org.prebid.server.settings.CachingApplicationSettings; -import org.prebid.server.settings.SettingsCache; -import org.prebid.server.settings.proto.request.InvalidateSettingsCacheRequest; -import org.prebid.server.settings.proto.request.UpdateSettingsCacheRequest; - -import java.util.Collections; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -public class AdminCentralServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private AdminCentralService adminCentralService; - - @Mock - private LineItemService lineItemService; - - @Mock - private DeliveryProgressService deliveryProgressService; - - @Mock - private CriteriaManager criteriaManager; - - @Mock - private SettingsCache settingsCache; - - @Mock - private SettingsCache ampSettingsCache; - - @Mock - private CachingApplicationSettings cachingApplicationSettings; - - @Mock - private Suspendable suspendable; - - @Before - public void setUp() { - adminCentralService = new AdminCentralService(criteriaManager, lineItemService, deliveryProgressService, - settingsCache, ampSettingsCache, cachingApplicationSettings, - jacksonMapper, singletonList(suspendable)); - } - - @Test - public void processAdminCentralEventShouldAddCriteriaWhenTraceLogAndCriteriaFilterArePresentAndCmdIsStart() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of( - LogTracer.of("start", false, 800L, LogCriteriaFilter.of(null, null, null)), null, null, null, null, - null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(criteriaManager).addCriteria(any(), anyLong()); - } - - @Test - public void processAdminCentralEventShouldAddCriteriaWhenTraceLogAndCriteriaFilterArePresentAndCmdIsStop() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(LogTracer.of("stop", false, 0L, null), - null, null, null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(criteriaManager).stop(); - } - - @Test - public void processAdminCentralEventShouldStopServicesWhenServicesStopCommandIsPresent() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, null, null, null, - ServicesCommand.of("stop")); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(suspendable).suspend(); - } - - @Test - public void processAdminCentralEventShouldNotStopServicesWhenServicesCommandIsNotStop() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, null, null, null, - ServicesCommand.of("invalid")); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(suspendable); - } - - @Test - public void processAdminCentralEventShouldAddCriteriaAndStopServices() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of( - LogTracer.of("start", false, 800L, LogCriteriaFilter.of(null, null, null)), null, null, null, null, - ServicesCommand.of("stop")); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(suspendable).suspend(); - verify(criteriaManager).addCriteria(any(), anyLong()); - } - - @Test - public void processAdminCentralEventShouldNotCallCriteriaManagerWhenCommandIsNull() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of( - LogTracer.of(null, false, 800L, LogCriteriaFilter.of(null, null, null)), null, null, null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(criteriaManager); - } - - @Test - public void processAdminCentralEventShouldNotCallCriteriaManagerWhenItIsNotStartOrStop() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of( - LogTracer.of("invalid", false, 800L, LogCriteriaFilter.of(null, null, null)), null, null, - null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(criteriaManager); - } - - @Test - public void processAdminCentralEventShouldNotCallSettingsCacheWhenCommandWasNotDefined() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, Command.of(null, null), - Command.of(null, null), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(settingsCache); - verifyNoInteractions(ampSettingsCache); - } - - @Test - public void processAdminCentralEventShouldNotCallSettingsCacheWhenBodyWasNotDefined() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, Command.of("save", null), - Command.of("save", null), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(settingsCache); - verifyNoInteractions(ampSettingsCache); - } - - @Test - public void processAdminCentralEventShouldCallSettings() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, Command.of("save", null), - Command.of("save", null), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(settingsCache); - verifyNoInteractions(ampSettingsCache); - } - - @Test - public void processAdminCentralEventShouldCallSaveAmpSettingsCache() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, - Command.of("save", jacksonMapper.mapper().valueToTree(UpdateSettingsCacheRequest - .of(Collections.emptyMap(), Collections.emptyMap()))), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(ampSettingsCache).save(any(), any()); - } - - @Test - public void processAdminCentralEventShouldCallInvalidateAmpSettingsCache() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, - Command.of("invalidate", jacksonMapper.mapper().valueToTree(InvalidateSettingsCacheRequest - .of(Collections.emptyList(), Collections.emptyList()))), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(ampSettingsCache).invalidate(any(), any()); - } - - @Test - public void processAdminCentralEventShouldNotCallAmpSettingsCacheWhenCantParseBody() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, - Command.of("save", jacksonMapper.mapper().createObjectNode().put("requests", 1)), null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(ampSettingsCache); - } - - @Test - public void processAdminCentralEventShouldCallSaveSettingsCache() throws JsonProcessingException { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - Command.of("save", jacksonMapper.mapper().valueToTree(UpdateSettingsCacheRequest - .of(Collections.singletonMap("requestId", - jacksonMapper.mapper().writeValueAsString(BidRequest.builder().id("requestId") - .build())), - Collections.singletonMap("impId", - jacksonMapper.mapper().writeValueAsString(Imp.builder().id("impId") - .build()))))), - null, null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(settingsCache).save(any(), any()); - } - - @Test - public void processAdminCentralEventShouldCallInvalidateSettingsCache() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - Command.of("invalidate", jacksonMapper.mapper().valueToTree(InvalidateSettingsCacheRequest - .of(Collections.emptyList(), Collections.emptyList()))), null, null, null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(settingsCache).invalidate(any(), any()); - } - - @Test - public void processAdminCentralEventShouldNotCallSettingsCacheWhenCantParseBody() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - Command.of("save", jacksonMapper.mapper().createObjectNode().put("requests", 1)), null, null, null, - null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(settingsCache); - } - - @Test - public void processAdminCentralEventShouldCallInvalidateLineItemsById() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, Command.of("invalidate", jacksonMapper.mapper() - .valueToTree(AdminLineItems.of(singletonList("lineItemId")))), null, null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(lineItemService).invalidateLineItemsByIds(eq(singletonList("lineItemId"))); - verify(deliveryProgressService).invalidateLineItemsByIds(eq(singletonList("lineItemId"))); - } - - @Test - public void processAdminCentralEventShouldCallInvalidateAllLineItems() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, Command.of("invalidate", null), null, null); - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(lineItemService).invalidateLineItems(); - verify(deliveryProgressService).invalidateLineItems(); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateWhenCmdNotDefined() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, Command.of(null, null), null, null); - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoMoreInteractions(lineItemService); - verifyNoMoreInteractions(deliveryProgressService); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateWhenCmdHasValueOtherToInvalidate() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, Command.of("save", null), null, null); - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoMoreInteractions(lineItemService); - verifyNoMoreInteractions(deliveryProgressService); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateWhenCantParseBody() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, Command.of("invalidate", mapper.createObjectNode() - .set("ids", mapper.valueToTree(AdminLineItems.of(singletonList("5"))))), null, - null); - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoMoreInteractions(lineItemService); - verifyNoMoreInteractions(deliveryProgressService); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateAccountsWhenCommandIsNotDefined() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, null, Command.of(null, mapper.createObjectNode() - .set("ids", mapper.valueToTree(AdminAccounts.of(singletonList("1001"))))), null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(cachingApplicationSettings); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateAccountsWhenInvalidCommandValue() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, null, Command.of("invalid", mapper.valueToTree(AdminAccounts.of(singletonList("1001")))), - null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(cachingApplicationSettings); - } - - @Test - public void processAdminCentralEventShouldNotCallInvalidateAccountsCantParseBody() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, null, Command.of("invalidate", mapper.createObjectNode() - .set("accounts", mapper.valueToTree(AdminAccounts.of(singletonList("5"))))), null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verifyNoInteractions(cachingApplicationSettings); - } - - @Test - public void processAdminCentralEventShouldInvalidateAccounts() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, null, Command.of("invalidate", - mapper.valueToTree(AdminAccounts.of(asList("1001", "1002")))), null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(cachingApplicationSettings).invalidateAccountCache(eq("1001")); - verify(cachingApplicationSettings).invalidateAccountCache(eq("1002")); - } - - @Test - public void processAdminCentralEventShouldInvalidateAllAccounts() { - // given - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, - null, null, null, Command.of("invalidate", mapper.createObjectNode() - .set("ids", mapper.valueToTree(AdminAccounts.of(null)))), null); - - // when - adminCentralService.processAdminCentralEvent(adminCentralResponse); - - // then - verify(cachingApplicationSettings).invalidateAllAccountCache(); - } -} diff --git a/src/test/java/org/prebid/server/deals/AlertHttpServiceTest.java b/src/test/java/org/prebid/server/deals/AlertHttpServiceTest.java deleted file mode 100644 index 3dd501bed23..00000000000 --- a/src/test/java/org/prebid/server/deals/AlertHttpServiceTest.java +++ /dev/null @@ -1,233 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.model.AlertEvent; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.AlertProxyProperties; -import org.prebid.server.deals.model.AlertSource; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.vertx.http.HttpClient; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.stream.IntStream; - -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class AlertHttpServiceTest extends VertxTest { - - @Rule - public final MockitoRule rule = MockitoJUnit.rule(); - - @Mock - private HttpClient httpClient; - - private ZonedDateTime now; - - private Clock clock; - - private AlertHttpService alertHttpService; - - @Before - public void setUp() { - clock = Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC); - now = ZonedDateTime.now(clock); - final HashMap servicesAlertPeriod = new HashMap<>(); - servicesAlertPeriod.put("pbs-error", 3L); - alertHttpService = new AlertHttpService(jacksonMapper, httpClient, clock, DeploymentProperties.builder() - .pbsVendor("pbsVendor") - .pbsRegion("pbsRegion").pbsHostId("pbsHostId").subSystem("pbsSubSystem").system("pbsSystem") - .dataCenter("pbsDataCenter").infra("pbsInfra").profile("pbsProfile").build(), - AlertProxyProperties.builder().password("password").username("username").timeoutSec(5) - .url("http://localhost") - .alertTypes(servicesAlertPeriod).enabled(true).build()); - } - - @Test - public void alertShouldNotSendAlertWhenServiceIsNotEnabled() { - // given - alertHttpService = new AlertHttpService(jacksonMapper, httpClient, clock, DeploymentProperties.builder() - .pbsVendor("pbsVendor").pbsRegion("pbsRegion").pbsHostId("pbsHostId").subSystem("pbsSubSystem") - .system("pbsSystem").dataCenter("pbsDataCenter").infra("pbsInfra").profile("pbsProfile").build(), - AlertProxyProperties.builder().password("password").username("username").timeoutSec(5) - .alertTypes(emptyMap()) - .url("http://localhost").enabled(false).build()); - - // when - alertHttpService.alert("pbs", AlertPriority.HIGH, "errorMessage"); - - // then - verifyNoInteractions(httpClient); - } - - @Test - public void alertShouldSendAlertWhenServiceIsEnabled() throws JsonProcessingException { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture()); - - // when - alertHttpService.alert("pbs", AlertPriority.HIGH, "errorMessage"); - - // then - final List requestPayloadObject = getRequestPayload(); - final String id = requestPayloadObject.get(0).getId(); - assertThat(requestPayloadObject) - .isEqualTo(singletonList(AlertEvent.builder().id(id).action("RAISE").priority(AlertPriority.HIGH) - .updatedAt(now).name("pbs").details("errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - } - - @Test - public void alertWithPeriodShouldSendAlertFirstTimeWithPassedAlertPriority() throws JsonProcessingException { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture()); - - // when - alertHttpService.alertWithPeriod("pbs", "pbs-error", AlertPriority.MEDIUM, "errorMessage"); - - // then - final List requestPayloadObject = getRequestPayload(); - final String id = requestPayloadObject.get(0).getId(); - assertThat(requestPayloadObject) - .isEqualTo(singletonList(AlertEvent.builder().id(id).action("RAISE").priority(AlertPriority.MEDIUM) - .updatedAt(now).name("pbs-error").details("Service pbs failed to send request 1 time(s) " - + "with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - } - - @Test - public void alertWithPeriodShouldSendAlertWithPassedPriorityAndWithHighPriorityAfterPeriodLimitReached() - throws JsonProcessingException { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture()); - - // when - IntStream.range(0, 3).forEach(ignored -> - alertHttpService.alertWithPeriod("pbs", "pbs-error", AlertPriority.MEDIUM, "errorMessage")); - - // then - final ArgumentCaptor requestBodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpClient, times(2)).post(anyString(), any(), requestBodyCaptor.capture(), anyLong()); - - final List requests = requestBodyCaptor.getAllValues(); - final List alertEvents1 = parseAlertEvents(requests.get(0)); - - final String id = alertEvents1.get(0).getId(); - - assertThat(alertEvents1) - .isEqualTo(singletonList(AlertEvent.builder().id(id).action("RAISE").priority(AlertPriority.MEDIUM) - .updatedAt(now).name("pbs-error").details("Service pbs failed to send request 1 time(s) " - + "with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - - final List alertEvents2 = parseAlertEvents(requests.get(1)); - final String id2 = alertEvents2.get(0).getId(); - - assertThat(alertEvents2) - .isEqualTo(singletonList(AlertEvent.builder().id(id2).action("RAISE").priority(AlertPriority.HIGH) - .updatedAt(now).name("pbs-error").details("Service pbs failed to send request 3 time(s) " - + "with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - } - - @Test - public void alertWithPeriodShouldSendAlertTwoTimesForUnknownServiceWithDefaultPeriod() - throws JsonProcessingException { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture()); - - // when - IntStream.range(0, 15).forEach(ignored -> - alertHttpService.alertWithPeriod("unknown", "unknown-error", AlertPriority.MEDIUM, "errorMessage")); - - // then - final ArgumentCaptor requestBodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpClient, times(2)).post(anyString(), any(), requestBodyCaptor.capture(), anyLong()); - - final List requests = requestBodyCaptor.getAllValues(); - final List alertEvents1 = parseAlertEvents(requests.get(0)); - - final String id = alertEvents1.get(0).getId(); - - assertThat(alertEvents1) - .isEqualTo(singletonList(AlertEvent.builder().id(id).action("RAISE").priority(AlertPriority.MEDIUM) - .updatedAt(now).name("unknown-error").details("Service unknown failed to send request" - + " 1 time(s) with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - - final List alertEvents2 = parseAlertEvents(requests.get(1)); - final String id2 = alertEvents2.get(0).getId(); - - assertThat(alertEvents2) - .isEqualTo(singletonList(AlertEvent.builder().id(id2).action("RAISE").priority(AlertPriority.HIGH) - .updatedAt(now).name("unknown-error").details("Service unknown failed to send request" - + " 15 time(s) with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - } - - @Test - public void alertWithPeriodShouldSendAlertFirstTimeWithPassedAlertPriorityForUnknownService() - throws JsonProcessingException { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture()); - - // when - alertHttpService.alertWithPeriod("unknown", "unknown-error", AlertPriority.MEDIUM, "errorMessage"); - - // then - final List requestPayloadObject = getRequestPayload(); - final String id = requestPayloadObject.get(0).getId(); - assertThat(requestPayloadObject) - .isEqualTo(singletonList(AlertEvent.builder().id(id).action("RAISE").priority(AlertPriority.MEDIUM) - .updatedAt(now).name("unknown-error").details("Service unknown failed to send request " - + "1 time(s) with error message : errorMessage") - .source(AlertSource.builder().env("pbsProfile").dataCenter("pbsDataCenter").region("pbsRegion") - .system("pbsSystem").subSystem("pbsSubSystem").hostId("pbsHostId").build()).build())); - } - - private List getRequestPayload() throws JsonProcessingException { - final ArgumentCaptor requestBodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpClient).post(anyString(), any(), requestBodyCaptor.capture(), anyLong()); - return parseAlertEvents(requestBodyCaptor.getValue()); - } - - private List parseAlertEvents(String row) throws JsonProcessingException { - return mapper.readValue(row, - new TypeReference<>() { - }); - } -} diff --git a/src/test/java/org/prebid/server/deals/DealsServiceTest.java b/src/test/java/org/prebid/server/deals/DealsServiceTest.java deleted file mode 100644 index 4bbd4d8a008..00000000000 --- a/src/test/java/org/prebid/server/deals/DealsServiceTest.java +++ /dev/null @@ -1,403 +0,0 @@ -package org.prebid.server.deals; - -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; -import org.assertj.core.api.InstanceOfAssertFactories; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.auction.model.AuctionParticipation; -import org.prebid.server.auction.model.BidderRequest; -import org.prebid.server.bidder.BidderCatalog; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.MatchLineItemsResult; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.LineItemSize; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; -import org.prebid.server.settings.model.Account; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.UnaryOperator; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.BDDMockito.given; - -public class DealsServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - @Mock - private LineItemService lineItemService; - @Mock - private CriteriaLogManager criteriaLogManager; - @Mock - private BidderCatalog bidderCatalog; - - private BidderAliases bidderAliases; - private DealsService dealsService; - - private static final Clock CLOCK = Clock.fixed(Instant.parse("2019-10-10T00:01:00Z"), ZoneOffset.UTC); - - @Before - public void setUp() { - given(lineItemService.accountHasDeals(any())).willReturn(true); - given(lineItemService.findMatchingLineItems(any(), any(), anyString(), any(), any())) - .willReturn(MatchLineItemsResult.of(emptyList())); - - bidderAliases = BidderAliases.of(emptyMap(), emptyMap(), bidderCatalog); - dealsService = new DealsService(lineItemService, jacksonMapper, criteriaLogManager); - } - - @Test - public void matchAndPopulateDealsShouldReturnOriginalBidderRequestIfAccountHasNoDeals() { - // given - given(lineItemService.accountHasDeals(any())).willReturn(false); - - final BidderRequest bidderRequest = givenBidderRequest(request -> request - .imp(singletonList(givenImp(identity())))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final BidderRequest result = dealsService.matchAndPopulateDeals(bidderRequest, bidderAliases, auctionContext); - - // then - assertThat(result).isEqualTo(bidderRequest.toBuilder().impIdToDeals(emptyMap()).build()); - } - - @Test - public void matchAndPopulateDealsShouldEnrichImpWithDeals() { - // given - given(lineItemService.findMatchingLineItems(any(), any(), anyString(), any(), any())) - .willReturn(MatchLineItemsResult.of(singletonList(LineItem.of( - LineItemMetaData.builder() - .lineItemId("lineItemId") - .extLineItemId("extLineItemId") - .source("bidder") - .dealId("dealId") - .build(), - null, - null, - ZonedDateTime.now(CLOCK))))); - - final BidderRequest bidderRequest = givenBidderRequest(request -> request - .device(Device.builder().ip("ip").ua("ua").build()) - .imp(singletonList(givenImp(imp -> imp - .id("impId") - .pmp(Pmp.builder() - .deals(singletonList(Deal.builder().id("existingDealId").build())) - .build()))))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final BidderRequest result = dealsService.matchAndPopulateDeals(bidderRequest, bidderAliases, auctionContext); - - // then - assertThat(result).satisfies(request -> { - assertThat(request.getImpIdToDeals()) - .containsExactlyEntriesOf(Map.of("impId", singletonList(Deal.builder() - .id("dealId") - .ext(mapper.valueToTree( - ExtDeal.of(ExtDealLine.of("lineItemId", "extLineItemId", null, "bidder")))) - .build()))); - - assertThat(request.getBidRequest()) - .extracting(BidRequest::getImp) - .asInstanceOf(InstanceOfAssertFactories.list(Imp.class)) - .extracting(Imp::getPmp) - .flatExtracting(Pmp::getDeals) - .containsExactly( - Deal.builder().id("existingDealId").build(), - Deal.builder() - .id("dealId") - .ext(mapper.valueToTree( - ExtDeal.of(ExtDealLine.of("lineItemId", "extLineItemId", null, null)))) - .build()); - }); - } - - @Test - public void matchAndPopulateDealsShouldEnrichImpWithDealsAndAddLineItemSizesIfSizesIntersectionMatched() { - // given - given(lineItemService.findMatchingLineItems(any(), any(), anyString(), any(), any())) - .willReturn(MatchLineItemsResult.of(singletonList(LineItem.of( - LineItemMetaData.builder() - .lineItemId("lineItemId") - .extLineItemId("extLineItemId") - .sizes(singletonList(LineItemSize.of(200, 20))) - .source("bidder") - .dealId("dealId") - .build(), - null, - null, - ZonedDateTime.now(CLOCK))))); - - final BidderRequest bidderRequest = givenBidderRequest(request -> request - .device(Device.builder().ip("ip").ua("ua").build()) - .imp(singletonList(givenImp(imp -> imp - .id("impId") - .banner(Banner.builder() - .format(asList( - Format.builder().w(100).h(10).build(), - Format.builder().w(200).h(20).build())) - .build()))))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final BidderRequest result = dealsService.matchAndPopulateDeals(bidderRequest, bidderAliases, auctionContext); - - // then - assertThat(result).satisfies(request -> { - assertThat(request.getImpIdToDeals()) - .containsExactlyEntriesOf(Map.of("impId", singletonList(Deal.builder() - .id("dealId") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId", - "extLineItemId", - singletonList(Format.builder().w(200).h(20).build()), - "bidder")))) - .build()))); - - assertThat(request.getBidRequest()) - .extracting(BidRequest::getImp) - .asInstanceOf(InstanceOfAssertFactories.list(Imp.class)) - .extracting(Imp::getPmp) - .flatExtracting(Pmp::getDeals) - .containsExactly( - Deal.builder() - .id("dealId") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId", - "extLineItemId", - singletonList(Format.builder().w(200).h(20).build()), - null)))) - .build()); - }); - } - - @Test - public void matchAndPopulateDealsShouldEnrichImpWithDealsAndNotAddLineItemSizesIfSizesIntersectionNotMatched() { - // given - given(lineItemService.findMatchingLineItems(any(), any(), anyString(), any(), any())) - .willReturn(MatchLineItemsResult.of(singletonList(LineItem.of( - LineItemMetaData.builder() - .lineItemId("lineItemId") - .extLineItemId("extLineItemId") - .sizes(singletonList(LineItemSize.of(200, 20))) - .source("bidder") - .dealId("dealId") - .build(), - null, - null, - ZonedDateTime.now(CLOCK))))); - - final BidderRequest bidderRequest = givenBidderRequest(request -> request - .device(Device.builder().ip("ip").ua("ua").build()) - .imp(singletonList(givenImp(imp -> imp - .id("impId") - .banner(Banner.builder() - .format(singletonList(Format.builder().w(100).h(10).build())) - .build()))))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final BidderRequest result = dealsService.matchAndPopulateDeals(bidderRequest, bidderAliases, auctionContext); - - // then - assertThat(result).satisfies(request -> { - assertThat(request.getImpIdToDeals()) - .containsExactlyEntriesOf(Map.of("impId", singletonList(Deal.builder() - .id("dealId") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId", - "extLineItemId", - null, - "bidder")))) - .build()))); - - assertThat(request.getBidRequest()) - .extracting(BidRequest::getImp) - .asInstanceOf(InstanceOfAssertFactories.list(Imp.class)) - .extracting(Imp::getPmp) - .flatExtracting(Pmp::getDeals) - .containsExactly( - Deal.builder() - .id("dealId") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - "lineItemId", - "extLineItemId", - null, - null)))) - .build()); - }); - } - - @Test - public void matchAndPopulateDealsShouldFilterExistingDeals() { - // given - given(lineItemService.findMatchingLineItems(any(), any(), anyString(), any(), any())) - .willReturn(MatchLineItemsResult.of(emptyList())); - - final BidderRequest bidderRequest = givenBidderRequest(request -> request - .device(Device.builder().ip("ip").ua("ua").build()) - .imp(singletonList(givenImp(imp -> imp - .id("impId") - .pmp(Pmp.builder() - .deals(asList( - Deal.builder().id("deal1").build(), - Deal.builder() - .id("deal2") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - null, - null, - null, - "anotherBidder")))) - .build(), - Deal.builder() - .id("deal3") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of( - null, - null, - null, - "bidder")))) - .build())) - .build()))))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final BidderRequest result = dealsService.matchAndPopulateDeals(bidderRequest, bidderAliases, auctionContext); - - // then - assertThat(result).satisfies(request -> { - assertThat(request.getImpIdToDeals()).isEmpty(); - - assertThat(request.getBidRequest()) - .extracting(BidRequest::getImp) - .asInstanceOf(InstanceOfAssertFactories.list(Imp.class)) - .extracting(Imp::getPmp) - .flatExtracting(Pmp::getDeals) - .containsExactly( - Deal.builder().id("deal1").build(), - Deal.builder().id("deal3").build()); - }); - } - - @Test - public void removePgDealsOnlyImpsWithoutDealsShouldRemovePgDealsOnlyImpsWithoutMatchedDeals() { - // given - final List auctionParticipations = asList( - givenAuctionParticipation(givenBidderRequest( - "bidder1", - request -> request.imp(asList( - givenImp(imp -> imp.id("imp1").ext(mapper.createObjectNode())), - givenImp(imp -> imp.id("imp2").ext(mapper.createObjectNode())))), - null)), - givenAuctionParticipation(givenBidderRequest( - "bidder2", - request -> request.imp(asList( - givenImp(imp -> imp - .id("imp1") - .ext(mapper.valueToTree(Map.of("bidder", Map.of("pgdealsonly", true))))), - givenImp(imp -> imp - .id("imp2") - .ext(mapper.valueToTree(Map.of("bidder", Map.of("pgdealsonly", true))))))), - emptyMap())), - givenAuctionParticipation(givenBidderRequest( - "bidder3", - request -> request.imp(asList( - givenImp(imp -> imp - .id("imp1") - .ext(mapper.valueToTree(Map.of("bidder", Map.of("pgdealsonly", true))))), - givenImp(imp -> imp - .id("imp2") - .ext(mapper.valueToTree(Map.of("bidder", Map.of("pgdealsonly", true))))))), - singletonMap("imp2", singletonList(Deal.builder().build()))))); - final AuctionContext auctionContext = givenAuctionContext(identity()); - - // when - final List result = DealsService.removePgDealsOnlyImpsWithoutDeals( - auctionParticipations, auctionContext); - - // then - assertThat(result).containsExactly( - givenAuctionParticipation(givenBidderRequest( - "bidder1", - request -> request.imp(asList( - givenImp(imp -> imp.id("imp1").ext(mapper.createObjectNode())), - givenImp(imp -> imp.id("imp2").ext(mapper.createObjectNode())))), - null)), - givenAuctionParticipation(givenBidderRequest( - "bidder3", - request -> request.imp(singletonList( - givenImp(imp -> imp - .id("imp2") - .ext(mapper.valueToTree(Map.of("bidder", Map.of("pgdealsonly", true))))))), - singletonMap("imp2", singletonList(Deal.builder().build()))))); - assertThat(auctionContext.getDebugWarnings()).containsExactly( - """ - Not calling bidder2 bidder for impressions imp1, imp2 \ - due to pgdealsonly flag and no available PG line items.""", - """ - Not calling bidder3 bidder for impressions imp1 \ - due to pgdealsonly flag and no available PG line items."""); - } - - private static Imp givenImp(UnaryOperator customizer) { - return customizer.apply(Imp.builder()).build(); - } - - private static BidderRequest givenBidderRequest(UnaryOperator customizer) { - return BidderRequest.builder() - .bidder("bidder") - .bidRequest(customizer.apply(BidRequest.builder()).build()) - .build(); - } - - private static BidderRequest givenBidderRequest(String bidder, - UnaryOperator customizer, - Map> impIdToDeals) { - - return BidderRequest.builder() - .bidder(bidder) - .bidRequest(customizer.apply(BidRequest.builder()).build()) - .impIdToDeals(impIdToDeals) - .build(); - } - - private static AuctionParticipation givenAuctionParticipation(BidderRequest bidderRequest) { - return AuctionParticipation.builder().bidderRequest(bidderRequest).build(); - } - - private static AuctionContext givenAuctionContext(UnaryOperator customizer) { - return AuctionContext.builder() - .account(customizer.apply(Account.builder().id("accountId")).build()) - .debugWarnings(new ArrayList<>()) - .build(); - } -} diff --git a/src/test/java/org/prebid/server/deals/DeliveryProgressReportFactoryTest.java b/src/test/java/org/prebid/server/deals/DeliveryProgressReportFactoryTest.java deleted file mode 100644 index ef9daed10eb..00000000000 --- a/src/test/java/org/prebid/server/deals/DeliveryProgressReportFactoryTest.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.prebid.server.deals; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.lineitem.LineItemStatus; -import org.prebid.server.deals.lineitem.LostToLineItem; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Token; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.DeliveryProgressReportBatch; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.LongAdder; - -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -public class DeliveryProgressReportFactoryTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private LineItemService lineItemService; - - private DeliveryProgressReportFactory deliveryProgressReportFactory; - - private ZonedDateTime now; - - @Before - public void setUp() { - deliveryProgressReportFactory = new DeliveryProgressReportFactory( - DeploymentProperties.builder().pbsHostId("pbsHost").pbsRegion("pbsRegion") - .pbsVendor("pbsVendor").build(), 2, lineItemService); - - now = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC)); - } - - @Test - public void fromDeliveryProgressShouldCreateReportWithTop2Competitors() { - // given - given(lineItemService.getLineItemById(anyString())) - .willReturn(LineItem.of( - LineItemMetaData.builder() - .accountId("accountId") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now.minusHours(1)) - .build())) - .source("rubicon") - .build(), - null, null, now)); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - deliveryProgress.setEndTimeStamp(now.minusHours(2)); - - final Map lostTo = new ConcurrentHashMap<>(); - lostTo.put("lineItemId1", LostToLineItem.of("lineItemId1", makeLongAdderWithValue(100L))); - lostTo.put("lineItemId2", LostToLineItem.of("lineItemId2", makeLongAdderWithValue(50L))); - lostTo.put("lineItemId3", LostToLineItem.of("lineItemId3", makeLongAdderWithValue(80L))); - lostTo.put("lineItemId4", LostToLineItem.of("lineItemId4", makeLongAdderWithValue(120L))); - deliveryProgress.getLineItemIdToLost().put("lineItemId5", lostTo); - deliveryProgress.getLineItemStatuses().put("lineItemId5", LineItemStatus.of("lineItemId5")); - - // when - final DeliveryProgressReport deliveryProgressReport = deliveryProgressReportFactory - .fromDeliveryProgress(deliveryProgress, now, false); - - // then - assertThat(deliveryProgressReport.getLineItemStatus()) - .flatExtracting(org.prebid.server.deals.proto.report.LineItemStatus::getLostToLineItems) - .extracting(org.prebid.server.deals.proto.report.LostToLineItem::getLineItemSource, - org.prebid.server.deals.proto.report.LostToLineItem::getLineItemId, - org.prebid.server.deals.proto.report.LostToLineItem::getCount) - .containsOnly( - tuple("rubicon", "lineItemId4", 120L), - tuple("rubicon", "lineItemId1", 100L)); - } - - @Test - public void fromDeliveryProgressShouldCreateOverallReport() { - // given - given(lineItemService.getLineItemById(anyString())) - .willReturn(LineItem.of( - LineItemMetaData.builder() - .accountId("accountId") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now.minusHours(1)) - .tokens(singleton(Token.of(1, 100))) - .build())) - .source("rubicon") - .build(), - null, null, now)); - - final DeliveryProgress deliveryProgress = mock(DeliveryProgress.class); - given(deliveryProgress.getRequests()).willReturn(new LongAdder()); - given(deliveryProgress.getLineItemStatuses()).willReturn(singletonMap("lineItemId1", - LineItemStatus.of("lineItemId1"))); - deliveryProgress.setEndTimeStamp(now.minusHours(2)); - - // when - final DeliveryProgressReport deliveryProgressReport = deliveryProgressReportFactory - .fromDeliveryProgress(deliveryProgress, now, true); - - // then - assertThat(deliveryProgressReport.getLineItemStatus()) - .extracting(org.prebid.server.deals.proto.report.LineItemStatus::getReadyAt, - org.prebid.server.deals.proto.report.LineItemStatus::getPacingFrequency, - org.prebid.server.deals.proto.report.LineItemStatus::getSpentTokens) - .containsOnly(tuple("2019-07-26T10:00:00.000Z", 72000L, 0L)); - } - - @Test - public void fromDeliveryProgressShouldDropLineItemsWithoutDeliverySchedule() { - // given - given(lineItemService.getLineItemById(anyString())) - .willReturn(LineItem.of( - LineItemMetaData.builder() - .accountId("accountId") - .source("rubicon") - .build(), - null, null, now)); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - deliveryProgress.setEndTimeStamp(now.minusHours(2)); - - // when - final DeliveryProgressReport deliveryProgressReport = deliveryProgressReportFactory - .fromDeliveryProgress(deliveryProgress, now, false); - - // then - assertThat(deliveryProgressReport.getLineItemStatus()).isEmpty(); - } - - @Test - public void batchFromDeliveryProgressShouldCreateTwoReportsInBatchWithSameId() { - // given - given(lineItemService.getLineItemById(anyString())) - .willReturn(LineItem.of( - LineItemMetaData.builder() - .accountId("accountId") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now.minusHours(1)) - .build())) - .source("rubicon") - .build(), - null, null, now)); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - deliveryProgress.setEndTimeStamp(now.minusHours(2)); - - deliveryProgress.getLineItemStatuses().put("lineItemId1", LineItemStatus.of("lineItemId1")); - deliveryProgress.getLineItemStatuses().put("lineItemId2", LineItemStatus.of("lineItemId2")); - deliveryProgress.getLineItemStatuses().put("lineItemId3", LineItemStatus.of("lineItemId3")); - - // when - final DeliveryProgressReportBatch deliveryProgressReportBatch = deliveryProgressReportFactory - .batchFromDeliveryProgress(deliveryProgress, null, now, 2, false); - - // then - final Set reports = deliveryProgressReportBatch.getReports(); - assertThat(reports).hasSize(2) - .extracting(DeliveryProgressReport::getReportId) - .containsOnly(deliveryProgressReportBatch.getReportId()); - assertThat(reports) - .extracting(deliveryProgressReport -> deliveryProgressReport.getLineItemStatus().size()) - .containsOnly(1, 2); - } - - private static LongAdder makeLongAdderWithValue(Long value) { - final LongAdder longAdder = new LongAdder(); - longAdder.add(value); - return longAdder; - } -} diff --git a/src/test/java/org/prebid/server/deals/DeliveryProgressServiceTest.java b/src/test/java/org/prebid/server/deals/DeliveryProgressServiceTest.java deleted file mode 100644 index 2981b1bc179..00000000000 --- a/src/test/java/org/prebid/server/deals/DeliveryProgressServiceTest.java +++ /dev/null @@ -1,426 +0,0 @@ -package org.prebid.server.deals; - -import org.assertj.core.api.iterable.ThrowingExtractor; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.lineitem.DeliveryPlan; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.lineitem.DeliveryToken; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.lineitem.LineItemStatus; -import org.prebid.server.deals.lineitem.LostToLineItem; -import org.prebid.server.deals.model.DeliveryProgressProperties; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.deals.proto.Token; -import org.prebid.server.deals.proto.report.Event; -import org.prebid.server.deals.proto.report.LineItemStatusReport; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.settings.model.Account; - -import java.math.BigDecimal; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.UnaryOperator; -import java.util.stream.IntStream; - -import static java.util.Arrays.asList; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -public class DeliveryProgressServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private LineItemService lineItemService; - @Mock - private DeliveryStatsService deliveryStatsService; - @Mock - private DeliveryProgressReportFactory deliveryProgressReportFactory; - @Mock - private CriteriaLogManager criteriaLogManager; - - private DeliveryProgressService deliveryProgressService; - - private final Clock clock = Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC); - private ZonedDateTime now; - - @Before - public void setUp() { - now = ZonedDateTime.now(clock); - - deliveryProgressService = new DeliveryProgressService( - DeliveryProgressProperties.of(200L, 20), - lineItemService, - deliveryStatsService, - deliveryProgressReportFactory, - clock, - criteriaLogManager); - } - - @Test - public void updateLineItemsShouldUpdateCurrentDeliveryReportIfUpdatedPlanUpdateTimeStampIsInFuture() { - // given - final LineItemMetaData firstPlanResponse = givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId("lineItem1") - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "planId1", - now.minusHours(1), - now.plusHours(1), - now, - singleton(Token.of(1, 100)))))); - final LineItemMetaData secondPlanResponse = givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId("lineItem1") - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "planId1", - now.minusHours(1), - now.plusHours(1), - now.plusMinutes(1), - singleton(Token.of(1, 200)))))); - - final LineItem lineItem1 = LineItem.of(firstPlanResponse, null, null, now); - final LineItem lineItem12 = LineItem.of(secondPlanResponse, null, null, now); - - given(lineItemService.getLineItems()).willReturn( - singletonList(lineItem1), - singletonList(lineItem12)); - - given(lineItemService.getLineItemById(anyString())).willReturn( - lineItem12); - - // when - deliveryProgressService.processDeliveryProgressUpdateEvent(); - recordLineItemsServed(40, "lineItem1"); - deliveryProgressService.processDeliveryProgressUpdateEvent(); - - // then - // trigger overall progress passing to report factory - deliveryProgressService.getOverallDeliveryProgressReport(); - - final ArgumentCaptor overallProgressCaptor = ArgumentCaptor.forClass(DeliveryProgress.class); - verify(deliveryProgressReportFactory).fromDeliveryProgress(overallProgressCaptor.capture(), any(), - anyBoolean()); - - final DeliveryProgress overallProgress = overallProgressCaptor.getValue(); - assertThat(overallProgress).isNotNull(); - assertThat(overallProgress.getLineItemStatuses()).isNotNull(); - assertThat(overallProgress.getLineItemStatuses().keySet()) - .containsOnly("lineItem1"); - final LineItemStatus overallLineItemStatus = overallProgress.getLineItemStatuses().get("lineItem1"); - assertThat(overallLineItemStatus).isNotNull(); - assertThat(overallLineItemStatus.getDeliveryPlans()) - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getStartTimeStamp, DeliveryPlan::getEndTimeStamp, - DeliveryPlan::getUpdatedTimeStamp) - .containsOnly(tuple("planId1", now.minusHours(1), now.plusHours(1), now.plusMinutes(1))); - assertThat(overallLineItemStatus.getDeliveryPlans()) - .flatExtracting(DeliveryPlan::getDeliveryTokens) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsOnly(tuple(1, 200, 40L)); - - // trigger current progress passing to delivery stats - deliveryProgressService.shutdown(); - - final ArgumentCaptor currentProgressCaptor = ArgumentCaptor.forClass(DeliveryProgress - .class); - verify(deliveryStatsService).addDeliveryProgress(currentProgressCaptor.capture(), any()); - - final DeliveryProgress currentProgress = currentProgressCaptor.getValue(); - assertThat(currentProgress).isNotNull(); - assertThat(currentProgress.getLineItemStatuses()).isNotNull(); - final LineItemStatus currentLineItemStatus = currentProgress.getLineItemStatuses().get("lineItem1"); - assertThat(currentLineItemStatus).isNotNull(); - assertThat(currentLineItemStatus.getDeliveryPlans()) - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getStartTimeStamp, DeliveryPlan::getEndTimeStamp, - DeliveryPlan::getUpdatedTimeStamp) - .containsOnly(tuple("planId1", now.minusHours(1), now.plusHours(1), now.plusMinutes(1))); - assertThat(currentLineItemStatus.getDeliveryPlans()) - .flatExtracting(DeliveryPlan::getDeliveryTokens) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsOnly(tuple(1, 200, 40L)); - } - - @Test - public void processAuctionEventShouldUpdateCurrentPlan() { - // given - final String lineItemId1 = "lineItemId1"; - final String lineItemId2 = "lineItemId2"; - - final LineItem lineItem1 = LineItem.of( - givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId(lineItemId1) - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "plan1", - now.minusHours(1), - now.plusHours(1), - Set.of(Token.of(1, 100), Token.of(2, 100)))))), - null, - null, - now); - final LineItem lineItem2 = LineItem.of( - givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId(lineItemId2) - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "plan2", - now.minusHours(1), - now.plusHours(1), - Set.of(Token.of(1, 100), Token.of(2, 100)))))), - null, - null, - now); - - given(lineItemService.getLineItemById(eq(lineItemId1))).willReturn(lineItem1); - given(lineItemService.getLineItemById(eq(lineItemId2))).willReturn(lineItem2); - - recordLineItemsServed(150, lineItemId1); - - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemSentToClientAsTopMatch().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsSentToClient().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsMatchedDomainTargeting().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsMatchedWholeTargeting().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsMatchedTargetingFcapped().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsMatchedTargetingFcapLookupFailed().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lineItemsSentToBidder().put("rubicon", new HashSet<>(asList(lineItemId1, lineItemId2))); - txnLog.lineItemsSentToBidderAsTopMatch().put("rubicon", singleton(lineItemId1)); - txnLog.lineItemsSentToBidderAsTopMatch().put("appnexus", singleton(lineItemId2)); - txnLog.lineItemsReceivedFromBidder().put("rubicon", new HashSet<>(asList(lineItemId1, lineItemId2))); - txnLog.lineItemsResponseInvalidated().addAll(asList(lineItemId1, lineItemId2)); - txnLog.lostMatchingToLineItems().put(lineItemId1, singleton(lineItemId2)); - - // when and then - deliveryProgressService.processAuctionEvent(AuctionContext.builder() - .account(Account.empty("1001")) - .txnLog(txnLog) - .build()); - deliveryProgressService.createDeliveryProgressReports(now); - - final ArgumentCaptor deliveryProgressReportCaptor = - ArgumentCaptor.forClass(DeliveryProgress.class); - verify(deliveryStatsService).addDeliveryProgress(deliveryProgressReportCaptor.capture(), any()); - final DeliveryProgress deliveryProgress = deliveryProgressReportCaptor.getValue(); - assertThat(deliveryProgress.getRequests().sum()).isEqualTo(151); - - final Set lineItemStatuses = new HashSet<>(deliveryProgress.getLineItemStatuses().values()); - - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getDomainMatched, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getTargetMatched, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getTargetMatchedButFcapped, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getTargetMatchedButFcapLookupFailed, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getSentToBidder, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getReceivedFromBidder, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getReceivedFromBidderInvalidated, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getSentToClientAsTopMatch, 151L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getSentToBidderAsTopMatch, 1L, 1L); - checkLineItemStatusStats(lineItemStatuses, LineItemStatus::getSentToClient, 1L, 1L); - - assertThat(deliveryProgress.getLineItemIdToLost()) - .extracting(lineItemId1) - .extracting(lineItemId2) - .extracting(lostToLineItem -> ((LostToLineItem) lostToLineItem).getCount().sum()) - .isEqualTo(1L); - - assertThat(lineItemStatuses) - .flatExtracting(LineItemStatus::getDeliveryPlans) - .flatExtracting(DeliveryPlan::getDeliveryTokens) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, - deliveryToken -> deliveryToken.getSpent().sum()) - .containsOnly( - tuple(1, 100, 100L), - tuple(2, 100, 51L), - tuple(1, 100, 1L), - tuple(2, 100, 0L)); - - assertThat(lineItem1.getActiveDeliveryPlan().getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsExactly( - tuple(1, 100, 100L), - tuple(2, 100, 51L)); - - assertThat(lineItem2.getActiveDeliveryPlan().getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsExactly( - tuple(1, 100, 1L), - tuple(2, 100, 0L)); - } - - @Test - public void trackWinEventShouldCreateLineItemStatusAndUpdateWinEventsMetric() { - // given - final LineItem lineItem = LineItem.of( - givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId("lineItemId1") - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "plan1", - now.minusHours(1), - now.plusHours(1), - Set.of(Token.of(1, 100), Token.of(2, 100)))))), - null, - null, - now); - - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(lineItem); - - // when - deliveryProgressService.processLineItemWinEvent("lineItemId1"); - - // then - // trigger current progress passing to delivery stats - deliveryProgressService.shutdown(); - - final ArgumentCaptor currentProgressCaptor = ArgumentCaptor.forClass(DeliveryProgress.class); - verify(deliveryStatsService).addDeliveryProgress(currentProgressCaptor.capture(), any()); - - final DeliveryProgress currentProgress = currentProgressCaptor.getValue(); - assertThat(currentProgress).isNotNull(); - assertThat(currentProgress.getLineItemStatuses().entrySet()).hasSize(1) - .extracting(Map.Entry::getValue) - .flatExtracting(LineItemStatus::getEvents) - .extracting(Event::getType, event -> event.getCount().sum()) - .containsOnly(tuple("win", 1L)); - } - - @Test - public void getLineItemStatusReportShouldReturnExpectedResult() { - // given - final LineItem lineItem = LineItem.of( - givenLineItemMetaData( - now, - lineItemMetaData -> lineItemMetaData - .lineItemId("lineItemId1") - .accountId("1001") - .source("rubicon") - .deliverySchedules(singletonList( - givenDeliverySchedule( - "plan1", - now.minusHours(1), - now.plusHours(1), - singleton(Token.of(1, 100))))) - .targeting(mapper.createObjectNode().put("targetingField", "targetingValue"))), - null, - null, - now); - given(lineItemService.getLineItemById(anyString())).willReturn(lineItem); - - // when - final LineItemStatusReport report = deliveryProgressService.getLineItemStatusReport("lineItemId1"); - - // then - assertThat(report).isEqualTo(LineItemStatusReport.builder() - .lineItemId("lineItemId1") - .deliverySchedule(org.prebid.server.deals.proto.report.DeliverySchedule.builder() - .planId("plan1") - .planStartTimeStamp("2019-07-26T09:00:00.000Z") - .planExpirationTimeStamp("2019-07-26T11:00:00.000Z") - .planUpdatedTimeStamp("2019-07-26T09:00:00.000Z") - .tokens(singleton(org.prebid.server.deals.proto.report.Token.of(1, 100, 0L, null))) - .build()) - .readyToServeTimestamp(now) - .spentTokens(0L) - .pacingFrequency(72000L) - .accountId("1001") - .target(mapper.createObjectNode().put("targetingField", "targetingValue")) - .build()); - } - - private static LineItemMetaData givenLineItemMetaData( - ZonedDateTime now, - UnaryOperator lineItemMetaDataCustomizer) { - - return lineItemMetaDataCustomizer - .apply(LineItemMetaData.builder() - .dealId("dealId") - .status("active") - .price(Price.of(BigDecimal.ONE, "USD")) - .relativePriority(5) - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now)) - .build(); - } - - private static DeliverySchedule givenDeliverySchedule(String planId, ZonedDateTime start, ZonedDateTime end, - ZonedDateTime updated, Set tokens) { - return DeliverySchedule.builder() - .planId(planId) - .startTimeStamp(start) - .endTimeStamp(end) - .updatedTimeStamp(updated) - .tokens(tokens) - .build(); - } - - private static DeliverySchedule givenDeliverySchedule(String planId, ZonedDateTime start, ZonedDateTime end, - Set tokens) { - return givenDeliverySchedule(planId, start, end, start, tokens); - } - - private static void checkLineItemStatusStats(Set lineItemStatuses, - ThrowingExtractor stat, - Long... values) { - assertThat(lineItemStatuses) - .extracting(stat) - .extracting(LongAdder::sum) - .containsOnly(values); - } - - private void recordLineItemsServed(int times, String... lineItemIds) { - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder() - .account(Account.empty("1001")) - .txnLog(txnLog) - .build(); - txnLog.lineItemSentToClientAsTopMatch().addAll(asList(lineItemIds)); - IntStream.range(0, times).forEach(i -> deliveryProgressService.processAuctionEvent(auctionContext)); - - } -} diff --git a/src/test/java/org/prebid/server/deals/DeliveryStatsServiceTest.java b/src/test/java/org/prebid/server/deals/DeliveryStatsServiceTest.java deleted file mode 100644 index 07badbbc5c3..00000000000 --- a/src/test/java/org/prebid/server/deals/DeliveryStatsServiceTest.java +++ /dev/null @@ -1,428 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import org.apache.http.HttpHeaders; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.lineitem.DeliveryProgress; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeliveryStatsProperties; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.DeliveryProgressReportBatch; -import org.prebid.server.deals.proto.report.LineItemStatus; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; -import org.springframework.test.util.ReflectionTestUtils; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.HashSet; -import java.util.NavigableSet; -import java.util.concurrent.TimeoutException; -import java.util.zip.GZIPInputStream; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static java.util.Collections.singleton; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class DeliveryStatsServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private DeliveryProgressReportFactory deliveryProgressReportFactory; - @Mock - private AlertHttpService alertHttpService; - @Mock - private HttpClient httpClient; - @Mock - private Clock clock; - @Mock - private Metrics metrics; - - @Mock - private Vertx vertx; - - private DeliveryStatsService deliveryStatsService; - - private ZonedDateTime now; - - @Mock - private LineItemService lineItemService; - - @Before - public void setUp() { - now = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC)); - given(clock.instant()).willReturn(now.toInstant()); - given(clock.getZone()).willReturn(ZoneOffset.UTC); - - deliveryStatsService = new DeliveryStatsService( - DeliveryStatsProperties.builder() - .endpoint("localhost/delivery") - .cachedReportsNumber(3) - .timeoutMs(500L) - .reportsIntervalMs(0) - .batchesIntervalMs(0) - .username("username") - .password("password") - .build(), - deliveryProgressReportFactory, - alertHttpService, - httpClient, - metrics, - clock, - vertx, - jacksonMapper); - } - - @SuppressWarnings("unchecked") - @Test - public void sendDeliveryProgressReportShouldSendBothBatches() { - // given - givenDeliveryProgressHttpResponse(httpClient, 200, null); - - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn( - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "1", - now.minusHours(2).toString()), - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("2") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(1).toString()).build()), "2", - now.minusHours(1).toString())); - - final DeliveryProgress deliveryProgress1 = DeliveryProgress.of(now.minusHours(3), lineItemService); - final DeliveryProgress deliveryProgress2 = DeliveryProgress.of(now.minusHours(2), lineItemService); - - // when - deliveryStatsService.addDeliveryProgress(deliveryProgress1, emptyMap()); - deliveryStatsService.addDeliveryProgress(deliveryProgress2, emptyMap()); - deliveryStatsService.sendDeliveryProgressReports(); - - // then - verify(httpClient, times(2)).post(anyString(), any(), anyString(), anyLong()); - final NavigableSet reports = (NavigableSet) - ReflectionTestUtils.getField(deliveryStatsService, "requiredBatches"); - assertThat(reports).isEmpty(); - verify(metrics, times(2)).updateDeliveryRequestMetric(eq(true)); - } - - @SuppressWarnings("unchecked") - @Test - public void sendDeliveryProgressReportShouldSendOneBatchAndCacheFailedBatch() { - // given - final DeliveryProgress deliveryProgress1 = DeliveryProgress.of(now.minusHours(3), lineItemService); - final DeliveryProgress deliveryProgress2 = DeliveryProgress.of(now.minusHours(2), lineItemService); - - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn( - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "1", - now.minusHours(2).toString()), - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("2") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(1).toString()).build()), "2", - now.minusHours(1).toString())); - - deliveryStatsService.addDeliveryProgress(deliveryProgress1, null); - deliveryStatsService.addDeliveryProgress(deliveryProgress2, null); - - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, null)), - Future.failedFuture(new TimeoutException())); - - deliveryStatsService.sendDeliveryProgressReports(); - - // when and then - verify(httpClient, times(2)).post(anyString(), any(), anyString(), anyLong()); - final NavigableSet reports = (NavigableSet) - ReflectionTestUtils.getField(deliveryStatsService, "requiredBatches"); - assertThat(reports).hasSize(1); - verify(metrics).updateDeliveryRequestMetric(eq(true)); - verify(metrics).updateDeliveryRequestMetric(eq(false)); - } - - @Test - public void sendDeliveryProgressReportShouldSendFirstReportFromFirstBatchFailOnSecondsAndCacheOther() { - // given - final DeliveryProgress deliveryProgress1 = DeliveryProgress.of(now.minusHours(3), lineItemService); - final DeliveryProgress deliveryProgress2 = DeliveryProgress.of(now.minusHours(2), lineItemService); - - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn( - DeliveryProgressReportBatch.of( - new HashSet<>(asList(DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(singleton(LineItemStatus.builder().lineItemId("1") - .build())) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build(), - DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(singleton(LineItemStatus.builder().lineItemId("2") - .build())) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build())), - "1", now.minusHours(2).toString()), - DeliveryProgressReportBatch.of( - new HashSet<>(asList(DeliveryProgressReport.builder().reportId("2") - .lineItemStatus(singleton(LineItemStatus.builder().lineItemId("1") - .build())) - .dataWindowEndTimeStamp(now.minusHours(3).toString()).build(), - DeliveryProgressReport.builder().reportId("2") - .lineItemStatus(singleton(LineItemStatus.builder().lineItemId("2") - .build())) - .dataWindowEndTimeStamp(now.minusHours(3).toString()).build())), - "2", now.minusHours(3).toString())); - - deliveryStatsService.addDeliveryProgress(deliveryProgress1, null); - deliveryStatsService.addDeliveryProgress(deliveryProgress2, null); - - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, null)), - Future.failedFuture(new TimeoutException())); - - deliveryStatsService.sendDeliveryProgressReports(); - - // when and then - verify(httpClient, times(2)).post(anyString(), any(), anyString(), anyLong()); - final NavigableSet reports = (NavigableSet) - ReflectionTestUtils.getField(deliveryStatsService, "requiredBatches"); - assertThat(reports).hasSize(2) - .flatExtracting(DeliveryProgressReportBatch::getReports) - .hasSize(3); - verify(metrics).updateDeliveryRequestMetric(eq(true)); - verify(metrics).updateDeliveryRequestMetric(eq(false)); - } - - @Test - public void sendDeliveryProgressReportShouldHandleFailedBatchesCacheLimitWhenResponseStatusIsBadRequest() { - // given - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn( - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .dataWindowEndTimeStamp(now.minusHours(4).toString()).build()), "1", - now.minusHours(4).toString()), - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("2") - .dataWindowEndTimeStamp(now.minusHours(3).toString()).build()), "2", - now.minusHours(3).toString()), - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("3") - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "3", - now.minusHours(2).toString()), - DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("4") - .dataWindowEndTimeStamp(now.minusHours(1).toString()).build()), "4", - now.minusHours(1).toString())); - - final DeliveryProgress deliveryProgress1 = DeliveryProgress.of(now.minusHours(5), lineItemService); - final DeliveryProgress deliveryProgress2 = DeliveryProgress.of(now.minusHours(4), lineItemService); - final DeliveryProgress deliveryProgress3 = DeliveryProgress.of(now.minusHours(3), lineItemService); - final DeliveryProgress deliveryProgress4 = DeliveryProgress.of(now.minusHours(2), lineItemService); - - deliveryStatsService.addDeliveryProgress(deliveryProgress1, null); - deliveryStatsService.addDeliveryProgress(deliveryProgress2, null); - deliveryStatsService.addDeliveryProgress(deliveryProgress3, null); - deliveryStatsService.addDeliveryProgress(deliveryProgress4, null); - - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(400, null, null))); - - deliveryStatsService.sendDeliveryProgressReports(); - - // when and then - verify(httpClient).post(anyString(), any(), anyString(), anyLong()); - @SuppressWarnings("unchecked") final NavigableSet reports = (NavigableSet) - ReflectionTestUtils.getField(deliveryStatsService, "requiredBatches"); - assertThat(reports).hasSize(3); - } - - @Test - public void sendDeliveryProgressReportShouldShouldRemoveReportFromQueueWhenDelStatsRespondWith409Conflict() { - // given - givenDeliveryProgressHttpResponse(httpClient, 409, null); - - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn(DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "1", - now.minusHours(2).toString())); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - - // when - deliveryStatsService.addDeliveryProgress(deliveryProgress, emptyMap()); - deliveryStatsService.sendDeliveryProgressReports(); - - // then - final NavigableSet reports = - (NavigableSet) ReflectionTestUtils.getField(deliveryStatsService, "requiredBatches"); - assertThat(reports).isEmpty(); - } - - @Test - public void sendDeliveryProgressReportShouldCallAlertServiceWhenRequestFailed() { - // given - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn(DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "1", - now.minusHours(2).toString())); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - - deliveryStatsService.addDeliveryProgress(deliveryProgress, emptyMap()); - - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("Timeout"))); - - // when - deliveryStatsService.sendDeliveryProgressReports(); - - // then - verify(alertHttpService).alertWithPeriod(eq("deliveryStats"), eq("pbs-delivery-stats-client-error"), - eq(AlertPriority.MEDIUM), - eq("Report was not send to delivery stats service with a reason: Sending report with id = 1 failed" - + " in a reason: Timeout")); - } - - @Test - public void sendDeliveryProgressReportShouldCallAlertServiceResetWhenRequestWasSuccessful() { - // given - givenDeliveryProgressHttpResponse(httpClient, 200, null); - - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn(DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build()), "1", - now.minusHours(2).toString())); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - - // when - deliveryStatsService.addDeliveryProgress(deliveryProgress, emptyMap()); - deliveryStatsService.sendDeliveryProgressReports(); - - // then - verify(alertHttpService).resetAlertCount(eq("pbs-delivery-stats-client-error")); - } - - @Test - public void suspendShouldSetSuspendFlagAndReportShouldNotBeSent() { - // given - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn(DeliveryProgressReportBatch.of(singleton(DeliveryProgressReport.builder().reportId("1") - .dataWindowEndTimeStamp(now.minusHours(4).toString()).build()), "1", - now.minusHours(4).toString())); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(5), lineItemService); - - deliveryStatsService.addDeliveryProgress(deliveryProgress, null); - - // when - deliveryStatsService.suspend(); - deliveryStatsService.sendDeliveryProgressReports(); - - // then - verifyNoInteractions(httpClient); - } - - @Test - public void sendDeliveryProgressReportShouldSendGzippedBody() throws JsonProcessingException { - // given - final DeliveryStatsService deliveryStatsService = new DeliveryStatsService( - DeliveryStatsProperties.builder() - .endpoint("localhost/delivery") - .cachedReportsNumber(3) - .timeoutMs(500L) - .reportsIntervalMs(0) - .requestCompressionEnabled(true) - .username("username") - .password("password") - .build(), - deliveryProgressReportFactory, - alertHttpService, - httpClient, - metrics, - clock, - vertx, - jacksonMapper); - - givenDeliveryProgressHttpResponse(httpClient, 200, null); - - final DeliveryProgressReport deliveryProgressReport = DeliveryProgressReport.builder().reportId("1") - .lineItemStatus(emptySet()) - .dataWindowEndTimeStamp(now.minusHours(2).toString()).build(); - given(deliveryProgressReportFactory.updateReportTimeStamp(any(), any())).willReturn(deliveryProgressReport); - given(deliveryProgressReportFactory.batchFromDeliveryProgress(any(), any(), any(), anyInt(), anyBoolean())) - .willReturn( - DeliveryProgressReportBatch.of(singleton(deliveryProgressReport), "1", - now.minusHours(2).toString())); - - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now.minusHours(3), lineItemService); - - // when - deliveryStatsService.addDeliveryProgress(deliveryProgress, emptyMap()); - deliveryStatsService.sendDeliveryProgressReports(); - - // then - final ArgumentCaptor bodyCaptor = ArgumentCaptor.forClass(byte[].class); - final ArgumentCaptor headerCaptor = ArgumentCaptor.forClass(MultiMap.class); - verify(httpClient).request(any(), anyString(), headerCaptor.capture(), bodyCaptor.capture(), anyLong()); - // verify body was compressed well - final byte[] compressedRequestBody = bodyCaptor.getValue(); - final String decompressedRequestBody = decompress(compressedRequestBody); - assertThat(mapper.readValue(decompressedRequestBody, DeliveryProgressReport.class)) - .isEqualTo(deliveryProgressReport); - // verify Content-encoding header was added - final MultiMap headers = headerCaptor.getValue(); - assertThat(headers.get(HttpHeaders.CONTENT_ENCODING)).isEqualTo("gzip"); - } - - private static String decompress(byte[] byteArray) { - final StringBuilder body = new StringBuilder(); - try ( - GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(byteArray)); - BufferedReader bufferedReader = - new BufferedReader(new InputStreamReader(gzipInputStream, StandardCharsets.UTF_8))) { - String line; - while ((line = bufferedReader.readLine()) != null) { - body.append(line); - } - return body.toString(); - } catch (IOException e) { - throw new RuntimeException("Error occurred while decompressing gzipped body"); - } - } - - private static void givenDeliveryProgressHttpResponse(HttpClient httpClient, int statusCode, String response) { - final HttpClientResponse httpClientResponse = HttpClientResponse.of(statusCode, null, response); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(httpClientResponse)); - } -} diff --git a/src/test/java/org/prebid/server/deals/LineItemServiceTest.java b/src/test/java/org/prebid/server/deals/LineItemServiceTest.java deleted file mode 100644 index 07fade4e37e..00000000000 --- a/src/test/java/org/prebid/server/deals/LineItemServiceTest.java +++ /dev/null @@ -1,2076 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.User; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.mockito.stubbing.Answer; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.bidder.BidderCatalog; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.events.ApplicationEventService; -import org.prebid.server.deals.lineitem.DeliveryPlan; -import org.prebid.server.deals.lineitem.DeliveryToken; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.DeepDebugLog; -import org.prebid.server.deals.model.MatchLineItemsResult; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.FrequencyCap; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.deals.proto.Token; -import org.prebid.server.deals.targeting.TargetingDefinition; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.model.CaseInsensitiveMultiMap; -import org.prebid.server.model.HttpRequestContext; -import org.prebid.server.proto.openrtb.ext.request.ExtRequest; -import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category; -import org.prebid.server.settings.model.Account; -import org.prebid.server.util.HttpUtil; - -import java.math.BigDecimal; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.IntStream; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class LineItemServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private TargetingService targetingService; - @Mock - private BidderCatalog bidderCatalog; - @Mock - private CurrencyConversionService conversionService; - @Mock - private ApplicationEventService applicationEventService; - @Mock - private Clock clock; - @Mock - private CriteriaLogManager criteriaLogManager; - - private BidderAliases bidderAliases; - - private LineItemService lineItemService; - - private ZonedDateTime now; - - @Before - public void setUp() { - now = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC)); - - given(clock.instant()).willReturn(now.toInstant()); - given(clock.getZone()).willReturn(ZoneOffset.UTC); - - given(conversionService.convertCurrency(any(), anyMap(), anyString(), anyString(), any())) - .willReturn(BigDecimal.ONE); - - bidderAliases = BidderAliases.of(Map.of("rubiAlias", "rubicon"), emptyMap(), bidderCatalog); - - lineItemService = new LineItemService( - 2, - targetingService, - conversionService, - applicationEventService, - "USD", - clock, - criteriaLogManager); - } - - @Test - public void updateLineItemsShouldRemoveLineItemIfItIsNotActiveFromPlannerResponse() { - // given - final List firstPlanResponse = asList( - givenLineItemMetaData("lineItem1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity()), - givenLineItemMetaData("lineItem2", now, "2", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - final List secondPlanResponse = asList( - givenLineItemMetaData("lineItem1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), - builder -> builder.status("inactive")), - givenLineItemMetaData("lineItem2", now, "2", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - lineItemService.updateLineItems(secondPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - } - - @Test - public void updateLineItemsShouldRemoveLineItemIfItHasEndTimeInPastInPlannerResponse() { - // given - final List firstPlanResponse = asList( - givenLineItemMetaData("lineItem1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity()), - givenLineItemMetaData("lineItem2", now, "2", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - final List secondPlanResponse = asList( - givenLineItemMetaData("lineItem1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), - builder -> builder.endTimeStamp(now.minusHours(1))), - givenLineItemMetaData("lineItem2", now, "2", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - lineItemService.updateLineItems(secondPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - } - - @Test - public void updateLineItemsShouldRemoveLineItemIfItHasEndTimeInPastInMemory() { - // given - final List firstPlanResponse = asList( - givenLineItemMetaData("lineItem1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), - builder -> builder.endTimeStamp(now.plusSeconds(1))), - givenLineItemMetaData("lineItem2", now, "2", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true, now); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - lineItemService.updateLineItems(emptyList(), true, now.plusSeconds(2)); - assertThat(lineItemService.getLineItemById("lineItem1")).isNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - } - - @Test - public void updateLineItemsShouldNotRemoveLineItemIfItWasMissedInPlannerResponse() { - // given - final List firstPlanResponse = asList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), now), - givenLineItemMetaData("lineItem2", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), now)); - - final List secondPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), now)); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - lineItemService.updateLineItems(secondPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - assertThat(lineItemService.getLineItemById("lineItem2")).isNotNull(); - } - - @Test - public void updateLineItemShouldSaveLineItemIfItHasEmptyDeliverySchedules() { - // given - final List firstPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", emptyList(), now)); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - } - - @Test - public void updateLineItemShouldSaveLineItemIfItDoesNotHaveDeliverySchedules() { - // given - final List firstPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", null, now)); - - // when and then - lineItemService.updateLineItems(firstPlanResponse, true); - assertThat(lineItemService.getLineItemById("lineItem1")).isNotNull(); - } - - @Test - public void updateLineItemsShouldUpdateCurrentPlanIfUpdatedPlanUpdateTimeStampIsInFuture() { - // given - final List firstPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), now)); - - final List secondPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now.plusMinutes(1), singleton(Token.of(1, 200)))), now)); - - // when - lineItemService.updateLineItems(firstPlanResponse, true); - incSpentTokens(10, "lineItem1"); - lineItemService.updateLineItems(secondPlanResponse, true); - - // then - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem).isNotNull(); - - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - - assertThat(activeDeliveryPlan).isNotNull() - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getStartTimeStamp, DeliveryPlan::getEndTimeStamp, - DeliveryPlan::getUpdatedTimeStamp) - .containsOnly("planId1", now.minusHours(1), now.plusHours(1), now.plusMinutes(1)); - assertThat(activeDeliveryPlan.getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsOnly(tuple(1, 200, 10L)); - - // 6 minutes after plan started - assertThat(lineItem.getReadyAt()).isEqualTo(now.minusHours(1).plusMinutes(6)); - } - - @Test - public void updateLineItemsShouldUpdateReadyAtBasedOnPlanStartTime() { - // given - final List firstPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), now, singleton(Token.of(1, 100)))), now)); - - // when - lineItemService.updateLineItems(firstPlanResponse, true); - incSpentTokens(1, "lineItem1"); - - // then - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem).isNotNull(); - - // 1 * (120 * 60 * 1000) \ 100 tokens = 72,000 millis = 1 minute 12 seconds shift from plan startTime - assertThat(lineItem.getReadyAt()).isEqualTo(now.minusHours(1).plusMinutes(1).plusSeconds(12)); - } - - @Test - public void updateLineItemsShouldConvertPriceWhenLineItemMetaDataCurrencyIsDifferent() { - // given - final String defaultCurrency = "RUB"; - lineItemService = new LineItemService( - 2, - targetingService, - conversionService, - applicationEventService, - defaultCurrency, - clock, - criteriaLogManager); - - final List planResponse = asList( - givenLineItemMetaData("lineItem1", null, null, - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusHours(1), - emptySet())), now), - givenLineItemMetaData("lineItem2", null, null, - singletonList(givenDeliverySchedule("planId2", now.minusHours(1), now.plusHours(1), - emptySet())), now)); - - final BigDecimal updatedCmp = BigDecimal.TEN; - given(conversionService.convertCurrency(any(), anyMap(), anyString(), anyString(), any())) - .willReturn(updatedCmp); - - // when - lineItemService.updateLineItems(planResponse, true); - - // then - final LineItem lineItem1 = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem1.getCpm()).isEqualTo(updatedCmp); - assertThat(lineItem1.getCurrency()).isEqualTo(defaultCurrency); - - final LineItem lineItem2 = lineItemService.getLineItemById("lineItem2"); - assertThat(lineItem2.getCpm()).isEqualTo(updatedCmp); - assertThat(lineItem2.getCurrency()).isEqualTo(defaultCurrency); - } - - @Test - public void updateLineItemsShouldCreateLineItemsWhenPlannerIsResponsive() { - // given - final List planResponse = asList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), singleton(Token.of(1, 100)))), now), - givenLineItemMetaData("lineItem2", "1002", "rubicon", - singletonList(givenDeliverySchedule("planId2", now.plusHours(1), - now.plusHours(2), singleton(Token.of(1, 100)))), now)); - - // when - lineItemService.updateLineItems(planResponse, true); - - // then - final LineItem lineItem1 = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem1).isNotNull(); - - final DeliveryPlan activeDeliveryPlan = lineItem1.getActiveDeliveryPlan(); - assertThat(activeDeliveryPlan).isNotNull() - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getStartTimeStamp, DeliveryPlan::getEndTimeStamp) - .containsOnly("planId1", now.minusHours(1), now.plusHours(1)); - assertThat(activeDeliveryPlan.getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal) - .containsOnly(tuple(1, 100)); - - assertThat(lineItem1.getReadyAt()).isEqualTo(now); - - final LineItem lineItem2 = lineItemService.getLineItemById("lineItem2"); - assertThat(lineItem2).isNotNull(); - assertThat(lineItem2.getActiveDeliveryPlan()).isNull(); - assertThat(lineItem2.getReadyAt()).isNull(); - } - - @Test - public void updateLineItemsShouldCreateLineItemsWithNullTargetingIfCantParse() { - // given - final List planResponse = singletonList( - LineItemMetaData.builder() - .lineItemId("lineItem1") - .status("active") - .dealId("dealId") - .accountId("1001") - .source("rubicon") - .price(Price.of(BigDecimal.ONE, "USD")) - .relativePriority(5) - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .targeting(mapper.createObjectNode().set("$invalid", new TextNode("invalid"))) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), singleton(Token.of(1, 100))))) - .build()); - - // when - lineItemService.updateLineItems(planResponse, true); - - // then - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem).isNotNull(); - assertThat(lineItem.getTargetingDefinition()).isNull(); - } - - @Test - public void updateLineItemsShouldNotUpdateCurrentPlanIfUpdatedPlanUpdateTimeStampIsNotInFuture() { - // given - final List firstPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), singleton(Token.of(1, 100)))), now)); - - final List secondPlanResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusHours(1), singleton(Token.of(1, 200)))), now)); - - // when - lineItemService.updateLineItems(firstPlanResponse, true); - incSpentTokens(10, "lineItem1"); - lineItemService.updateLineItems(secondPlanResponse, true); - - // then - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - assertThat(lineItem).isNotNull(); - - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - assertThat(activeDeliveryPlan).isNotNull() - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getStartTimeStamp, DeliveryPlan::getEndTimeStamp) - .containsOnly("planId1", now.minusHours(1), now.plusHours(1)); - assertThat(activeDeliveryPlan.getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, token -> token.getSpent().sum()) - .containsOnly(tuple(1, 100, 10L)); - - // should be ready at 12 minutes after plan start - assertThat(lineItem.getReadyAt()).isEqualTo(now.minusHours(1).plusMinutes(12)); - } - - @Test - public void updateLineItemsShouldMergeLineItemsWhenPlannerIsNotResponsive() { - // given - given(clock.instant()).willReturn(now.toInstant(), now.toInstant(), now.plusSeconds(2).toInstant()); - given(clock.getZone()).willReturn(ZoneOffset.UTC); - - final Set expiredTokens = new HashSet<>(); - expiredTokens.add(Token.of(1, 100)); - expiredTokens.add(Token.of(3, 300)); - expiredTokens.add(Token.of(4, 400)); - expiredTokens.add(Token.of(5, 500)); - - final Set newActiveTokens = new HashSet<>(); - newActiveTokens.add(Token.of(1, 100)); - newActiveTokens.add(Token.of(2, 200)); - newActiveTokens.add(Token.of(3, 300)); - newActiveTokens.add(Token.of(4, 400)); - - final List planResponse = singletonList(givenLineItemMetaData( - "lineItem1", "1001", "rubicon", - asList( - givenDeliverySchedule("planId1", now.minusHours(1), now.plusSeconds(1), expiredTokens), - givenDeliverySchedule("planId2", now.plusSeconds(1), now.plusHours(1), newActiveTokens)), - now)); - - // when and then - lineItemService.updateLineItems(planResponse, true); - incSpentTokens(240, "lineItem1"); - lineItemService.updateLineItems(null, false); - lineItemService.advanceToNextPlan(now.plusSeconds(1)); - - verify(clock, times(2)).instant(); - - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - assertThat(activeDeliveryPlan).isNotNull(); - assertThat(activeDeliveryPlan.getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, - deliveryToken -> deliveryToken.getSpent().sum()) - .containsExactly( - tuple(1, 200, 100L), - tuple(2, 200, 0L), - tuple(3, 600, 140L), - tuple(4, 800, 0L), - tuple(5, 500, 0L)); - } - - @Test - public void updateLineItemShouldUpdatePlanWithoutActiveCurrentDeliveryPlan() { - // given - given(clock.instant()).willReturn(now.toInstant(), now.toInstant(), now.plusSeconds(3).toInstant()); - given(clock.getZone()).willReturn(ZoneOffset.UTC); - - final List planResponse = singletonList(givenLineItemMetaData( - "lineItem1", "1001", "rubicon", - asList( - givenDeliverySchedule("planId1", now.minusHours(2), - now.minusHours(1), singleton(Token.of(1, 100))), - givenDeliverySchedule("planId2", now.plusSeconds(2), - now.plusHours(1), singleton(Token.of(1, 100)))), - now)); - - // when and then - lineItemService.updateLineItems(planResponse, true); - lineItemService.updateLineItems(null, false); - lineItemService.advanceToNextPlan(now.plusSeconds(2)); - - verify(clock, times(2)).instant(); - - final LineItem lineItem = lineItemService.getLineItemById("lineItem1"); - - final DeliveryPlan activeDeliveryPlan = lineItem.getActiveDeliveryPlan(); - assertThat(activeDeliveryPlan).isNotNull(); - assertThat(activeDeliveryPlan.getDeliveryTokens()) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, - deliveryToken -> deliveryToken.getSpent().sum()) - .containsExactly(tuple(1, 100, 0L)); - } - - @Test - public void accountHasDealsShouldReturnTrue() { - // given - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusHours(1), - emptySet())), now)); - lineItemService.updateLineItems(planResponse, true); - - // when and then - assertThat(lineItemService.accountHasDeals(AuctionContext.builder() - .account(Account.builder().id("1001").build()).build())) - .isTrue(); - } - - @Test - public void accountHasDealsShouldReturnFalseWhenAccountIsEmptyString() { - // given - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusHours(1), - emptySet())), now)); - lineItemService.updateLineItems(planResponse, true); - - // when and then - assertThat(lineItemService.accountHasDeals(AuctionContext.builder().account(Account.builder().id("").build()) - .build())).isFalse(); - } - - @Test - public void accountHasDealsShouldReturnFalseWhenNoMatchingLineItemWereFound() { - // given - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "3003", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusHours(1), - emptySet())), now)); - lineItemService.updateLineItems(planResponse, true); - - // when and then - assertThat(lineItemService.accountHasDeals(AuctionContext.builder().account(Account.builder().id("1001") - .build()).build())).isFalse(); - } - - @Test - public void accountHasDealsShouldReturnFalseWhenMatchedLineItemIsNotActive() { - // given - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusHours(1), - emptySet())), now)); - lineItemService.updateLineItems(planResponse, true); - given(clock.instant()).willReturn(now.plusHours(2).toInstant()); - - // when and then - assertThat(lineItemService.accountHasDeals(AuctionContext.builder().account(Account.builder().id("1001") - .build()).build())).isFalse(); - } - - @Test - public void findMatchingLineItemsShouldReturnEmptyListWhenLineItemsIsEmpty() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldReturnEmptyListWhenNoLineItemsForAccount() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountIdUnknown", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldReturnEmptyListWhenNoBiddersMatched() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountId", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusMinutes(1), - singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "pubmatic", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldReturnLineItemsForMatchingBidder() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountId", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusMinutes(1), - singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("lineItem1"); - } - - @Test - public void findMatchingLineItemsShouldReturnLineItemsWhenLineItemsBidderIsAlias() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountId", "rubiAlias", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusMinutes(1), - singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("lineItem1"); - } - - @Test - public void findMatchingLineItemsShouldReturnLineItemsWhenBidderFromInputBiddersIsAlias() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountId", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusMinutes(1), - singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubiAlias", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("lineItem1"); - } - - @Test - public void findMatchingLineItemsShouldReturnEmptyListWhenAccountIsEmptyString() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder().account(Account.builder().id("").build()).build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = singletonList( - givenLineItemMetaData("lineItem1", "accountId", "rubicon", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), now.plusMinutes(1), - singleton(Token.of(1, 100)))), now)); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldFilterNotMatchingTargeting() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - given(targetingService.parseTargetingDefinition(any(), eq("id1"))) - .willReturn(TargetingDefinition.of(context -> false)); - given(targetingService.parseTargetingDefinition(any(), eq("id2"))) - .willReturn(TargetingDefinition.of(context -> true)); - given(targetingService.matchesTargeting(any(), any(), any(), any())) - .willAnswer(withEvaluatedTargeting()); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).isEmpty(); - - assertThat(auctionContext.getDeepDebugLog().entries()).containsOnly( - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.targeting, - "Line Item id1 targeting did not match imp with id imp1")); - } - - @Test - public void findMatchingLineItemsShouldReturnLineItemsThatMatchedTargeting() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - given(targetingService.parseTargetingDefinition(any(), eq("id1"))) - .willReturn(TargetingDefinition.of(context -> false)); - given(targetingService.parseTargetingDefinition(any(), eq("id2"))) - .willReturn(TargetingDefinition.of(context -> true)); - given(targetingService.matchesTargeting(any(), any(), any(), any())) - .willAnswer(withEvaluatedTargeting()); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "appnexus", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - - assertThat(auctionContext.getDeepDebugLog().entries()).containsOnly( - ExtTraceDeal.of("id2", ZonedDateTime.now(clock), Category.targeting, - "Line Item id2 targeting matched imp with id imp1"), - ExtTraceDeal.of("id2", ZonedDateTime.now(clock), Category.pacing, - "Matched Line Item id2 for bidder appnexus ready to serve. relPriority null")); - } - - @Test - public void findMatchingLineItemsShouldFilterNullTargeting() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - given(targetingService.parseTargetingDefinition(any(), eq("id1"))) - .willReturn(null); - given(targetingService.parseTargetingDefinition(any(), eq("id2"))) - .willReturn(TargetingDefinition.of(context -> true)); - given(targetingService.matchesTargeting(any(), any(), any(), any())) - .willAnswer(withEvaluatedTargeting()); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).isEmpty(); - - assertThat(auctionContext.getDeepDebugLog().entries()).containsOnly( - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.targeting, - "Line Item id1 targeting was not defined or has incorrect format")); - } - - @Test - public void findMatchingLineItemsShouldFilterNotReadyLineItems() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusMinutes(1), - now.plusDays(1), singleton(Token.of(1, 1))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - lineItemService.getLineItemById("id1").incSpentToken(now.plusSeconds(1)); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldFilterLineItemsWithFcapIdsWhenUserDetailsFcapIsNull() { - // given - final AuctionContext auctionContext = givenAuctionContext(null); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .frequencyCaps(singletonList(FrequencyCap.builder().fcapId("123").build())) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).isEmpty(); - } - - @Test - public void findMatchingLineItemsShouldFilterFcappedLineItems() { - // given - final AuctionContext auctionContext = givenAuctionContext(asList("fcap2", "fcap3")); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .frequencyCaps(singletonList(FrequencyCap.builder().fcapId("fcap2").build())) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).isEmpty(); - assertThat(auctionContext.getTxnLog().lineItemsMatchedTargetingFcapped()).containsOnly("id1"); - assertThat(auctionContext.getDeepDebugLog().entries()).contains( - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.pacing, - "Matched Line Item id1 for bidder rubicon is frequency capped by fcap id fcap2.")); - } - - @Test - public void findMatchingLineItemsShouldFilterSameSentToBidderAsTopMatchLineItemsPerBidder() { - // given - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemsSentToBidderAsTopMatch().put("rubicon", new HashSet<>(singleton("id1"))); - final AuctionContext auctionContext = givenAuctionContext(emptyList()).toBuilder().txnLog(txnLog).build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("rubicon") - .accountId("accountId") - .relativePriority(2) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - } - - @Test - public void findMatchingLineItemsShouldFilterSameSentToBidderAsTopMatchLineItemsPerAllBidders() { - // given - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemsSentToBidderAsTopMatch().put("appnexus", new HashSet<>(singleton("id1"))); - final AuctionContext auctionContext = givenAuctionContext(emptyList()).toBuilder().txnLog(txnLog).build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("appnexus") - .accountId("accountId") - .relativePriority(1) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("rubicon") - .accountId("accountId") - .relativePriority(2) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - } - - @Test - public void findMatchingLineItemsShouldFilterLineItemsWithSameDealAndLowestPriorityTokenClassWithinBidder() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(3, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - } - - @Test - public void findMatchingLineItemsShouldFilterLineItemsWithSameDealIdAndLowestLineItemPriority() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(3) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - } - - @Test - public void findMatchingLineItemsShouldFilterLineItemsWithSameDealIdAndLowestCpm() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - } - - @Test - public void findMatchingLineItemsShouldFilterLineItemsWithoutUnspentTokensAndIncrementDeferred() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 0))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(auctionContext.getTxnLog().lineItemsPacingDeferred()).contains("id1"); - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2"); - assertThat(auctionContext.getDeepDebugLog().entries()).contains( - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.pacing, - "Matched Line Item id1 for bidder rubicon does not have unspent tokens to be served")); - } - - @Test - public void findMatchingLineItemsShouldLimitLineItemsPerBidder() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id3") - .status("active") - .dealId("3") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id2", "id3"); - } - - @Test - public void findMatchingLineItemsShouldReturnLineItemWithReadyToServeEqualToNow() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - givenClock(now, now.plusSeconds((now.plusMinutes(5).toEpochSecond() - now.toEpochSecond()) / 100)); - - final List planResponse = singletonList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("futurePlanId", now.minusMinutes(1), - now.plusMinutes(5), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsOnly("id1"); - } - - @Test - public void findMatchingLineItemsShouldRecordLineItemsInTxnLog() { - // given - final AuctionContext auctionContext = givenAuctionContext(asList("fcap2", "fcap3")); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .frequencyCaps(singletonList(FrequencyCap.builder().fcapId("fcap3").build())) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id3") - .status("active") - .dealId("3") - .source("appnexus") - .accountId("accountId") - .relativePriority(2) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id4") - .status("active") - .dealId("4") - .source("appnexus") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "appnexus", bidderAliases, auctionContext); - - // then - final TxnLog expectedTxnLog = TxnLog.create(); - expectedTxnLog.lineItemsMatchedWholeTargeting().addAll(asList("id1", "id2", "id3", "id4")); - expectedTxnLog.lineItemsMatchedTargetingFcapped().add("id2"); - expectedTxnLog.lineItemsReadyToServe().addAll(asList("id1", "id3", "id4")); - expectedTxnLog.lineItemsSentToBidderAsTopMatch().put("rubicon", singleton("id1")); - expectedTxnLog.lineItemsSentToBidderAsTopMatch().put("appnexus", singleton("id4")); - expectedTxnLog.lineItemsSentToBidder().get("rubicon").add("id1"); - expectedTxnLog.lineItemsSentToBidder().get("appnexus").addAll(asList("id3", "id4")); - expectedTxnLog.lostMatchingToLineItems().put("id3", singleton("id4")); - assertThat(auctionContext.getTxnLog()).isEqualTo(expectedTxnLog); - } - - @Test - public void findMatchingLineItemsShouldRecordLineItemsInTxnLogWhenPacingDeferred() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - givenTargetingService(); - - final List planResponse = singletonList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id5") - .status("active") - .dealId("5") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(2), singleton(Token.of(1, 2))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - lineItemService.getLineItemById("id5").incSpentToken(now.plusSeconds(1)); - lineItemService.getLineItemById("id5").incSpentToken(now.plusSeconds(1)); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - final TxnLog expectedTxnLog = TxnLog.create(); - expectedTxnLog.lineItemsMatchedWholeTargeting().add("id5"); - expectedTxnLog.lineItemsPacingDeferred().add("id5"); - assertThat(auctionContext.getTxnLog()).isEqualTo(expectedTxnLog); - } - - @Test - public void findMatchingLineItemsShouldRecordLineItemsInTxnLogWhenFcapLookupFailed() { - // given - final AuctionContext auctionContext = givenAuctionContext(null); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .dealId("1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .dealId("2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .frequencyCaps(singletonList(FrequencyCap.builder().fcapId("fcap3").build())) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(auctionContext.getTxnLog().lineItemsMatchedTargetingFcapLookupFailed()).containsOnly("id2"); - assertThat(auctionContext.getDeepDebugLog().entries()).contains( - ExtTraceDeal.of("id2", ZonedDateTime.now(clock), Category.pacing, - "Failed to match fcap for Line Item id2 bidder rubicon in a reason of bad response" - + " from user data service")); - } - - @Test - public void findMatchingLineItemsShouldHasCorrectRandomDistribution() { - // given - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - lineItemService = new LineItemService( - 3, - targetingService, - conversionService, - applicationEventService, - "USD", - clock, - criteriaLogManager); - - final List planResponse = asList( - givenLineItemMetaData("id1", now, "1", - singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), now, singleton(Token.of(1, 100)))), Function.identity()), - givenLineItemMetaData("id2", now, "2", - singletonList(givenDeliverySchedule("planId2", now.minusHours(1), - now.plusMinutes(1), now, singleton(Token.of(1, 100)))), Function.identity()), - givenLineItemMetaData("id3", now, "3", - singletonList(givenDeliverySchedule("planId3", now.minusHours(1), - now.plusMinutes(1), now, singleton(Token.of(1, 100)))), Function.identity())); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final Map count = new HashMap<>(); - for (int i = 0; i < 1000; i++) { - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - final MatchLineItemsResult matchLineItemsResult = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - count.compute(matchLineItemsResult.getLineItems().get(0).getLineItemId(), - (s, integer) -> integer != null ? ++integer : 1); - } - - // then - assertThat(count.get("id1")).isBetween(290, 390); - assertThat(count.get("id2")).isBetween(290, 390); - assertThat(count.get("id3")).isBetween(290, 390); - } - - @Test - public void findMatchingLineItemsShouldAddDebugMessages() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id1") - .status("active") - .source("rubicon") - .accountId("accountId") - .relativePriority(2) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(1), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId("id2") - .status("active") - .source("appnexus") - .accountId("accountId") - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusMinutes(1), - now.plusDays(1), singleton(Token.of(1, 2))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - lineItemService.getLineItemById("id2").incSpentToken(now.plusSeconds(1)); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "appnexus", bidderAliases, auctionContext); - - // then - assertThat(auctionContext.getDeepDebugLog().entries()).containsOnly( - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.targeting, - "Line Item id1 targeting matched imp with id imp1"), - ExtTraceDeal.of("id2", ZonedDateTime.now(clock), Category.targeting, - "Line Item id2 targeting matched imp with id imp1"), - ExtTraceDeal.of("id1", ZonedDateTime.now(clock), Category.pacing, - "Matched Line Item id1 for bidder rubicon ready to serve. relPriority 2"), - ExtTraceDeal.of("id2", ZonedDateTime.now(clock), Category.pacing, - "Matched Line Item id2 for bidder appnexus not ready to serve. Will be ready" - + " at 2019-07-26T21:59:30.000Z, current time is 2019-07-26T10:01:00.000Z")); - } - - @Test - public void findMatchingLineItemsShouldReturnWithoutUnspentTokensOrOnCoolDownIfIgnorePacingHeaderProvided() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder() - .httpRequest(HttpRequestContext.builder() - .headers(CaseInsensitiveMultiMap.builder().add(HttpUtil.PG_IGNORE_PACING, "1").build()) - .build()) - .build(); - - givenTargetingService(); - - givenClock(now.plusMinutes(5), now); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 0))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsExactly("id2", "id1"); - } - - @Test - public void findMatchingLineItemsShouldLowerPriorityIfDeliveryPlanIsNullAndPgIgnorePacing() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder() - .httpRequest(HttpRequestContext.builder() - .headers(CaseInsensitiveMultiMap.builder().add(HttpUtil.PG_IGNORE_PACING, "1").build()) - .build()) - .build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(null) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsExactly("id1", "id2"); - } - - @Test - public void findMatchingLineItemsShouldLowerPriorityIfNoTokensUnspentAndPgIgnorePacing() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder() - .httpRequest(HttpRequestContext.builder() - .headers(CaseInsensitiveMultiMap.builder().add(HttpUtil.PG_IGNORE_PACING, "1").build()) - .build()) - .build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 0))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsExactly("id1", "id2"); - } - - @Test - public void findMatchingLineItemsShouldLowerPriorityIfRelativePriorityIsNullAndPgIgnorePacing() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder() - .httpRequest(HttpRequestContext.builder() - .headers(CaseInsensitiveMultiMap.builder().add(HttpUtil.PG_IGNORE_PACING, "1").build()) - .build()) - .build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ONE, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(null) - .price(Price.of(BigDecimal.TEN, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsExactly("id1", "id2"); - } - - @Test - public void findMatchingLineItemsShouldLowerPriorityIfCpmIsNullAndPgIgnorePacing() { - // given - final AuctionContext auctionContext = givenAuctionContext(emptyList()) - .toBuilder() - .httpRequest(HttpRequestContext.builder() - .headers(CaseInsensitiveMultiMap.builder().add(HttpUtil.PG_IGNORE_PACING, "1").build()) - .build()) - .build(); - - givenTargetingService(); - - givenClock(now, now.plusMinutes(1)); - - final List planResponse = asList( - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id1") - .status("active") - .dealId("dealId1") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(BigDecimal.ZERO, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build(), - LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(10)) - .lineItemId("id2") - .status("active") - .dealId("dealId2") - .source("rubicon") - .accountId("accountId") - .relativePriority(1) - .price(Price.of(null, "USD")) - .deliverySchedules(singletonList(givenDeliverySchedule("planId1", now.minusHours(1), - now.plusMinutes(10), singleton(Token.of(1, 100))))) - .build()); - - lineItemService.updateLineItems(planResponse, true); - - final Imp imp = Imp.builder().id("imp1").build(); - - // when - final MatchLineItemsResult result = lineItemService.findMatchingLineItems( - auctionContext.getBidRequest(), imp, "rubicon", bidderAliases, auctionContext); - - // then - assertThat(result.getLineItems()).extracting(LineItem::getLineItemId).containsExactly("id1", "id2"); - } - - private static LineItemMetaData givenLineItemMetaData( - String lineItemId, - ZonedDateTime now, - String dealId, - List deliverySchedules, - Function lineItemMetaDataCustomizer) { - return lineItemMetaDataCustomizer.apply(LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId(lineItemId) - .dealId(dealId) - .status("active") - .accountId("accountId") - .source("rubicon") - .price(Price.of(BigDecimal.ONE, "USD")) - .relativePriority(5) - .updatedTimeStamp(now) - .deliverySchedules(deliverySchedules)) - .build(); - } - - private static LineItemMetaData givenLineItemMetaData( - String lineItemId, String account, String bidderCode, List deliverySchedules, - ZonedDateTime now) { - - return LineItemMetaData.builder() - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .lineItemId(lineItemId) - .dealId("dealId") - .status("active") - .accountId(account) - .source(bidderCode) - .price(Price.of(BigDecimal.ONE, "USD")) - .relativePriority(5) - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .deliverySchedules(deliverySchedules) - .build(); - } - - private static DeliverySchedule givenDeliverySchedule(String planId, ZonedDateTime start, ZonedDateTime end, - ZonedDateTime updated, Set tokens) { - return DeliverySchedule.builder() - .planId(planId) - .startTimeStamp(start) - .endTimeStamp(end) - .updatedTimeStamp(updated) - .tokens(tokens) - .build(); - } - - private static DeliverySchedule givenDeliverySchedule(String planId, ZonedDateTime start, ZonedDateTime end, - Set tokens) { - return givenDeliverySchedule(planId, start, end, start, tokens); - } - - private void incSpentTokens(int times, String... lineItemIds) { - for (final String lineItemId : lineItemIds) { - final LineItem lineItem = lineItemService.getLineItemById(lineItemId); - IntStream.range(0, times).forEach(i -> lineItem.incSpentToken(now)); - } - } - - private AuctionContext givenAuctionContext(List fcaps) { - return AuctionContext.builder() - .httpRequest(HttpRequestContext.builder().headers(CaseInsensitiveMultiMap.empty()).build()) - .account(Account.builder().id("accountId").build()) - .deepDebugLog(DeepDebugLog.create(true, clock)) - .txnLog(TxnLog.create()) - .bidRequest(BidRequest.builder() - .user(User.builder().ext( - ExtUser.builder().fcapIds(fcaps).build()).build()) - .ext(ExtRequest.of(ExtRequestPrebid.builder() - .aliases(singletonMap("rubiAlias", "rubicon")) - .build())) - .build()) - .build(); - } - - private void givenTargetingService() { - given(targetingService.parseTargetingDefinition(any(), any())) - .willReturn(TargetingDefinition.of(context -> true)); - given(targetingService.matchesTargeting(any(), any(), any(), any())) - .willAnswer(withEvaluatedTargeting()); - } - - private Answer withEvaluatedTargeting() { - return invocation -> ((TargetingDefinition) invocation.getArgument(2)).getRootExpression().matches(null); - } - - private void givenClock(ZonedDateTime... dateTimes) { - given(clock.instant()).willReturn( - dateTimes[0].toInstant(), - Arrays.stream(dateTimes).skip(1).map(ZonedDateTime::toInstant).toArray(Instant[]::new)); - given(clock.getZone()).willReturn(dateTimes[0].getZone()); - } -} diff --git a/src/test/java/org/prebid/server/deals/PlannerServiceTest.java b/src/test/java/org/prebid/server/deals/PlannerServiceTest.java deleted file mode 100644 index 940f6c3628c..00000000000 --- a/src/test/java/org/prebid/server/deals/PlannerServiceTest.java +++ /dev/null @@ -1,351 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.BDDMockito; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.FrequencyCap; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.deals.proto.Token; -import org.prebid.server.metric.MetricName; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.math.BigDecimal; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.List; -import java.util.concurrent.TimeoutException; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.anyBoolean; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class PlannerServiceTest extends VertxTest { - - private static final String PLAN_ENDPOINT = "plan-endpoint"; - private static final String REGISTER_ENDPOINT = "register-endpoint"; - private static final String USERNAME = "username"; - private static final String PASSWORD = "password"; - private static final String PBS_HOST = "pbs-host"; - private static final String PBS_REGION = "pbs-region"; - private static final String PBS_VENDOR = "pbs-vendor"; - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private HttpClient httpClient; - @Mock - private LineItemService lineItemService; - @Mock - private DeliveryProgressService deliveryProgressService; - @Mock - private AlertHttpService alertHttpService; - @Mock - private Metrics metrics; - @Mock - private Clock clock; - - private PlannerService plannerService; - - private ZonedDateTime now; - - @Before - public void setUp() throws JsonProcessingException { - clock = Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC); - now = ZonedDateTime.now(clock); - - plannerService = new PlannerService( - PlannerProperties.builder() - .planEndpoint(PLAN_ENDPOINT) - .registerEndpoint(REGISTER_ENDPOINT) - .timeoutMs(100L) - .registerPeriodSeconds(60L) - .username(USERNAME) - .password(PASSWORD) - .build(), - DeploymentProperties.builder().pbsHostId(PBS_HOST).pbsRegion(PBS_REGION).pbsVendor(PBS_VENDOR).build(), - lineItemService, - deliveryProgressService, - alertHttpService, - httpClient, - metrics, - clock, - jacksonMapper); - - givenPlanHttpResponse(200, mapper.writeValueAsString( - asList(givenLineItemMetaData("lineItem1", "1001", "rubicon", now), - givenLineItemMetaData("lineItem2", "1002", "appnexus", now)))); - } - - @Test - public void updateLineItemMetaDataShouldRetryOnceWhenResponseCantBeParsed() { - // given - givenPlanHttpResponse(200, "{"); - - // when - plannerService.updateLineItemMetaData(); - - // then - verify(lineItemService, never()).updateLineItems(any(), anyBoolean()); - verify(alertHttpService).alertWithPeriod(eq("planner"), - eq("pbs-planner-client-error"), - eq(AlertPriority.MEDIUM), - eq("Failed to retrieve line items from GP. Reason: Cannot parse response: {")); - verify(metrics, times(2)).updatePlannerRequestMetric(eq(false)); - verify(httpClient, times(2)).get(anyString(), any(), anyLong()); - } - - @Test - public void updateLineItemMetaDataShouldRetryWhenHttpClientReturnsFailedFuture() { - // given - given(httpClient.get(anyString(), any(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("Timeout has been exceeded"))); - - // when - plannerService.updateLineItemMetaData(); - - // then - verify(alertHttpService).alertWithPeriod(eq("planner"), eq("pbs-planner-client-error"), - eq(AlertPriority.MEDIUM), - eq("Failed to retrieve line items from GP. Reason: Timeout has been exceeded")); - verify(httpClient, times(2)).get(anyString(), any(), anyLong()); - } - - @Test - public void updateLineItemMetaDataShouldAlertWithoutRetryWhenPlannerReturnsEmptyLineItemList() - throws JsonProcessingException { - // given - givenPlanHttpResponse(200, mapper.writeValueAsString(emptyList())); - - // when - plannerService.updateLineItemMetaData(); - - // then - verify(alertHttpService).alertWithPeriod(eq("planner"), eq("pbs-planner-empty-response-error"), - eq(AlertPriority.LOW), eq("Response without line items was received from planner")); - verify(httpClient).get(anyString(), any(), anyLong()); - verify(lineItemService).updateLineItems(eq(emptyList()), anyBoolean()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemsShouldReturnLineItemsSuccessfulInitialization() { - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - assertThat(planResponseCaptor.getValue()).isEqualTo(asList( - givenLineItemMetaData("lineItem1", "1001", "rubicon", now), - givenLineItemMetaData("lineItem2", "1002", "appnexus", now))); - verify(alertHttpService).resetAlertCount(eq("pbs-planner-empty-response-error")); - verify(metrics).updatePlannerRequestMetric(eq(true)); - verify(metrics).updateLineItemsNumberMetric(eq(2L)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.planner_request_time), anyLong()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemsShouldReturnOverwrittenMetaDataAfterSchedulerCallsRefresh() - throws JsonProcessingException { - // given - givenHttpClientReturnsResponses( - Future.succeededFuture(HttpClientResponse.of(200, null, - mapper.writeValueAsString(singletonList(LineItemMetaData.builder().lineItemId("id1") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .planId("id1") - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .tokens(singleton(Token.of(1, 300))).build())) - .accountId("1").build())))), - Future.succeededFuture(HttpClientResponse.of(200, null, - mapper.writeValueAsString(singletonList(LineItemMetaData.builder().lineItemId("id2") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .planId("id2") - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .tokens(singleton(Token.of(1, 300))).build())) - .accountId("2").build()))))); - - // when and then - plannerService.updateLineItemMetaData(); - - // fire request seconds time - plannerService.updateLineItemMetaData(); - - verify(httpClient, times(2)).get(anyString(), any(), anyLong()); - verify(lineItemService, times(2)).updateLineItems(any(), anyBoolean()); - - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, times(2)).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - - assertThat(planResponseCaptor.getAllValues().get(1)) - .isEqualTo(singletonList(LineItemMetaData.builder().lineItemId("id2") - .deliverySchedules(singletonList(DeliverySchedule.builder() - .planId("id2") - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .tokens(singleton(Token.of(1, 300))).build())) - .accountId("2").build())); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemMetaDataShouldReturnExpectedResult() { - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - - assertThat(planResponseCaptor.getValue()) - .containsOnly( - givenLineItemMetaData("lineItem1", "1001", "rubicon", now), - givenLineItemMetaData("lineItem2", "1002", "appnexus", now)); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemMetaDataShouldNotCallUpdateLineItemAfterFailedRequest() { - // given - givenPlanHttpResponse(404, null); - - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, never()).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemMetaDataShouldNotCallUpdateLineItemsWhenBodyIsNull() { - // given - givenPlanHttpResponse(200, null); - - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, never()).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemMetaDataShouldNotCallUpdateLineItemWhenBodyCantBeParsed() { - // given - givenPlanHttpResponse(200, "{"); - - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, never()).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemsShouldNotCallLineItemsUpdateAfter404Response() { - // given - givenPlanHttpResponse(404, null); - - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, never()).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - } - - @SuppressWarnings("unchecked") - @Test - public void getIdToLineItemsShouldNotCallLineItemsUpdateWhenBodyIsNull() { - // given - givenPlanHttpResponse(200, null); - - // when - plannerService.updateLineItemMetaData(); - - // then - final ArgumentCaptor> planResponseCaptor = ArgumentCaptor.forClass(List.class); - verify(lineItemService, never()).updateLineItems(planResponseCaptor.capture(), anyBoolean()); - } - - private void givenPlanHttpResponse(int statusCode, String response) { - final HttpClientResponse httpClientResponse = HttpClientResponse.of(statusCode, null, response); - given(httpClient.get(startsWith(PLAN_ENDPOINT), any(), anyLong())) - .willReturn(Future.succeededFuture(httpClientResponse)); - } - - private static LineItemMetaData givenLineItemMetaData(String lineItemId, String account, String bidderCode, - ZonedDateTime now) { - return LineItemMetaData.builder() - .lineItemId(lineItemId) - .dealId("dealId") - .accountId(account) - .source(bidderCode) - .price(Price.of(BigDecimal.ONE, "USD")) - .relativePriority(5) - .startTimeStamp(now) - .endTimeStamp(now) - .updatedTimeStamp(now) - .frequencyCaps(singletonList(FrequencyCap.builder() - .fcapId("fcap").count(6L).periods(7).periodType("day").build())) - .deliverySchedules(singletonList(DeliverySchedule.builder() - .planId("plan") - .startTimeStamp(now.minusHours(1)) - .endTimeStamp(now.plusHours(1)) - .updatedTimeStamp(now) - .tokens(singleton(Token.of(1, 300))).build())) - .targeting(mapper.createObjectNode()) - .build(); - } - - @SafeVarargs - private void givenHttpClientReturnsResponses(Future... futureHttpClientResponses) { - BDDMockito.BDDMyOngoingStubbing> stubbing = - given(httpClient.get(anyString(), any(), anyLong())); - - // setup multiple answers - for (Future futureHttpClientResponse : futureHttpClientResponses) { - stubbing = stubbing.willReturn(futureHttpClientResponse); - } - } -} diff --git a/src/test/java/org/prebid/server/deals/RegisterServiceTest.java b/src/test/java/org/prebid/server/deals/RegisterServiceTest.java deleted file mode 100644 index 1f65a78fd79..00000000000 --- a/src/test/java/org/prebid/server/deals/RegisterServiceTest.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.deals.events.AdminEventService; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.deals.model.AlertPriority; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.model.ServicesCommand; -import org.prebid.server.deals.proto.CurrencyServiceState; -import org.prebid.server.deals.proto.RegisterRequest; -import org.prebid.server.deals.proto.Status; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.health.HealthMonitor; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.math.BigDecimal; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class RegisterServiceTest extends VertxTest { - - private static final String PLAN_ENDPOINT = "plan-endpoint"; - private static final String REGISTER_ENDPOINT = "register-endpoint"; - private static final String USERNAME = "username"; - private static final String PASSWORD = "password"; - private static final String PBS_HOST = "pbs-host"; - private static final String PBS_REGION = "pbs-region"; - private static final String PBS_VENDOR = "pbs-vendor"; - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private RegisterService registerService; - @Mock - private HealthMonitor healthMonitor; - @Mock - private CurrencyConversionService currencyConversionService; - @Mock - private AdminEventService adminEventService; - @Mock - private DeliveryProgressService deliveryProgressService; - @Mock - private HttpClient httpClient; - @Mock - private AlertHttpService alertHttpService; - @Mock - private Vertx vertx; - - private ZonedDateTime fixedDate; - - @Before - public void setUp() { - fixedDate = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC)); - registerService = new RegisterService( - PlannerProperties.builder() - .planEndpoint(PLAN_ENDPOINT) - .registerEndpoint(REGISTER_ENDPOINT) - .timeoutMs(100L) - .registerPeriodSeconds(60L) - .username(USERNAME) - .password(PASSWORD) - .build(), - DeploymentProperties.builder().pbsHostId(PBS_HOST).pbsRegion(PBS_REGION).pbsVendor(PBS_VENDOR).build(), - adminEventService, - deliveryProgressService, - alertHttpService, - healthMonitor, - currencyConversionService, - httpClient, - vertx, - jacksonMapper); - - givenRegisterHttpResponse(200); - } - - @Test - public void initializeShouldSetRegisterTimer() throws JsonProcessingException { - // given - given(vertx.setPeriodic(anyLong(), any())).willReturn(1L); - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(currencyConversionService.getLastUpdated()).willReturn(fixedDate); - - // when - registerService.initialize(); - - // then - verify(vertx).setPeriodic(eq(60000L), any()); - verify(vertx, never()).cancelTimer(anyLong()); - - final ArgumentCaptor registerBodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpClient).post(startsWith(REGISTER_ENDPOINT), any(), registerBodyCaptor.capture(), anyLong()); - assertThat(registerBodyCaptor.getValue()).isEqualTo(mapper.writeValueAsString( - RegisterRequest.of(BigDecimal.ONE, Status.of(CurrencyServiceState.of("2019-07-26T10:00:00.000Z"), null), - PBS_HOST, PBS_REGION, PBS_VENDOR))); - } - - @Test - public void initializeShouldSetDeliveryReportToRegisterRequest() throws JsonProcessingException { - // given - given(vertx.setPeriodic(anyLong(), any())).willReturn(1L); - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(deliveryProgressService.getOverallDeliveryProgressReport()).willReturn(DeliveryProgressReport.builder() - .reportId("reportId").build()); - - // when - registerService.initialize(); - - // then - final ArgumentCaptor registerBodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpClient).post(startsWith(REGISTER_ENDPOINT), any(), registerBodyCaptor.capture(), anyLong()); - assertThat(registerBodyCaptor.getValue()).isEqualTo(mapper.writeValueAsString( - RegisterRequest.of(BigDecimal.ONE, - Status.of(null, DeliveryProgressReport.builder().reportId("reportId").build()), - PBS_HOST, PBS_REGION, PBS_VENDOR))); - } - - @Test - public void registerShouldNotCallAdminCentralWhenResponseIsEmpty() { - // given - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, MultiMap.caseInsensitiveMultiMap(), ""))); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verifyNoInteractions(adminEventService); - } - - @Test - public void registerShouldCallAdminCentralWhenResponseIsNotEmpty() throws JsonProcessingException { - // given - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, MultiMap.caseInsensitiveMultiMap(), - mapper.writeValueAsString(AdminCentralResponse.of(null, null, null, null, null, - ServicesCommand.of("stop")))))); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verify(adminEventService).publishAdminCentralEvent(any()); - } - - @Test - public void registerShouldNotCallAdminCentralWhenFutureFailed() { - // given - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.failedFuture("failed")); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verifyNoInteractions(adminEventService); - } - - @Test - public void registerShouldCallAlertServiceWhenFutureFailed() { - // given - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.failedFuture("failed")); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verify(alertHttpService).alertWithPeriod(eq("register"), eq("pbs-register-client-error"), - eq(AlertPriority.MEDIUM), - eq("Error occurred while registering with the Planner:" - + " io.vertx.core.impl.NoStackTraceThrowable: failed")); - } - - @Test - public void registerShouldCallAlertServiceResetWhenRequestWasSuccessful() { - // given - given(healthMonitor.calculateHealthIndex()).willReturn(BigDecimal.ONE); - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, MultiMap.caseInsensitiveMultiMap(), ""))); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verify(alertHttpService).resetAlertCount(eq("pbs-register-client-error")); - } - - @Test - public void registerShouldNotSendAdminEventWhenResponseStatusIsBadRequest() { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(400, null, null))); - - // when - registerService.register(MultiMap.caseInsensitiveMultiMap()); - - // then - verifyNoInteractions(adminEventService); - } - - @Test - public void registerShouldThrowPrebidExceptionWhenResponseIsInvalidJson() { - // given - given(httpClient.post(anyString(), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, "{"))); - - // when and then - assertThatThrownBy(() -> registerService.register(MultiMap.caseInsensitiveMultiMap())) - .isInstanceOf(PreBidException.class) - .hasMessage("Cannot parse register response: {"); - } - - @Test - public void suspendShouldStopRegisterTimer() { - // when - registerService.suspend(); - - // then - verify(vertx).cancelTimer(anyLong()); - } - - @Test - public void initializeShouldCallHealthMonitor() { - // when - registerService.initialize(); - - // then - verify(healthMonitor).calculateHealthIndex(); - } - - private void givenRegisterHttpResponse(int statusCode) { - final HttpClientResponse httpClientResponse = HttpClientResponse.of(statusCode, null, null); - given(httpClient.post(startsWith(REGISTER_ENDPOINT), any(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(httpClientResponse)); - } -} diff --git a/src/test/java/org/prebid/server/deals/TargetingServiceTest.java b/src/test/java/org/prebid/server/deals/TargetingServiceTest.java deleted file mode 100644 index 30274979ef8..00000000000 --- a/src/test/java/org/prebid/server/deals/TargetingServiceTest.java +++ /dev/null @@ -1,919 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.IntNode; -import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Data; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Geo; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Publisher; -import com.iab.openrtb.request.Segment; -import com.iab.openrtb.request.Site; -import com.iab.openrtb.request.User; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.targeting.TargetingDefinition; -import org.prebid.server.deals.targeting.interpret.And; -import org.prebid.server.deals.targeting.interpret.DomainMetricAwareExpression; -import org.prebid.server.deals.targeting.interpret.InIntegers; -import org.prebid.server.deals.targeting.interpret.InStrings; -import org.prebid.server.deals.targeting.interpret.IntersectsIntegers; -import org.prebid.server.deals.targeting.interpret.IntersectsSizes; -import org.prebid.server.deals.targeting.interpret.IntersectsStrings; -import org.prebid.server.deals.targeting.interpret.Matches; -import org.prebid.server.deals.targeting.interpret.Not; -import org.prebid.server.deals.targeting.interpret.Or; -import org.prebid.server.deals.targeting.interpret.Within; -import org.prebid.server.deals.targeting.model.GeoRegion; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; -import org.prebid.server.deals.targeting.syntax.TargetingCategory.Type; -import org.prebid.server.exception.TargetingSyntaxException; -import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtGeo; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; - -import java.io.IOException; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class TargetingServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private TargetingService targetingService; - - @Before - public void setUp() { - targetingService = new TargetingService(jacksonMapper); - } - - @Test - public void parseTargetingDefinitionShouldReturnValidExpression() throws IOException { - // when - final TargetingDefinition definition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-valid-targeting-definition.json"), "lineItemId"); - - // then - assertThat(definition).isNotNull().isEqualTo(TargetingDefinition.of( - new And(asList( - new IntersectsSizes(category(Type.size), asList(Size.of(300, 250), Size.of(400, 200))), - new IntersectsStrings(category(Type.mediaType), asList("banner", "video")), - new Or(asList( - new Or(asList( - new DomainMetricAwareExpression(new Matches(category(Type.domain), - "*nba.com*"), "lineItemId"), - new DomainMetricAwareExpression(new Matches(category(Type.publisherDomain), - "*nba.com*"), "lineItemId"))), - new Or(asList( - new DomainMetricAwareExpression(new Matches(category(Type.domain), - "nba.com*"), "lineItemId"), - new DomainMetricAwareExpression(new Matches(category(Type.publisherDomain), - "nba.com*"), "lineItemId"))), - new Or(asList( - new DomainMetricAwareExpression(new InStrings(category(Type.domain), - asList("nba.com", "cnn.com")), "lineItemId"), - new DomainMetricAwareExpression(new InStrings(category(Type.publisherDomain), - asList("nba.com", "cnn.com")), "lineItemId"))) - )), - new Or(asList( - new Matches(category(Type.referrer), "*sports*"), - new Matches(category(Type.referrer), "http://nba.com/lalakers*"), - new InStrings(category(Type.referrer), - asList("http://cnn.com/culture", "http://cnn.com/weather")) - )), - new Or(asList( - new Matches(category(Type.appBundle), "*com.google.calendar*"), - new Matches(category(Type.appBundle), "com.google.calendar*"), - new InStrings(category(Type.appBundle), - asList("com.google.calendar", "com.tmz")) - )), - new Or(asList( - new Matches(category(Type.adslot), "*/home/top*"), - new Matches(category(Type.adslot), "/home/top*"), - new InStrings(category(Type.adslot), asList("/home/top", "/home/bottom")) - )), - new InStrings(category(Type.deviceGeoExt, "vendor.attribute"), - asList("device_geo_ext_value1", "device_geo_ext_value2")), - new InStrings(category(Type.deviceGeoExt, "vendor.nested.attribute"), - asList("device_geo_ext_nested_value1", "device_geo_ext_nested_value2")), - new InStrings(category(Type.deviceExt, "vendor.attribute"), - asList("device_ext_value1", "device_ext_value2")), - new InStrings(category(Type.deviceExt, "vendor.nested.attribute"), - asList("device_ext_nested_value1", "device_ext_nested_value2")), - new InIntegers(category(Type.pagePosition), asList(1, 3)), - new Within(category(Type.location), GeoRegion.of(123.456f, 789.123f, 10.0f)), - new Or(asList( - new InIntegers(category(Type.bidderParam, "siteId"), asList(123, 321)), - new IntersectsIntegers(category(Type.bidderParam, "siteId"), asList(123, 321)) - )), - new Or(asList( - new Matches(category(Type.bidderParam, "placementName"), "*somePlacement*"), - new Matches(category(Type.bidderParam, "placementName"), "somePlacement*"), - new InStrings(category(Type.bidderParam, "placementName"), - asList("somePlacement1", "somePlacement2")), - new IntersectsStrings(category(Type.bidderParam, "placementName"), - asList("somePlacement1", "somePlacement2")) - )), - new Or(asList( - new IntersectsStrings( - category(Type.userSegment, "rubicon"), asList("123", "234", "345")), - new IntersectsStrings( - category(Type.userSegment, "bluekai"), asList("123", "234", "345")) - )), - new Or(asList( - new InIntegers(category(Type.userFirstPartyData, "someId"), asList(123, 321)), - new IntersectsIntegers(category(Type.userFirstPartyData, "someId"), asList(123, 321)) - )), - new Or(asList( - new Matches(category(Type.userFirstPartyData, "sport"), "*hockey*"), - new Matches(category(Type.userFirstPartyData, "sport"), "hockey*"), - new InStrings(category(Type.userFirstPartyData, "sport"), asList("hockey", "soccer")), - new IntersectsStrings( - category(Type.userFirstPartyData, "sport"), asList("hockey", "soccer")) - )), - new Or(asList( - new InIntegers(category(Type.siteFirstPartyData, "someId"), asList(123, 321)), - new IntersectsIntegers(category(Type.siteFirstPartyData, "someId"), asList(123, 321)) - )), - new Or(asList( - new Matches(category(Type.siteFirstPartyData, "sport"), "*hockey*"), - new Matches(category(Type.siteFirstPartyData, "sport"), "hockey*"), - new InStrings(category(Type.siteFirstPartyData, "sport"), asList("hockey", "soccer")), - new IntersectsStrings( - category(Type.siteFirstPartyData, "sport"), asList("hockey", "soccer")) - )), - new InIntegers(category(Type.dow), asList(5, 6)), - new InIntegers(category(Type.hour), asList(10, 11, 12, 13, 14)) - )))); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenTopLevelFieldIsNonObject() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-non-object.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected array, got NUMBER"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenTopLevelObjectHasMultipleFields() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-multiple-fields.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected only one element in the object, got 2"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenBooleanOperatorArgumentHasMultipleFields() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-multiple-fields-boolean-args.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected only one element in the object, got 2"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenFieldIsUnknown() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-unknown-field.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected either boolean operator or targeting category, got aaa"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenAndWithNonArray() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-and-with-non-array.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected array, got OBJECT"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenNotWithNonObject() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-not-with-non-object.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected object, got ARRAY"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithNonObject() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-category-non-object.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected object, got NUMBER"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenFunctionHasMultipleFields() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-multiple-fields-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected only one element in the object, got 2"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenUnknownFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-unknown-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected matching function, got $abc"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithIncompatibleFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-category-incompatible-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected $intersects matching function, got $in"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsNonArray() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-non-array.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected array, got OBJECT"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsSizesWithNonObjects() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-sizes-non-objects.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected object, got NUMBER"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsSizesWithNonReadableSize() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-sizes-non-readable-size.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessageStartingWith("Exception occurred while parsing size: " - + "Cannot deserialize value of type `java.lang.Integer`"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsSizesWithEmptySize() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-sizes-empty-size.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Height and width in size definition could not be null or missing"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsStringsWithNonString() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-strings-non-string.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected string, got NUMBER"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenIntersectsStringsWithEmptyString() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-intersects-strings-empty.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("String value could not be empty"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenUnknownStringFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-unknown-string-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected matching function, got $abc"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithIncompatibleStringFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-category-incompatible-string-function.json"), - null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected one of $matches, $in matching functions, got $intersects"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenMatchesWithNonString() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-matches-non-string.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected string, got NUMBER"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenMatchesWithEmptyString() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-matches-empty.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("String value could not be empty"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenInIntegersWithNonInteger() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-in-integers-non-integer.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected integer, got STRING"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithIncompatibleGeoFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-category-incompatible-geo-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected $within matching function, got $intersects"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenWithinWithNonObject() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-within-non-object.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected object, got ARRAY"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenWithinWithNonReadableGeoRegion() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-within-non-readable-georegion.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessageStartingWith("Exception occurred while parsing geo region: " - + "Cannot deserialize value of type `java.lang.Float`"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenWithinWithEmptyGeoRegion() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-within-empty-georegion.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Lat, lon and radiusMiles in geo region definition could not be null or missing"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithIncompatibleSegmentFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom( - "targeting/test-invalid-targeting-definition-category-incompatible-segment-function.json"), - null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected $intersects matching function, got $in"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenUnknownTypedFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-unknown-typed-function.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected matching function, got $abc"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenCategoryWithIncompatibleTypedFunction() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-category-incompatible-typed-function.json"), - null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected one of $matches, $in, $intersects matching functions, got $within"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenTypedFunctionWithIncompatibleType() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-typed-function-incompatible-type.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected integer or string, got BOOLEAN"); - } - - @Test - public void parseTargetingDefinitionShouldFailWhenTypedFunctionWithMixedTypes() { - assertThatThrownBy(() -> targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-invalid-targeting-definition-typed-function-mixed-types.json"), null)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Expected integer, got STRING"); - } - - @Test - public void matchesTargetingShouldReturnTrue() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new And(asList( - new IntersectsSizes(category(Type.size), asList(Size.of(300, 250), Size.of(400, 200))), - new IntersectsStrings(category(Type.mediaType), asList("banner", "video")), - new DomainMetricAwareExpression( - new Matches(category(Type.domain), "*nba.com*"), "lineItemId"), - new DomainMetricAwareExpression( - new Matches(category(Type.domain), "lakers.nba.com"), "lineItemId"), - new DomainMetricAwareExpression( - new Matches(category(Type.publisherDomain), "nba.com"), "lineItemId"), - new InIntegers(category(Type.pagePosition), asList(1, 3)), - new Within(category(Type.location), GeoRegion.of(50.424744f, 30.506435f, 10.0f)), - new InIntegers(category(Type.bidderParam, "siteId"), asList(123, 321)), - new IntersectsStrings(category(Type.userSegment, "rubicon"), asList("123", "234", "345")), - new IntersectsIntegers(category(Type.userFirstPartyData, "someId"), asList(123, 321))))); - - final BidRequest bidRequest = BidRequest.builder() - .site(Site.builder() - .domain("lakers.nba.com") - .publisher(Publisher.builder().domain("nba.com").build()) - .build()) - .device(Device.builder() - .geo(Geo.builder() - .lat(50.432069f) - .lon(30.516455f) - .build()) - .build()) - .user(User.builder() - .data(asList( - Data.builder() - .id("rubicon") - .segment(asList( - Segment.builder().id("234").build(), - Segment.builder().id("567").build())) - .build(), - Data.builder() - .id("bluekai") - .segment(asList( - Segment.builder().id("789").build(), - Segment.builder().id("890").build())) - .build())) - .ext(ExtUser.builder().data(mapper.valueToTree(singletonMap("someId", asList(123, 456)))) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .pos(3) - .build()) - .ext(mapper.createObjectNode().set("bidder", mapper.valueToTree(singletonMap("siteId", 123)))) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - assertThat(txnLog.lineItemsMatchedDomainTargeting()).containsOnly("lineItemId"); - } - - @Test - public void matchesTargetingShouldReturnTrueForIntersectsStringsOnSingleString() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new IntersectsStrings(category(Type.userFirstPartyData, "segment"), asList("test", "111"))); - - final BidRequest bidRequest = BidRequest.builder() - .user(User.builder() - .ext(ExtUser.builder() - .data(mapper.createObjectNode().set("segment", TextNode.valueOf("test"))) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder().build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForIntersectsIntegersOnSingleInteger() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new IntersectsIntegers(category(Type.userFirstPartyData, "segment"), asList(123, 456))); - - final BidRequest bidRequest = BidRequest.builder() - .user(User.builder() - .ext(ExtUser.builder() - .data(mapper.createObjectNode().set("segment", IntNode.valueOf(123))) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder().build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotInIntegers() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-in-integers-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder() - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .ext(mapper.createObjectNode() - .set("prebid", mapper.createObjectNode() - .set("bidder", mapper.valueToTree( - singletonMap("rubicon", singletonMap("siteId", 123)))))) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotInStrings() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-in-strings-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder() - .site(Site.builder() - .domain("lakers.nba.com") - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotIntersectsInteger() throws IOException { - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-intersects-integer-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder() - .user(User.builder() - .ext(ExtUser.builder().data(mapper.valueToTree(singletonMap("someId", asList(123, 456)))) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder().build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotIntersectsSizes() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-intersects-sizes-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder().build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .build()) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotWithin() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-within-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder() - .device(Device.builder() - .geo(Geo.builder() - .lat(50.432069f) - .lon(30.516455f) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotFalseAnd() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-and-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder().build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .build()) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnTrueForNotMatches() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-matches-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder() - .site(Site.builder() - .domain("lakers.uefa.com") - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotTrueOr() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-not-or-definition.json"), "lineItemId"); - - final BidRequest bidRequest = BidRequest.builder().build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .build()) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnTrueForDeviceExt() throws IOException { - // given - final TargetingDefinition targetingDefinition = targetingService.parseTargetingDefinition( - jsonFrom("targeting/test-device-targeting.json"), "lineItemId"); - - final ExtGeo extGeo = ExtGeo.of(); - extGeo.addProperty("geoprovider", mapper.createObjectNode().set("country", new TextNode("us"))); - final ExtDevice extDevice = ExtDevice.empty(); - extDevice.addProperty("deviceinfoprovider", mapper.createObjectNode().set("browser", new TextNode("Chrome"))); - final BidRequest bidRequest = BidRequest.builder() - .device(Device - .builder() - .geo(Geo.builder().ext(extGeo) - .build()) - .ext(extDevice) - .build()).build(); - - final TxnLog txnLog = TxnLog.create(); - - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder().build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)).isTrue(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotInIntegers() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new InIntegers(category(Type.bidderParam, "siteId"), asList(123, 778)))); - - final BidRequest bidRequest = BidRequest.builder() - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .ext(mapper.createObjectNode().set("bidder", mapper.valueToTree(singletonMap("siteId", 123)))) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotInStrings() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new InStrings(category(Type.domain), asList("nba.com", "cnn.com")))); - - final BidRequest bidRequest = BidRequest.builder() - .site(Site.builder() - .domain("nba.com") - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotIntersectsInteger() { - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new IntersectsIntegers(category(Type.userFirstPartyData, "someId"), asList(123, 321)))); - - final BidRequest bidRequest = BidRequest.builder() - .user(User.builder() - .ext(ExtUser.builder().data(mapper.valueToTree(singletonMap("someId", asList(123, 456)))) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder().build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotIntersectsSizes() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new IntersectsSizes(category(Type.size), asList(Size.of(300, 250), Size.of(400, 200))))); - - final BidRequest bidRequest = BidRequest.builder().build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .build()) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotWithin() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new Within(category(Type.location), GeoRegion.of(50.424744f, 30.506435f, 10.0f)))); - - final BidRequest bidRequest = BidRequest.builder() - .device(Device.builder() - .geo(Geo.builder() - .lat(50.432069f) - .lon(30.516455f) - .build()) - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotTrueAnd() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new And(asList( - new IntersectsSizes(category(Type.size), asList(Size.of(300, 250), Size.of(400, 200))), - new IntersectsStrings(category(Type.mediaType), asList("banner", "video")))))); - - final BidRequest bidRequest = BidRequest.builder().build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - .banner(Banner.builder() - .format(asList( - Format.builder().w(300).h(500).build(), - Format.builder().w(300).h(250).build(), - Format.builder().w(400).h(500).build())) - .build()) - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - @Test - public void matchesTargetingShouldReturnFalseForNotMatches() { - // given - final TargetingDefinition targetingDefinition = TargetingDefinition.of( - new Not(new Matches(category(Type.domain), "*nba.com*"))); - - final BidRequest bidRequest = BidRequest.builder() - .site(Site.builder() - .domain("lakers.nba.com") - .build()) - .build(); - - final TxnLog txnLog = TxnLog.create(); - final AuctionContext auctionContext = AuctionContext.builder().txnLog(txnLog).build(); - - final Imp imp = Imp.builder() - - .build(); - - // when and then - assertThat(targetingService.matchesTargeting(bidRequest, imp, targetingDefinition, auctionContext)) - .isFalse(); - } - - private static JsonNode jsonFrom(String file) throws IOException { - return mapper.readTree(TargetingServiceTest.class.getResourceAsStream(file)); - } - - private static TargetingCategory category(Type type) { - return new TargetingCategory(type); - } - - private static TargetingCategory category(Type type, String path) { - return new TargetingCategory(type, path); - } -} diff --git a/src/test/java/org/prebid/server/deals/UserAdditionalInfoServiceTest.java b/src/test/java/org/prebid/server/deals/UserAdditionalInfoServiceTest.java deleted file mode 100644 index c11d278412f..00000000000 --- a/src/test/java/org/prebid/server/deals/UserAdditionalInfoServiceTest.java +++ /dev/null @@ -1,507 +0,0 @@ -package org.prebid.server.deals; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Data; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Segment; -import com.iab.openrtb.request.User; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.auction.model.TimeoutContext; -import org.prebid.server.deals.deviceinfo.DeviceInfoService; -import org.prebid.server.deals.model.DeviceInfo; -import org.prebid.server.deals.model.UserData; -import org.prebid.server.deals.model.UserDetails; -import org.prebid.server.geolocation.GeoLocationService; -import org.prebid.server.geolocation.model.GeoInfo; -import org.prebid.server.log.CriteriaLogManager; -import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtDeviceInt; -import org.prebid.server.proto.openrtb.ext.request.ExtDevicePrebid; -import org.prebid.server.proto.openrtb.ext.request.ExtDeviceVendor; -import org.prebid.server.proto.openrtb.ext.request.ExtGeo; -import org.prebid.server.proto.openrtb.ext.request.ExtGeoVendor; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.request.ExtUserTime; -import org.prebid.server.settings.model.Account; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.util.ArrayList; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class UserAdditionalInfoServiceTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private LineItemService lineItemService; - - @Mock - private DeviceInfoService deviceInfoService; - - @Mock - private GeoLocationService geoLocationService; - - @Mock - private UserService userService; - - @Mock - private CriteriaLogManager criteriaLogManager; - - private UserAdditionalInfoService userAdditionalInfoService; - - private static final Clock CLOCK = Clock.fixed(Instant.parse("2019-10-10T00:01:00Z"), ZoneOffset.UTC); - - @Before - public void setUp() { - given(lineItemService.accountHasDeals(any())).willReturn(true); - - given(deviceInfoService.getDeviceInfo(any())) - .willReturn(Future.failedFuture("deviceInfoService error")); - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.failedFuture("geoLocationService error")); - given(userService.getUserDetails(any(), any())) - .willReturn(Future.failedFuture("userService error")); - - userAdditionalInfoService = new UserAdditionalInfoService( - lineItemService, - deviceInfoService, - geoLocationService, - userService, - CLOCK, - jacksonMapper, - criteriaLogManager); - } - - @Test - public void populateShouldReturnOriginalContextIfAccountHasNoDeals() { - // given - given(lineItemService.accountHasDeals(any())).willReturn(false); - - final AuctionContext auctionContext = AuctionContext.builder() - .account(givenAccount(identity())) - .bidRequest(givenBidRequest(identity())) - .build(); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result).isSameAs(auctionContext); - } - - @Test - public void populateShouldPopulateDevice() { - // given - given(deviceInfoService.getDeviceInfo(any())) - .willReturn(Future.succeededFuture(DeviceInfo.builder() - .vendor("vendor") - .deviceTypeRaw("mobile") - .os("os") - .osVersion("osVersion") - .browser("browser") - .browserVersion("browserVersion") - .language("ENG") - .carrier("AT&T") - .manufacturer("Apple") - .model("iPhone 8") - .build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder() - .ip("ip") - .ua("ua") - .ext(ExtDevice.of(null, ExtDevicePrebid.of(ExtDeviceInt.of(640, 480)))) - .build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - final ExtDevice expectedExtDevice = ExtDevice.of(null, ExtDevicePrebid.of(ExtDeviceInt.of(640, 480))); - expectedExtDevice.addProperty("vendor", mapper.valueToTree(ExtDeviceVendor.builder() - .type("mobile") - .os("os") - .osver("osVersion") - .browser("browser") - .browserver("browserVersion") - .make("Apple") - .model("iPhone 8") - .language("ENG") - .carrier("AT&T") - .build())); - assertThat(result.getBidRequest().getDevice()).isEqualTo(Device.builder() - .ip("ip") - .ua("ua") - .ext(expectedExtDevice) - .build()); - } - - @Test - public void populateShouldPopulateDeviceGeo() { - // given - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.succeededFuture(GeoInfo.builder() - .vendor("vendor") - .continent("continent") - .country("country") - .region("region") - .regionCode(1) - .city("city") - .metroGoogle("metroGoogle") - .metroNielsen(516) - .zip("12345") - .connectionSpeed("broadband") - .lat(11.11F) - .lon(22.22F) - .build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder() - .geo(Geo.builder().zip("zip").build()) - .build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - final ExtGeo expectedExtGeo = ExtGeo.of(); - expectedExtGeo.addProperty("vendor", mapper.valueToTree(ExtGeoVendor.builder() - .continent("continent") - .country("country") - .region(1) - .metro(516) - .city("city") - .zip("12345") - .build())); - final ExtDevice expectedDevice = ExtDevice.of(null, null); - expectedDevice.addProperty("vendor", mapper.valueToTree(ExtDeviceVendor.builder() - .connspeed("broadband") - .build())); - assertThat(result.getBidRequest().getDevice()).isEqualTo(Device.builder() - .geo(Geo.builder() - .zip("zip") - .country("country") - .region("region") - .metro("metroGoogle") - .lat(11.11F) - .lon(22.22F) - .ext(expectedExtGeo) - .build()) - .ext(expectedDevice) - .build()); - } - - @Test - public void populateShouldPopulateUserWithUserDetails() { - // given - given(userService.getUserDetails(any(), any())) - .willReturn(Future.succeededFuture(UserDetails.of( - singletonList(UserData.of( - null, - "rubicon", - singletonList(org.prebid.server.deals.model.Segment.of("segmentId")))), - singletonList("fcapId")))); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ip("ip").ua("ua").build()) - .user(User.builder() - .consent("consent") - .build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getUser()).isEqualTo(User.builder() - .data(singletonList(Data.builder() - .id("rubicon") - .segment(singletonList(Segment.builder().id("segmentId").build())) - .build())) - .consent("consent") - .ext(ExtUser.builder() - .fcapIds(singletonList("fcapId")) - .time(ExtUserTime.of(5, 0)) - .build()) - .build()); - } - - @Test - public void populateShouldUseForGeoLocationIpV6IfIpV4IsNotDefined() { - // given - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ipv6("ipv6").build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - userAdditionalInfoService.populate(auctionContext).result(); - - // then - verify(geoLocationService).lookup(eq("ipv6"), any()); - } - - @Test - public void populateShouldPopulateUserExtWithGeoInfo() { - // given - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.succeededFuture(GeoInfo.builder() - .vendor("vendor") - .timeZone(ZoneId.of("America/Los_Angeles")) - .build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ip("ip").ua("ua").build()) - .user(User.builder().consent("consent").build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getUser()).isEqualTo(User.builder() - .consent("consent") - .ext(ExtUser.builder().time(ExtUserTime.of(4, 17)).build()) - .build()); - } - - @Test - public void populateShouldPopulateUserExtWithGeoInfoIfTimeZoneIsMissing() { - // given - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.succeededFuture(GeoInfo.builder().vendor("vendor").build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ip("ip").ua("ua").build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getUser()).isEqualTo(User.builder() - .ext(ExtUser.builder().time(ExtUserTime.of(5, 0)).build()) - .build()); - } - - @Test - public void populateShouldPopulateUserWithEmptyCappedIds() { - // given - given(userService.getUserDetails(any(), any())) - .willReturn(Future.succeededFuture(UserDetails.of(null, null))); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ip("ip").ua("ua").build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getUser()).isEqualTo(User.builder() - .ext(ExtUser.builder() - .fcapIds(emptyList()) - .time(ExtUserTime.of(5, 0)) - .build()) - .build()); - } - - @Test - public void populateShouldPopulateUserWithNullCappedIds() { - // given - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().ip("ip").ua("ua").build()) - .user(User.builder().consent("consent").build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getUser()).isEqualTo(User.builder() - .consent("consent") - .ext(ExtUser.builder().time(ExtUserTime.of(5, 0)).build()) - .build()); - } - - @Test - public void populateShouldNotPopulateDeviceGeoIfGeolocationServiceIsNotDefined() { - // given - userAdditionalInfoService = new UserAdditionalInfoService( - lineItemService, - deviceInfoService, - null, - userService, - CLOCK, - jacksonMapper, - criteriaLogManager); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().build())); - - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getBidRequest().getDevice().getGeo()).isNull(); - } - - @Test - public void populateShouldCreateExtDeviceIfDeviceInfoIsNotEmptyAndExtDidNotExistBefore() { - // given - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.succeededFuture(GeoInfo.builder().vendor("geoVendor").build())); - - given(deviceInfoService.getDeviceInfo(any())) - .willReturn(Future.succeededFuture(DeviceInfo.builder() - .vendor("deviceVendor") - .browser("browser") - .build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().build())); - - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - final ExtDevice expectedExtDevice = ExtDevice.of(null, null); - expectedExtDevice.addProperty( - "deviceVendor", mapper.valueToTree(ExtDeviceVendor.builder().browser("browser").build())); - assertThat(result.getBidRequest().getDevice().getExt()).isEqualTo(expectedExtDevice); - } - - @Test - public void populateShouldCreateExtDeviceIfGeoInfoIsNotEmptyAndExtDidNotExistBefore() { - // given - given(geoLocationService.lookup(any(), any())) - .willReturn(Future.succeededFuture(GeoInfo.builder() - .vendor("geoVendor") - .connectionSpeed("100") - .continent("continent") - .build())); - - given(deviceInfoService.getDeviceInfo(any())) - .willReturn(Future.succeededFuture(DeviceInfo.builder().vendor("deviceVendor").build())); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().build())); - - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - final ExtDevice expectedExtDevice = ExtDevice.of(null, null); - expectedExtDevice.addProperty( - "geoVendor", mapper.valueToTree(ExtDeviceVendor.builder().connspeed("100").build())); - assertThat(result.getBidRequest().getDevice().getExt()).isEqualTo(expectedExtDevice); - } - - @Test - public void populateShouldUseGeoInfoFromContext() { - // given - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().build())); - final GeoInfo geoInfo = GeoInfo.builder() - .vendor("vendor") - .city("city") - .build(); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())).toBuilder() - .geoInfo(geoInfo) - .build(); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - final ExtGeo expectedExtGeo = ExtGeo.of(); - expectedExtGeo.addProperty("vendor", mapper.valueToTree(ExtGeoVendor.builder().city("city").build())); - assertThat(result.getBidRequest().getDevice()).isEqualTo(Device.builder() - .geo(Geo.builder().ext(expectedExtGeo).build()) - .build()); - verifyNoInteractions(geoLocationService); - assertThat(result.getGeoInfo()).isSameAs(geoInfo); - } - - @Test - public void populateShouldStoreGeoInfoInContext() { - // given - final GeoInfo geoInfo = GeoInfo.builder() - .vendor("vendor") - .city("city") - .build(); - given(geoLocationService.lookup(any(), any())).willReturn(Future.succeededFuture(geoInfo)); - - final BidRequest bidRequest = givenBidRequest(builder -> builder - .imp(singletonList(Imp.builder().ext(mapper.createObjectNode()).build())) - .device(Device.builder().build())); - final AuctionContext auctionContext = givenAuctionContext(bidRequest, givenAccount(identity())); - - // when - final AuctionContext result = userAdditionalInfoService.populate(auctionContext).result(); - - // then - assertThat(result.getGeoInfo()).isSameAs(geoInfo); - } - - private static BidRequest givenBidRequest(UnaryOperator customizer) { - return customizer.apply(BidRequest.builder()).build(); - } - - private static Account givenAccount(Function customizer) { - return customizer.apply(Account.builder().id("accountId")).build(); - } - - private static AuctionContext givenAuctionContext(BidRequest bidRequest, Account account) { - return AuctionContext.builder() - .bidRequest(bidRequest) - .account(account) - .timeoutContext(TimeoutContext.of(0, null, 0)) - .debugWarnings(new ArrayList<>()) - .build(); - } -} diff --git a/src/test/java/org/prebid/server/deals/UserServiceTest.java b/src/test/java/org/prebid/server/deals/UserServiceTest.java deleted file mode 100644 index 241e00d99d4..00000000000 --- a/src/test/java/org/prebid/server/deals/UserServiceTest.java +++ /dev/null @@ -1,596 +0,0 @@ -package org.prebid.server.deals; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.cache.model.CacheHttpRequest; -import org.prebid.server.cache.model.DebugHttpCall; -import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.cookie.model.UidWithExpiry; -import org.prebid.server.cookie.proto.Uids; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.model.ExtUser; -import org.prebid.server.deals.model.Segment; -import org.prebid.server.deals.model.User; -import org.prebid.server.deals.model.UserData; -import org.prebid.server.deals.model.UserDetails; -import org.prebid.server.deals.model.UserDetailsProperties; -import org.prebid.server.deals.model.UserDetailsRequest; -import org.prebid.server.deals.model.UserDetailsResponse; -import org.prebid.server.deals.model.UserId; -import org.prebid.server.deals.model.UserIdRule; -import org.prebid.server.deals.model.WinEventNotification; -import org.prebid.server.deals.proto.FrequencyCap; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.execution.Timeout; -import org.prebid.server.execution.TimeoutFactory; -import org.prebid.server.metric.MetricName; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; - -import java.io.IOException; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.TimeoutException; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class UserServiceTest extends VertxTest { - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String USER_DETAILS_ENDPOINT = "http://user-data.com"; - private static final String WIN_EVENT_ENDPOINT = "http://win-event.com"; - private static final String DATA_CENTER_REGION = "region"; - private static final long CONFIG_TIMEOUT = 300L; - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private LineItemService lineItemService; - @Mock - private HttpClient httpClient; - @Mock - private Metrics metrics; - - private List userIdRules; - private Clock clock; - - private UserService userService; - - private UidsCookie uidsCookie; - private AuctionContext auctionContext; - private Timeout timeout; - private ZonedDateTime now; - - @Before - public void setUp() { - clock = Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC); - now = ZonedDateTime.now(clock); - userIdRules = singletonList(UserIdRule.of("khaos", "uid", "rubicon")); - - userService = new UserService( - UserDetailsProperties.of(USER_DETAILS_ENDPOINT, WIN_EVENT_ENDPOINT, CONFIG_TIMEOUT, userIdRules), - DATA_CENTER_REGION, - lineItemService, - httpClient, - clock, - metrics, - jacksonMapper); - - uidsCookie = new UidsCookie(Uids.builder() - .uids(singletonMap("rubicon", new UidWithExpiry("uid", null))) - .build(), jacksonMapper); - auctionContext = AuctionContext.builder().uidsCookie(uidsCookie).debugHttpCalls(new HashMap<>()).build(); - - timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(500L); - } - - @Test - public void getUserDetailsShouldReturnEmptyUserDetailsWhenUidsAreEmpty() { - // given - final UidsCookie uidsCookie = new UidsCookie(Uids.builder().uids(emptyMap()).build(), jacksonMapper); - final AuctionContext context = AuctionContext.builder().uidsCookie(uidsCookie) - .debugHttpCalls(new HashMap<>()).build(); - - // when - final UserDetails result = userService.getUserDetails(context, timeout).result(); - - // then - verify(metrics).updateUserDetailsRequestPreparationFailed(); - verifyNoInteractions(httpClient); - - assertEquals(UserDetails.empty(), result); - } - - @Test - public void getUserDetailsShouldReturnReturnEmptyUserDetailsWhenUidsDoesNotContainRuleLocation() { - // given - final List ruleWithMissingLocation = singletonList( - UserIdRule.of("khaos", "uid", "bad_location")); - - userService = new UserService( - UserDetailsProperties.of( - USER_DETAILS_ENDPOINT, WIN_EVENT_ENDPOINT, CONFIG_TIMEOUT, ruleWithMissingLocation), - DATA_CENTER_REGION, - lineItemService, - httpClient, - clock, - metrics, - jacksonMapper); - - // when - final UserDetails result = userService.getUserDetails(auctionContext, timeout).result(); - - // then - verify(metrics).updateUserDetailsRequestPreparationFailed(); - verifyNoInteractions(httpClient); - - assertEquals(UserDetails.empty(), result); - } - - @Test - public void getUserDetailsShouldSendPostRequestWithExpectedParameters() throws IOException { - // given - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn(Future.failedFuture("something")); - - // when - userService.getUserDetails(auctionContext, timeout); - - // then - final ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - verify(httpClient).post(eq(USER_DETAILS_ENDPOINT), captor.capture(), eq(CONFIG_TIMEOUT)); - - final UserDetailsRequest capturedRequest = mapper.readValue(captor.getValue(), UserDetailsRequest.class); - - assertThat(ZonedDateTime.parse(capturedRequest.getTime())).isEqualTo(UTC_MILLIS_FORMATTER.format(now)); - assertThat(capturedRequest.getIds()).hasSize(1) - .containsOnly(UserId.of("khaos", "uid")); - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - } - - @Test - public void getUserDetailsShouldUseRemainingGlobalTimeoutIfTimeoutFromConfigurationIsGreaterThanRemaining() { - // given - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn(Future.failedFuture("something")); - - userService = new UserService( - UserDetailsProperties.of(USER_DETAILS_ENDPOINT, WIN_EVENT_ENDPOINT, 600L, userIdRules), - DATA_CENTER_REGION, - lineItemService, - httpClient, - clock, - metrics, - jacksonMapper); - - // when - userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - verify(httpClient).post(anyString(), anyString(), eq(500L)); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenResponseStatusIsNotOk() { - // given - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(400, null, null))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - verify(httpClient).post(eq(USER_DETAILS_ENDPOINT), anyString(), eq(CONFIG_TIMEOUT)); - - assertTrue(result.failed()); - assertThat(result.cause()) - .isInstanceOf(PreBidException.class) - .hasMessage("Bad response status code: 400"); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenErrorOccurs() { - // given - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("Timeout has been exceeded"))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - verify(httpClient).post(eq(USER_DETAILS_ENDPOINT), anyString(), eq(CONFIG_TIMEOUT)); - - assertTrue(result.failed()); - assertThat(result.cause()) - .isInstanceOf(TimeoutException.class) - .hasMessage("Timeout has been exceeded"); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenResponseBodyDecodingFails() { - // given - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, "invalid_body"))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - verify(httpClient).post(eq(USER_DETAILS_ENDPOINT), anyString(), eq(CONFIG_TIMEOUT)); - - assertTrue(result.failed()); - assertThat(result.cause()) - .isInstanceOf(PreBidException.class) - .hasMessage("Cannot parse response: invalid_body"); - } - - @Test - public void getUserDetailsShouldReturnExpectedResult() { - // given - final UserDetailsResponse response = UserDetailsResponse.of(User.of( - asList( - UserData.of("1", "rubicon", asList(Segment.of("2222"), Segment.of("3333"))), - UserData.of("2", "bluekai", asList(Segment.of("5555"), Segment.of("6666")))), - ExtUser.of(asList("L-1111", "O-2222")))); - - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn( - Future.succeededFuture(HttpClientResponse.of(200, null, jacksonMapper.encodeToString(response)))); - - // when - final UserDetails result = userService.getUserDetails(auctionContext, timeout).result(); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(true)); - verify(metrics).updateRequestTimeMetric(eq(MetricName.user_details_request_time), anyLong()); - verify(httpClient).post(eq(USER_DETAILS_ENDPOINT), anyString(), eq(CONFIG_TIMEOUT)); - - final UserDetails expectedDetails = UserDetails.of( - asList(UserData.of("1", "rubicon", asList(Segment.of("2222"), Segment.of("3333"))), - UserData.of("2", "bluekai", asList(Segment.of("5555"), Segment.of("6666")))), - asList("L-1111", "O-2222")); - - assertEquals(expectedDetails, result); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenUserInResponseIsNull() { - // given - final UserDetailsResponse response = UserDetailsResponse.of(null); - - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn( - Future.succeededFuture(HttpClientResponse.of(200, null, jacksonMapper.encodeToString(response)))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - assertThat(result.failed()).isTrue(); - assertThat(result.cause()).isInstanceOf(PreBidException.class) - .hasMessage("Field 'user' is missing in response: {}"); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenUserDataInResponseIsNull() { - // given - final UserDetailsResponse response = UserDetailsResponse.of(User.of( - null, ExtUser.of(asList("L-1111", "O-2222")))); - - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn( - Future.succeededFuture(HttpClientResponse.of(200, null, jacksonMapper.encodeToString(response)))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - assertThat(result.failed()).isTrue(); - assertThat(result.cause()).isInstanceOf(PreBidException.class) - .hasMessage("Field 'user.data' is missing in response: {\"user\":{\"ext\":{\"fcapIds\":[\"L-1111\"," - + "\"O-2222\"]}}}"); - } - - @Test - public void getUserDetailsShouldReturnFailedFutureWhenExtUserInResponseIsNull() { - // given - final UserDetailsResponse response = UserDetailsResponse.of(User.of( - singletonList(UserData.of("2", "bluekai", singletonList(Segment.of("6666")))), null)); - - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn( - Future.succeededFuture(HttpClientResponse.of(200, null, jacksonMapper.encodeToString(response)))); - - // when - final Future result = userService.getUserDetails(auctionContext, timeout); - - // then - verify(metrics).updateUserDetailsRequestMetric(eq(false)); - assertThat(result.failed()).isTrue(); - assertThat(result.cause()).isInstanceOf(PreBidException.class) - .hasMessage("Field 'user.ext' is missing in response: {\"user\":{\"data\":[{\"id\":\"2\",\"name\":" - + "\"bluekai\",\"segment\":[{\"id\":\"6666\"}]}]}}"); - } - - @Test - public void getUserDetailsShouldAddEmptyCachedHttpCallWhenUidsAreNotDefined() { - // given - final UidsCookie uidsCookie = new UidsCookie(Uids.builder().uids(emptyMap()).build(), jacksonMapper); - final AuctionContext context = AuctionContext.builder().uidsCookie(uidsCookie) - .debugHttpCalls(new HashMap<>()).build(); - - // when - userService.getUserDetails(context, timeout).result(); - - // then - assertThat(context.getDebugHttpCalls()).hasSize(1) - .containsEntry("userservice", singletonList(DebugHttpCall.empty())); - } - - @Test - public void getUserDetailsShouldAddEmptyCachedHttpCallWhenUserIdsAreNotDefined() { - // given - final List ruleWithMissingLocation = singletonList( - UserIdRule.of("khaos", "uid", "bad_location")); - - userService = new UserService( - UserDetailsProperties.of( - USER_DETAILS_ENDPOINT, WIN_EVENT_ENDPOINT, CONFIG_TIMEOUT, ruleWithMissingLocation), - DATA_CENTER_REGION, - lineItemService, - httpClient, - clock, - metrics, - jacksonMapper); - - // when - userService.getUserDetails(auctionContext, timeout).result(); - - // then - assertThat(auctionContext.getDebugHttpCalls()).hasSize(1) - .containsEntry("userservice", singletonList(DebugHttpCall.empty())); - } - - @Test - public void getUserDetailsShouldAddCachedHttpCallWhenThrowsPrebidException() throws JsonProcessingException { - // given - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, "invalid_body"))); - - // when - userService.getUserDetails(auctionContext, timeout); - - // then - assertThat(auctionContext.getDebugHttpCalls()).hasSize(1) - .containsEntry("userservice", singletonList(DebugHttpCall.builder() - .requestUri("http://user-data.com") - .requestBody(mapper.writeValueAsString(UserDetailsRequest.of(UTC_MILLIS_FORMATTER.format(now), - singletonList(UserId.of("khaos", "uid"))))) - .responseStatus(200) - .responseBody("invalid_body") - .responseTimeMillis(0) - .build())); - } - - @Test - public void getUserDetailsShouldAddCachedHttpCallWhenCallCompletesSuccessful() throws JsonProcessingException { - // given - final UserDetailsResponse response = UserDetailsResponse.of(User.of( - singletonList( - UserData.of("1", "rubicon", asList(Segment.of("2222"), Segment.of("3333")))), - ExtUser.of(asList("L-1111", "O-2222")))); - - given(httpClient.post(anyString(), anyString(), anyLong())).willReturn( - Future.succeededFuture(HttpClientResponse.of(200, null, jacksonMapper.encodeToString(response)))); - - // when - userService.getUserDetails(auctionContext, timeout).result(); - - CacheHttpRequest.of("http://user-data.com", - mapper.writeValueAsString(UserDetailsRequest.of(UTC_MILLIS_FORMATTER.format(now), - singletonList(UserId.of("khaos", "uid"))))); - - // then - assertThat(auctionContext.getDebugHttpCalls()).hasSize(1) - .containsEntry("userservice", singletonList(DebugHttpCall.builder() - .requestUri("http://user-data.com") - .requestBody(mapper.writeValueAsString(UserDetailsRequest.of(UTC_MILLIS_FORMATTER.format(now), - singletonList(UserId.of("khaos", "uid"))))) - .responseStatus(200) - .responseBody(mapper.writeValueAsString( - UserDetailsResponse.of(User.of(singletonList(UserData.of("1", "rubicon", - asList(Segment.of("2222"), Segment.of("3333")))), - ExtUser.of(asList("L-1111", "O-2222")))))) - .responseTimeMillis(0) - .build())); - } - - @Test - public void getUserDetailsShouldAddCachedHttpCallWhenCallFailed() throws JsonProcessingException { - // given - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(400, null, null))); - - // when - userService.getUserDetails(auctionContext, timeout); - - // then - assertThat(auctionContext.getDebugHttpCalls()).hasSize(1) - .containsEntry("userservice", singletonList(DebugHttpCall.builder() - .requestUri("http://user-data.com") - .requestBody(mapper.writeValueAsString(UserDetailsRequest.of(UTC_MILLIS_FORMATTER.format(now), - singletonList(UserId.of("khaos", "uid"))))) - .responseTimeMillis(0) - .build())); - } - - @Test - public void processWinEventShouldCallMetricsPreparationFailedMetricWhenHttpClientWhenMetaDataIsMissing() { - // given - given(lineItemService.getLineItemById(any())).willReturn( - null, - LineItem.of(LineItemMetaData.builder().build(), null, null, ZonedDateTime.now(clock))); - - // when - userService.processWinEvent("lineItem1", "bidId", uidsCookie); - - // then - verify(metrics).updateWinRequestPreparationFailed(); - verifyNoInteractions(httpClient); - } - - @Test - public void processWinEventShouldCallMetricsPreparationFailedMetricWhenHttpClientWhenUserIdsAreMissing() { - // given - final List frequencyCaps = singletonList(FrequencyCap.builder().fcapId("213").build()); - final UidsCookie emptyCookie = new UidsCookie(Uids.builder().uids(emptyMap()).build(), jacksonMapper); - - given(lineItemService.getLineItemById(any())).willReturn(LineItem.of( - LineItemMetaData.builder() - .source("rubicon") - .updatedTimeStamp(now) - .frequencyCaps(frequencyCaps) - .build(), - null, null, ZonedDateTime.now(clock))); - - // when - userService.processWinEvent("lineItem1", "bidId", emptyCookie); - - // then - verify(metrics).updateWinRequestPreparationFailed(); - verifyNoInteractions(httpClient); - } - - @Test - public void processWinEventShouldCallMetricsWinRequestWithFalseWhenStatusIsNot200() { - // given - final List frequencyCaps = singletonList(FrequencyCap.builder().fcapId("213").build()); - - given(lineItemService.getLineItemById(any())).willReturn(LineItem.of( - LineItemMetaData.builder() - .source("rubicon") - .updatedTimeStamp(now) - .frequencyCaps(frequencyCaps) - .build(), - null, null, ZonedDateTime.now(clock))); - - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(400, null, null))); - - // when - userService.processWinEvent("lineItem1", "bidId", uidsCookie); - - // then - verify(metrics).updateWinEventRequestMetric(eq(false)); - verify(metrics).updateWinRequestTime(anyLong()); - } - - @Test - public void processWinEventShouldCallMetricsWinRequestWithFalseWhenFailedFuture() { - // given - final List frequencyCaps = singletonList(FrequencyCap.builder().fcapId("213").build()); - - given(lineItemService.getLineItemById(any())).willReturn(LineItem.of( - LineItemMetaData.builder() - .source("rubicon") - .updatedTimeStamp(now) - .frequencyCaps(frequencyCaps) - .build(), - null, null, ZonedDateTime.now(clock))); - - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("timeout"))); - - // when - userService.processWinEvent("lineItem1", "bidId", uidsCookie); - - // then - verify(metrics).updateWinEventRequestMetric(eq(false)); - verify(metrics).updateWinRequestTime(anyLong()); - } - - @Test - public void processWinEventShouldCallExpectedServicesWithExpectedParameters() throws IOException { - // given - final List frequencyCaps = singletonList(FrequencyCap.builder().fcapId("213").build()); - - given(lineItemService.getLineItemById(any())).willReturn(LineItem.of( - LineItemMetaData.builder() - .source("rubicon") - .updatedTimeStamp(now) - .frequencyCaps(frequencyCaps) - .build(), - null, null, ZonedDateTime.now(clock))); - - given(httpClient.post(anyString(), anyString(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, null))); - - // when - userService.processWinEvent("lineItem1", "bidId", uidsCookie); - - // then - verify(lineItemService).getLineItemById(eq("lineItem1")); - verify(metrics).updateWinNotificationMetric(); - verify(metrics).updateWinEventRequestMetric(eq(true)); - verify(metrics).updateWinRequestTime(anyLong()); - final ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - verify(httpClient).post(eq(WIN_EVENT_ENDPOINT), captor.capture(), eq(CONFIG_TIMEOUT)); - - final WinEventNotification capturedRequest = mapper.readValue(captor.getValue(), WinEventNotification.class); - assertThat(capturedRequest.getWinEventDateTime()).isEqualTo(UTC_MILLIS_FORMATTER.format(now)); - - final WinEventNotification expectedRequestWithoutWinTime = WinEventNotification.builder() - .bidderCode("rubicon") - .bidId("bidId") - .lineItemId("lineItem1") - .region(DATA_CENTER_REGION) - .userIds(singletonList(UserId.of("khaos", "uid"))) - .lineUpdatedDateTime(now) - .frequencyCaps(frequencyCaps) - .build(); - - assertThat(capturedRequest) - .usingRecursiveComparison() - .ignoringFields("winEventDateTime") - .isEqualTo(expectedRequestWithoutWinTime); - } -} diff --git a/src/test/java/org/prebid/server/deals/events/AdminEventServiceTest.java b/src/test/java/org/prebid/server/deals/events/AdminEventServiceTest.java deleted file mode 100644 index 98ef9e34f94..00000000000 --- a/src/test/java/org/prebid/server/deals/events/AdminEventServiceTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.deals.events; - -import io.vertx.core.Context; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.eventbus.EventBus; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.junit.VertxUnitRunner; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.deals.model.AdminCentralResponse; -import org.prebid.server.vertx.LocalMessageCodec; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(VertxUnitRunner.class) -public class AdminEventServiceTest { - - private Vertx vertx; - private EventBus eventBus; - - @Before - public void setUp(TestContext context) { - vertx = Vertx.vertx(); - vertx.exceptionHandler(context.exceptionHandler()); - - eventBus = vertx.eventBus(); - eventBus.registerCodec(LocalMessageCodec.create()); - } - - @After - public void tearDown(TestContext context) { - vertx.close(context.asyncAssertSuccess()); - } - - @Test - public void publishAuctionEventShouldPassEventToAllRecorders(TestContext testContext) { - // given - final Context initContext = vertx.getOrCreateContext(); - final Context publishContext = vertx.getOrCreateContext(); - - final AdminCentralResponse adminCentralResponse = AdminCentralResponse.of(null, null, null, null, null, null); - - final Handler consumeHandler = event -> { - // then - assertThat(event).isSameAs(adminCentralResponse); - assertThat(Vertx.currentContext()).isSameAs(initContext); - }; - - final AdminEventService adminEventService = new AdminEventService(eventBus); - final EventServiceInitializer eventServiceInitializer = new EventServiceInitializer( - emptyList(), singletonList(new ProcessorStub(consumeHandler)), eventBus); - - // when - final Async initAsync = testContext.async(); - initContext.runOnContext(ignored -> { - eventServiceInitializer.initialize(); - initAsync.complete(); - }); - initAsync.await(); - - publishContext.runOnContext(ignored -> adminEventService.publishAdminCentralEvent(adminCentralResponse)); - } - - private static class ProcessorStub implements AdminEventProcessor { - - private final Handler handler; - - ProcessorStub(Handler handler) { - this.handler = handler; - } - - @Override - public void processAdminCentralEvent(AdminCentralResponse adminCentralResponse) { - handler.handle(adminCentralResponse); - } - } -} diff --git a/src/test/java/org/prebid/server/deals/events/ApplicationEventServiceTest.java b/src/test/java/org/prebid/server/deals/events/ApplicationEventServiceTest.java deleted file mode 100644 index 4aeae4e52d8..00000000000 --- a/src/test/java/org/prebid/server/deals/events/ApplicationEventServiceTest.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.prebid.server.deals.events; - -import io.vertx.core.Context; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.eventbus.EventBus; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.junit.VertxUnitRunner; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.auction.model.AuctionContext; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.vertx.LocalMessageCodec; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(VertxUnitRunner.class) -public class ApplicationEventServiceTest { - - private Vertx vertx; - private EventBus eventBus; - - @Before - public void setUp(TestContext context) { - vertx = Vertx.vertx(); - vertx.exceptionHandler(context.exceptionHandler()); - - eventBus = vertx.eventBus(); - eventBus.registerCodec(LocalMessageCodec.create()); - } - - @After - public void tearDown(TestContext context) { - vertx.close(context.asyncAssertSuccess()); - } - - @Test - public void publishAuctionEventShouldPassEventToAllRecorders(TestContext testContext) { - // given - final Context initContext = vertx.getOrCreateContext(); - final Context publishContext = vertx.getOrCreateContext(); - - final AuctionContext auctionContext = AuctionContext.builder().txnLog(TxnLog.create()).build(); - - final Async async = testContext.async(2); - final Handler consumeHandler = event -> { - // then - assertThat(event).isSameAs(auctionContext); - assertThat(Vertx.currentContext()).isSameAs(initContext); - async.countDown(); - }; - - final ApplicationEventService applicationEventService = new ApplicationEventService(eventBus); - final EventServiceInitializer eventServiceInitializer = new EventServiceInitializer( - asList(new ProcessorStub(consumeHandler), new ProcessorStub(consumeHandler)), emptyList(), eventBus); - - // when - final Async initAsync = testContext.async(); - initContext.runOnContext(ignored -> { - eventServiceInitializer.initialize(); - initAsync.complete(); - }); - initAsync.await(); - - publishContext.runOnContext(ignored -> applicationEventService.publishAuctionEvent(auctionContext)); - } - - @Test - public void publishLineItemWinEventShouldPassEventToAllRecorders(TestContext testContext) { - // given - final Context initContext = vertx.getOrCreateContext(); - final Context publishContext = vertx.getOrCreateContext(); - - final String lineItemId = "lineItemId1"; - - final Async async = testContext.async(2); - final Handler consumeHandler = event -> { - // then - assertThat(event).isSameAs(lineItemId); - assertThat(Vertx.currentContext()).isSameAs(initContext); - async.countDown(); - }; - - final ApplicationEventService applicationEventService = new ApplicationEventService(eventBus); - final EventServiceInitializer eventServiceInitializer = new EventServiceInitializer( - asList(new ProcessorStub(consumeHandler), new ProcessorStub(consumeHandler)), emptyList(), eventBus); - - // when - final Async initAsync = testContext.async(); - initContext.runOnContext(ignored -> { - eventServiceInitializer.initialize(); - initAsync.complete(); - }); - initAsync.await(); - - publishContext.runOnContext(ignored -> applicationEventService.publishLineItemWinEvent(lineItemId)); - } - - @Test - public void publishDeliveryProgressUpdateEventShouldPassEventToAllRecorders(TestContext testContext) { - // given - final Context initContext = vertx.getOrCreateContext(); - final Context publishContext = vertx.getOrCreateContext(); - - final Async async = testContext.async(2); - final Handler consumeHandler = event -> { - // then - assertThat(event).isSameAs(null); - assertThat(Vertx.currentContext()).isSameAs(initContext); - async.countDown(); - }; - - final ApplicationEventService applicationEventService = new ApplicationEventService(eventBus); - final EventServiceInitializer eventServiceInitializer = new EventServiceInitializer( - asList(new ProcessorStub(consumeHandler), new ProcessorStub(consumeHandler)), emptyList(), eventBus); - - // when - final Async initAsync = testContext.async(); - initContext.runOnContext(ignored -> { - eventServiceInitializer.initialize(); - initAsync.complete(); - }); - initAsync.await(); - - publishContext.runOnContext(ignored -> applicationEventService.publishDeliveryUpdateEvent()); - } - - private static class ProcessorStub implements ApplicationEventProcessor { - - private final Handler handler; - - ProcessorStub(Handler handler) { - this.handler = handler; - } - - @Override - public void processAuctionEvent(AuctionContext auctionContext) { - handler.handle(auctionContext); - } - - @Override - public void processLineItemWinEvent(String lineItemId) { - handler.handle(lineItemId); - } - - @Override - public void processDeliveryProgressUpdateEvent() { - handler.handle(null); - } - } -} diff --git a/src/test/java/org/prebid/server/deals/lineitem/DeliveryPlanTest.java b/src/test/java/org/prebid/server/deals/lineitem/DeliveryPlanTest.java deleted file mode 100644 index 1e104f2f8f2..00000000000 --- a/src/test/java/org/prebid/server/deals/lineitem/DeliveryPlanTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import org.junit.Test; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.Token; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.IntStream; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeliveryPlanTest { - - @Test - public void getHighestUnspentTokensClassShouldReturnHighestUnspentToken() { - // given - final Set tokens = new HashSet<>(); - tokens.add(Token.of(1, 100)); - tokens.add(Token.of(2, 100)); - tokens.add(Token.of(3, 100)); - - final DeliveryPlan plan = DeliveryPlan.of(DeliverySchedule.builder().tokens(tokens).build()); - - IntStream.range(0, 150).forEach(i -> plan.incSpentToken()); - - // when and then - assertThat(plan.getHighestUnspentTokensClass()).isEqualTo(2); - } -} diff --git a/src/test/java/org/prebid/server/deals/lineitem/DeliveryProgressTest.java b/src/test/java/org/prebid/server/deals/lineitem/DeliveryProgressTest.java deleted file mode 100644 index bc03de3aa36..00000000000 --- a/src/test/java/org/prebid/server/deals/lineitem/DeliveryProgressTest.java +++ /dev/null @@ -1,365 +0,0 @@ -package org.prebid.server.deals.lineitem; - -import org.assertj.core.groups.Tuple; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.proto.DeliverySchedule; -import org.prebid.server.deals.proto.Token; -import org.prebid.server.deals.proto.report.Event; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static java.util.Collections.singleton; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -public class DeliveryProgressTest extends VertxTest { - - @Rule - public MockitoRule rule = MockitoJUnit.rule(); - - @Mock - private Clock clock; - - @Mock - private LineItemService lineItemService; - - private ZonedDateTime now; - - private DeliveryProgress deliveryProgress; - - @Before - public void setUp() { - now = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC)); - - given(clock.instant()).willReturn(now.toInstant()); - given(clock.getZone()).willReturn(ZoneOffset.UTC); - deliveryProgress = DeliveryProgress.of(now, lineItemService); - } - - @Test - public void cleanLineItemStatusesShouldRemoveOldestCachedPlans() { - // given - final TxnLog txnLog1 = TxnLog.create(); - txnLog1.lineItemSentToClientAsTopMatch().add("lineItemId1"); - - final TxnLog txnLog2 = TxnLog.create(); - txnLog2.lineItemSentToClientAsTopMatch().add("lineItemId1"); - - final TxnLog txnLog3 = TxnLog.create(); - txnLog3.lineItemSentToClientAsTopMatch().add("lineItemId1"); - - final LineItem lineItem1 = Mockito.mock(LineItem.class); - final DeliveryPlan deliveryPlan1 = Mockito.mock(DeliveryPlan.class); - final DeliveryPlan deliveryPlan2 = Mockito.mock(DeliveryPlan.class); - final DeliveryPlan deliveryPlan3 = Mockito.mock(DeliveryPlan.class); - - given(deliveryPlan1.getPlanId()).willReturn("lineItemId1Plan"); - given(deliveryPlan2.getPlanId()).willReturn("lineItemId2Plan"); - given(deliveryPlan3.getPlanId()).willReturn("lineItemId3Plan"); - - given(deliveryPlan1.withoutSpentTokens()).willReturn(deliveryPlan1); - given(deliveryPlan2.withoutSpentTokens()).willReturn(deliveryPlan2); - given(deliveryPlan3.withoutSpentTokens()).willReturn(deliveryPlan3); - - given(deliveryPlan1.getEndTimeStamp()).willReturn(now.minusMinutes(1)); - given(deliveryPlan2.getEndTimeStamp()).willReturn(now.minusMinutes(2)); - given(deliveryPlan3.getEndTimeStamp()).willReturn(now.minusMinutes(3)); - - given(lineItem1.getEndTimeStamp()).willReturn(now.minusMinutes(1)); - given(lineItem1.getActiveDeliveryPlan()).willReturn(deliveryPlan1, deliveryPlan2, deliveryPlan3); - - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(lineItem1); - - // when and then - deliveryProgress.recordTransactionLog(txnLog1, singletonMap("lineItemId1Plan", 1), "1001"); - deliveryProgress.recordTransactionLog(txnLog2, singletonMap("lineItemId2Plan", 1), "1001"); - deliveryProgress.recordTransactionLog(txnLog3, singletonMap("lineItemId3Plan", 1), "1001"); - - // check that 3 lineItemStatuses - assertThat(deliveryProgress.getLineItemStatuses().get("lineItemId1").getDeliveryPlans()) - .hasSize(3) - .extracting(DeliveryPlan::getPlanId) - .containsOnly("lineItemId1Plan", "lineItemId2Plan", "lineItemId3Plan"); - - deliveryProgress.cleanLineItemStatuses(now, 10000000L, 1); - - assertThat(deliveryProgress.getLineItemStatuses().get("lineItemId1").getDeliveryPlans()) - .hasSize(1) - .extracting(DeliveryPlan::getPlanId) - .containsOnly("lineItemId1Plan"); - } - - @Test - public void cleanLineItemStatusesShouldRemoveExpiredLineItemStatuses() { - // given - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemsSentToClient().add("lineItemId1"); - txnLog.lineItemsSentToClient().add("lineItemId2"); - final Map planIdToTokenPriority = new HashMap<>(); - planIdToTokenPriority.put("lineItemId1Plan", 1); - planIdToTokenPriority.put("lineItemId2Plan", 1); - - final LineItem lineItem1 = Mockito.mock(LineItem.class); - final LineItem lineItem2 = Mockito.mock(LineItem.class); - - given(lineItem1.getEndTimeStamp()).willReturn(now.minusHours(1)); - given(lineItem2.getEndTimeStamp()).willReturn(now.minusHours(2)); - - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(lineItem1); - given(lineItemService.getLineItemById(eq("lineItemId2"))).willReturn(lineItem2); - - // when and then - deliveryProgress.recordTransactionLog(txnLog, planIdToTokenPriority, "1001"); - - // check that 2 lineItemStatuses - assertThat(deliveryProgress.getLineItemStatuses().keySet()).hasSize(2) - .containsOnly("lineItemId1", "lineItemId2"); - - deliveryProgress.cleanLineItemStatuses(now, 6000000, 5); - - assertThat(deliveryProgress.getLineItemStatuses().keySet()).hasSize(1) - .containsOnly("lineItemId1"); - } - - @Test - public void fromAnotherCopyingPlansShouldReturnDeliveryProgressWithPlansAndStatistics() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - final TxnLog txnLog = TxnLog.create(); - txnLog.lineItemsMatchedWholeTargeting().add("lineItemId1"); - txnLog.lineItemsMatchedDomainTargeting().add("lineItemId1"); - txnLog.lineItemsReadyToServe().add("lineItemId1"); - txnLog.lineItemsMatchedTargetingFcapped().add("lineItemId1"); - txnLog.lineItemsMatchedTargetingFcapLookupFailed().add("lineItemId1"); - txnLog.lineItemsPacingDeferred().add("lineItemId1"); - txnLog.lineItemsSentToBidder().get("bidder1").add("lineItemId1"); - txnLog.lineItemsSentToBidderAsTopMatch().put("bidder1", singleton("lineItemId1")); - txnLog.lineItemsReceivedFromBidder().get("bidder1").add("lineItemId1"); - txnLog.lineItemsSentToClient().add("lineItemId1"); - txnLog.lineItemSentToClientAsTopMatch().add("lineItemId1"); - txnLog.lostAuctionToLineItems().put("lineItemId1", singleton("lineItemId2")); - txnLog.lostMatchingToLineItems().put("lineItemId1", singleton("lineItemId3")); - - final LineItem lineItem = mock(LineItem.class); - given(lineItemService.getLineItemById("lineItemId1")).willReturn(lineItem); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - - deliveryProgress.recordTransactionLog(txnLog, singletonMap("planId1", 1), "1001"); - - // when - final DeliveryProgress copiedDeliveryProgress = deliveryProgress.copyWithOriginalPlans(); - - // then - final LineItemStatus lineItemStatusCopied = copiedDeliveryProgress.getLineItemStatuses().get("lineItemId1"); - final LineItemStatus lineItemStatusOriginal = deliveryProgress.getLineItemStatuses().get("lineItemId1"); - - assertThat(lineItemStatusCopied).isNotSameAs(lineItemStatusOriginal); - - assertThat(lineItemStatusCopied.getDomainMatched().sum()) - .isEqualTo(lineItemStatusOriginal.getDomainMatched().sum()); - - assertThat(lineItemStatusCopied.getTargetMatched().sum()) - .isEqualTo(lineItemStatusOriginal.getTargetMatched().sum()); - - assertThat(lineItemStatusCopied.getTargetMatchedButFcapped().sum()) - .isEqualTo(lineItemStatusOriginal.getTargetMatchedButFcapped().sum()); - - assertThat(lineItemStatusCopied.getTargetMatchedButFcapLookupFailed().sum()) - .isEqualTo(lineItemStatusOriginal.getTargetMatchedButFcapLookupFailed().sum()); - - assertThat(lineItemStatusCopied.getPacingDeferred().sum()) - .isEqualTo(lineItemStatusOriginal.getPacingDeferred().sum()); - - assertThat(lineItemStatusCopied.getSentToBidder().sum()) - .isEqualTo(lineItemStatusOriginal.getSentToBidder().sum()); - - assertThat(lineItemStatusCopied.getSentToBidderAsTopMatch().sum()) - .isEqualTo(lineItemStatusOriginal.getSentToBidderAsTopMatch().sum()); - - assertThat(lineItemStatusCopied.getReceivedFromBidder().sum()) - .isEqualTo(lineItemStatusOriginal.getReceivedFromBidder().sum()); - - assertThat(lineItemStatusCopied.getReceivedFromBidderInvalidated().sum()) - .isEqualTo(lineItemStatusOriginal.getReceivedFromBidderInvalidated().sum()); - - assertThat(lineItemStatusCopied.getSentToClient().sum()) - .isEqualTo(lineItemStatusOriginal.getSentToClient().sum()); - - assertThat(lineItemStatusCopied.getSentToClientAsTopMatch().sum()) - .isEqualTo(lineItemStatusOriginal.getSentToClientAsTopMatch().sum()); - - assertThat(lineItemStatusCopied.getSentToClientAsTopMatch().sum()) - .isEqualTo(lineItemStatusOriginal.getSentToClientAsTopMatch().sum()); - - assertThat(copiedDeliveryProgress.getLineItemIdToLost().get("lineItemId1").entrySet()) - .extracting(Map.Entry::getKey, entry -> entry.getValue().getCount().sum()) - .containsOnly(Tuple.tuple("lineItemId2", 1L), Tuple.tuple("lineItemId3", 1L)); - - final DeliveryPlan originDeliveryPlan = lineItemStatusOriginal.getDeliveryPlans().stream().findFirst().get(); - final DeliveryPlan copiedDeliveryPlan = lineItemStatusCopied.getDeliveryPlans().stream().findFirst().get(); - assertThat(originDeliveryPlan).isSameAs(copiedDeliveryPlan); - } - - @Test - public void recordWinEventShouldRecordEventForAbsentInReportLineItemStatus() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - - // when - deliveryProgress.recordWinEvent("lineItemId1"); - - // then - final LineItemStatus lineItemStatus = deliveryProgress.getLineItemStatuses().get("lineItemId1"); - assertThat(lineItemStatus.getEvents()) - .extracting(Event::getType, event -> event.getCount().sum()) - .containsOnly(Tuple.tuple("win", 1L)); - } - - @Test - public void upsertPlanReferenceFromLineItemShouldInsertReferenceToNotExistingLineItemStatus() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - final LineItem lineItem = mock(LineItem.class); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - - // when - deliveryProgress.upsertPlanReferenceFromLineItem(lineItem); - - // then - assertThat(deliveryProgress.getLineItemStatuses()).hasSize(1); - final Set deliveryPlans = deliveryProgress.getLineItemStatuses().get("lineItemId1") - .getDeliveryPlans(); - assertThat(deliveryPlans).hasSize(1).extracting(DeliveryPlan::getDeliverySchedule) - .containsOnly(givenDeliverySchedule(now, "planId1")); - } - - @Test - public void upsertPlanReferenceFromLineItemShouldInsertToExistingWhenNotContainsPlanWithSameId() { - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - deliveryProgress.getLineItemStatuses().put("lineItemId1", LineItemStatus.of("lineItemId1")); - final LineItem lineItem = mock(LineItem.class); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - - // when - deliveryProgress.upsertPlanReferenceFromLineItem(lineItem); - - // then - assertThat(deliveryProgress.getLineItemStatuses()).hasSize(1); - final Set deliveryPlans = deliveryProgress.getLineItemStatuses().get("lineItemId1") - .getDeliveryPlans(); - assertThat(deliveryPlans).hasSize(1).extracting(DeliveryPlan::getDeliverySchedule) - .containsOnly(givenDeliverySchedule(now, "planId1")); - } - - @Test - public void upsertPlanReferenceFromLineItemShouldReplacePlanWhenContainsPlanWithSameId() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - final LineItemStatus lineItemStatus = LineItemStatus.of("lineItemId1"); - lineItemStatus.getDeliveryPlans().add(DeliveryPlan.of(givenDeliverySchedule(now.minusMinutes(1), "planId1"))); - deliveryProgress.getLineItemStatuses().put("lineItemId1", lineItemStatus); - final LineItem lineItem = mock(LineItem.class); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - - // when - deliveryProgress.upsertPlanReferenceFromLineItem(lineItem); - - // then - assertThat(deliveryProgress.getLineItemStatuses()).hasSize(1); - final Set deliveryPlans = deliveryProgress.getLineItemStatuses().get("lineItemId1") - .getDeliveryPlans(); - assertThat(deliveryPlans).hasSize(1).extracting(DeliveryPlan::getDeliverySchedule) - .containsOnly(givenDeliverySchedule(now, "planId1")); - } - - @Test - public void mergePlanFromLineItemShouldMergeCurrentPlanWithNewActiveOne() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - final LineItemStatus lineItemStatus = LineItemStatus.of("lineItemId1"); - lineItemStatus.getDeliveryPlans().add(DeliveryPlan.of(DeliverySchedule.builder().planId("planId1") - .startTimeStamp(now.minusMinutes(1)).endTimeStamp(now.plusMinutes(1)) - .updatedTimeStamp(now.minusMinutes(2)) - .tokens(singleton(Token.of(2, 50))).build())); - deliveryProgress.getLineItemStatuses().put("lineItemId1", lineItemStatus); - final LineItem lineItem = mock(LineItem.class); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - - // when - deliveryProgress.mergePlanFromLineItem(lineItem); - - // then - assertThat(deliveryProgress.getLineItemStatuses()).hasSize(1); - final Set deliveryPlans = deliveryProgress.getLineItemStatuses().get("lineItemId1") - .getDeliveryPlans(); - assertThat(deliveryPlans).hasSize(1) - .flatExtracting(DeliveryPlan::getDeliveryTokens) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, - deliveryToken -> deliveryToken.getSpent().sum()) - .containsOnly(Tuple.tuple(1, 100, 0L), Tuple.tuple(2, 50, 0L)); - - assertThat(deliveryPlans).hasSize(1) - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getUpdatedTimeStamp) - .containsOnly(Tuple.tuple("planId1", now.minusMinutes(1))); - } - - @Test - public void mergePlanFromLineItemShouldReplaceCurrentPlanWithNewActiveOneWithoutSpentTokens() { - // given - final DeliveryProgress deliveryProgress = DeliveryProgress.of(now, lineItemService); - deliveryProgress.getLineItemStatuses().put("lineItemId1", LineItemStatus.of("lineItemId1")); - final LineItem lineItem = mock(LineItem.class); - given(lineItem.getActiveDeliveryPlan()).willReturn(DeliveryPlan.of(givenDeliverySchedule(now, "planId1"))); - given(lineItem.getLineItemId()).willReturn("lineItemId1"); - - // when - deliveryProgress.mergePlanFromLineItem(lineItem); - - // then - assertThat(deliveryProgress.getLineItemStatuses()).hasSize(1); - final Set deliveryPlans = deliveryProgress.getLineItemStatuses().get("lineItemId1") - .getDeliveryPlans(); - assertThat(deliveryPlans).hasSize(1) - .flatExtracting(DeliveryPlan::getDeliveryTokens) - .extracting(DeliveryToken::getPriorityClass, DeliveryToken::getTotal, - deliveryToken -> deliveryToken.getSpent().sum()) - .containsOnly(Tuple.tuple(1, 100, 0L)); - - assertThat(deliveryPlans).hasSize(1) - .extracting(DeliveryPlan::getPlanId, DeliveryPlan::getUpdatedTimeStamp) - .containsOnly(Tuple.tuple("planId1", now.minusMinutes(1))); - } - - private static DeliverySchedule givenDeliverySchedule(ZonedDateTime now, String planId) { - return DeliverySchedule.builder() - .planId(planId) - .startTimeStamp(now.minusMinutes(1)) - .endTimeStamp(now.plusMinutes(1)) - .updatedTimeStamp(now.minusMinutes(1)) - .tokens(singleton(Token.of(1, 100))) - .build(); - } -} diff --git a/src/test/java/org/prebid/server/deals/model/DeepDebugLogTest.java b/src/test/java/org/prebid/server/deals/model/DeepDebugLogTest.java deleted file mode 100644 index 0e70f86ca56..00000000000 --- a/src/test/java/org/prebid/server/deals/model/DeepDebugLogTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.prebid.server.deals.model; - -import org.junit.Test; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal; -import org.prebid.server.proto.openrtb.ext.response.ExtTraceDeal.Category; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.function.Supplier; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -public class DeepDebugLogTest { - - private final Clock clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); - - @SuppressWarnings("unchecked") - @Test - public void addShouldNotRecordMessageWhenDeepDebugIsDisabled() { - // given - final DeepDebugLog deepDebugLog = DeepDebugLog.create(false, clock); - - final Supplier messageSupplier = (Supplier) mock(Supplier.class); - - // when - deepDebugLog.add(null, Category.pacing, messageSupplier); - - // then - verify(messageSupplier, never()).get(); - - assertThat(deepDebugLog.entries()).isEmpty(); - } - - @Test - public void addShouldRecordMessageWhenDeepDebugIsEnabled() { - // given - final DeepDebugLog deepDebugLog = DeepDebugLog.create(true, clock); - - // when - deepDebugLog.add(null, Category.pacing, () -> "debug message 1"); - - // then - assertThat(deepDebugLog.entries()).containsOnly( - ExtTraceDeal.of(null, ZonedDateTime.now(clock), Category.pacing, "debug message 1")); - } -} diff --git a/src/test/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandlerTest.java b/src/test/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandlerTest.java deleted file mode 100644 index 72069ad5f88..00000000000 --- a/src/test/java/org/prebid/server/deals/simulation/DealsSimulationAdminHandlerTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.MultiMap; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.ext.web.RoutingContext; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.exception.PreBidException; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Collections; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.verify; - -public class DealsSimulationAdminHandlerTest extends VertxTest { - - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private SimulationAwareRegisterService registerService; - - @Mock - private SimulationAwarePlannerService plannerService; - - @Mock - private SimulationAwareDeliveryProgressService deliveryProgressService; - - @Mock - private SimulationAwareDeliveryStatsService deliveryStatsService; - - @Mock - private SimulationAwareHttpBidderRequester httpBidderRequester; - - @Mock - private RoutingContext routingContext; - - @Mock - private HttpServerRequest request; - - @Mock - private HttpServerResponse response; - - private ZonedDateTime now; - - private DealsSimulationAdminHandler dealsSimulationAdminHandler; - - @Before - public void setUp() { - now = ZonedDateTime.now(Clock.fixed(Instant.parse("2019-10-10T00:00:00Z"), ZoneOffset.UTC)); - dealsSimulationAdminHandler = new DealsSimulationAdminHandler(registerService, - plannerService, deliveryProgressService, deliveryStatsService, httpBidderRequester, jacksonMapper, - "endpoint"); - given(routingContext.request()).willReturn(request); - given(routingContext.response()).willReturn(response); - given(request.headers()).willReturn(MultiMap.caseInsensitiveMultiMap() - .add("pg-sim-timestamp", now.toString())); - given(response.setStatusCode(anyInt())).willReturn(response); - } - - @Test - public void handleShouldCallPerformRegistrationHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/planner/register"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(registerService).performRegistration(eq(now)); - } - - @Test - public void handleShouldCallFetchLineItemHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/planner/fetchLineItems"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(plannerService).initiateLineItemsFetching(eq(now)); - } - - @Test - public void handleShouldCallAdvancePlanHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/advancePlans"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(plannerService).advancePlans(eq(now)); - } - - @Test - public void handleShouldCallReportHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/dealstats/report"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(deliveryProgressService).createDeliveryProgressReport(eq(now)); - verify(deliveryStatsService).sendDeliveryProgressReports(eq(now)); - } - - @Test - public void handleShouldCallSetBidRateHandler() throws JsonProcessingException { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/bidRate"); - given(routingContext.getBody()).willReturn(Buffer.buffer( - mapper.writeValueAsString(Collections.singletonMap("lineItemId", 1.00)))); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(httpBidderRequester).setBidRates(any()); - } - - @Test - public void handleShouldRespondWithErrorWhenBidderRequesterIsNotSet() { - // given - dealsSimulationAdminHandler = new DealsSimulationAdminHandler( - registerService, plannerService, deliveryProgressService, deliveryStatsService, null, jacksonMapper, - "endpoint"); - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/bidRate"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(400); - verify(response).end(eq("Calling /bidRate is not make sense since " - + "Prebid Server configured to use real bidder exchanges in simulation mode")); - } - - @Test - public void handleShouldRespondWithNotFoundWhenHandlerNotFound() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/invalid"); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(404); - verify(response).end(eq("Requested url /invalid was not found")); - } - - @Test - public void handleShouldRespondWithBadRequestWhenRequiredDateHeaderNotFound() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/dealstats/startreport"); - given(request.headers()).willReturn(MultiMap.caseInsensitiveMultiMap()); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(400); - verify(response).end(eq("pg-sim-timestamp with simulated current date is required for endpoints:" - + " /planner/register, /planner/fetchLineItems, /advancePlans, /dealstats/report")); - } - - @Test - public void handleShouldRespondWithBadRequestWhenBodyNotFoundForSetBidRatesHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/bidRate"); - given(routingContext.getBody()).willReturn(null); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(400); - verify(response).end(eq("Body is required for /bidRate endpoint")); - } - - @Test - public void handleShouldRespondWithBadRequestWhenBodyHasIncorrectFormatForSetBidRatesHandler() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/bidRate"); - given(routingContext.getBody()).willReturn(Buffer.buffer("{")); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(400); - verify(response).end(startsWith("Failed to parse bid rates body")); - } - - @Test - public void handleShouldRespondWithInternalServerErrorStatus() { - // given - given(request.uri()).willReturn("/pbs-admin/e2eAdmin/advancePlans"); - doThrow(new PreBidException("Error")).when(plannerService).advancePlans(any()); - - // when - dealsSimulationAdminHandler.handle(routingContext); - - // then - verify(response).setStatusCode(eq(500)); - verify(response).end(eq("Error")); - } -} diff --git a/src/test/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequesterTest.java b/src/test/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequesterTest.java deleted file mode 100644 index 3287ca2e1a1..00000000000 --- a/src/test/java/org/prebid/server/deals/simulation/SimulationAwareHttpBidderRequesterTest.java +++ /dev/null @@ -1,324 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.fasterxml.jackson.databind.node.IntNode; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; -import com.iab.openrtb.response.Bid; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.auction.BidderAliases; -import org.prebid.server.auction.model.BidRejectionTracker; -import org.prebid.server.auction.model.BidderRequest; -import org.prebid.server.bidder.BidderErrorNotifier; -import org.prebid.server.bidder.BidderRequestCompletionTrackerFactory; -import org.prebid.server.bidder.HttpBidderRequestEnricher; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.BidderSeatBid; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.lineitem.LineItem; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.deals.proto.Price; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.model.CaseInsensitiveMultiMap; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.vertx.http.HttpClient; -import org.springframework.test.util.ReflectionTestUtils; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.tuple; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; - -public class SimulationAwareHttpBidderRequesterTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private SimulationAwareHttpBidderRequester bidderRequester; - - @Mock - private HttpClient httpClient; - @Mock - private BidderAliases bidderAliases; - @Mock - private BidRejectionTracker bidRejectionTracker; - @Mock - private BidderRequestCompletionTrackerFactory bidderRequestCompletionTrackerFactory; - @Mock - private BidderErrorNotifier bidderErrorNotifier; - @Mock - private HttpBidderRequestEnricher requestEnricher; - @Mock - private CaseInsensitiveMultiMap requestHeaders; - @Mock - private LineItemService lineItemService; - - @Before - public void setUp() { - bidderRequester = new SimulationAwareHttpBidderRequester( - httpClient, bidderRequestCompletionTrackerFactory, bidderErrorNotifier, requestEnricher, - lineItemService, jacksonMapper); - } - - @Test - public void requestBidsShouldReturnBidderSeatBidWithOneBidAndFilterOutOne() { - // given - final Map rates = new HashMap<>(); - rates.put("lineItemId1", 1.00); - rates.put("lineItemId2", 0.00); - bidderRequester.setBidRates(rates); - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(LineItem.of( - LineItemMetaData.builder().price(Price.of(BigDecimal.ONE, "USD")).build(), Price.of(BigDecimal.ONE, - "USD"), null, null)); - given(lineItemService.getLineItemById(eq("lineItemId2"))).willReturn(LineItem.of( - LineItemMetaData.builder().price(Price.of(BigDecimal.TEN, "USD")).build(), Price.of(BigDecimal.ONE, - "USD"), null, null)); - - final BidRequest bidRequest = BidRequest.builder().imp(asList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId1", null, - singletonList(Format.builder().w(100).h(100).build()), null)))) - .build())).build()).build(), - Imp.builder().id("impId2").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId2") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId2", null, - singletonList(Format.builder().w(100).h(100).build()), null)))) - .build())).build()).build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when - final Future result = bidderRequester - .requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false); - - // then - assertThat(result.succeeded()).isTrue(); - assertThat(result.result()).isEqualTo(BidderSeatBid.of(singletonList( - BidderBid.of( - Bid.builder().id("impId1-lineItemId1").impid("impId1").dealid("dealId1").price(BigDecimal.ONE) - .adm("").crid("crid").w(100).h(100) - .build(), - BidType.banner, - "USD")))); - } - - @Test - public void requestBidsShouldFilterBidderSeatBidForWhichImpPmpIsNull() { - // given - bidderRequester.setBidRates(Collections.singletonMap("lineItemId1", 1.00)); - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(LineItem.of( - LineItemMetaData.builder().price(Price.of(BigDecimal.ONE, "USD")).build(), - Price.of(BigDecimal.ONE, "USD"), null, null)); - - final BidRequest bidRequest = BidRequest.builder().imp(asList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId1", null, - singletonList(Format.builder().w(100).h(100).build()), null)))) - .build())).build()).build(), - Imp.builder().id("impId2").build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when - final Future result = bidderRequester.requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false); - - // then - assertThat(result.succeeded()).isTrue(); - assertThat(result.result()).isEqualTo(BidderSeatBid.of(singletonList( - BidderBid.of( - Bid.builder().id("impId1-lineItemId1").impid("impId1").dealid("dealId1").price(BigDecimal.ONE) - .adm("").crid("crid").w(100).h(100) - .build(), - BidType.banner, - "USD")))); - } - - @Test - public void requestBidsShouldSetSizesAsZeroIfExtDealsLinesDoesNotHaveSizes() { - // given - final Map rates = new HashMap<>(); - rates.put("lineItemId1", 1.00); - bidderRequester.setBidRates(rates); - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(LineItem.of( - LineItemMetaData.builder().price(Price.of(BigDecimal.ONE, "USD")).build(), - Price.of(BigDecimal.ONE, "USD"), null, null)); - - final BidRequest bidRequest = BidRequest.builder().imp(singletonList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId1", null, null, null)))) - .build())).build()).build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when - final Future result = bidderRequester.requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false); - - // then - assertThat(result.succeeded()).isTrue(); - assertThat(result.result()).isEqualTo(BidderSeatBid.of(singletonList( - BidderBid.of( - Bid.builder().id("impId1-lineItemId1").impid("impId1").dealid("dealId1").price(BigDecimal.ONE) - .adm("").crid("crid").w(0).h(0) - .build(), - BidType.banner, - "USD")))); - } - - @Test - public void requestBidsShouldThrowPrebidExceptionWhenExtDealsInvalidFormat() { - // given - final Map rates = new HashMap<>(); - rates.put("lineItemId1", 1.00); - bidderRequester.setBidRates(rates); - given(lineItemService.getLineItemById(eq("lineItemId1"))).willReturn(LineItem.of( - LineItemMetaData.builder().price(Price.of(BigDecimal.ONE, "USD")).build(), - Price.of(BigDecimal.ONE, "USD"), null, null)); - - final BidRequest bidRequest = BidRequest.builder().imp(singletonList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1") - .ext(mapper.createObjectNode().set("line", new IntNode(5))) - .build())).build()).build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when and then - assertThatThrownBy(() -> bidderRequester - .requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false)) - .isInstanceOf(PreBidException.class) - .hasMessageStartingWith("Error decoding bidRequest.imp.pmp.deal.ext:"); - } - - @Test - public void requestBidsShouldReturnBidderSeatBidWithoutBidderBidsAndWithError() { - // given - bidderRequester.setBidRates(Collections.singletonMap("lineItemId1", 1.00)); - - final BidRequest bidRequest = BidRequest.builder().imp(singletonList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1").build())).build()).build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when - final Future result = bidderRequester - .requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false); - - // then - assertThat(result.succeeded()).isTrue(); - assertThat(result.result()).isEqualTo(BidderSeatBid.builder() - .errors(singletonList(BidderError.failedToRequestBids( - "Matched or ready to serve line items were not found, but required in simulation mode"))) - .build()); - } - - @Test - public void requestBidsShouldThrowPrebidExceptionWhenBidRatesForLineItemWereNotFound() { - // given - bidderRequester.setBidRates(Collections.singletonMap("lineItemId1", 1.00)); - - final BidRequest bidRequest = BidRequest.builder().imp(singletonList( - Imp.builder().id("impId1").pmp(Pmp.builder().deals(singletonList(Deal.builder() - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId2", null, null, null)))) - .build())).build()).build())) - .build(); - final BidderRequest bidderRequest = BidderRequest.builder().bidder("bidder").bidRequest(bidRequest).build(); - - // when - assertThatThrownBy(() -> bidderRequester - .requestBids( - null, - bidderRequest, - bidRejectionTracker, - null, - requestHeaders, - bidderAliases, - false)) - .isInstanceOf(PreBidException.class) - .hasMessage("Bid rate for line item with id lineItemId2 was not found"); - } - - @Test - public void setBidRatesShouldMergeRates() { - // given - final Map initialBidRates = new HashMap<>(); - initialBidRates.put("lineItemId1", 1.00); - initialBidRates.put("lineItemId2", 0.5); - bidderRequester.setBidRates(initialBidRates); - - final Map updateBidRates = new HashMap<>(); - updateBidRates.put("lineItemId1", 0.00); - updateBidRates.put("lineItemId3", 0.75); - - // when - bidderRequester.setBidRates(updateBidRates); - - // then - @SuppressWarnings("unchecked") final Map resultBidRates = - (Map) ReflectionTestUtils.getField(bidderRequester, "bidRates"); - - assertThat(resultBidRates).isNotNull(); - assertThat(resultBidRates.entrySet()).hasSize(3) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .containsOnly(tuple("lineItemId1", 0.00), tuple("lineItemId2", 0.5), tuple("lineItemId3", 0.75)); - } -} diff --git a/src/test/java/org/prebid/server/deals/simulation/SimulationAwarePlannerServiceTest.java b/src/test/java/org/prebid/server/deals/simulation/SimulationAwarePlannerServiceTest.java deleted file mode 100644 index 0774f31314d..00000000000 --- a/src/test/java/org/prebid/server/deals/simulation/SimulationAwarePlannerServiceTest.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.prebid.server.deals.simulation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import io.vertx.core.Future; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.model.DeploymentProperties; -import org.prebid.server.deals.model.PlannerProperties; -import org.prebid.server.deals.proto.LineItemMetaData; -import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; -import org.springframework.test.util.ReflectionTestUtils; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.TimeoutException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -public class SimulationAwarePlannerServiceTest extends VertxTest { - - private static final String PLAN_ENDPOINT = "plan-endpoint"; - private static final String REGISTER_ENDPOINT = "register-endpoint"; - private static final String USERNAME = "username"; - private static final String PASSWORD = "password"; - private static final String PBS_HOST = "pbs-host"; - private static final String PBS_REGION = "pbs-region"; - private static final String PBS_VENDOR = "pbs-vendor"; - - @Rule - public final MockitoRule rule = MockitoJUnit.rule(); - - @Mock - private HttpClient httpClient; - @Mock - private SimulationAwareLineItemService lineItemService; - @Mock - private DeliveryProgressService deliveryProgressService; - @Mock - private AlertHttpService alertHttpService; - @Mock - private Metrics metrics; - - private SimulationAwarePlannerService simulationAwarePlannerService; - - private ZonedDateTime now; - - @Before - public void setUp() { - final Clock clock = Clock.fixed(Instant.parse("2019-07-26T10:00:00Z"), ZoneOffset.UTC); - now = ZonedDateTime.now(clock); - - simulationAwarePlannerService = new SimulationAwarePlannerService( - PlannerProperties.builder() - .planEndpoint(PLAN_ENDPOINT) - .registerEndpoint(REGISTER_ENDPOINT) - .timeoutMs(100L) - .registerPeriodSeconds(60L) - .username(USERNAME) - .password(PASSWORD) - .build(), - DeploymentProperties.builder().pbsHostId(PBS_HOST).pbsRegion(PBS_REGION).pbsVendor(PBS_VENDOR).build(), - lineItemService, - deliveryProgressService, - alertHttpService, - httpClient, - metrics, - clock, - jacksonMapper); - } - - @Test - public void initiateLineItemFetchingShouldNotCallLineItemServiceUpdateMethod() throws JsonProcessingException { - // given - given(httpClient.get(anyString(), any(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString( - Collections.singletonList(LineItemMetaData.builder().lineItemId("id").build()))))); - - // when - simulationAwarePlannerService.initiateLineItemsFetching(now); - - // then - verify(lineItemService, never()).updateLineItems(any(), anyBoolean()); - } - - @Test - public void initiateLineItemFetchingShouldNotRetryWhenCallToPlannerFailed() { - // given - given(httpClient.get(anyString(), any(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("time out"))); - - // when - simulationAwarePlannerService.initiateLineItemsFetching(now); - - // then - verify(httpClient).get(anyString(), any(), anyLong()); - } - - @Test - public void initiateLineItemFetchingShouldUpdateMetricsAndLineItemServiceWithResponsiveFlagWhenCallSuccessful() - throws JsonProcessingException { - // given - given(httpClient.get(anyString(), any(), anyLong())) - .willReturn(Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString( - Collections.singletonList(LineItemMetaData.builder().lineItemId("id").build()))))); - - // when - simulationAwarePlannerService.initiateLineItemsFetching(now); - - // then - @SuppressWarnings("unchecked") - final List lineItemMetaData = (List) ReflectionTestUtils - .getField(simulationAwarePlannerService, "lineItemMetaData"); - assertThat(lineItemMetaData).hasSize(1) - .containsOnly(LineItemMetaData.builder().lineItemId("id").build()); - verify(metrics).updatePlannerRequestMetric(eq(true)); - verify(lineItemService).updateIsPlannerResponsive(eq(true)); - } - - @Test - public void initiateLineItemFetchingShouldUpdateMetricsAndLineItemServiceWithResponsiveFlagWhenCallFailed() { - // given - given(httpClient.get(anyString(), any(), anyLong())) - .willReturn(Future.failedFuture(new TimeoutException("time out"))); - - // when - simulationAwarePlannerService.initiateLineItemsFetching(now); - - // then - verify(metrics).updatePlannerRequestMetric(eq(false)); - verify(lineItemService).updateIsPlannerResponsive(eq(false)); - } - - @Test - public void advancePlansShouldCallUpdateLineItemsAndUpdateProgress() { - // given and when - simulationAwarePlannerService.advancePlans(now); - - // then - verify(lineItemService).updateLineItems(anyList(), anyBoolean(), eq(now)); - verify(lineItemService).advanceToNextPlan(now); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/RequestContextTest.java b/src/test/java/org/prebid/server/deals/targeting/RequestContextTest.java deleted file mode 100644 index 7d80fd036bb..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/RequestContextTest.java +++ /dev/null @@ -1,1262 +0,0 @@ -package org.prebid.server.deals.targeting; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Data; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Format; -import com.iab.openrtb.request.Geo; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Publisher; -import com.iab.openrtb.request.Segment; -import com.iab.openrtb.request.Site; -import com.iab.openrtb.request.User; -import com.iab.openrtb.request.Video; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.model.TxnLog; -import org.prebid.server.deals.targeting.model.GeoLocation; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; -import org.prebid.server.exception.TargetingSyntaxException; -import org.prebid.server.proto.openrtb.ext.request.ExtApp; -import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtGeo; -import org.prebid.server.proto.openrtb.ext.request.ExtSite; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.request.ExtUserTime; - -import java.util.function.Function; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class RequestContextTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private TxnLog txnLog; - - @Before - public void setUp() { - txnLog = TxnLog.create(); - } - - @Test - public void lookupStringShouldReturnDomainFromSite() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.domain("domain.com")))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("domain.com"); - } - - @Test - public void lookupStringShouldReturnDomainFromSitePublisher() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s - .publisher(Publisher.builder().domain("domain.com").build())))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("domain.com"); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenDomainIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(r -> r.site(site(identity()))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultForDomainWhenSiteIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnPublisherDomainFromSitePublisher() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.publisherDomain); - final RequestContext context = - new RequestContext( - request(r -> r.site(site(s -> s - .publisher(Publisher.builder().domain("domain.com").build())))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("domain.com"); - } - - @Test - public void lookupStringShouldReturnEmptyResultForPublisherDomainWhenSiteIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.publisherDomain); - final RequestContext context = new RequestContext(request(identity()), imp(identity()), txnLog, jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnReferrer() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.referrer); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.page("https://domain.com/index")))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("https://domain.com/index"); - } - - @Test - public void lookupStringShouldReturnAppBundle() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.appBundle); - final RequestContext context = new RequestContext( - request(r -> r.app(app(a -> a.bundle("com.google.calendar")))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("com.google.calendar"); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenBundleIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.appBundle); - final RequestContext context = new RequestContext( - request(r -> r.app(app(identity()))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenAppIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.appBundle); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnAdslotFromTagId() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.adslot); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.tagid("/123/456")), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("/123/456"); - } - - @Test - public void lookupStringShouldReturnAdslotFromGpid() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.adslot); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(mapper.createObjectNode().set("gpid", TextNode.valueOf("/234/567")))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("/234/567"); - } - - @Test - public void lookupStringShouldReturnAdslotFromDataPbadslot() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.adslot); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(mapper.createObjectNode() - .set("data", mapper.createObjectNode().put("pbadslot", "/345/678")))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("/345/678"); - } - - @Test - public void lookupStringShouldReturnAdslotFromDataAdserverAdslot() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.adslot); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(mapper.createObjectNode() - .set("data", mapper.createObjectNode() - .set("adserver", obj("adslot", "/456/789"))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("/456/789"); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenAdslotIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.adslot); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("context", obj("data", mapper.createObjectNode())))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnCountryFromDeviceGeoExtValue() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.deviceGeoExt, - "vendor.attribute"); - final ExtGeo extGeo = ExtGeo.of(); - extGeo.addProperty("vendor", obj("attribute", "value")); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.geo(geo(g -> g.ext(extGeo)))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("value"); - } - - @Test - public void lookupStringShouldReturnRegionFromDeviceGeoExtValue() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.deviceGeoExt, - "vendor.nested.attribute"); - final ExtGeo extGeo = ExtGeo.of(); - extGeo.addProperty("vendor", obj("nested", obj("attribute", "value"))); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.geo(geo(g -> g.ext(extGeo)))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("value"); - } - - @Test - public void lookupStringShouldReturnMetroFromDeviceExtValue() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.deviceExt, - "vendor.attribute"); - final ExtDevice extDevice = ExtDevice.of(null, null); - extDevice.addProperty("vendor", obj("attribute", "value")); - - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.ext(extDevice)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("value"); - } - - @Test - public void lookupStringShouldReturnMetroFromDeviceExtNestedValue() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.deviceExt, - "vendor.nested.attribute"); - final ExtDevice extDevice = ExtDevice.of(null, null); - extDevice.addProperty("vendor", obj("nested", obj("attribute", "value"))); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.ext(extDevice)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("value"); - } - - @Test - public void lookupStringShouldReturnSimpleBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", "123")))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("123"); - } - - @Test - public void lookupStringShouldReturnNestedBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "inv.code"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("inv", obj("code", "123"))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("123"); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenBidderParamIsNotString() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("rubicon", obj("siteId", mapper.valueToTree(123))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenBidderParamIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("rubicon", "phony"))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenImpExtIsMissingForBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnSimpleUserFirstPartyDataFromObject() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "buyeruid"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.buyeruid("123")))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("123"); - } - - @Test - public void lookupStringShouldReturnSimpleUserFirstPartyDataFromExt() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "sport"); - final ExtUser extUser = ExtUser.builder().data(obj("sport", "hockey")).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupStringShouldReturnUserFirstPartyDataFromExtWhenObjectAttributeTypeIsNotString() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "yob"); - final ExtUser extUser = ExtUser.builder().data(obj("yob", "1900")).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.yob(1800).ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("1900"); - } - - @Test - public void lookupStringShouldReturnNestedUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "section.sport"); - final ExtUser extUser = ExtUser.builder().data(obj("section", obj("sport", "hockey"))).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenUserFirstPartyDataIsNotString() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "sport"); - final ExtUser extUser = ExtUser.builder().data(obj("sport", mapper.valueToTree(123))).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenUserExtIsMissingForUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(identity()))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnEmptyResultWhenUserIsMissingForUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.userFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringShouldReturnSiteFirstPartyDataFromImpExt() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.siteFirstPartyData, "section.sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("context", obj("data", obj("section", obj("sport", "hockey")))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupStringShouldReturnSiteFirstPartyDataFromSiteExt() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.siteFirstPartyData, "section.sport"); - final ExtSite extSite = ExtSite.of(null, obj("section", obj("sport", "hockey"))); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.ext(extSite)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupStringShouldReturnSiteFirstPartyDataFromAppExt() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.siteFirstPartyData, "section.sport"); - final ExtApp extApp = ExtApp.of(null, obj("section", obj("sport", "hockey"))); - final RequestContext context = new RequestContext( - request(r -> r.app(app(a -> a.ext(extApp)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupStringShouldReturnSiteFirstPartyDataFromImpExtData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(imp -> imp.ext(obj("data", obj("sport", "hockey")))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupString(category).getValues()).containsExactly("hockey"); - } - - @Test - public void lookupIntegerShouldReturnDowFromUserExt() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.dow); - final ExtUser extUser = ExtUser.builder().time(ExtUserTime.of(5, 15)).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(5); - } - - @Test - public void lookupIntegerShouldReturnHourFromExt() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.hour); - final ExtUser extUser = ExtUser.builder().time(ExtUserTime.of(5, 15)).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(15); - } - - @Test - public void lookupIntegerShouldReturnBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.valueToTree(123))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(123); - } - - @Test - public void lookupIntegerShouldReturnEmptyResultWhenBidderParamIsNotInteger() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("rubicon", obj("siteId", mapper.valueToTree(123.456d))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupIntegerShouldReturnEmptyResultWhenBidderParamIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("rubicon", "phony"))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupIntegerShouldReturnUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userFirstPartyData, "sport"); - final ExtUser extUser = ExtUser.builder().data(obj("sport", mapper.valueToTree(123))).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(123); - } - - @Test - public void lookupIntegerShouldReturnSiteFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final ExtSite extSite = ExtSite.of(null, obj("sport", mapper.valueToTree(123))); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.ext(extSite)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(123); - } - - @Test - public void lookupIntegerShouldReturnSiteFirstPartyDataFromImpExtData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(imp -> imp.ext(obj("data", obj("sport", 1)))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupInteger(category).getValues()).containsExactly(1); - } - - @Test - public void lookupStringsShouldReturnMediaTypeBannerAndVideo() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.mediaType); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.banner(banner(identity())).video(Video.builder().build())), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("banner", "video")); - } - - @Test - public void lookupStringsShouldReturnMediaTypeVideoAndNative() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.mediaType); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.video(Video.builder().build()).xNative(Native.builder().build())), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("video", "native")); - } - - @Test - public void lookupStringsShouldReturnBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.valueToTree(asList("123", "456")))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("123", "456")); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenBidderParamIsNotArray() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.createObjectNode())))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldReturnListOfSingleStringWhenBidderParamIsString() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", "value")))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(singletonList("value")); - } - - @Test - public void lookupStringsShouldReturnOnlyStringsWhenNonStringBidderParamPresent() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.valueToTree(asList("123", 456)))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(singletonList("123")); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenBidderParamIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("bidder", obj("rubicon", "phony"))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldReturnUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userFirstPartyData, "buyeruid"); - final ExtUser extUser = ExtUser.builder() - .data(obj("buyeruid", mapper.valueToTree(asList("buyeruid1", "buyeruid2")))) - .build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.buyeruid("buyeruid3").ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()) - .containsExactly(singletonList("buyeruid3"), asList("buyeruid1", "buyeruid2")); - } - - @Test - public void lookupStringsShouldReturnSiteFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final ExtSite extSite = ExtSite.of(null, obj("sport", mapper.valueToTree(asList("123", "456")))); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.ext(extSite)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("123", "456")); - } - - @Test - public void lookupStringsShouldReturnSiteFirstPartyDataFromImpExtData() { - // given - final TargetingCategory category = new TargetingCategory( - TargetingCategory.Type.siteFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(imp -> imp.ext(obj("data", obj("sport", mapper.valueToTree(asList("hockey", "football")))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("hockey", "football")); - } - - @Test - public void lookupStringsShouldReturnSegmentsWithDesiredSource() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.data(asList( - data(d -> d.id("rubicon").segment(asList(segment(s -> s.id("1")), segment(s -> s.id("2"))))), - data(d -> d.id("bluekai").segment( - asList(segment(s -> s.id("3")), segment(s -> s.id("4")))))))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(asList("1", "2")); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenDesiredSourceIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.data(singletonList( - data(d -> d.id("bluekai").segment( - asList(segment(s -> s.id("3")), segment(s -> s.id("4")))))))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldSkipSegmentsWithoutIds() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.data(singletonList( - data(d -> d.id("rubicon").segment(asList(segment(s -> s.id("1")), segment(identity()))))))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category).getValues()).containsExactly(singletonList("1")); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenSegmentsAreMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.data(singletonList(data(d -> d.id("rubicon"))))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldTolerateMissingSource() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.data(singletonList(data(identity())))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenDataIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(r -> r.user(user(identity()))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupStringsShouldReturnEmptyResultWhenUserIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userSegment, "rubicon"); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupStrings(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupIntegersShouldReturnBidderParam() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.valueToTree(asList(123, 456)))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(asList(123, 456)); - } - - @Test - public void lookupIntegersShouldReturnEmptyResultWhenBidderParamIsNotArray() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.createObjectNode())))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupIntegersShouldReturnListOfSingleIntegerWhenBidderParamIsInteger() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", 123)))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(singletonList(123)); - } - - @Test - public void lookupIntegersShouldReturnOnlyIntegersWhenNonIntegerBidderParamPresent() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", obj("siteId", mapper.valueToTree(asList(123, "456")))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(singletonList(123)); - } - - @Test - public void lookupIntegersShouldReturnEmptyResultWhenBidderParamIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.bidderParam, "rubicon.siteId"); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.ext(obj("bidder", "phony"))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupIntegersShouldReturnUserFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.userFirstPartyData, "yob"); - final ExtUser extUser = ExtUser.builder().data(obj("yob", mapper.valueToTree(asList(123, 456)))).build(); - final RequestContext context = new RequestContext( - request(r -> r.user(user(u -> u.yob(789).ext(extUser)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(singletonList(789), asList(123, 456)); - } - - @Test - public void lookupIntegersShouldReturnSiteFirstPartyData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final ExtSite extSite = ExtSite.of(null, obj("sport", mapper.valueToTree(asList(123, 456)))); - final RequestContext context = new RequestContext( - request(r -> r.site(site(s -> s.ext(extSite)))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(asList(123, 456)); - } - - @Test - public void lookupIntegersShouldReturnSiteFirstPartyDataFromImpExtData() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.siteFirstPartyData, "sport"); - final RequestContext context = new RequestContext( - request(identity()), - imp(imp -> imp.ext(obj("data", obj("sport", mapper.valueToTree(asList(1, 2)))))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupIntegers(category).getValues()).containsExactly(asList(1, 2)); - } - - @Test - public void lookupSizesShouldReturnSizes() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.size); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i - .banner(banner(b -> b.format(asList(format(300, 250), format(400, 300))))) - .video(Video.builder().w(350).h(350).build())), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupSizes(category).getValues()) - .containsExactly(asList(Size.of(300, 250), Size.of(400, 300), Size.of(350, 350))); - } - - @Test - public void lookupSizesShouldReturnEmptyResultWhenFormatIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.size); - final RequestContext context = new RequestContext( - request(identity()), - imp(i -> i.banner(banner(identity()))), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupSizes(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupSizesShouldReturnEmptyResultWhenBannerIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.size); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupSizes(category)).isEqualTo(LookupResult.empty()); - } - - @Test - public void lookupSizesShouldThrowExceptionWhenUnexpectedCategory() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThatThrownBy(() -> context.lookupSizes(category)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Unexpected category for fetching sizes for: domain"); - } - - @Test - public void lookupGeoLocationShouldReturnLocation() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.location); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.geo(geo(g -> g.lat(50f).lon(60f)))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupGeoLocation(category)).isEqualTo(GeoLocation.of(50f, 60f)); - } - - @Test - public void lookupGeoLocationShouldReturnNullWhenLonIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.location); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.geo(geo(g -> g.lat(50f)))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupGeoLocation(category)).isNull(); - } - - @Test - public void lookupGeoLocationShouldReturnNullWhenLatIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.location); - final RequestContext context = new RequestContext( - request(r -> r.device(device(d -> d.geo(geo(g -> g.lon(60f)))))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupGeoLocation(category)).isNull(); - } - - @Test - public void lookupGeoLocationShouldReturnNullWhenGeoIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.location); - final RequestContext context = new RequestContext( - request(r -> r.device(device(identity()))), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupGeoLocation(category)).isNull(); - } - - @Test - public void lookupGeoLocationShouldReturnNullWhenDeviceIsMissing() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.location); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThat(context.lookupGeoLocation(category)).isNull(); - } - - @Test - public void lookupGeoLocationShouldThrowExceptionWhenUnexpectedCategory() { - // given - final TargetingCategory category = new TargetingCategory(TargetingCategory.Type.domain); - final RequestContext context = new RequestContext( - request(identity()), - imp(identity()), - txnLog, - jacksonMapper); - - // when and then - assertThatThrownBy(() -> context.lookupGeoLocation(category)) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("Unexpected category for fetching geo location for: domain"); - } - - private static BidRequest request(Function customizer) { - return customizer.apply(BidRequest.builder()).build(); - } - - private static Site site(Function customizer) { - return customizer.apply(Site.builder()).build(); - } - - private static App app(Function customizer) { - return customizer.apply(App.builder()).build(); - } - - private static Device device(Function customizer) { - return customizer.apply(Device.builder()).build(); - } - - private static Geo geo(Function customizer) { - return customizer.apply(Geo.builder()).build(); - } - - private static User user(Function customizer) { - return customizer.apply(User.builder()).build(); - } - - private static Data data(Function customizer) { - return customizer.apply(Data.builder()).build(); - } - - private static Segment segment(Function customizer) { - return customizer.apply(Segment.builder()).build(); - } - - private static Imp imp(Function customizer) { - return customizer.apply(Imp.builder()).build(); - } - - private static Banner banner(Function customizer) { - return customizer.apply(Banner.builder()).build(); - } - - private static Format format(int w, int h) { - return Format.builder().w(w).h(h).build(); - } - - private static ObjectNode obj(String field, String value) { - return mapper.createObjectNode().put(field, value); - } - - private static ObjectNode obj(String field, Integer value) { - return mapper.createObjectNode().put(field, value); - } - - private static ObjectNode obj(String field, JsonNode value) { - return mapper.createObjectNode().set(field, value); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/AndTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/AndTest.java deleted file mode 100644 index 0cb4b0d02cd..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/AndTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -public class AndTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private TerminalExpression trueExpression; - @Mock - private TerminalExpression falseExpression; - @Mock - private RequestContext context; - - @Before - public void setUp() { - given(trueExpression.matches(any())).willReturn(true); - given(falseExpression.matches(any())).willReturn(false); - } - - @Test - public void matchesShouldReturnTrue() { - assertThat(new And(asList(trueExpression, trueExpression, trueExpression)).matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalse() { - assertThat(new And(asList(falseExpression, falseExpression, falseExpression)).matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseAndNotEvaluateRemainingExpressions() { - assertThat(new And(asList(trueExpression, falseExpression, trueExpression)).matches(context)).isFalse(); - - verify(trueExpression).matches(context); - verify(falseExpression).matches(context); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/InIntegersTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/InIntegersTest.java deleted file mode 100644 index 805060bd30d..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/InIntegersTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class InIntegersTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = new TargetingCategory(TargetingCategory.Type.pagePosition); - expression = new InIntegers(category, asList(1, 2, 3)); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(LookupResult.ofValue(2)).given(context).lookupInteger(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupInteger(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(LookupResult.ofValue(4)).given(context).lookupInteger(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(LookupResult.empty()).given(context).lookupInteger(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/InStringsTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/InStringsTest.java deleted file mode 100644 index abad9a83326..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/InStringsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class InStringsTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = new TargetingCategory(TargetingCategory.Type.referrer); - expression = new InStrings(category, asList("Munich", "Berlin", "Stuttgart", "123")); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(LookupResult.ofValue("Berlin")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupString(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(LookupResult.ofValue("Ingolstadt")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldPerformCaseInsensitiveComparison() { - // given - willReturn(LookupResult.ofValue("BERLIN")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(LookupResult.empty()).given(context).lookupString(any()); - willReturn(LookupResult.empty()).given(context).lookupInteger(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnTrueWhenActualValueIsInteger() { - // given - willReturn(LookupResult.empty()).given(context).lookupString(any()); - willReturn(LookupResult.ofValue(123)).given(context).lookupInteger(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegersTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegersTest.java deleted file mode 100644 index 56ec56d1de2..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsIntegersTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class IntersectsIntegersTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = TargetingCategory.fromString("bidp.rubicon.invCodes"); - expression = new IntersectsIntegers(category, asList(1, 2, 3)); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(LookupResult.ofValue(asList(2, 3, 4))).given(context).lookupIntegers(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupIntegers(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(LookupResult.ofValue(asList(4, 5))).given(context).lookupIntegers(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(LookupResult.empty()).given(context).lookupIntegers(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsNotDefined() { - // given - willReturn(LookupResult.empty()).given(context).lookupIntegers(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsSizesTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsSizesTest.java deleted file mode 100644 index 236c8a9f3eb..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsSizesTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.model.Size; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class IntersectsSizesTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = TargetingCategory.fromString("adunit.size"); - expression = new IntersectsSizes(category, asList(Size.of(250, 300), Size.of(300, 350), Size.of(350, 400))); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(LookupResult.ofValue(asList(Size.of(300, 350), Size.of(350, 400), Size.of(450, 500)))) - .given(context).lookupSizes(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupSizes(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(LookupResult.ofValue(asList(Size.of(450, 500), Size.of(500, 550)))) - .given(context).lookupSizes(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(LookupResult.empty()).given(context).lookupSizes(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsNotDefined() { - // given - willReturn(LookupResult.empty()).given(context).lookupSizes(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsStringsTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsStringsTest.java deleted file mode 100644 index d41ddd4db9d..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/IntersectsStringsTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class IntersectsStringsTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = TargetingCategory.fromString("adunit.mediatype"); - expression = new IntersectsStrings(category, asList("Pop", "Rock", "Alternative")); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(LookupResult.ofValue(asList("Rock", "Alternative", "Folk"))).given(context).lookupStrings(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupStrings(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(LookupResult.ofValue(asList("Folk", "Trance"))).given(context).lookupStrings(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldPerformCaseInsensitiveComparison() { - // given - willReturn(LookupResult.ofValue(asList("ROCK", "ALTERNATIVE", "FOLK"))).given(context).lookupStrings(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(LookupResult.empty()).given(context).lookupStrings(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsNotDefined() { - // given - willReturn(LookupResult.empty()).given(context).lookupStrings(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/MatchesTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/MatchesTest.java deleted file mode 100644 index c4fbab9a98b..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/MatchesTest.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.LookupResult; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class MatchesTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = TargetingCategory.fromString("adunit.adslot"); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForEquals() { - // given - expression = new Matches(category, "adunit"); - - willReturn(LookupResult.ofValue("adunit")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupString(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatchForEquals() { - // given - expression = new Matches(category, "adunit"); - - willReturn(LookupResult.ofValue("notadunit")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForStartsWith() { - // given - expression = new Matches(category, "adunit*"); - - willReturn(LookupResult.ofValue("adunitOne")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatchForStartsWith() { - // given - expression = new Matches(category, "adunit"); - - willReturn(LookupResult.ofValue("somedunit")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForEndsWith() { - // given - expression = new Matches(category, "*adunit"); - - willReturn(LookupResult.ofValue("someadunit")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatchForEndsWith() { - // given - expression = new Matches(category, "*adunit"); - - willReturn(LookupResult.ofValue("adunitOne")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForContainsInTheMiddle() { - // given - expression = new Matches(category, "*adunit*"); - - willReturn(LookupResult.ofValue("someadunitOne")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForContainsInTheBeginning() { - // given - expression = new Matches(category, "*adunit*"); - - willReturn(LookupResult.ofValue("adunitOne")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatchForContainsInTheEnd() { - // given - expression = new Matches(category, "*adunit*"); - - willReturn(LookupResult.ofValue("someadunit")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatchForContains() { - // given - expression = new Matches(category, "*adunit*"); - - willReturn(LookupResult.ofValue("One")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldPerformCaseInsensitiveComparison() { - // given - expression = new Matches(category, "AdUnIt"); - - willReturn(LookupResult.ofValue("aDuNiT")).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - expression = new Matches(category, "adunit"); - - willReturn(LookupResult.empty()).given(context).lookupString(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/NotTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/NotTest.java deleted file mode 100644 index ef1fec7e66f..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/NotTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; - -public class NotTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private TerminalExpression trueExpression; - @Mock - private TerminalExpression falseExpression; - @Mock - private RequestContext context; - - @Before - public void setUp() { - given(trueExpression.matches(any())).willReturn(true); - given(falseExpression.matches(any())).willReturn(false); - } - - @Test - public void matchesShouldReturnTrue() { - assertThat(new Not(trueExpression).matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalse() { - assertThat(new Not(falseExpression).matches(context)).isTrue(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/OrTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/OrTest.java deleted file mode 100644 index f677fd09da4..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/OrTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -public class OrTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private TerminalExpression trueExpression; - @Mock - private TerminalExpression falseExpression; - @Mock - private RequestContext context; - - @Before - public void setUp() { - given(trueExpression.matches(any())).willReturn(true); - given(falseExpression.matches(any())).willReturn(false); - } - - @Test - public void matchesShouldReturnTrue() { - assertThat(new Or(asList(trueExpression, trueExpression, trueExpression)).matches(context)).isTrue(); - } - - @Test - public void matchesShouldReturnFalse() { - assertThat(new Or(asList(falseExpression, falseExpression, falseExpression)).matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnTrueAndNotEvaluateRemainingExpressions() { - assertThat(new Or(asList(falseExpression, trueExpression, falseExpression)).matches(context)).isTrue(); - - verify(falseExpression).matches(context); - verify(trueExpression).matches(context); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/interpret/WithinTest.java b/src/test/java/org/prebid/server/deals/targeting/interpret/WithinTest.java deleted file mode 100644 index c6dccf1e537..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/interpret/WithinTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.prebid.server.deals.targeting.interpret; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.targeting.RequestContext; -import org.prebid.server.deals.targeting.model.GeoLocation; -import org.prebid.server.deals.targeting.model.GeoRegion; -import org.prebid.server.deals.targeting.syntax.TargetingCategory; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.verify; - -public class WithinTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private RequestContext context; - - private Expression expression; - private TargetingCategory category; - - @Before - public void setUp() { - // given - category = new TargetingCategory(TargetingCategory.Type.location); - expression = new Within(category, GeoRegion.of(50.424782f, 30.506423f, 10f)); - } - - @Test - public void matchesShouldReturnTrueWhenThereIsMatch() { - // given - willReturn(GeoLocation.of(50.442406f, 30.521439f)).given(context).lookupGeoLocation(any()); - - // when and then - assertThat(expression.matches(context)).isTrue(); - verify(context).lookupGeoLocation(eq(category)); - } - - @Test - public void matchesShouldReturnFalseWhenThereIsNoMatch() { - // given - willReturn(GeoLocation.of(50.588196f, 30.512357f)).given(context).lookupGeoLocation(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } - - @Test - public void matchesShouldReturnFalseWhenActualValueIsMissing() { - // given - willReturn(null).given(context).lookupGeoLocation(any()); - - // when and then - assertThat(expression.matches(context)).isFalse(); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/syntax/BooleanOperatorTest.java b/src/test/java/org/prebid/server/deals/targeting/syntax/BooleanOperatorTest.java deleted file mode 100644 index bfc03545845..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/syntax/BooleanOperatorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import org.assertj.core.api.SoftAssertions; -import org.junit.Test; - -import java.util.EnumMap; -import java.util.Map; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class BooleanOperatorTest { - - @Test - public void isBooleanOperatorShouldReturnTrueForKnownFunctions() { - SoftAssertions.assertSoftly(softly -> { - for (final String functionString : asList("$and", "$or", "$not")) { - softly.assertThat(BooleanOperator.isBooleanOperator(functionString)).isTrue(); - } - }); - } - - @Test - public void isBooleanOperatorShouldReturnFalseForUnknownFunctions() { - assertThat(BooleanOperator.isBooleanOperator("unknown")).isFalse(); - } - - @Test - public void fromStringShouldReturnEnumValue() { - // given - final EnumMap enumToString = new EnumMap<>(BooleanOperator.class); - enumToString.put(BooleanOperator.AND, "$and"); - enumToString.put(BooleanOperator.OR, "$or"); - enumToString.put(BooleanOperator.NOT, "$not"); - - // when and then - SoftAssertions.assertSoftly(softly -> { - for (final Map.Entry entry : enumToString.entrySet()) { - softly.assertThat(BooleanOperator.fromString(entry.getValue())).isEqualTo(entry.getKey()); - } - }); - } - - @Test - public void fromStringShouldThrowExceptionWhenUnkownFunction() { - assertThatThrownBy(() -> BooleanOperator.fromString("unknown")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unrecognized boolean operator: unknown"); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/syntax/MatchingFunctionTest.java b/src/test/java/org/prebid/server/deals/targeting/syntax/MatchingFunctionTest.java deleted file mode 100644 index 748ffd3289c..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/syntax/MatchingFunctionTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import org.assertj.core.api.SoftAssertions; -import org.junit.Test; - -import java.util.EnumMap; -import java.util.Map; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class MatchingFunctionTest { - - @Test - public void isMatchingFunctionShouldReturnTrueForKnownFunctions() { - SoftAssertions.assertSoftly(softly -> { - for (final String functionString : asList("$matches", "$in", "$intersects", "$within")) { - softly.assertThat(MatchingFunction.isMatchingFunction(functionString)).isTrue(); - } - }); - } - - @Test - public void isMatchingFunctionShouldReturnFalseForUnknownFunctions() { - assertThat(MatchingFunction.isMatchingFunction("unknown")).isFalse(); - } - - @Test - public void fromStringShouldReturnEnumValue() { - // given - final EnumMap enumToString = new EnumMap<>(MatchingFunction.class); - enumToString.put(MatchingFunction.MATCHES, "$matches"); - enumToString.put(MatchingFunction.IN, "$in"); - enumToString.put(MatchingFunction.INTERSECTS, "$intersects"); - enumToString.put(MatchingFunction.WITHIN, "$within"); - - // when and then - SoftAssertions.assertSoftly(softly -> { - for (final Map.Entry entry : enumToString.entrySet()) { - softly.assertThat(MatchingFunction.fromString(entry.getValue())).isEqualTo(entry.getKey()); - } - }); - } - - @Test - public void fromStringShouldThrowExceptionWhenUnkownFunction() { - assertThatThrownBy(() -> MatchingFunction.fromString("unknown")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unrecognized matching function: unknown"); - } -} diff --git a/src/test/java/org/prebid/server/deals/targeting/syntax/TargetingCategoryTest.java b/src/test/java/org/prebid/server/deals/targeting/syntax/TargetingCategoryTest.java deleted file mode 100644 index 8b75e609ed5..00000000000 --- a/src/test/java/org/prebid/server/deals/targeting/syntax/TargetingCategoryTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.prebid.server.deals.targeting.syntax; - -import org.assertj.core.api.AutoCloseableSoftAssertions; -import org.junit.Test; -import org.prebid.server.exception.TargetingSyntaxException; - -import java.util.List; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class TargetingCategoryTest { - - @Test - public void isTargetingCategoryShouldReturnTrueForKnownCategories() { - final List categories = asList( - "adunit.size", - "adunit.mediatype", - "adunit.adslot", - "site.domain", - "site.publisher.domain", - "site.referrer", - "app.bundle", - "device.geo.ext.vendor.attribute", - "device.geo.ext.vendor.nested.attribute", - "device.ext.vendor.attribute", - "device.ext.vendor.nested.attribute", - "pos", - "geo.distance", - "segment.bluekai", - "user.ext.time.userdow", - "user.ext.time.userhour", - "bidp.rubicon.siteId", - "ufpd.sport", - "sfpd.sport"); - - try (AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions()) { - categories.forEach(categoryString -> - softly.assertThat(TargetingCategory.isTargetingCategory(categoryString)).isTrue()); - } - } - - @Test - public void isTargetingCategoryShouldReturnFalseForUnknownCategory() { - assertThat(TargetingCategory.isTargetingCategory("phony")).isFalse(); - } - - @Test - public void fromStringShouldReturnCategoryWithoutPathForStaticTypes() { - final List categories = asList( - "adunit.size", - "adunit.mediatype", - "adunit.adslot", - "site.domain", - "site.publisher.domain", - "site.referrer", - "app.bundle", - "pos", - "geo.distance", - "user.ext.time.userdow", - "user.ext.time.userhour"); - - try (AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions()) { - for (final String categoryString : categories) { - final TargetingCategory category = TargetingCategory.fromString(categoryString); - softly.assertThat(category.type()).isEqualTo(TargetingCategory.Type.fromString(categoryString)); - softly.assertThat(category.path()).isNull(); - } - } - } - - @Test - public void fromStringShouldReturnCategoryWithPathForDynamicTypes() { - // when - final TargetingCategory bidderParamCategory = TargetingCategory.fromString("bidp.rubicon.siteId"); - // then - assertThat(bidderParamCategory.type()).isEqualTo(TargetingCategory.Type.bidderParam); - assertThat(bidderParamCategory.path()).isEqualTo("siteId"); - - // when - final TargetingCategory userSegmentCategory = TargetingCategory.fromString("segment.bluekai"); - // then - assertThat(userSegmentCategory.type()).isEqualTo(TargetingCategory.Type.userSegment); - assertThat(userSegmentCategory.path()).isEqualTo("bluekai"); - - // when - final TargetingCategory userFirstPartyDataCategory = TargetingCategory.fromString("ufpd.sport"); - // then - assertThat(userFirstPartyDataCategory.type()).isEqualTo(TargetingCategory.Type.userFirstPartyData); - assertThat(userFirstPartyDataCategory.path()).isEqualTo("sport"); - - // when - final TargetingCategory siteFirstPartyDataCategory = TargetingCategory.fromString("sfpd.sport"); - // then - assertThat(siteFirstPartyDataCategory.type()).isEqualTo(TargetingCategory.Type.siteFirstPartyData); - assertThat(siteFirstPartyDataCategory.path()).isEqualTo("sport"); - } - - @Test - public void fromStringShouldThrowExceptionWhenCategoryIsUnknown() { - assertThatThrownBy(() -> TargetingCategory.fromString("unknown")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unrecognized targeting category: unknown"); - } - - @Test - public void fromStringShouldThrowExceptionWhenBidderParamIsIncorrect() { - assertThatThrownBy(() -> TargetingCategory.fromString("bidp.rubicon")) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("BidderParam path is incorrect: rubicon"); - - assertThatThrownBy(() -> TargetingCategory.fromString("bidp.rubicon.")) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("BidderParam path is incorrect: rubicon."); - - assertThatThrownBy(() -> TargetingCategory.fromString("bidp.rubicon.siteId.")) - .isInstanceOf(TargetingSyntaxException.class) - .hasMessage("BidderParam path is incorrect: rubicon.siteId."); - } -} diff --git a/src/test/java/org/prebid/server/events/EventUtilTest.java b/src/test/java/org/prebid/server/events/EventUtilTest.java index 59a8b1044aa..12fe4381fe0 100644 --- a/src/test/java/org/prebid/server/events/EventUtilTest.java +++ b/src/test/java/org/prebid/server/events/EventUtilTest.java @@ -216,8 +216,7 @@ public void fromShouldReturnExpectedEventRequest() { .add("b", "bidId") .add("ts", "1000") .add("f", "i") - .add("x", "0") - .add("l", "lineItemId")); + .add("x", "0")); // when final EventRequest result = EventUtil.from(routingContext); @@ -231,7 +230,6 @@ public void fromShouldReturnExpectedEventRequest() { .timestamp(1000L) .format(EventRequest.Format.image) .analytics(EventRequest.Analytics.disabled) - .lineItemId("lineItemId") .build()); } @@ -273,7 +271,6 @@ public void toUrlShouldReturnExpectedUrl() { .integration("pbjs") .analytics(EventRequest.Analytics.enabled) .timestamp(1000L) - .lineItemId("lineItemId") .build(); // when @@ -282,12 +279,11 @@ public void toUrlShouldReturnExpectedUrl() { // then assertThat(result).isEqualTo( "http://external-url/event?t=win&b=bidId&a=accountId" - + "&aid=auctionId&ts=1000&bidder=bidder&f=b&int=pbjs&x=1" - + "&l=lineItemId"); + + "&aid=auctionId&ts=1000&bidder=bidder&f=b&int=pbjs&x=1"); } @Test - public void toUrlShouldReturnExpectedUrlWithoutFormatAndAnalyticsAndLineItemId() { + public void toUrlShouldReturnExpectedUrlWithoutFormatAndAnalytics() { // given final EventRequest eventRequest = EventRequest.builder() .type(EventRequest.Type.win) diff --git a/src/test/java/org/prebid/server/events/EventsServiceTest.java b/src/test/java/org/prebid/server/events/EventsServiceTest.java index 6ebab3978e6..d423044670a 100644 --- a/src/test/java/org/prebid/server/events/EventsServiceTest.java +++ b/src/test/java/org/prebid/server/events/EventsServiceTest.java @@ -30,30 +30,12 @@ public void createEventsShouldReturnExpectedEvent() { .build(); // when - final Events events = eventsService.createEvent("bidId", "bidder", "accountId", "lineItemId", true, - eventsContext); + final Events events = eventsService.createEvent("bidId", "bidder", "accountId", true, eventsContext); // then assertThat(events).isEqualTo(Events.of( - "http://external-url/event?t=win&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs&l=lineItemId", - "http://external-url/event?t=imp&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs&l=lineItemId")); - } - - @Test - public void createEventsShouldSkipLineItemIdIfMissing() { - // given - final EventsContext eventsContext = EventsContext.builder().auctionId("auctionId").integration( - "pbjs").auctionTimestamp(1000L).build(); - - // when - final Events events = eventsService.createEvent("bidId", "bidder", "accountId", null, true, eventsContext); - - // then - assertThat(events).isEqualTo(Events.of( - "http://external-url/event?t=win&b=bidId&a=accountId" - + "&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs", - "http://external-url/event?t=imp&b=bidId&a=accountId" - + "&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs")); + "http://external-url/event?t=win&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs", + "http://external-url/event?t=imp&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=i&int=pbjs")); } @Test @@ -62,15 +44,12 @@ public void createEventsShouldSetAnalyticsDisabled() { final EventsContext eventsContext = EventsContext.builder().integration("pbjs").auctionTimestamp(1000L).build(); // when - final Events events = eventsService.createEvent("bidId", "bidder", "accountId", "lineItemId", false, - eventsContext); + final Events events = eventsService.createEvent("bidId", "bidder", "accountId", false, eventsContext); // then assertThat(events).isEqualTo(Events.of( - "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0" - + "&l=lineItemId", - "http://external-url/event?t=imp&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0" - + "&l=lineItemId")); + "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0", + "http://external-url/event?t=imp&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0")); } @Test @@ -79,11 +58,11 @@ public void winUrlShouldReturnExpectedUrl() { final EventsContext eventsContext = EventsContext.builder().integration("pbjs").auctionTimestamp(1000L).build(); // when - final String winUrl = eventsService.winUrl("bidId", "bidder", "accountId", "lineItemId", true, eventsContext); + final String winUrl = eventsService.winUrl("bidId", "bidder", "accountId", true, eventsContext); // then assertThat(winUrl).isEqualTo( - "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&l=lineItemId"); + "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs"); } @Test @@ -92,12 +71,11 @@ public void winUrlShouldSEtAnalyticsDisabled() { final EventsContext eventsContext = EventsContext.builder().integration("pbjs").auctionTimestamp(1000L).build(); // when - final String winUrl = eventsService.winUrl("bidId", "bidder", "accountId", "lineItemId", false, eventsContext); + final String winUrl = eventsService.winUrl("bidId", "bidder", "accountId", false, eventsContext); // then assertThat(winUrl).isEqualTo( - "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0" - + "&l=lineItemId"); + "http://external-url/event?t=win&b=bidId&a=accountId&ts=1000&bidder=bidder&f=i&int=pbjs&x=0"); } @Test @@ -109,11 +87,10 @@ public void vastUrlShouldReturnExpectedUrl() { .build(); // when - final String vastUrl = eventsService.vastUrlTracking("bidId", "bidder", "accountId", "lineItemId", - eventsContext); + final String vastUrl = eventsService.vastUrlTracking("bidId", "bidder", "accountId", eventsContext); // then assertThat(vastUrl).isEqualTo( - "http://external-url/event?t=imp&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=b&int=pbjs&l=lineItemId"); + "http://external-url/event?t=imp&b=bidId&a=accountId&aid=auctionId&ts=1000&bidder=bidder&f=b&int=pbjs"); } } diff --git a/src/test/java/org/prebid/server/handler/DealsStatusHandlerTest.java b/src/test/java/org/prebid/server/handler/DealsStatusHandlerTest.java deleted file mode 100644 index 68e4a2fed66..00000000000 --- a/src/test/java/org/prebid/server/handler/DealsStatusHandlerTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.prebid.server.handler; - -import io.netty.handler.codec.http.HttpHeaderValues; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.ext.web.RoutingContext; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.util.HttpUtil; - -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -public class DealsStatusHandlerTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private DealsStatusHandler dealsStatusHandler; - - @Mock - private DeliveryProgressService deliveryProgressService; - - @Mock - private RoutingContext routingContext; - - @Mock - private HttpServerResponse httpServerResponse; - - @Before - public void setUp() { - dealsStatusHandler = new DealsStatusHandler(deliveryProgressService, jacksonMapper); - given(routingContext.response()).willReturn(httpServerResponse); - given(httpServerResponse.putHeader(any(CharSequence.class), any(CharSequence.class))) - .willReturn(httpServerResponse); - given(httpServerResponse.closed()).willReturn(false); - given(httpServerResponse.exceptionHandler(any())).willReturn(httpServerResponse); - } - - @Test - public void handleShouldNotSendDeliveryProgressReportWhenClientHasGone() { - // given - given(httpServerResponse.closed()).willReturn(true); - - // when - dealsStatusHandler.handle(routingContext); - - // then - verify(httpServerResponse, never()).end(); - } - - @Test - public void handleShouldReturnDeliveryProgressReport() throws IOException { - // given - given(deliveryProgressService.getOverallDeliveryProgressReport()) - .willReturn(DeliveryProgressReport.builder().reportId("reportId").build()); - - // when - dealsStatusHandler.handle(routingContext); - - // then - final String responseBody = getResponseBody(); - verify(httpServerResponse).putHeader(eq(HttpUtil.CONTENT_TYPE_HEADER), eq(HttpHeaderValues.APPLICATION_JSON)); - assertThat(mapper.readValue(responseBody, DeliveryProgressReport.class)) - .isEqualTo(DeliveryProgressReport.builder().reportId("reportId").build()); - } - - private String getResponseBody() { - final ArgumentCaptor bodyCaptor = ArgumentCaptor.forClass(String.class); - verify(httpServerResponse).end(bodyCaptor.capture()); - return bodyCaptor.getValue(); - } -} diff --git a/src/test/java/org/prebid/server/handler/ForceDealsUpdateHandlerTest.java b/src/test/java/org/prebid/server/handler/ForceDealsUpdateHandlerTest.java deleted file mode 100644 index 3a414d3eb36..00000000000 --- a/src/test/java/org/prebid/server/handler/ForceDealsUpdateHandlerTest.java +++ /dev/null @@ -1,240 +0,0 @@ -package org.prebid.server.handler; - -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.ext.web.RoutingContext; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.deals.AlertHttpService; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.DeliveryStatsService; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.PlannerService; -import org.prebid.server.deals.RegisterService; -import org.prebid.server.exception.PreBidException; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; - -public class ForceDealsUpdateHandlerTest { - - private static final String ACTION_NAME_PARAM = "action_name"; - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private DeliveryStatsService deliveryStatsService; - @Mock - private PlannerService plannerService; - @Mock - private RegisterService registerService; - @Mock - private AlertHttpService alertHttpService; - @Mock - private DeliveryProgressService deliveryProgressService; - @Mock - private LineItemService lineItemService; - - private ForceDealsUpdateHandler handler; - @Mock - private RoutingContext routingContext; - @Mock - private HttpServerRequest httpRequest; - @Mock - private HttpServerResponse httpResponse; - - @Before - public void setUp() { - handler = new ForceDealsUpdateHandler( - deliveryStatsService, - plannerService, - registerService, - alertHttpService, - deliveryProgressService, - lineItemService, - "/endpoint"); - - given(routingContext.request()).willReturn(httpRequest); - given(routingContext.response()).willReturn(httpResponse); - - given(httpResponse.setStatusCode(anyInt())).willReturn(httpResponse); - given(httpResponse.closed()).willReturn(false); - } - - @Test - public void shouldReturnBadRequestWhenActionParamIsMissing() { - // given - given(httpRequest.getParam(any())).willReturn(null); - - // when - handler.handle(routingContext); - - // then - verify(httpRequest).getParam(eq(ACTION_NAME_PARAM)); - - verify(httpResponse).setStatusCode(400); - verify(httpResponse).end("Parameter '%s' is required and can't be empty".formatted(ACTION_NAME_PARAM)); - } - - @Test - public void shouldReturnBadRequestWhenBadActionParamIsGiven() { - // given - final String badParamName = "bad_param_name"; - given(httpRequest.getParam(any())).willReturn(badParamName); - - // when - handler.handle(routingContext); - - // then - verify(httpRequest).getParam(eq(ACTION_NAME_PARAM)); - - verify(httpResponse).setStatusCode(400); - verify(httpResponse).end("Given '%s' parameter value '%s' is not among possible actions" - .formatted(ACTION_NAME_PARAM, badParamName)); - } - - @Test - public void shouldCallLineItemsUpdateMethodWhenUpdateLineItemsParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.UPDATE_LINE_ITEMS.name()); - - // when - handler.handle(routingContext); - - // then - verify(plannerService).updateLineItemMetaData(); - verifyNoInteractions(deliveryStatsService, registerService, alertHttpService, deliveryProgressService, - lineItemService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldCallReportSendingMethodWhenSendReportParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.SEND_REPORT.name()); - - // when - handler.handle(routingContext); - - // then - verify(deliveryStatsService).sendDeliveryProgressReports(); - verifyNoInteractions(plannerService, registerService, alertHttpService, deliveryProgressService, - lineItemService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldCallRegisterInstanceMethodWhenRegisterInstanceParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.REGISTER_INSTANCE.name()); - - // when - handler.handle(routingContext); - - // then - verify(registerService).performRegistration(); - verifyNoInteractions(plannerService, deliveryStatsService, alertHttpService, deliveryProgressService, - lineItemService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldCallResetAlertCountMethodWhenResetAlertCounterParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.RESET_ALERT_COUNT.name()); - - // when - handler.handle(routingContext); - - // then - verify(alertHttpService).resetAlertCount("pbs-register-client-error"); - verify(alertHttpService).resetAlertCount("pbs-planner-client-error"); - verify(alertHttpService).resetAlertCount("pbs-planner-empty-response-error"); - verify(alertHttpService).resetAlertCount("pbs-delivery-stats-client-error"); - verifyNoInteractions(plannerService, deliveryStatsService, registerService, deliveryProgressService, - lineItemService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldCallCreateReportMethodWhenCreateReportParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.CREATE_REPORT.name()); - - // when - handler.handle(routingContext); - - // then - verify(deliveryProgressService).createDeliveryProgressReports(any()); - verifyNoInteractions(registerService, plannerService, deliveryStatsService, alertHttpService, - lineItemService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldCallInvalidateLineItemsMethodWhenInvalidateLineItemsParamIsGiven() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.INVALIDATE_LINE_ITEMS.name()); - - // when - handler.handle(routingContext); - - // then - verify(lineItemService).invalidateLineItems(); - verifyNoInteractions(registerService, plannerService, deliveryStatsService, alertHttpService, - deliveryProgressService); - - verify(httpResponse).setStatusCode(204); - verify(httpResponse).end(); - } - - @Test - public void shouldReturnInternalServerExceptionWhenUpdatingLineItemActionFailed() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.UPDATE_LINE_ITEMS.name()); - final String exceptionMessage = "Failed to fetch data from Planner"; - doThrow(new PreBidException(exceptionMessage)).when(plannerService).updateLineItemMetaData(); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(500); - verify(httpResponse).end(exceptionMessage); - } - - @Test - public void shouldReturnInternalServerExceptionWhenSendingReportActionFailed() { - // given - given(httpRequest.getParam(any())).willReturn(ForceDealsUpdateHandler.DealsAction.SEND_REPORT.name()); - final String exceptionMessage = "Sending report failed"; - doThrow(new PreBidException(exceptionMessage)).when(deliveryStatsService).sendDeliveryProgressReports(); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(500); - verify(httpResponse).end(exceptionMessage); - } -} diff --git a/src/test/java/org/prebid/server/handler/LineItemStatusHandlerTest.java b/src/test/java/org/prebid/server/handler/LineItemStatusHandlerTest.java deleted file mode 100644 index d05dbe49b76..00000000000 --- a/src/test/java/org/prebid/server/handler/LineItemStatusHandlerTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.prebid.server.handler; - -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.ext.web.RoutingContext; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.DeliveryProgressService; -import org.prebid.server.deals.proto.report.LineItemStatusReport; -import org.prebid.server.exception.PreBidException; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -public class LineItemStatusHandlerTest extends VertxTest { - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock - private DeliveryProgressService deliveryProgressService; - - private LineItemStatusHandler handler; - @Mock - private RoutingContext routingContext; - @Mock - private HttpServerRequest httpRequest; - @Mock - private HttpServerResponse httpResponse; - - @Before - public void setUp() { - given(routingContext.request()).willReturn(httpRequest); - given(routingContext.response()).willReturn(httpResponse); - - given(httpRequest.headers()).willReturn(MultiMap.caseInsensitiveMultiMap()); - given(httpResponse.setStatusCode(anyInt())).willReturn(httpResponse); - - given(routingContext.request().getParam(any())).willReturn("lineItemId"); - - handler = new LineItemStatusHandler(deliveryProgressService, jacksonMapper, "endpoint"); - } - - @Test - public void handleShouldRespondWithErrorIfNoLineItemIdSpecified() { - // given - given(routingContext.request().getParam(any())).willReturn(null); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(400); - verify(httpResponse).end("id parameter is required"); - } - - @Test - public void handleShouldRespondWithErrorIfProcessingFailed() { - // given - given(deliveryProgressService.getLineItemStatusReport(any())).willThrow(new PreBidException("error")); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(400); - verify(httpResponse).end("error"); - } - - @Test - public void handleShouldRespondWithErrorIfUnexpectedExceptionOccurred() { - // given - given(deliveryProgressService.getLineItemStatusReport(any())).willThrow(new RuntimeException("error")); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(500); - verify(httpResponse).end("error"); - } - - @Test - public void handleShouldRespondWithExpectedResult() { - // given - given(deliveryProgressService.getLineItemStatusReport(any())) - .willReturn(LineItemStatusReport.builder().lineItemId("lineItemId").build()); - - // when - handler.handle(routingContext); - - // then - verify(httpResponse).setStatusCode(200); - verify(httpResponse).end("{\"lineItemId\":\"lineItemId\"}"); - } -} diff --git a/src/test/java/org/prebid/server/handler/NotificationEventHandlerTest.java b/src/test/java/org/prebid/server/handler/NotificationEventHandlerTest.java index 42a5a78bad7..3262830eba7 100644 --- a/src/test/java/org/prebid/server/handler/NotificationEventHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/NotificationEventHandlerTest.java @@ -19,9 +19,6 @@ import org.prebid.server.analytics.model.NotificationEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; import org.prebid.server.auction.model.Tuple2; -import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.deals.UserService; -import org.prebid.server.deals.events.ApplicationEventService; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.model.CaseInsensitiveMultiMap; @@ -38,8 +35,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; @@ -49,12 +44,6 @@ public class NotificationEventHandlerTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); - @Mock - private UidsCookieService uidsCookieService; - @Mock - private ApplicationEventService applicationEventService; - @Mock - private UserService userService; @Mock private ActivityInfrastructureCreator activityInfrastructureCreator; @Mock @@ -85,15 +74,11 @@ public void setUp() { given(httpResponse.setStatusCode(anyInt())).willReturn(httpResponse); notificationHandler = new NotificationEventHandler( - uidsCookieService, - applicationEventService, - userService, activityInfrastructureCreator, analyticsReporterDelegator, timeoutFactory, applicationSettings, - 1000, - true); + 1000); } @Test @@ -315,117 +300,6 @@ public void shouldPassEventToAnalyticsReporterWhenAccountEventEnabled() { }); } - @Test - public void shouldUpdateEventForLineItemForEventTypeWinAndAccountEventsEnabled() { - // given - given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap() - .add("t", "win") - .add("b", "bidId") - .add("l", "lineItemId") - .add("a", "accountId")); - - final Account account = Account.builder() - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build(); - given(applicationSettings.getAccountById(anyString(), any())) - .willReturn(Future.succeededFuture(account)); - - // when - notificationHandler.handle(routingContext); - - // then - verify(applicationEventService).publishLineItemWinEvent(eq("lineItemId")); - } - - @Test - public void shouldProcessLineItemEventWhenRequestAnalyticsFlagDisabled() { - // given - given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap() - .add("t", "win") - .add("b", "bidId") - .add("l", "lineItemId") - .add("a", "accountId") - .add("x", "0")); - - final Account account = Account.builder() - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build(); - given(applicationSettings.getAccountById(anyString(), any())) - .willReturn(Future.succeededFuture(account)); - - // when - notificationHandler.handle(routingContext); - - // then - verify(applicationEventService).publishLineItemWinEvent(eq("lineItemId")); - verify(userService).processWinEvent(eq("lineItemId"), eq("bidId"), any()); - } - - @Test - public void shouldProcessLineItemEventWhenAccountEventsDisabled() { - // given - given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap() - .add("t", "win") - .add("b", "bidId") - .add("l", "lineItemId") - .add("a", "accountId")); - - final Account account = Account.builder() - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(false)) - .build()) - .build(); - given(applicationSettings.getAccountById(anyString(), any())) - .willReturn(Future.succeededFuture(account)); - - // when - notificationHandler.handle(routingContext); - - // then - verify(applicationEventService).publishLineItemWinEvent(eq("lineItemId")); - verify(userService).processWinEvent(eq("lineItemId"), eq("bidId"), any()); - } - - @Test - public void shouldNotProcessLineItemEventWhenDealsDisabled() { - // given - notificationHandler = new NotificationEventHandler( - uidsCookieService, - applicationEventService, - userService, - activityInfrastructureCreator, - analyticsReporterDelegator, - timeoutFactory, - applicationSettings, - 1000, - false); - - given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap() - .add("t", "win") - .add("b", "bidId") - .add("l", "lineItemId") - .add("a", "accountId")); - - final Account account = Account.builder() - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build(); - given(applicationSettings.getAccountById(anyString(), any())) - .willReturn(Future.succeededFuture(account)); - - // when - notificationHandler.handle(routingContext); - - // then - verifyNoInteractions(applicationEventService); - verifyNoInteractions(userService); - } - @Test public void shouldNotPassEventToAnalyticsReporterWhenAnalyticsValueIsZero() { // given @@ -567,56 +441,6 @@ public void shouldPassExpectedEventToAnalyticsReporter() { }); } - @Test - public void shouldPassEventObjectToUserServiceWhenLineItemIdParameterIsPresent() { - // given - given(httpRequest.params()) - .willReturn(MultiMap.caseInsensitiveMultiMap() - .add("t", "win") - .add("b", "bidId") - .add("a", "accountId") - .add("l", "lineItemId")); - - given(applicationSettings.getAccountById(anyString(), any())) - .willReturn(Future.succeededFuture(Account.builder() - .id("accountId") - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build())); - - // when - notificationHandler.handle(routingContext); - - // then - verify(uidsCookieService).parseFromRequest(eq(routingContext)); - - final CaseInsensitiveMultiMap.Builder queryParams = CaseInsensitiveMultiMap.builder() - .add("t", "win") - .add("b", "bidId") - .add("a", "accountId") - .add("l", "lineItemId"); - - final HttpRequestContext expectedHttpContext = HttpRequestContext.builder() - .queryParams(queryParams.build()) - .headers(CaseInsensitiveMultiMap.empty()) - .build(); - - verify(userService).processWinEvent(eq("lineItemId"), eq("bidId"), isNull()); - assertThat(captureAnalyticEvent()).satisfies(event -> { - assertThat(event.getType()).isEqualTo(NotificationEvent.Type.win); - assertThat(event.getBidId()).isEqualTo("bidId"); - assertThat(event.getAccount()).isEqualTo(Account.builder() - .id("accountId") - .auction(AccountAuctionConfig.builder() - .events(AccountEventsConfig.of(true)) - .build()) - .build()); - assertThat(event.getHttpContext()).isEqualTo(expectedHttpContext); - assertThat(event.getLineItemId()).isEqualTo("lineItemId"); - }); - } - private Integer captureResponseStatusCode() { final ArgumentCaptor captor = ArgumentCaptor.forClass(Integer.class); verify(httpResponse).setStatusCode(captor.capture()); diff --git a/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java b/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java index fe86539c68c..0d94217fea3 100644 --- a/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java @@ -54,7 +54,7 @@ public void handleShouldReturnBadRequestWhenNoParametersInRequest() { // then verify(httpResponse).setStatusCode(eq(400)); - verify(httpResponse).end(eq("At least one parameter should ne defined: account, bidderCode, lineItemId")); + verify(httpResponse).end(eq("At least one parameter should be defined: account, bidderCode")); } @Test @@ -90,7 +90,7 @@ public void handleShouldReturnBadRequestWhenLogLevelHasIncorrectValue() { given(httpRequest.params()).willReturn(MultiMap.caseInsensitiveMultiMap().add("account", "1001") .add("duration", "200").add("level", "invalid")); doThrow(new IllegalArgumentException("Invalid LoggingLevel: invalid")) - .when(criteriaManager).addCriteria(any(), any(), any(), any(), any()); + .when(criteriaManager).addCriteria(any(), any(), any(), any()); // when tracerLogHandler.handle(routingContext); diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java index 33b071d9a95..502f13fccc6 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java @@ -566,7 +566,7 @@ public void shouldRespondWithDebugInfoIncludedIfTestFlagIsTrue() { givenHoldAuction(givenBidResponseWithExt( ExtBidResponse.builder() - .debug(ExtResponseDebug.of(null, auctionContext.getBidRequest(), null, null)) + .debug(ExtResponseDebug.of(null, auctionContext.getBidRequest(), null)) .prebid(ExtBidResponsePrebid.builder().auctiontimestamp(1000L).targeting(emptyMap()).build()) .build())); diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java index 17ef6934398..14f83a310f9 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java @@ -395,8 +395,7 @@ public void shouldRespondWithCorrectResolvedRequestMediaTypePriceGranularity() { final BidResponse bidResponse = BidResponse.builder() .ext(ExtBidResponse.builder() - .debug(ExtResponseDebug.of(null, resolvedRequest, - null, null)) + .debug(ExtResponseDebug.of(null, resolvedRequest, null)) .build()) .build(); final AuctionContext auctionContext = AuctionContext.builder() diff --git a/src/test/java/org/prebid/server/it/ApplicationTest.java b/src/test/java/org/prebid/server/it/ApplicationTest.java index 4184a06f04c..ac40c02648c 100644 --- a/src/test/java/org/prebid/server/it/ApplicationTest.java +++ b/src/test/java/org/prebid/server/it/ApplicationTest.java @@ -649,7 +649,6 @@ public void traceHandlerShouldReturn200Ok() { .param("duration", "1000") .param("account", "1001") .param("bidderCode", "rubicon") - .param("lineitemId", "1001") .post("/pbs-admin/tracelog") .then() .assertThat() diff --git a/src/test/java/org/prebid/server/it/DealsSimulationTest.java b/src/test/java/org/prebid/server/it/DealsSimulationTest.java deleted file mode 100644 index ffed682509e..00000000000 --- a/src/test/java/org/prebid/server/it/DealsSimulationTest.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.prebid.server.it; - -import com.github.tomakehurst.wiremock.client.VerificationException; -import com.github.tomakehurst.wiremock.junit.WireMockClassRule; -import com.github.tomakehurst.wiremock.matching.AnythingPattern; -import com.github.tomakehurst.wiremock.verification.LoggedRequest; -import io.restassured.response.Response; -import io.restassured.specification.RequestSpecification; -import org.json.JSONException; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.LineItemService; -import org.skyscreamer.jsonassert.ArrayValueMatcher; -import org.skyscreamer.jsonassert.Customization; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.skyscreamer.jsonassert.ValueMatcher; -import org.skyscreamer.jsonassert.comparator.CustomComparator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.WeekFields; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static io.restassured.RestAssured.given; -import static java.util.Collections.singletonList; -import static org.awaitility.Awaitility.await; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) -@RunWith(SpringRunner.class) -@TestPropertySource(locations = { - "test-application.properties", - "deals/test-deals-application.properties", - "deals/test-deals-simulation-application.properties"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) -public class DealsSimulationTest extends VertxTest { - - private static final int APP_PORT = 10080; - private static final int WIREMOCK_PORT = 8090; - - private static final RequestSpecification SPEC = IntegrationTest.spec(APP_PORT); - - @ClassRule - public static final WireMockClassRule WIRE_MOCK_RULE = new WireMockClassRule(options().port(WIREMOCK_PORT)); - - private static final ZonedDateTime NOW = ZonedDateTime.now( - Clock.fixed(Instant.parse("2019-10-10T00:00:00Z"), ZoneOffset.UTC)); - - private static final DateTimeFormatter UTC_MILLIS_FORMATTER = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - .toFormatter(); - - private static final String RUBICON = "rubicon"; - - @Autowired - private LineItemService lineItemService; - - @Autowired - private Clock clock; - - @BeforeClass - public static void setUpInner() throws IOException { - // given - WIRE_MOCK_RULE.stubFor(get(urlPathEqualTo("/planner-plan")) - .withQueryParam("instanceId", equalTo("localhost")) - .withQueryParam("region", equalTo("local")) - .withQueryParam("vendor", equalTo("local")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .withHeader("pg-sim-timestamp", equalTo(UTC_MILLIS_FORMATTER.format(NOW))) - .willReturn(aResponse() - .withBody(IntegrationTest.jsonFrom("deals/simulation/test-planner-plan-response-1.json")))); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/planner-register")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .withHeader("pg-sim-timestamp", equalTo(NOW.toString())) - .withRequestBody(equalToJson(IntegrationTest.jsonFrom( - "deals/simulation/test-planner-register-request-1.json"))) - .willReturn(aResponse())); - } - - @Test - public void openrtb2AuctionShouldRespondWithDealBids() throws IOException, JSONException, InterruptedException { - // given - given(SPEC) - .header("pg-sim-timestamp", NOW.plusSeconds(0).toString()) - .when() - .post("/pbs-admin/e2eAdmin/planner/fetchLineItems"); - - TimeUnit.SECONDS.sleep(1); // no way to check that planner response handling is complete - - given(SPEC) - .when() - .header("pg-sim-timestamp", NOW.plusSeconds(1).toString()) - .post("/pbs-admin/e2eAdmin/advancePlans"); - - awaitForLineItemMetadata(NOW.plusSeconds(1)); - - given(SPEC) - .when() - .body(IntegrationTest.jsonFrom("deals/simulation/test-bid-rates.json")) - .post("/pbs-admin/e2eAdmin/bidRate"); - - final Response beforePlansUpdateResponse = given(SPEC) - .header("Referer", "http://www.example.com") - .header("User-Agent", "userAgent") - .header("X-Forwarded-For", "185.199.110.153") - .header("pg-sim-timestamp", NOW.plusSeconds(2).toString()) - // this uids cookie value stands for {"uids":{"rubicon":"J5VLCWQP-26-CWFT"}} - .cookie("uids", "eyJ1aWRzIjp7InJ1Ymljb24iOiJKNVZMQ1dRUC0yNi1DV0ZUIn19") - .body(IntegrationTest.jsonFrom("deals/simulation/test-auction-request.json")) - .post("/openrtb2/auction"); - - assertResponse("deals/simulation/test-auction-response-1.json", beforePlansUpdateResponse, - singletonList(RUBICON)); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/delivery-stats-progress")) - .withBasicAuth("username", "password") - .withHeader("pg-sim-timestamp", equalTo(UTC_MILLIS_FORMATTER.format(NOW.plusSeconds(3)))) - .withHeader("pg-trx-id", new AnythingPattern()) - .willReturn(aResponse())); - - given(SPEC) - .when() - .header("pg-sim-timestamp", NOW.plusSeconds(3).toString()) - .post("/pbs-admin/e2eAdmin/dealstats/report"); - - // update plans for now date = 2019-10-10T00:15:00Z - making lineItem1 inactive due to absence of active plan - given(SPEC) - .when() - .header("pg-sim-timestamp", NOW.plusMinutes(15).toString()) - .post("/pbs-admin/e2eAdmin/advancePlans"); - - final Response afterPlansUpdateResponse = given(SPEC) - .header("Referer", "http://www.example.com") - .header("User-Agent", "userAgent") - .header("X-Forwarded-For", "185.199.110.153") - .header("pg-sim-timestamp", NOW.plusMinutes(16).toString()) - // this uids cookie value stands for {"uids":{"rubicon":"J5VLCWQP-26-CWFT"}} - .cookie("uids", "eyJ1aWRzIjp7InJ1Ymljb24iOiJKNVZMQ1dRUC0yNi1DV0ZUIn19") - .body(IntegrationTest.jsonFrom("deals/simulation/test-auction-request.json")) - .post("/openrtb2/auction"); - - assertResponse("deals/simulation/test-auction-response-2.json", afterPlansUpdateResponse, - singletonList(RUBICON)); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/delivery-stats-progress")) - .withBasicAuth("username", "password") - .withHeader("pg-sim-timestamp", equalTo(UTC_MILLIS_FORMATTER.format(NOW.plusMinutes(17)))) - .withHeader("pg-trx-id", new AnythingPattern()) - .willReturn(aResponse())); - - given(SPEC) - .when() - .header("pg-sim-timestamp", NOW.plusMinutes(17).toString()) - .post("/pbs-admin/e2eAdmin/dealstats/report"); - - assertDeliveryStatsProgressRequests( - "deals/simulation/test-delivery-stats-progress-request-1.json", - "deals/simulation/test-delivery-stats-progress-request-2.json"); - - given(SPEC) - .header("pg-sim-timestamp", NOW.toString()) - .when() - .post("/pbs-admin/e2eAdmin/planner/register"); - } - - private void awaitForLineItemMetadata(ZonedDateTime now) { - await().atMost(20, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS) - .until(() -> lineItemService.accountHasDeals("2001", now)); - } - - /** - * Timestamps in response are always generated anew. - * This comparator allows to just verify they are present and parsable. - */ - private static CustomComparator openrtbDeepDebugTimeComparator() { - final ValueMatcher timeValueMatcher = (actual, expected) -> { - try { - return mapper.readValue("\"" + actual.toString() + "\"", ZonedDateTime.class) != null; - } catch (IOException e) { - return false; - } - }; - - final ArrayValueMatcher arrayValueMatcher = new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.trace.deals[*].time", timeValueMatcher))); - - final List arrayValueMatchers = IntStream.range(1, 5) - .mapToObj(i -> new Customization("ext.debug.trace.lineitems.lineItem" + i, - new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.trace.lineitems.lineItem" + i + "[*].time", - timeValueMatcher))))) - .collect(Collectors.toCollection(ArrayList::new)); - - arrayValueMatchers.add(new Customization("ext.debug.trace.deals", arrayValueMatcher)); - - return new CustomComparator(JSONCompareMode.NON_EXTENSIBLE, - arrayValueMatchers.toArray(Customization[]::new)); - } - - private void assertResponse(String expectedResponsePath, Response response, List bidders) - throws IOException, JSONException { - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - expectedResponsePath, response, bidders)); - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - public static void assertDeliveryStatsProgressRequests(String path1, String path2) - throws IOException, JSONException { - final String firstReportRequest = IntegrationTest.jsonFrom(path1); - final String secondReportRequest = IntegrationTest.jsonFrom(path2); - - await().atMost(20, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> - verify(() -> WIRE_MOCK_RULE.verify(2, postRequestedFor(urlPathEqualTo("/delivery-stats-progress"))))); - - final List loggedRequests = - WIRE_MOCK_RULE.findAll(postRequestedFor(urlPathEqualTo("/delivery-stats-progress"))); - - JSONAssert.assertEquals(firstReportRequest, loggedRequests.get(0).getBodyAsString(), JSONCompareMode.LENIENT); - JSONAssert.assertEquals(secondReportRequest, loggedRequests.get(1).getBodyAsString(), JSONCompareMode.LENIENT); - } - - private String withTemporalFields(String auctionResponse) { - final ZonedDateTime dateTime = ZonedDateTime.now(clock); - - return auctionResponse - .replaceAll("\"?\\{\\{ userdow }}\"?", Integer.toString( - dateTime.getDayOfWeek().get(WeekFields.SUNDAY_START.dayOfWeek()))) - .replaceAll("\"?\\{\\{ userhour }}\"?", Integer.toString(dateTime.getHour())); - } - - private static boolean verify(Runnable verify) { - try { - verify.run(); - return true; - } catch (VerificationException e) { - return false; - } - } -} diff --git a/src/test/java/org/prebid/server/it/DealsTest.java b/src/test/java/org/prebid/server/it/DealsTest.java deleted file mode 100644 index 78f775288d8..00000000000 --- a/src/test/java/org/prebid/server/it/DealsTest.java +++ /dev/null @@ -1,333 +0,0 @@ -package org.prebid.server.it; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.github.tomakehurst.wiremock.client.CountMatchingStrategy; -import com.github.tomakehurst.wiremock.client.VerificationException; -import com.github.tomakehurst.wiremock.junit.WireMockClassRule; -import com.github.tomakehurst.wiremock.matching.AnythingPattern; -import com.github.tomakehurst.wiremock.verification.LoggedRequest; -import io.restassured.response.Response; -import io.restassured.specification.RequestSpecification; -import org.apache.commons.collections4.CollectionUtils; -import org.json.JSONException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.LineItemService; -import org.prebid.server.deals.proto.report.DeliveryProgressReport; -import org.prebid.server.deals.proto.report.Event; -import org.prebid.server.deals.proto.report.LineItemStatus; -import org.skyscreamer.jsonassert.ArrayValueMatcher; -import org.skyscreamer.jsonassert.Customization; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.skyscreamer.jsonassert.ValueMatcher; -import org.skyscreamer.jsonassert.comparator.CustomComparator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.temporal.WeekFields; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static io.restassured.RestAssured.given; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.prebid.server.it.IntegrationTest.equalToBidCacheRequest; -import static org.prebid.server.it.IntegrationTest.openrtbAuctionResponseFrom; -import static org.prebid.server.util.IntegrationTestsUtil.jsonFrom; -import static org.skyscreamer.jsonassert.JSONCompare.compareJSON; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) -@RunWith(SpringRunner.class) -@TestPropertySource(locations = {"test-application.properties", "deals/test-deals-application.properties"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) -public class DealsTest extends VertxTest { - - private static final int APP_PORT = 8070; - private static final int WIREMOCK_PORT = 8090; - - private static final RequestSpecification SPEC = IntegrationTest.spec(APP_PORT); - - @SuppressWarnings("unchecked") - @ClassRule - public static final WireMockClassRule WIRE_MOCK_RULE = new WireMockClassRule(options() - .port(WIREMOCK_PORT) - .extensions( - IntegrationTest.CacheResponseTransformer.class, - IntegrationTest.ResponseOrderTransformer.class)); - - private static final String GENERIC = "generic"; - - @Autowired - private LineItemService lineItemService; - - @Autowired - private Clock clock; - - @BeforeClass - public static void setUpInner() throws IOException { - // given - WIRE_MOCK_RULE.stubFor(get(urlPathEqualTo("/periodic-update")) - .willReturn(aResponse() - .withJsonBody(mapper.createObjectNode() - .putPOJO("requests", emptyMap()) - .putPOJO("imps", emptyMap())))); - - WIRE_MOCK_RULE.stubFor(get(urlPathEqualTo("/currency-rates")) - .willReturn(aResponse().withJsonBody(mapper.createObjectNode()))); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/delivery-stats-progress")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .willReturn(aResponse())); - - WIRE_MOCK_RULE.stubFor(get(urlPathEqualTo("/planner-plan")) - .withQueryParam("instanceId", equalTo("localhost")) - .withQueryParam("region", equalTo("local")) - .withQueryParam("vendor", equalTo("local")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .willReturn(aResponse().withBody(plannerResponseFrom("deals/test-planner-plan-response.json")))); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/planner-register")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .withRequestBody(equalToJson(jsonFrom("deals/test-planner-register-request.json"), false, true)) - .willReturn(aResponse().withBody(jsonFrom("deals/test-planner-register-response.json")))); - - // pre-bid cache - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/cache")) - .withRequestBody(equalToBidCacheRequest(jsonFrom("deals/test-cache-deals-request.json"))) - .willReturn(aResponse() - .withTransformers("cache-response-transformer") - .withTransformerParameter("matcherName", "deals/test-cache-matcher.json"))); - } - - @Before - public void setUp() throws IOException { - // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/user-data-win-event")) - .withRequestBody(equalToJson(jsonFrom("deals/test-user-data-win-event-request.json"), false, true)) - .willReturn(aResponse())); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/user-data-details")) - .withRequestBody(equalToJson(jsonFrom("deals/test-user-data-details-request.json"), false, true)) - .willReturn(aResponse().withBody(jsonFrom("deals/test-user-data-details-generic-response.json")))); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/generic-exchange")) - .withRequestBody(equalToJson(jsonFrom("deals/test-generic-bid-request.json"), false, true)) - .willReturn(aResponse() - .withFixedDelay(600) - .withBody(jsonFrom("deals/test-generic-bid-response.json")))); - } - - @Test - public void openrtb2AuctionShouldRespondWithDealBids() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - // when - final Response response = given(SPEC) - .header("Referer", "http://www.example.com") - .header("User-Agent", "userAgent") - .header("X-Forwarded-For", "185.199.110.153") - // this uids cookie value stands for { "tempUIDs":{ "rubicon":{ "uid":"J5VLCWQP-26-CWFT", - // "expires":"2023-12-05T19:00:05.103329-03:00" } } } - .cookie("uids", "eyAidGVtcFVJRHMiOnsgInJ1Ymljb24iOnsgInVpZCI6Iko1VkxDV1FQ" - + "LTI2LUNXRlQiLCAiZXhwaXJlcyI6IjIwMjMtMTItMDVUMTk6MDA6MDUuMTAzMzI5LTAzOjAwIiB9IH0gfQ==") - .body(jsonFrom("deals/test-auction-request.json")) - .post("/openrtb2/auction"); - - // then - JSONAssert.assertEquals( - withTemporalFields(openrtbAuctionResponseFrom( - "deals/test-auction-response.json", response, singletonList(GENERIC))), - response.asString(), - openrtbDeepDebugTimeComparator()); - - // when - final Response eventResponse = given(SPEC) - .queryParam("t", "win") - .queryParam("b", "bidId") - .queryParam("a", "14062") - .queryParam("l", "lineItem1") - .queryParam("f", "i") - // this uids cookie value stands for { "tempUIDs":{ "rubicon":{ "uid":"J5VLCWQP-26-CWFT", - // "expires":"2023-12-05T19:00:05.103329-03:00" } } } - .cookie("uids", "eyAidGVtcFVJRHMiOnsgInJ1Ymljb24iOnsgInVpZCI6Iko1VkxDV1FQ" - + "LTI2LUNXRlQiLCAiZXhwaXJlcyI6IjIwMjMtMTItMDVUMTk6MDA6MDUuMTAzMzI5LTAzOjAwIiB9IH0gfQ==") - .get("/event"); - - // then - assertThat(eventResponse.getStatusCode()).isEqualTo(200); - await().atMost(5, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> - verify(() -> WIRE_MOCK_RULE.verify(postRequestedFor(urlPathEqualTo("/user-data-win-event"))))); - - // verify delivery stats report - await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> - verify(() -> WIRE_MOCK_RULE.verify( - new CountMatchingStrategy(CountMatchingStrategy.GREATER_THAN_OR_EQUAL, 2), - postRequestedFor(urlPathEqualTo("/delivery-stats-progress"))))); - - final List requestList = WIRE_MOCK_RULE.findAll( - postRequestedFor(urlPathEqualTo("/delivery-stats-progress"))); - final DeliveryProgressReport report = chooseReportToCompare(requestList); - - JSONAssert.assertEquals( - jsonFrom("deals/test-delivery-stats-progress-request.json"), - mapper.writeValueAsString(report), - JSONCompareMode.LENIENT); - } - - private static String plannerResponseFrom(String templatePath) throws IOException { - final ZonedDateTime now = ZonedDateTime.now().withFixedOffsetZone(); - - return jsonFrom(templatePath) - .replaceAll("\\{\\{ now }}", now.toString()) - .replaceAll("\\{\\{ lineItem.startTime }}", now.minusDays(5).toString()) - .replaceAll("\\{\\{ lineItem.endTime }}", now.plusDays(5).toString()) - .replaceAll("\\{\\{ plan.startTime }}", now.minusHours(1).toString()) - .replaceAll("\\{\\{ plan.endTime }}", now.plusHours(1).toString()); - } - - private String withTemporalFields(String auctionResponse) { - final ZonedDateTime dateTime = ZonedDateTime.now(clock); - final int dayOfWeek = dateTime.getDayOfWeek().get(WeekFields.SUNDAY_START.dayOfWeek()); - - return auctionResponse - .replaceAll("\"?\\{\\{ userdow }}\"?", Integer.toString(dayOfWeek)) - .replaceAll("\"?\\{\\{ userhour }}\"?", Integer.toString(dateTime.getHour())); - } - - private void awaitForLineItemMetadata() { - await().atMost(5, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS) - .until(() -> lineItemService.accountHasDeals("2001", ZonedDateTime.now(clock))); - } - - /** - * Timestamps in response are always generated anew. - * This comparator allows to just verify they are present and parsable. - */ - private static CustomComparator openrtbDeepDebugTimeComparator() { - final ValueMatcher timeValueMatcher = (actual, expected) -> { - try { - return mapper.readValue("\"" + actual.toString() + "\"", ZonedDateTime.class) != null; - } catch (IOException e) { - return false; - } - }; - - final ArrayValueMatcher arrayValueMatcher = new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.trace.deals[*].time", timeValueMatcher))); - - final ValueMatcher jsonStringValueMatcher = (actual, expected) -> { - try { - return compareJSON(actual.toString(), expected.toString(), JSONCompareMode.NON_EXTENSIBLE).passed(); - } catch (JSONException e) { - throw new RuntimeException("Unexpected json exception", e); - } - }; - - final ArrayValueMatcher cacheArrayValueMatcher = new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.httpcalls.cache[*].requestbody", jsonStringValueMatcher), - new Customization("ext.debug.httpcalls.cache[*].responsebody", jsonStringValueMatcher))); - - final List arrayValueMatchers = IntStream.range(1, 5) - .mapToObj(i -> new Customization( - "ext.debug.trace.lineitems.lineItem" + i, - new ArrayValueMatcher<>( - new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization( - "ext.debug.trace.lineitems.lineItem" + i + "[*].time", - timeValueMatcher))))) - .collect(Collectors.toCollection(ArrayList::new)); - - arrayValueMatchers.add(new Customization("ext.debug.trace.deals", arrayValueMatcher)); - arrayValueMatchers.add(new Customization("ext.debug.httpcalls.cache", cacheArrayValueMatcher)); - arrayValueMatchers.add(new Customization("ext.debug.httpcalls.generic", new ArrayValueMatcher<>( - new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("**.requestheaders", (o1, o2) -> true), - new Customization("**.requestbody", (o1, o2) -> true), - new Customization("**.responsebody", (o1, o2) -> true))))); - - return new CustomComparator(JSONCompareMode.NON_EXTENSIBLE, arrayValueMatchers.toArray(Customization[]::new)); - } - - private static boolean verify(Runnable verify) { - try { - verify.run(); - return true; - } catch (VerificationException e) { - return false; - } - } - - private static DeliveryProgressReport chooseReportToCompare(List requestList) - throws JsonProcessingException { - - final int size = requestList.size(); - final DeliveryProgressReport firstReport = readDeliveryProgressReport(requestList.get(size - 2)); - final DeliveryProgressReport secondReport = readDeliveryProgressReport(requestList.get(size - 1)); - - // in a reason cron high dependent on time value, report with statistic should be chosen - final DeliveryProgressReport report = firstReport.getClientAuctions() != 0 ? firstReport : secondReport; - final LineItemStatus lineItem1 = firstReport.getLineItemStatus().stream() - .filter(lineItemStatus -> lineItemStatus.getLineItemId().equals("lineItem1")) - .findFirst().orElse(null); - - // if report does not contain win event for lineItem1 it is possible that it got by the second report - if (lineItem1 != null && CollectionUtils.isEmpty(lineItem1.getEvents())) { - final Set mergedEvents = lineItem1.getEvents(); - - firstReport.getLineItemStatus().stream() - .filter(lineItemStatus -> lineItemStatus.getLineItemId().equals("lineItem1")) - .map(LineItemStatus::getEvents) - .filter(CollectionUtils::isNotEmpty) - .findFirst() - .ifPresent(mergedEvents::addAll); - - secondReport.getLineItemStatus().stream() - .filter(lineItemStatus -> lineItemStatus.getLineItemId().equals("lineItem1")) - .map(LineItemStatus::getEvents) - .filter(CollectionUtils::isNotEmpty) - .findFirst() - .ifPresent(mergedEvents::addAll); - } - - return report; - } - - private static DeliveryProgressReport readDeliveryProgressReport(LoggedRequest loggedRequest) - throws JsonProcessingException { - - return mapper.readValue(loggedRequest.getBodyAsString(), DeliveryProgressReport.class); - } -} diff --git a/src/test/java/org/prebid/server/it/IntegrationTest.java b/src/test/java/org/prebid/server/it/IntegrationTest.java index ab1af668b7c..119537ba161 100644 --- a/src/test/java/org/prebid/server/it/IntegrationTest.java +++ b/src/test/java/org/prebid/server/it/IntegrationTest.java @@ -42,13 +42,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Queue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -240,10 +233,6 @@ static Customization openrtbCacheDebugCustomization() { return new Customization("ext.debug.httpcalls.cache", arrayValueMatcher); } - static Customization headersDebugCustomization() { - return new Customization("**.requestheaders.x-prebid", (o1, o2) -> true); - } - protected static void assertJsonEquals(String file, Response response, List bidders, @@ -303,77 +292,6 @@ public boolean applyGlobally() { } } - static final String LINE_ITEM_RESPONSE_ORDER = "lineItemResponseOrder"; - static final String ID_TO_EXECUTION_PARAMETERS = "idToExecutionParameters"; - - public static class ResponseOrderTransformer extends ResponseTransformer { - - private static final String LINE_ITEM_PATH = "/imp/0/ext/rp/target/line_item"; - - private final Lock lock = new ReentrantLock(); - private final Condition lockCondition = lock.newCondition(); - - @Override - @SuppressWarnings("unchecked") - public com.github.tomakehurst.wiremock.http.Response transform( - Request request, - com.github.tomakehurst.wiremock.http.Response response, - FileSource files, - Parameters parameters) { - - final Queue lineItemResponseOrder = - (Queue) parameters.get(LINE_ITEM_RESPONSE_ORDER); - final Map idToParameters = - (Map) parameters.get(ID_TO_EXECUTION_PARAMETERS); - - final String requestDealId; - try { - requestDealId = readStringValue(mapper.readTree(request.getBodyAsString()), LINE_ITEM_PATH); - } catch (IOException e) { - throw new RuntimeException("Request should contain imp/ext/rp/target/line_item for deals request"); - } - - final BidRequestExecutionParameters requestParameters = idToParameters.get(requestDealId); - - waitForTurn(lineItemResponseOrder, requestParameters.getDealId(), requestParameters.getDelay()); - - return com.github.tomakehurst.wiremock.http.Response.response() - .body(requestParameters.getBody()) - .status(requestParameters.getStatus()) - .build(); - } - - private void waitForTurn(Queue dealsResponseOrder, String id, Long delay) { - lock.lock(); - try { - while (!Objects.equals(dealsResponseOrder.peek(), id)) { - lockCondition.await(); - } - TimeUnit.MILLISECONDS.sleep(delay); - dealsResponseOrder.poll(); - lockCondition.signalAll(); - } catch (InterruptedException e) { - throw new RuntimeException("Failed on waiting to return bid request for lineItem id = " + id); - } finally { - lock.unlock(); - } - } - - private String readStringValue(JsonNode jsonNode, String path) { - return jsonNode.at(path).asText(); - } - - @Override - public String getName() { - return "response-order-transformer"; - } - - @Override - public boolean applyGlobally() { - return false; - } - } - @Value @AllArgsConstructor(staticName = "of") static class BidRequestExecutionParameters { diff --git a/src/test/java/org/prebid/server/it/PrematureReturnTest.java b/src/test/java/org/prebid/server/it/PrematureReturnTest.java deleted file mode 100644 index dec6e307a14..00000000000 --- a/src/test/java/org/prebid/server/it/PrematureReturnTest.java +++ /dev/null @@ -1,451 +0,0 @@ -package org.prebid.server.it; - -import com.github.tomakehurst.wiremock.junit.WireMockClassRule; -import com.github.tomakehurst.wiremock.matching.AnythingPattern; -import io.restassured.response.Response; -import io.restassured.specification.RequestSpecification; -import org.json.JSONException; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.VertxTest; -import org.prebid.server.deals.LineItemService; -import org.skyscreamer.jsonassert.ArrayValueMatcher; -import org.skyscreamer.jsonassert.Customization; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.skyscreamer.jsonassert.ValueMatcher; -import org.skyscreamer.jsonassert.comparator.CustomComparator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; -import java.time.Clock; -import java.time.ZonedDateTime; -import java.time.temporal.WeekFields; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static io.restassured.RestAssured.given; -import static java.util.Collections.singletonList; -import static org.awaitility.Awaitility.await; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) -@RunWith(SpringRunner.class) -@TestPropertySource(locations = {"test-application.properties", "deals/test-deals-application.properties"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) -public class PrematureReturnTest extends VertxTest { - - private static final int APP_PORT = 8070; - private static final int WIREMOCK_PORT = 8090; - - private static final RequestSpecification SPEC = IntegrationTest.spec(APP_PORT); - - @SuppressWarnings("unchecked") - @ClassRule - public static final WireMockClassRule WIRE_MOCK_RULE = new WireMockClassRule(options() - .port(WIREMOCK_PORT) - .extensions(IntegrationTest.ResponseOrderTransformer.class)); - - private static final String RUBICON = "rubicon"; - - @Autowired - private LineItemService lineItemService; - - @Autowired - private Clock clock; - - @BeforeClass - public static void setUpInner() throws IOException { - // given - WIRE_MOCK_RULE.stubFor(get(urlPathEqualTo("/planner-plan")) - .withQueryParam("instanceId", equalTo("localhost")) - .withQueryParam("region", equalTo("local")) - .withQueryParam("vendor", equalTo("local")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .willReturn(aResponse() - .withBody(plannerResponseFrom("deals/premature/test-planner-plan-response.json")))); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/planner-register")) - .withBasicAuth("username", "password") - .withHeader("pg-trx-id", new AnythingPattern()) - .withRequestBody(equalToJson(IntegrationTest.jsonFrom("deals/test-planner-register-request.json"), - false, true)) - .willReturn(aResponse())); - - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/user-data-details")) - .withRequestBody(equalToJson(IntegrationTest - .jsonFrom("deals/test-user-data-details-request.json"), false, true)) - .willReturn(aResponse().withBody(IntegrationTest - .jsonFrom("deals/test-user-data-details-rubicon-response.json")))); - } - - @Test - public void openrtb2AuctionWhenAllThreeBidsReturnsInOrderWithMinimalDelay() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 20L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-in-order-response.json", response, singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenAllThreeBidsReturnsInReverseOrderWithMinimalDelay() throws IOException, - JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem3"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem1"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 0L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-in-reverse-order-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenAllThreeBidsReturnsInOrderWithHighDelay() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 200L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-in-order-response.json", response, singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenAllThreeBidsReturnsInReverseOrderWithHighDelay() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem3"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem1"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 0L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-in-reverse-order-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenOnlyFirstBidComesBack() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-2.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-3.json"), 200, 20L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-first-bid-only-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenOnlySecondBidComesBack() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-1.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-3.json"), 200, 20L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-second-bid-only-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenOnlyThirdBidComesBack() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-1.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-2.json"), 200, 20L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 20L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-third-bid-only-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenFirstAndSecondBidsComesBackReverseWithHighDelay() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem1"); - lineItemResponseOrder.add("extLineItem3"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-1.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 0L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-3.json"), 200, 200L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-first-and-second-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - @Test - public void openrtb2AuctionWhenSecondAndThirdBidsComesBackReverseWithHighDelay() throws IOException, JSONException { - // given - awaitForLineItemMetadata(); - - final Queue lineItemResponseOrder = new LinkedList<>(); - lineItemResponseOrder.add("extLineItem3"); - lineItemResponseOrder.add("extLineItem2"); - lineItemResponseOrder.add("extLineItem1"); - - final Map idToExecutionParameters = new HashMap<>(); - idToExecutionParameters.put("extLineItem1", IntegrationTest.BidRequestExecutionParameters.of("extLineItem1", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-no-bid-response-1.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem2", IntegrationTest.BidRequestExecutionParameters.of("extLineItem2", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-2.json"), 200, 200L)); - idToExecutionParameters.put("extLineItem3", IntegrationTest.BidRequestExecutionParameters.of("extLineItem3", - IntegrationTest.jsonFrom("deals/premature/test-rubicon-bid-response-3.json"), 200, 0L)); - - stubExchange(lineItemResponseOrder, idToExecutionParameters); - - // when - final Response response = givenResponse(); - - final String expectedAuctionResponse = withTemporalFields(IntegrationTest.openrtbAuctionResponseFrom( - "deals/premature/responses/test-auction-third-and-second-response.json", response, - singletonList(RUBICON))); - - JSONAssert.assertEquals(expectedAuctionResponse, response.asString(), openrtbDeepDebugTimeComparator()); - } - - private Response givenResponse() throws IOException { - return given(SPEC) - .header("Referer", "http://www.example.com") - .header("User-Agent", "userAgent") - .header("X-Forwarded-For", "185.199.110.153") - // this uids cookie value stands for { "tempUIDs":{ "rubicon":{ "uid":"J5VLCWQP-26-CWFT", - // "expires":"2023-12-05T19:00:05.103329-03:00" } } } - .cookie("uids", "eyAidGVtcFVJRHMiOnsgInJ1Ymljb24iOnsgInVpZCI6Iko1VkxDV1FQ" - + "LTI2LUNXRlQiLCAiZXhwaXJlcyI6IjIwMjMtMTItMDVUMTk6MDA6MDUuMTAzMzI5LTAzOjAwIiB9IH0gfQ==") - .body(IntegrationTest.jsonFrom("deals/premature/test-auction-request.json")) - .post("/openrtb2/auction"); - } - - private void stubExchange(Queue lineItemResponseOrder, - Map idToExecutionParameters) { - WIRE_MOCK_RULE.stubFor(post(urlMatching("/rubicon-exchange.*")) - .willReturn(aResponse() - .withTransformers("response-order-transformer") - .withTransformerParameter(IntegrationTest.LINE_ITEM_RESPONSE_ORDER, lineItemResponseOrder) - .withTransformerParameter(IntegrationTest.ID_TO_EXECUTION_PARAMETERS, - idToExecutionParameters))); - } - - private void awaitForLineItemMetadata() { - await().atMost(20, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS) - .until(() -> lineItemService.accountHasDeals("2001", ZonedDateTime.now(clock))); - } - - private static String plannerResponseFrom(String templatePath) throws IOException { - final ZonedDateTime now = ZonedDateTime.now().withFixedOffsetZone(); - - return IntegrationTest.jsonFrom(templatePath) - .replaceAll("\\{\\{ now }}", now.toString()) - .replaceAll("\\{\\{ lineItem.startTime }}", now.minusDays(5).toString()) - .replaceAll("\\{\\{ lineItem.endTime }}", now.plusDays(5).toString()) - .replaceAll("\\{\\{ plan.startTime }}", now.minusHours(1).toString()) - .replaceAll("\\{\\{ plan.endTime }}", now.plusHours(1).toString()); - } - - private static CustomComparator openrtbDeepDebugTimeComparator() { - final ValueMatcher timeValueMatcher = (actual, expected) -> { - try { - return mapper.readValue("\"" + actual.toString() + "\"", ZonedDateTime.class) != null; - } catch (IOException e) { - return false; - } - }; - - final ArrayValueMatcher arrayValueMatcher = new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.trace.deals[*].time", timeValueMatcher))); - - final List arrayValueMatchers = IntStream.range(1, 5) - .mapToObj(i -> new Customization("ext.debug.trace.lineitems.lineItem" + i, - new ArrayValueMatcher<>(new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("ext.debug.trace.lineitems.lineItem" + i + "[*].time", - timeValueMatcher))))) - .collect(Collectors.toCollection(ArrayList::new)); - - arrayValueMatchers.add(new Customization("ext.debug.trace.deals", arrayValueMatcher)); - arrayValueMatchers.add(new Customization("ext.debug.httpcalls.rubicon", new ArrayValueMatcher<>( - new CustomComparator( - JSONCompareMode.NON_EXTENSIBLE, - new Customization("**.requestheaders", (o1, o2) -> true), - new Customization("**.requestbody", (o1, o2) -> true), - new Customization("**.responsebody", (o1, o2) -> true))))); - - return new CustomComparator(JSONCompareMode.NON_EXTENSIBLE, - arrayValueMatchers.toArray(new Customization[0])); - } - - private String withTemporalFields(String auctionResponse) { - final ZonedDateTime dateTime = ZonedDateTime.now(clock); - - return auctionResponse - .replaceAll("\"?\\{\\{ userdow }}\"?", Integer.toString( - dateTime.getDayOfWeek().get(WeekFields.SUNDAY_START.dayOfWeek()))) - .replaceAll("\"?\\{\\{ userhour }}\"?", Integer.toString(dateTime.getHour())); - } -} diff --git a/src/test/java/org/prebid/server/log/CriteriaManagerTest.java b/src/test/java/org/prebid/server/log/CriteriaManagerTest.java index 7be8a0c8af7..b8dd599c790 100644 --- a/src/test/java/org/prebid/server/log/CriteriaManagerTest.java +++ b/src/test/java/org/prebid/server/log/CriteriaManagerTest.java @@ -8,7 +8,6 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.deals.model.LogCriteriaFilter; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; @@ -35,14 +34,14 @@ public void setUp() { @Test public void addCriteriaShouldThrowIllegalArgumentExceptionWhenLoggerLevelHasInvalidValue() { assertThatIllegalArgumentException() - .isThrownBy(() -> criteriaManager.addCriteria("1001", "rubicon", "lineItemId1", "invalid", 800)) + .isThrownBy(() -> criteriaManager.addCriteria("1001", "rubicon", "invalid", 800)) .withMessage("Invalid LoggingLevel: invalid"); } @Test public void addCriteriaShouldAddVertxTimerWithLimitedDurationInMillis() { // given and when - criteriaManager.addCriteria("1001", "rubicon", "lineItemId1", "error", 800000); + criteriaManager.addCriteria("1001", "rubicon", "error", 800000); // then verify(vertx).setTimer(eq(300000L), any()); @@ -51,25 +50,7 @@ public void addCriteriaShouldAddVertxTimerWithLimitedDurationInMillis() { @Test public void addCriteriaShouldAddVertxTimerWithDefaultDurationInMillis() { // given and when - criteriaManager.addCriteria("1001", "rubicon", "lineItemId1", "error", 200000); - - // then - verify(vertx).setTimer(eq(200000L), any()); - } - - @Test - public void addCriteriaByFilterShouldAddVertxTimeWithLimitedDurationInMillis() { - // given and when - criteriaManager.addCriteria(LogCriteriaFilter.of("1001", "rubicon", "lineItemId1"), 800L); - - // then - verify(vertx).setTimer(eq(300000L), any()); - } - - @Test - public void addCriteriaByFilterShouldAddVertxTimeWithNotLimitedDurationInMillis() { - // given and when - criteriaManager.addCriteria(LogCriteriaFilter.of("1001", "rubicon", "lineItemId1"), 200L); + criteriaManager.addCriteria("1001", "rubicon", "error", 200000); // then verify(vertx).setTimer(eq(200000L), any()); diff --git a/src/test/java/org/prebid/server/log/CriteriaTest.java b/src/test/java/org/prebid/server/log/CriteriaTest.java index 4e5fcad3839..dd24d167fa0 100644 --- a/src/test/java/org/prebid/server/log/CriteriaTest.java +++ b/src/test/java/org/prebid/server/log/CriteriaTest.java @@ -20,73 +20,22 @@ public class CriteriaTest { @Mock private Logger logger; - @Test - public void logShouldChooseCriteriaLoggerLevelWhenAccountsMatchedAndElseFieldsAreNull() { - // given - final Criteria criteria = Criteria.create("account", null, null, Logger::error); - - // when - criteria.log(Criteria.builder().account("account").bidder("rubicon").build(), logger, "message", logger::info); - - // then - verify(logger).error(anyString()); - } - - @Test - public void logShouldChooseDefaultLogLevelWhenAccountsMatchedAndElseFieldsAreNotNullAndNotMatched() { - // given - final Criteria criteria = Criteria.create("account", "appnexus", null, Logger::error); - - // when - criteria.log(Criteria.builder().account("account").bidder("rubicon").build(), - logger, "message", logger::info); - - // then - verify(logger).info(anyString()); - } - - @Test - public void logShouldChooseCriteriaLogLevelAccountAndBidderMatchedLineItemIsNull() { - // given - final Criteria criteria = Criteria.create("account", "rubicon", null, Logger::error); - - // when - criteria.log(Criteria.builder().account("account").bidder("rubicon") - .lineItemId("lineItemId").build(), logger, "message", logger::info); - - // then - verify(logger).error(anyString()); - } - - @Test - public void logShouldChooseCriteriaLogLevelWhenAllMatched() { - // given - final Criteria criteria = Criteria.create("account", "rubicon", "lineItemId", Logger::error); - - // when - criteria.log(Criteria.builder().account("account").bidder("rubicon") - .lineItemId("lineItemId").build(), logger, "message", logger::info); - - // then - verify(logger).error(anyString()); - } - @Test public void logResponseShouldLogResponseWhenAllNotNullCriteriasPresent() { // given - final Criteria criteria = Criteria.create("account", null, "lineItemId", Logger::error); + final Criteria criteria = Criteria.create("account", null, Logger::error); // when - criteria.logResponse("Response has account and lineItemId", logger); + criteria.logResponse("Response has account", logger); // then verify(logger).error(anyString()); } @Test - public void logResponseShouldNotLogResponseWhenOneOfNutNullCriteriaMissing() { + public void logResponseShouldNotLogResponseWhenOneOfNotNullCriteriaMissing() { // given - final Criteria criteria = Criteria.create("account", null, "lineItemId", Logger::error); + final Criteria criteria = Criteria.create("account", "bidder", Logger::error); // when criteria.logResponse("Response has account", logger); @@ -98,19 +47,19 @@ public void logResponseShouldNotLogResponseWhenOneOfNutNullCriteriaMissing() { @Test public void logResponseAndRequestShouldLogResponseWhenAllNotNullCriteriasPresent() { // given - final Criteria criteria = Criteria.create("account", null, "lineItemId", Logger::error); + final Criteria criteria = Criteria.create("account", null, Logger::error); // when - criteria.logResponseAndRequest("Response has account", "Request has lineItemId", logger); + criteria.logResponseAndRequest("Response has account", "Request", logger); // then verify(logger, times(2)).error(anyString()); } @Test - public void logResponseAndRequestShouldNotLogResponseWhenOneOfNutNullCriteriaMissing() { + public void logResponseAndRequestShouldNotLogResponseWhenOneOfNotNullCriteriaMissing() { // given - final Criteria criteria = Criteria.create("account", null, "lineItemId", Logger::error); + final Criteria criteria = Criteria.create("account", "bidder", Logger::error); // when criteria.logResponseAndRequest("Response has account", "Request", logger); diff --git a/src/test/java/org/prebid/server/metric/MetricsTest.java b/src/test/java/org/prebid/server/metric/MetricsTest.java index c428db441c2..e06847c7386 100644 --- a/src/test/java/org/prebid/server/metric/MetricsTest.java +++ b/src/test/java/org/prebid/server/metric/MetricsTest.java @@ -672,140 +672,6 @@ public void updateCookieSyncFilteredMetricShouldIncrementMetric() { assertThat(metricRegistry.counter("cookie_sync.conversant.filtered").getCount()).isEqualTo(2); } - @Test - public void updateGpRequestMetricShouldIncrementPlannerRequestAndPlannerSuccessfulRequest() { - // when - metrics.updatePlannerRequestMetric(true); - - // then - assertThat(metricRegistry.counter("pg.planner_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("pg.planner_request_successful").getCount()).isEqualTo(1); - } - - @Test - public void updateGpRequestMetricShouldIncrementPlannerRequestAndPlannerFailedRequest() { - // when - metrics.updatePlannerRequestMetric(false); - - // then - assertThat(metricRegistry.counter("pg.planner_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("pg.planner_request_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateGpRequestMetricShouldIncrementUserDetailsSuccessfulRequest() { - // when - metrics.updateUserDetailsRequestMetric(true); - - // then - assertThat(metricRegistry.counter("user_details_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("user_details_request_successful").getCount()).isEqualTo(1); - } - - @Test - public void updateGpRequestMetricShouldIncrementUserDetailsFailedRequest() { - // when - metrics.updateUserDetailsRequestMetric(false); - - // then - assertThat(metricRegistry.counter("user_details_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("user_details_request_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateGpRequestMetricShouldIncrementWinSuccessfulRequest() { - // when - metrics.updateWinEventRequestMetric(true); - - // then - assertThat(metricRegistry.counter("win_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("win_request_successful").getCount()).isEqualTo(1); - } - - @Test - public void updateGpRequestMetricShouldIncrementWinFailedRequest() { - // when - metrics.updateWinEventRequestMetric(false); - - // then - assertThat(metricRegistry.counter("win_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("win_request_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateWinRequestTimeShouldLogTime() { - // when - metrics.updateWinRequestTime(20L); - - // then - assertThat(metricRegistry.timer("win_request_time").getCount()).isEqualTo(1); - } - - @Test - public void updateWinRequestPreparationFailedShouldIncrementMetric() { - // when - metrics.updateWinRequestPreparationFailed(); - - // then - assertThat(metricRegistry.counter("win_request_preparation_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateUserDetailsRequestPreparationFailedShouldIncrementMetric() { - // when - metrics.updateUserDetailsRequestPreparationFailed(); - - // then - assertThat(metricRegistry.counter("user_details_request_preparation_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateDeliveryRequestMetricShouldIncrementDeliveryRequestAndSuccessfulDeliveryRequest() { - // when - metrics.updateDeliveryRequestMetric(true); - - // then - assertThat(metricRegistry.counter("pg.delivery_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("pg.delivery_request_successful").getCount()).isEqualTo(1); - } - - @Test - public void updateDeliveryRequestMetricShouldIncrementDeliveryRequestAndFailedDeliveryRequest() { - // when - metrics.updateDeliveryRequestMetric(false); - - // then - assertThat(metricRegistry.counter("pg.delivery_requests").getCount()).isEqualTo(1); - assertThat(metricRegistry.counter("pg.delivery_request_failed").getCount()).isEqualTo(1); - } - - @Test - public void updateLineItemsNumberMetricShouldIncrementLineItemsNumberForAAcountValue() { - // when - metrics.updateLineItemsNumberMetric(20L); - - // then - assertThat(metricRegistry.counter("pg.planner_lineitems_received").getCount()).isEqualTo(20); - } - - @Test - public void updatePlannerRequestTimeShouldLogTime() { - // when - metrics.updatePlannerRequestTime(20L); - - // then - assertThat(metricRegistry.timer("pg.planner_request_time").getCount()).isEqualTo(1); - } - - @Test - public void updateDeliveryRequestTimeShouldLogTime() { - // when - metrics.updateDeliveryRequestTime(20L); - - // then - assertThat(metricRegistry.timer("pg.delivery_request_time").getCount()).isEqualTo(1); - } - @Test public void updateAuctionTcfMetricsShouldIncrementMetrics() { // when @@ -1355,15 +1221,6 @@ public void updateAccountModuleDurationMetricShouldNotIncrementMetricsIfVerbosit .isZero(); } - @Test - public void shouldIncrementWinNotificationMetric() { - // when - metrics.updateWinNotificationMetric(); - - // then - assertThat(metricRegistry.counter("win_notifications").getCount()).isEqualTo(1); - } - @Test public void shouldIncrementRequestsActivityDisallowedCount() { // when diff --git a/src/test/java/org/prebid/server/util/HttpUtilTest.java b/src/test/java/org/prebid/server/util/HttpUtilTest.java index 7abfcc6532f..d516ad2c6d8 100644 --- a/src/test/java/org/prebid/server/util/HttpUtilTest.java +++ b/src/test/java/org/prebid/server/util/HttpUtilTest.java @@ -11,18 +11,15 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.prebid.server.exception.PreBidException; import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.model.HttpRequestContext; -import java.time.ZonedDateTime; import java.util.Map; import java.util.function.Consumer; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.entry; import static org.assertj.core.api.Assertions.tuple; import static org.mockito.ArgumentMatchers.any; @@ -204,53 +201,4 @@ public void executeSafelyShouldReturnFalseIfResponseFailed() { // then assertThat(result).isFalse(); } - - @Test - public void getDateFromHeaderShouldReturnDate() { - // given - final MultiMap headers = MultiMap.caseInsensitiveMultiMap().add("date-header", - "2019-11-04T13:31:24.365+02:00[Europe/Kiev]"); - - // when - final ZonedDateTime result = HttpUtil.getDateFromHeader(headers, "date-header"); - - // then - assertThat(result).isEqualTo(ZonedDateTime.parse("2019-11-04T13:31:24.365+02:00[Europe/Kiev]")); - } - - @Test - public void getDateFromHeaderShouldReturnNullWhenHeaderWasNotFound() { - // given - final MultiMap headers = MultiMap.caseInsensitiveMultiMap(); - - // when - final ZonedDateTime result = HttpUtil.getDateFromHeader(headers, "not-exist"); - - // then - assertThat(result).isNull(); - } - - @Test - public void getDateFromHeaderShouldThrowExceptionWhenHeaderHasIncorrectFormat() { - // given - final MultiMap headers = MultiMap.caseInsensitiveMultiMap().add("date-header", "invalid"); - - // when and then - assertThatThrownBy(() -> HttpUtil.getDateFromHeader(headers, "date-header")) - .isInstanceOf(PreBidException.class) - .hasMessage("date-header header is not compatible to ISO-8601 format: invalid"); - } - - @Test - public void getDateFromHeaderShouldReturnDateFromHeaders() { - // given - final MultiMap headers = MultiMap.caseInsensitiveMultiMap().add("date-header", - "2019-11-04T13:31:24.365+02:00[Europe/Kiev]"); - - // when - final ZonedDateTime result = HttpUtil.getDateFromHeader(headers, "date-header"); - - // then - assertThat(result).isEqualTo(ZonedDateTime.parse("2019-11-04T13:31:24.365+02:00[Europe/Kiev]")); - } } diff --git a/src/test/java/org/prebid/server/validation/ResponseBidValidatorTest.java b/src/test/java/org/prebid/server/validation/ResponseBidValidatorTest.java index 2b87c30ae63..bd312b447c1 100644 --- a/src/test/java/org/prebid/server/validation/ResponseBidValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/ResponseBidValidatorTest.java @@ -3,10 +3,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Deal; import com.iab.openrtb.request.Format; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Pmp; import com.iab.openrtb.response.Bid; import org.junit.Before; import org.junit.Rule; @@ -20,8 +18,6 @@ import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; -import org.prebid.server.proto.openrtb.ext.request.ExtDeal; -import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountAuctionConfig; @@ -29,7 +25,6 @@ import org.prebid.server.validation.model.ValidationResult; import java.math.BigDecimal; -import java.util.List; import java.util.function.UnaryOperator; import static java.util.Arrays.asList; @@ -37,7 +32,6 @@ import static java.util.function.UnaryOperator.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.prebid.server.settings.model.BidValidationEnforcement.enforce; @@ -62,7 +56,7 @@ public class ResponseBidValidatorTest extends VertxTest { @Before public void setUp() { - target = new ResponseBidValidator(enforce, enforce, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(enforce, enforce, metrics, 0.01); given(bidderAliases.resolveBidder(anyString())).willReturn(BIDDER_NAME); } @@ -359,7 +353,7 @@ public void validateShouldReturnSuccessfulResultForValidBid() { @Test public void validateShouldReturnSuccessIfBannerSizeValidationNotEnabled() { // given - target = new ResponseBidValidator(skip, enforce, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(skip, enforce, metrics, 0.01); // when final ValidationResult result = target.validate( @@ -375,7 +369,7 @@ public void validateShouldReturnSuccessIfBannerSizeValidationNotEnabled() { @Test public void validateShouldReturnSuccessWithWarningIfBannerSizeEnforcementIsWarn() { // given - target = new ResponseBidValidator(warn, enforce, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(warn, enforce, metrics, 0.01); // when final ValidationResult result = target.validate( @@ -396,7 +390,7 @@ public void validateShouldReturnSuccessWithWarningIfBannerSizeEnforcementIsWarn( @Test public void validateShouldReturnSuccessIfSecureMarkupValidationNotEnabled() { // given - target = new ResponseBidValidator(enforce, skip, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(enforce, skip, metrics, 0.01); // when final ValidationResult result = target.validate( @@ -412,7 +406,7 @@ public void validateShouldReturnSuccessIfSecureMarkupValidationNotEnabled() { @Test public void validateShouldReturnSuccessWithWarningIfSecureMarkupEnforcementIsWarn() { // given - target = new ResponseBidValidator(enforce, warn, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(enforce, warn, metrics, 0.01); // when final ValidationResult result = target.validate( @@ -446,7 +440,7 @@ public void validateShouldIncrementSizeValidationErrMetrics() { @Test public void validateShouldIncrementSizeValidationWarnMetrics() { // given - target = new ResponseBidValidator(warn, warn, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(warn, warn, metrics, 0.01); // when target.validate( @@ -475,7 +469,7 @@ public void validateShouldIncrementSecureValidationErrMetrics() { @Test public void validateShouldIncrementSecureValidationWarnMetrics() { // given - target = new ResponseBidValidator(warn, warn, metrics, jacksonMapper, true, 0.01); + target = new ResponseBidValidator(warn, warn, metrics, 0.01); // when target.validate( @@ -488,189 +482,6 @@ public void validateShouldIncrementSecureValidationWarnMetrics() { verify(metrics).updateSecureValidationMetrics(BIDDER_NAME, ACCOUNT_ID, MetricName.warn); } - @Test - public void validateShouldReturnSuccessfulResultForValidNonDealBid() { - final ValidationResult result = target.validate( - givenVideoBid(identity()), - BIDDER_NAME, - givenAuctionContext(), - bidderAliases); - - assertThat(result.hasErrors()).isFalse(); - } - - @Test - public void validateShouldFailIfBidHasNoDealid() { - final ValidationResult result = target.validate( - givenVideoBid(identity()), - BIDDER_NAME, - givenAuctionContext(givenRequest(identity())), - bidderAliases); - - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Bid \"bidId1\" missing required field 'dealid'"); - } - - @Test - public void validateShouldSuccessIfBidHasDealidAndImpHasNoDeals() { - final ValidationResult result = target.validate( - givenVideoBid(bid -> bid.dealid("dealId1")), - BIDDER_NAME, - givenAuctionContext(givenRequest(identity())), - bidderAliases); - - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getWarnings()).isEmpty(); - } - - @Test - public void validateShouldWarnIfBidHasDealidMissingInImp() { - given(bidderAliases.isSame(eq(BIDDER_NAME), eq(BIDDER_NAME))).willReturn(true); - - final ValidationResult result = target.validate( - givenVideoBid(bid -> bid.dealid("dealId1")), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp.pmp(pmp(asList( - deal(builder -> builder - .id("dealId2") - .ext(mapper.valueToTree(ExtDeal.of( - ExtDealLine.of(null, null, null, BIDDER_NAME))))), - deal(builder -> builder - .id("dealId3") - .ext(mapper.valueToTree(ExtDeal.of( - ExtDealLine.of(null, null, null, BIDDER_NAME))))), - deal(builder -> builder - .id("dealId4") - .ext(mapper.valueToTree(ExtDeal.of( - ExtDealLine.of(null, null, null, "anotherBidder")))))))))), - bidderAliases); - - assertThat(result.getWarnings()).hasSize(1) - .containsOnly("WARNING: Bid \"bidId1\" has 'dealid' not present in corresponding imp in request." - + " 'dealid' in bid: 'dealId1', deal Ids in imp: 'dealId2,dealId3'"); - } - - @Test - public void validateShouldFailIfBidIsBannerAndImpHasNoBanner() { - target = new ResponseBidValidator(skip, enforce, metrics, jacksonMapper, true, 0.01); - - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1")), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder.id("dealId1"))))))), - bidderAliases); - - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Bid \"bidId1\" has banner media type but corresponding imp in request is missing " - + "'banner' object"); - } - - @Test - public void validateShouldFailIfBidIsBannerAndSizeHasNoMatchInBannerFormats() { - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1").w(300).h(400)), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder.id("dealId1"))))) - .banner(Banner.builder() - .format(singletonList(Format.builder().w(400).h(500).build())) - .build()))), - bidderAliases); - - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Bid \"bidId1\" has 'w' and 'h' not supported by corresponding imp in request. Bid " - + "dimensions: '300x400', formats in imp: '400x500'"); - } - - @Test - public void validateShouldFailIfBidIsBannerAndSizeHasNoMatchInLineItem() { - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1").w(300).h(400)), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId", null, - singletonList(Format.builder().w(500).h(600).build()), null)))))))) - .banner(Banner.builder() - .format(singletonList(Format.builder().w(300).h(400).build())) - .build()))), - bidderAliases); - - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Bid \"bidId1\" has 'w' and 'h' not matched to Line Item. Bid dimensions: '300x400', " - + "Line Item sizes: '500x600'"); - } - - @Test - public void validateShouldFailIfBidIsBannerAndMatchingLineItemDoesNotHaveSizes() { - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1").w(300).h(400)), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of("lineItemId", null, - null, null)))))))) - .banner(Banner.builder() - .format(singletonList(Format.builder().w(300).h(400).build())) - .build()))), - bidderAliases); - - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Line item sizes were not found for bidId bidId1 and dealId dealId1"); - } - - @Test - public void validateShouldSuccessIfBidIsBannerAndSizeHasNoMatchInLineItemForNonPgDeal() { - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1").w(300).h(400)), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of(null, null, - singletonList(Format.builder().w(500).h(600).build()), null)))))))) - .banner(Banner.builder() - .format(singletonList(Format.builder().w(300).h(400).build())) - .build()))), - bidderAliases); - - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getWarnings()).isEmpty(); - } - - @Test - public void validateShouldReturnSuccessfulResultForValidDealNonBannerBid() { - final ValidationResult result = target.validate( - givenVideoBid(bid -> bid.dealid("dealId1")), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp.pmp(pmp(singletonList( - deal(builder -> builder.id("dealId1"))))))), - bidderAliases); - - assertThat(result.hasErrors()).isFalse(); - } - - @Test - public void validateShouldReturnSuccessfulResultForValidDealBannerBid() { - final ValidationResult result = target.validate( - givenBid(bid -> bid.dealid("dealId1").w(300).h(400)), - BIDDER_NAME, - givenAuctionContext(givenRequest(imp -> imp - .pmp(pmp(singletonList(deal(builder -> builder - .id("dealId1") - .ext(mapper.valueToTree(ExtDeal.of(ExtDealLine.of(null, null, - singletonList(Format.builder().w(300).h(400).build()), null)))))))) - .banner(Banner.builder() - .format(singletonList(Format.builder().w(300).h(400).build())) - .build()))), - bidderAliases); - - assertThat(result.hasErrors()).isFalse(); - } - private BidRequest givenRequest(UnaryOperator impCustomizer) { final ObjectNode ext = mapper.createObjectNode().set( "prebid", mapper.createObjectNode().set( @@ -686,14 +497,6 @@ private BidRequest givenRequest(UnaryOperator impCustomizer) { return BidRequest.builder().imp(singletonList(imp)).build(); } - private static Pmp pmp(List deals) { - return Pmp.builder().deals(deals).build(); - } - - private static Deal deal(UnaryOperator dealCustomizer) { - return dealCustomizer.apply(Deal.builder()).build(); - } - private static BidderBid givenVideoBid(UnaryOperator bidCustomizer) { return givenBid(BidType.video, bidCustomizer); } diff --git a/src/test/java/org/prebid/server/vast/VastModifierTest.java b/src/test/java/org/prebid/server/vast/VastModifierTest.java index 89dce72913d..010bda5229c 100644 --- a/src/test/java/org/prebid/server/vast/VastModifierTest.java +++ b/src/test/java/org/prebid/server/vast/VastModifierTest.java @@ -35,7 +35,6 @@ public class VastModifierTest { private static final String VAST_URL_TRACKING = "http://external-url/event"; private static final String BID_ID = "bidId"; private static final String BID_NURL = "nurl1"; - private static final String LINEITEM_ID = "lineItemId"; private static final long AUCTION_TIMESTAMP = 1000L; @Rule @@ -52,7 +51,7 @@ public class VastModifierTest { @Before public void setUp() { - given(eventsService.vastUrlTracking(any(), any(), any(), any(), any())) + given(eventsService.vastUrlTracking(any(), any(), any(), any())) .willReturn(VAST_URL_TRACKING); given(bidderCatalog.isModifyingVastXmlAllowed(any())).willReturn(true); @@ -97,7 +96,7 @@ public void modifyVastXmlShouldNotModifyVastAndAppendUrlWhenValueWithoutImpressi final JsonNode result = target.modifyVastXml(true, singleton(BIDDER), givenPutObject(vastWithoutImpression), ACCOUNT_ID, INTEGRATION); - verify(eventsService).vastUrlTracking(any(), any(), any(), any(), any()); + verify(eventsService).vastUrlTracking(any(), any(), any(), any()); assertThat(result).isEqualTo(vastWithoutImpression); } @@ -111,11 +110,11 @@ public void modifyVastXmlShouldModifyVastAndAppendUrl() { // then final String modifiedVast = """ - prebid.org wrapper\ - \ - \ - \ - """; + prebid.org wrapper\ + \ + \ + \ + """; assertThat(result).isEqualTo(new TextNode(modifiedVast)); } @@ -127,8 +126,7 @@ public void createBidVastXmlShouldNotModifyWhenBidderNotAllowed() { // when final String result = target - .createBidVastXml(BIDDER, adm(), BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, adm(), BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then assertThat(result).isEqualTo(adm()); @@ -137,8 +135,8 @@ public void createBidVastXmlShouldNotModifyWhenBidderNotAllowed() { @Test public void createBidVastXmlShouldInjectBidNurlWhenBidAdmIsNullAndEventsDisabledByAccount() { // when - final String result = target.createBidVastXml(BIDDER, null, BID_NURL, BID_ID, ACCOUNT_ID, - givenEventsContext(false), emptyList(), LINEITEM_ID); + final String result = target + .createBidVastXml(BIDDER, null, BID_NURL, BID_ID, ACCOUNT_ID, givenEventsContext(false), emptyList()); // then assertThat(result).isEqualTo(modifiedAdm(BID_NURL)); @@ -147,8 +145,8 @@ public void createBidVastXmlShouldInjectBidNurlWhenBidAdmIsNullAndEventsDisabled @Test public void createBidVastXmlShouldInjectBidNurlWhenBidAdmIsEmptyAndEventsDisabledByAccount() { // when - final String result = target.createBidVastXml(BIDDER, "", BID_NURL, BID_ID, ACCOUNT_ID, - givenEventsContext(false), emptyList(), LINEITEM_ID); + final String result = target + .createBidVastXml(BIDDER, "", BID_NURL, BID_ID, ACCOUNT_ID, givenEventsContext(false), emptyList()); // then assertThat(result).isEqualTo(modifiedAdm(BID_NURL)); @@ -157,8 +155,8 @@ public void createBidVastXmlShouldInjectBidNurlWhenBidAdmIsEmptyAndEventsDisable @Test public void createBidVastXmlShouldReturnAdmWhenBidAdmIsPresentAndEventsDisabledByAccount() { // when - final String result = target.createBidVastXml(BIDDER, adm(), BID_NURL, BID_ID, ACCOUNT_ID, - givenEventsContext(false), emptyList(), LINEITEM_ID); + final String result = target + .createBidVastXml(BIDDER, adm(), BID_NURL, BID_ID, ACCOUNT_ID, givenEventsContext(false), emptyList()); // then assertThat(result).isEqualTo(adm()); @@ -169,11 +167,10 @@ public void createBidVastXmlShouldBeModifiedWithNewImpressionVastUrlWhenEventsEn // when final String bidAdm = "http:/test.com"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("http:/test.com" + ""); @@ -184,11 +181,10 @@ public void createBidVastXmlShouldBeModifiedWithNewImpressionVastUrlWhenEventsEn // when final String bidAdm = "< impreSSion garbage >http:/test.com< /ImPression garbage >"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("< impreSSion garbage >http:/test.com< /ImPression garbage >" + ""); @@ -200,11 +196,10 @@ public void createBidVastXmlShouldBeModifiedWithNewImpressionAfterExistingImpres final String bidAdm = "http:/test.com" + "http:/test2.com"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("http:/test.com" + "http:/test2.com" @@ -217,11 +212,10 @@ public void createBidVastXmlShouldBeModifiedWithNewImpressionAfterExistingImpres final String bidAdm = "< Impression >http:/test.com< /Impression >" + "http:/test2.com< /ImPRession garbage>"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("< Impression >http:/test.com< /Impression >" + "http:/test2.com< /ImPRession garbage>" @@ -233,11 +227,10 @@ public void createBidVastXmlShouldInsertImpressionTagForEmptyInLine() { // when final String bidAdm = ""; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(""); } @@ -247,11 +240,10 @@ public void createBidVastXmlShouldNotInsertImpressionTagForNoInLineCloseTag() { // when final String bidAdm = ""; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(bidAdm); } @@ -261,11 +253,10 @@ public void createBidVastXmlShouldModifyWrapperTagInCaseInsensitiveMode() { // when final String bidAdm = "http:/test.com"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("http:/test.com" + ""); @@ -276,11 +267,10 @@ public void createBidVastXmlShouldModifyWrapperTagInCaseInsensitiveMode2() { // when final String bidAdm = "< wraPPer garbage>http:/test.com< / wraPPer garbage>"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("< wraPPer garbage>http:/test.com" + "< / wraPPer garbage>"); @@ -290,13 +280,11 @@ public void createBidVastXmlShouldModifyWrapperTagInCaseInsensitiveMode2() { public void createBidVastXmlShouldInsertImpressionTagForEmptyWrapper() { // when final String bidAdm = ""; - final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, - BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + final String result = target.createBidVastXml( + BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result) .isEqualTo(""); @@ -308,11 +296,10 @@ public void createBidVastXmlShouldInsertImpressionTagForEmptyWrapper2() { final String bidAdm = "< wraPPer garbage>< / wrapPer garbage>"; final String result = target .createBidVastXml(BIDDER, bidAdm, BID_NURL, - BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result) .isEqualTo("< wraPPer garbage>"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(bidAdm); } @@ -338,11 +324,10 @@ public void createBidVastXmlShouldModifyInlineTagInCaseInsensitiveMode() { // when final String bidAdm = "http:/test.com"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("http:/test.com" + ""); @@ -353,11 +338,10 @@ public void createBidVastXmlShouldModifyInlineTagInCaseInsensitiveMode2() { // when final String bidAdm = "< InLIne garbage >http:/test.com"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("< InLIne garbage >http:/test.com" + ""); @@ -368,11 +352,10 @@ public void createBidVastXmlShouldBeModifiedIfInLineHasNoImpressionTags() { // when final String bidAdm = ""; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(""); } @@ -382,11 +365,10 @@ public void createBidVastXmlShouldBeModifiedIfInLineHasNoImpressionTags2() { // when final String bidAdm = "< InLIne garbage >< / InLIne garbage >"; final String result = target - .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList(), - LINEITEM_ID); + .createBidVastXml(BIDDER, bidAdm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), emptyList()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo("< InLIne garbage >< / InLIne garbage >"); @@ -398,10 +380,10 @@ public void createBidVastXmlShouldNotBeModifiedIfNoParentTagsPresent() { final String adm = "http:/test.com"; final List warnings = new ArrayList<>(); final String result = target - .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings, LINEITEM_ID); + .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(adm); assertThat(warnings).containsExactly("VastXml does not contain neither InLine nor Wrapper for bidder response"); verify(metrics).updateAdapterRequestErrorMetric(BIDDER, MetricName.badserverresponse); @@ -413,10 +395,10 @@ public void createBidVastXmlShouldNotBeModifiedIfWrapperTagIsInvalid() { final String adm = ""; final List warnings = new ArrayList<>(); final String result = target - .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings, LINEITEM_ID); + .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(adm); assertThat(warnings).containsExactly("VastXml does not contain neither InLine nor Wrapper for bidder response"); verify(metrics).updateAdapterRequestErrorMetric(BIDDER, MetricName.badserverresponse); @@ -428,10 +410,10 @@ public void createBidVastXmlShouldNotBeModifiedIfInlineTagIsInvalid() { final String adm = ""; final List warnings = new ArrayList<>(); final String result = target - .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings, LINEITEM_ID); + .createBidVastXml(BIDDER, adm, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), warnings); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(adm); assertThat(warnings).containsExactly("VastXml does not contain neither InLine nor Wrapper for bidder response"); verify(metrics).updateAdapterRequestErrorMetric(BIDDER, MetricName.badserverresponse); @@ -441,11 +423,11 @@ public void createBidVastXmlShouldNotBeModifiedIfInlineTagIsInvalid() { public void createBidVastXmlShouldNotModifyWhenEventsEnabledAndAdmHaveNoImpression() { // when final String admWithNoImpression = "no impression"; - final String result = target.createBidVastXml(BIDDER, admWithNoImpression, BID_NURL, BID_ID, - ACCOUNT_ID, eventsContext(), new ArrayList<>(), LINEITEM_ID); + final String result = target.createBidVastXml( + BIDDER, admWithNoImpression, BID_NURL, BID_ID, ACCOUNT_ID, eventsContext(), new ArrayList<>()); // then - verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, LINEITEM_ID, eventsContext()); + verify(eventsService).vastUrlTracking(BID_ID, BIDDER, ACCOUNT_ID, eventsContext()); assertThat(result).isEqualTo(admWithNoImpression); } diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-device-targeting.json b/src/test/resources/org/prebid/server/deals/targeting/test-device-targeting.json deleted file mode 100644 index b28efce2c2f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-device-targeting.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$and": [ - { - "device.ext.deviceinfoprovider.browser": { - "$in": [ - "Chrome", - "Firefox" - ] - } - }, - { - "device.geo.ext.geoprovider.country": { - "$in": [ - "us", - "jp" - ] - } - } - ] -} diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-and-with-non-array.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-and-with-non-array.json deleted file mode 100644 index 4459a762640..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-and-with-non-array.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$and": {} -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-function.json deleted file mode 100644 index 8315dec8997..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.size": { - "$in": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-geo-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-geo-function.json deleted file mode 100644 index 07ac026bd2b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-geo-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "geo.distance": { - "$intersects": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-segment-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-segment-function.json deleted file mode 100644 index ea2a189602f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-segment-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "segment.bluekai": { - "$in": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-string-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-string-function.json deleted file mode 100644 index b451647996b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-string-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.adslot": { - "$intersects": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-typed-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-typed-function.json deleted file mode 100644 index eddac02192f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-incompatible-typed-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "bidp.rubicon.siteId": { - "$within": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-non-object.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-non-object.json deleted file mode 100644 index f67d1e4a258..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-category-non-object.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "adunit.size": 123 -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-in-integers-non-integer.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-in-integers-non-integer.json deleted file mode 100644 index 19fd40b0906..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-in-integers-non-integer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "user.ext.time.userhour": { - "$in": [ - "abc" - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-non-array.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-non-array.json deleted file mode 100644 index 85710c883e9..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-non-array.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.size": { - "$intersects": {} - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-empty-size.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-empty-size.json deleted file mode 100644 index e3c0b26ba08..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-empty-size.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "adunit.size": { - "$intersects": [ - { - } - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-objects.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-objects.json deleted file mode 100644 index 91b6c932bde..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-objects.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "adunit.size": { - "$intersects": [ - 123, - 234 - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-readable-size.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-readable-size.json deleted file mode 100644 index 57ef2fce627..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-sizes-non-readable-size.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "adunit.size": { - "$intersects": [ - { - "w": {} - } - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-empty.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-empty.json deleted file mode 100644 index 5a1cd32db73..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-empty.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "adunit.mediatype": { - "$intersects": [ - "" - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-non-string.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-non-string.json deleted file mode 100644 index 974de4e4c1a..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-intersects-strings-non-string.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "adunit.mediatype": { - "$intersects": [ - 123 - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-empty.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-empty.json deleted file mode 100644 index 413e4c7b71f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-empty.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.adslot": { - "$matches": "" - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-non-string.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-non-string.json deleted file mode 100644 index 3f2439279d9..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-matches-non-string.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.adslot": { - "$matches": 123 - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-boolean-args.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-boolean-args.json deleted file mode 100644 index d544404457e..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-boolean-args.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$and": [ - { - "aaa": {}, - "bbb": {} - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-function.json deleted file mode 100644 index f4d51caf96b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields-function.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "adunit.size": { - "aaa": {}, - "bbb": {} - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields.json deleted file mode 100644 index 186dd09685f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-multiple-fields.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "aaa": {}, - "bbb": {} -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-non-object.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-non-object.json deleted file mode 100644 index 5862557ee7f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-non-object.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$and": 123 -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-not-with-non-object.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-not-with-non-object.json deleted file mode 100644 index 6741ef4d8ef..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-not-with-non-object.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$not": [] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-incompatible-type.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-incompatible-type.json deleted file mode 100644 index edafbc6a05b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-incompatible-type.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "bidp.rubicon.siteId": { - "$in": [ - false - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-mixed-types.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-mixed-types.json deleted file mode 100644 index 40b94d6ec36..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-typed-function-mixed-types.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "bidp.rubicon.siteId": { - "$in": [ - 123, - "321" - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-field.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-field.json deleted file mode 100644 index 81cc228d55f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-field.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "aaa": {} -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-function.json deleted file mode 100644 index ccea774510a..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.size": { - "$abc": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-string-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-string-function.json deleted file mode 100644 index d83962f0989..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-string-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "adunit.adslot": { - "$abc": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-typed-function.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-typed-function.json deleted file mode 100644 index 0cc0c3a781b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-unknown-typed-function.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "bidp.rubicon.siteId": { - "$abc": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-empty-georegion.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-empty-georegion.json deleted file mode 100644 index 22a638b0b53..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-empty-georegion.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "geo.distance": { - "$within": { - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-object.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-object.json deleted file mode 100644 index d10af646564..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-object.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "geo.distance": { - "$within": [] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-readable-georegion.json b/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-readable-georegion.json deleted file mode 100644 index b21c6a2523d..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-invalid-targeting-definition-within-non-readable-georegion.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "geo.distance": { - "$within": { - "lat": {} - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-and-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-and-definition.json deleted file mode 100644 index ddb8501fd06..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-and-definition.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$not": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 450, - "h": 250 - }, - { - "w": 400, - "h": 200 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner", - "video" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-in-integers-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-in-integers-definition.json deleted file mode 100644 index 27284bdc6d3..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-in-integers-definition.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$not": { - "bidp.rubicon.siteId": { - "$in": [ - 785, - 778 - ] - } - } -} diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-in-strings-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-in-strings-definition.json deleted file mode 100644 index 011d00d81c1..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-in-strings-definition.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$not": { - "site.domain": { - "$in": [ - "nba.com", - "cnn.com" - ] - } - } -} diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-integer-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-integer-definition.json deleted file mode 100644 index 08c0b5c166c..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-integer-definition.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$not": { - "ufpd.data.someId": { - "$intersects": [ - 123, - 321 - ] - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-sizes-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-sizes-definition.json deleted file mode 100644 index 50f0f524a4b..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-intersects-sizes-definition.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$not": { - "adunit.size": { - "$intersects": [ - { - "w": 450, - "h": 250 - }, - { - "w": 400, - "h": 200 - } - ] - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-matches-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-matches-definition.json deleted file mode 100644 index 4f3d9a69c3f..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-matches-definition.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$not": { - "site.domain": { - "$matches": "*nba.com*" - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-or-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-or-definition.json deleted file mode 100644 index b8da565c351..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-or-definition.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$not": { - "$or": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 450, - "h": 250 - }, - { - "w": 400, - "h": 200 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner", - "video" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-not-within-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-not-within-definition.json deleted file mode 100644 index 98a0670f5fa..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-not-within-definition.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$not": { - "geo.distance": { - "$within": { - "lat": 2.424744, - "lon": 3.506435, - "radiusMiles": 10 - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/deals/targeting/test-valid-targeting-definition.json b/src/test/resources/org/prebid/server/deals/targeting/test-valid-targeting-definition.json deleted file mode 100644 index cd2acc99523..00000000000 --- a/src/test/resources/org/prebid/server/deals/targeting/test-valid-targeting-definition.json +++ /dev/null @@ -1,354 +0,0 @@ -{ - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - }, - { - "w": 400, - "h": 200 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner", - "video" - ] - } - }, - { - "$or": [ - { - "site.domain": { - "$matches": "*nba.com*" - } - }, - { - "site.domain": { - "$matches": "nba.com*" - } - }, - { - "site.domain": { - "$in": [ - "nba.com", - "cnn.com" - ] - } - } - ] - }, - { - "$or": [ - { - "site.referrer": { - "$matches": "*sports*" - } - }, - { - "site.referrer": { - "$matches": "http://nba.com/lalakers*" - } - }, - { - "site.referrer": { - "$in": [ - "http://cnn.com/culture", - "http://cnn.com/weather" - ] - } - } - ] - }, - { - "$or": [ - { - "app.bundle": { - "$matches": "*com.google.calendar*" - } - }, - { - "app.bundle": { - "$matches": "com.google.calendar*" - } - }, - { - "app.bundle": { - "$in": [ - "com.google.calendar", - "com.tmz" - ] - } - } - ] - }, - { - "$or": [ - { - "adunit.adslot": { - "$matches": "*/home/top*" - } - }, - { - "adunit.adslot": { - "$matches": "/home/top*" - } - }, - { - "adunit.adslot": { - "$in": [ - "/home/top", - "/home/bottom" - ] - } - } - ] - }, - { - "device.geo.ext.vendor.attribute": { - "$in": [ - "device_geo_ext_value1", - "device_geo_ext_value2" - ] - } - }, - { - "device.geo.ext.vendor.nested.attribute": { - "$in": [ - "device_geo_ext_nested_value1", - "device_geo_ext_nested_value2" - ] - } - }, - { - "device.ext.vendor.attribute": { - "$in": [ - "device_ext_value1", - "device_ext_value2" - ] - } - }, - { - "device.ext.vendor.nested.attribute": { - "$in": [ - "device_ext_nested_value1", - "device_ext_nested_value2" - ] - } - }, - { - "pos": { - "$in": [ - 1, - 3 - ] - } - }, - { - "geo.distance": { - "$within": { - "lat": 123.456, - "lon": 789.123, - "radiusMiles": 10 - } - } - }, - { - "$or": [ - { - "bidp.rubicon.siteId": { - "$in": [ - 123, - 321 - ] - } - }, - { - "bidp.rubicon.siteId": { - "$intersects": [ - 123, - 321 - ] - } - } - ] - }, - { - "$or": [ - { - "bidp.appnexus.placementName": { - "$matches": "*somePlacement*" - } - }, - { - "bidp.appnexus.placementName": { - "$matches": "somePlacement*" - } - }, - { - "bidp.appnexus.placementName": { - "$in": [ - "somePlacement1", - "somePlacement2" - ] - } - }, - { - "bidp.appnexus.placementName": { - "$intersects": [ - "somePlacement1", - "somePlacement2" - ] - } - } - ] - }, - { - "$or": [ - { - "segment.rubicon": { - "$intersects": [ - "123", - "234", - "345" - ] - } - }, - { - "segment.bluekai": { - "$intersects": [ - "123", - "234", - "345" - ] - } - } - ] - }, - { - "$or": [ - { - "ufpd.someId": { - "$in": [ - 123, - 321 - ] - } - }, - { - "ufpd.someId": { - "$intersects": [ - 123, - 321 - ] - } - } - ] - }, - { - "$or": [ - { - "ufpd.sport": { - "$matches": "*hockey*" - } - }, - { - "ufpd.sport": { - "$matches": "hockey*" - } - }, - { - "ufpd.sport": { - "$in": [ - "hockey", - "soccer" - ] - } - }, - { - "ufpd.sport": { - "$intersects": [ - "hockey", - "soccer" - ] - } - } - ] - }, - { - "$or": [ - { - "sfpd.someId": { - "$in": [ - 123, - 321 - ] - } - }, - { - "sfpd.someId": { - "$intersects": [ - 123, - 321 - ] - } - } - ] - }, - { - "$or": [ - { - "sfpd.sport": { - "$matches": "*hockey*" - } - }, - { - "sfpd.sport": { - "$matches": "hockey*" - } - }, - { - "sfpd.sport": { - "$in": [ - "hockey", - "soccer" - ] - } - }, - { - "sfpd.sport": { - "$intersects": [ - "hockey", - "soccer" - ] - } - } - ] - }, - { - "user.ext.time.userdow": { - "$in": [ - 5, - 6 - ] - } - }, - { - "user.ext.time.userhour": { - "$in": [ - 10, - 11, - 12, - 13, - 14 - ] - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-and-second-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-and-second-response.json deleted file mode 100644 index 67635c5327b..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-and-second-response.json +++ /dev/null @@ -1,461 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "price": 10.6, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "10.60", - "hb_pb_rubicon": "10.60", - "hb_deal_rubicon": "dealId1", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId1" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 10.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId1\",\"impid\":\"impId1\",\"dealid\":\"dealId1\",\"price\":10.6,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId2\",\"impid\":\"impId1\",\"dealid\":\"dealId2\",\"price\":9.6,\"adm\":\"\",\"crid\":\"crid2\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}" - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "domain": "example.com", - "id": "2001" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem1" - ], - "sent_to_client_as_top_match": [ - "lineItem1" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem1", - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-bid-only-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-bid-only-response.json deleted file mode 100644 index b6eb2ef21fa..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-first-bid-only-response.json +++ /dev/null @@ -1,458 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "price": 10.6, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "10.60", - "hb_pb_rubicon": "10.60", - "hb_deal_rubicon": "dealId1", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId1" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 10.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId1\",\"impid\":\"impId1\",\"dealid\":\"dealId1\",\"price\":10.6,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}" - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}" - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem1" - ], - "sent_to_client_as_top_match": [ - "lineItem1" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem1" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-order-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-order-response.json deleted file mode 100644 index b6eb2ef21fa..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-order-response.json +++ /dev/null @@ -1,458 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "price": 10.6, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "10.60", - "hb_pb_rubicon": "10.60", - "hb_deal_rubicon": "dealId1", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId1" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 10.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId1\",\"impid\":\"impId1\",\"dealid\":\"dealId1\",\"price\":10.6,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}" - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}" - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem1" - ], - "sent_to_client_as_top_match": [ - "lineItem1" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem1" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-reverse-order-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-reverse-order-response.json deleted file mode 100644 index 0888ea6f0ce..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-in-reverse-order-response.json +++ /dev/null @@ -1,464 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "price": 10.6, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "10.60", - "hb_pb_rubicon": "10.60", - "hb_deal_rubicon": "dealId1", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId1" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 10.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId2\",\"impid\":\"impId1\",\"dealid\":\"dealId2\",\"price\":9.6,\"adm\":\"\",\"crid\":\"crid2\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId3\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId3\",\"impid\":\"impId1\",\"dealid\":\"dealId3\",\"price\":8.6,\"adm\":\"\",\"crid\":\"crid3\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId1\",\"impid\":\"impId1\",\"dealid\":\"dealId1\",\"price\":10.6,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "source": { - "tid": "someTid" - }, - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem1" - ], - "sent_to_client_as_top_match": [ - "lineItem1" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:07:36.045Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:07:36.064Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:07:36.049Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:07:36.064Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:07:36.056Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:07:36.064Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-second-bid-only-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-second-bid-only-response.json deleted file mode 100644 index 4855226c745..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-second-bid-only-response.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId2", - "impid": "impId1", - "price": 9.6, - "adm": "", - "crid": "crid2", - "dealid": "dealId2", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "9.60", - "hb_pb_rubicon": "9.60", - "hb_deal_rubicon": "dealId2", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId2" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2", - "imp": "http://localhost:8080/event?t=imp&b=bidId2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2" - } - }, - "origbidcpm": 9.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId2\",\"impid\":\"impId1\",\"dealid\":\"dealId2\",\"price\":9.6,\"adm\":\"\",\"crid\":\"crid2\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId3\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[]}]}", - "status": 200 - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem2" - ], - "sent_to_client_as_top_match": [ - "lineItem2" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-and-second-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-and-second-response.json deleted file mode 100644 index fe231c9b49c..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-and-second-response.json +++ /dev/null @@ -1,463 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId2", - "impid": "impId1", - "price": 9.6, - "adm": "", - "crid": "crid2", - "dealid": "dealId2", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "9.60", - "hb_pb_rubicon": "9.60", - "hb_deal_rubicon": "dealId2", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId2" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2", - "imp": "http://localhost:8080/event?t=imp&b=bidId2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2" - } - }, - "origbidcpm": 9.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId2\",\"impid\":\"impId1\",\"dealid\":\"dealId2\",\"price\":9.6,\"adm\":\"\",\"crid\":\"crid2\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId3\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId3\",\"impid\":\"impId1\",\"dealid\":\"dealId3\",\"price\":8.6,\"adm\":\"\",\"crid\":\"crid3\",\"w\":300,\"h\":250}]}]}", - "status": 200 - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem2" - ], - "sent_to_client_as_top_match": [ - "lineItem2" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem3", - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-bid-only-response.json b/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-bid-only-response.json deleted file mode 100644 index 50b88237167..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/responses/test-auction-third-bid-only-response.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId3", - "impid": "impId1", - "price": 8.6, - "adm": "", - "crid": "crid3", - "dealid": "dealId3", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "8.60", - "hb_pb_rubicon": "8.60", - "hb_deal_rubicon": "dealId3", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId3" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId3&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem3", - "imp": "http://localhost:8080/event?t=imp&b=bidId3&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem3" - } - }, - "origbidcpm": 8.6 - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "rubicon": [ - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[]}]}", - "status": 200 - }, - { - "uri": "{{ rubicon.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId3\",\"seatbid\":[{\"seat\":\"seatId\",\"bid\":[{\"id\":\"bidId3\",\"impid\":\"impId1\",\"dealid\":\"dealId3\",\"price\":8.6,\"adm\":\"\",\"crid\":\"crid3\",\"w\":300,\"h\":250}]}]}", - "status": 200 - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"rubicon\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "auctiontimestamp": 1000, - "debug": 1, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "channel": { - "name": "web" - }, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem3" - ], - "sent_to_client_as_top_match": [ - "lineItem3" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem1" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem3" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.044Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:08:59.061Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.048Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.053Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:08:59.062Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-auction-request.json b/src/test/resources/org/prebid/server/it/deals/premature/test-auction-request.json deleted file mode 100644 index 307b091e591..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-auction-request.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "id": "tid", - "imp": [ - { - "id": "impId1", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "cur": [ - "USD" - ], - "user": { - "ext": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA" - } - }, - "source": { - "tid": "someTid" - }, - "site": { - "publisher": { - "id": "2001" - } - }, - "ext": { - "prebid": { - "debug": 1, - "trace": "verbose", - "targeting": { - }, - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-planner-plan-response.json b/src/test/resources/org/prebid/server/it/deals/premature/test-planner-plan-response.json deleted file mode 100644 index d80ece7ad26..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-planner-plan-response.json +++ /dev/null @@ -1,209 +0,0 @@ -[ - { - "lineItemId": "lineItem1", - "extLineItemId": "extLineItem1", - "dealId": "dealId1", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 10.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 9.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId2", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem3", - "extLineItemId": "extLineItem3", - "dealId": "dealId3", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 8.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - } -] diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-1.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-1.json deleted file mode 100644 index 9b3e45e74e4..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-1.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "id": "bidResponseId1", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "dealid": "dealId1", - "price": 10.60, - "adm": "", - "crid": "crid1", - "w": 300, - "h": 250 - } - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-2.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-2.json deleted file mode 100644 index ba3e19d5887..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-2.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "id": "bidResponseId2", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - { - "id": "bidId2", - "impid": "impId1", - "dealid": "dealId2", - "price": 9.60, - "adm": "", - "crid": "crid2", - "w": 300, - "h": 250 - } - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-3.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-3.json deleted file mode 100644 index 3583fa59b7f..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-bid-response-3.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "id": "bidResponseId3", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - { - "id": "bidId3", - "impid": "impId1", - "dealid": "dealId3", - "price": 8.60, - "adm": "", - "crid": "crid3", - "w": 300, - "h": 250 - } - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-1.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-1.json deleted file mode 100644 index 533d6537f8f..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-1.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "bidResponseId1", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-2.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-2.json deleted file mode 100644 index b3c9444dd24..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "bidResponseId2", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-3.json b/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-3.json deleted file mode 100644 index 5363e36c8f9..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/premature/test-rubicon-no-bid-response-3.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "bidResponseId3", - "seatbid": [ - { - "seat": "seatId", - "bid": [ - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-request.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-request.json deleted file mode 100644 index ba27f286b81..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-request.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "id": "tid", - "imp": [ - { - "id": "impId1", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "cur": [ - "USD" - ], - "source": { - "tid": "someTid" - }, - "site": { - "publisher": { - "id": "2001" - } - }, - "user": { - "ext": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA" - } - }, - "ext": { - "prebid": { - "debug": 1, - "trace": "verbose", - "targeting": { - }, - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-1.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-1.json deleted file mode 100644 index 4a51433c278..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-1.json +++ /dev/null @@ -1,366 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "impId1-lineItem1", - "impid": "impId1", - "price": 10.0, - "adm": "", - "crid": "crid", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "10.00", - "hb_pb_rubicon": "10.00", - "hb_deal_rubicon": "dealId1", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId1" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=impId1-lineItem1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=impId1-lineItem1&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 10.0, - "origbidcur": "USD" - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "debug": 1, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - }, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "auctiontimestamp": 1000, - "channel": { - "name": "web" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem1" - ], - "sent_to_client_as_top_match": [ - "lineItem1" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem3" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem1", - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T13:54:17.715Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T13:54:17.733Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T13:54:17.72Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T13:54:17.734Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T13:54:17.725Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T13:54:17.734Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-2.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-2.json deleted file mode 100644 index 85591873f73..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-auction-response-2.json +++ /dev/null @@ -1,350 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "impId1-lineItem2", - "impid": "impId1", - "price": 7.0, - "adm": "", - "crid": "crid", - "dealid": "dealId2", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_pb": "7.00", - "hb_pb_rubicon": "7.00", - "hb_deal_rubicon": "dealId2", - "hb_size": "300x250", - "hb_bidder": "rubicon", - "hb_size_rubicon": "300x250", - "hb_bidder_rubicon": "rubicon", - "hb_deal": "dealId2" - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=impId1-lineItem2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2", - "imp": "http://localhost:8080/event?t=imp&b=impId1-lineItem2&a=2001&aid=tid&ts=1000&bidder=rubicon&f=i&int=&x=0&l=lineItem2" - } - }, - "origbidcpm": 7.0, - "origbidcur": "USD" - } - } - ], - "seat": "rubicon", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "resolvedrequest": { - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - }, - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "rubicon" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "rubicon": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "debug": 1, - "trace": "verbose", - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - }, - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "auctiontimestamp": 1000, - "channel": { - "name": "web" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem2" - ], - "sent_to_client_as_top_match": [ - "lineItem2" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem2" - ], - "pacing_deferred": [ - "lineItem1" - ], - "sent_to_bidder": { - "rubicon": [ - "lineItem3", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "rubicon": [ - "lineItem3" - ] - }, - "received_from_bidder": { - "rubicon": [ - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:03:17.986Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-24T14:03:18.002Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder rubicon ready to serve. relPriority 3" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:03:17.993Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-24T14:03:18.002Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder rubicon not ready to serve. Will be ready at never, current time is 2019-10-10T00:16:00.000Z" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:03:18.001Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-24T14:03:18.003Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder rubicon ready to serve. relPriority 3" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "rubicon" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "responsetimemillis": { - "rubicon": "{{ rubicon.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-bid-rates.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-bid-rates.json deleted file mode 100644 index fe32f4a040e..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-bid-rates.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "lineItem1": 1.00, - "lineItem2": 1.00, - "lineItem3": 0.00 -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-1.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-1.json deleted file mode 100644 index 07187887734..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-1.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "reportTimeStamp": "2019-10-10T00:00:03.000Z", - "dataWindowStartTimeStamp": "2019-10-10T00:00:02.000Z", - "dataWindowEndTimeStamp": "2019-10-10T00:00:03.000Z", - "instanceId": "localhost", - "vendor": "local", - "region": "local", - "clientAuctions": 1, - "lineItemStatus": [ - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 0, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 0, - "sentToClientAsTopMatch": 0, - "lostToLineItems": [ - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem3", - "count": 1 - }, - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem1", - "count": 1 - } - ], - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "planStartTimeStamp": "2019-10-10T00:00:00.000Z", - "planExpirationTimeStamp": "2019-10-10T00:10:00.000Z", - "planUpdatedTimeStamp": "2019-10-10T00:00:00.000Z", - "tokens": [ - { - "class": 1, - "total": 5000, - "spent": 0 - }, - { - "class": 2, - "total": 125, - "spent": 0 - } - ] - } - ] - }, - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem3", - "dealId": "dealId3", - "extLineItemId": "extLineItem3", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 1, - "receivedFromBidder": 0, - "receivedFromBidderInvalidated": 0, - "sentToClient": 0, - "sentToClientAsTopMatch": 0, - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "planStartTimeStamp": "2019-10-10T00:00:00.000Z", - "planExpirationTimeStamp": "2019-10-10T00:10:00.000Z", - "planUpdatedTimeStamp": "2019-10-10T00:00:00.000Z", - "tokens": [ - { - "class": 1, - "total": 5000, - "spent": 0 - }, - { - "class": 2, - "total": 125, - "spent": 0 - } - ] - } - ] - }, - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem1", - "dealId": "dealId1", - "extLineItemId": "extLineItem1", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 0, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 1, - "sentToClientAsTopMatch": 1, - "lostToLineItems": [ - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem3", - "count": 1 - } - ], - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "planStartTimeStamp": "2019-10-10T00:00:00.000Z", - "planExpirationTimeStamp": "2019-10-10T00:10:00.000Z", - "planUpdatedTimeStamp": "2019-10-10T00:00:00.000Z", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0, - "totalSpent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 1, - "totalSpent": 1 - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-2.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-2.json deleted file mode 100644 index ab3a570202f..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-delivery-stats-progress-request-2.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "reportTimeStamp": "2019-10-10T00:17:00.000Z", - "dataWindowStartTimeStamp": "2019-10-10T00:00:03.000Z", - "dataWindowEndTimeStamp": "2019-10-10T00:17:00.000Z", - "instanceId": "localhost", - "vendor": "local", - "region": "local", - "clientAuctions": 1, - "lineItemStatus": [ - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 0, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 1, - "sentToClientAsTopMatch": 1, - "lostToLineItems": [ - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem3", - "count": 1 - } - ], - "events": [], - "deliverySchedule": [ - { - "planId": "2", - "planStartTimeStamp": "2019-10-10T00:10:00.000Z", - "planExpirationTimeStamp": "2019-10-10T00:20:00.000Z", - "planUpdatedTimeStamp": "2019-10-10T00:10:00.000Z", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0, - "totalSpent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 1, - "totalSpent": 1 - } - ] - } - ] - }, - { - "lineItemSource": "rubicon", - "lineItemId": "lineItem3", - "dealId": "dealId3", - "extLineItemId": "extLineItem3", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 1, - "receivedFromBidder": 0, - "receivedFromBidderInvalidated": 0, - "sentToClient": 0, - "sentToClientAsTopMatch": 0, - "events": [], - "deliverySchedule": [ - { - "planId": "2", - "planStartTimeStamp": "2019-10-10T00:10:00.000Z", - "planExpirationTimeStamp": "2019-10-10T00:20:00.000Z", - "planUpdatedTimeStamp": "2019-10-10T00:10:00.000Z", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 0 - } - ] - } - ] - } - ] -} diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-plan-response-1.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-plan-response-1.json deleted file mode 100644 index 4dc1db3ce10..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-plan-response-1.json +++ /dev/null @@ -1,257 +0,0 @@ -[ - { - "lineItemId": "lineItem1", - "extLineItemId": "extLineItem1", - "dealId": "dealId1", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 10.00, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:20:00Z", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:10:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - }, - { - "planId": "2", - "updatedTimeStamp": "2019-10-10T00:10:00Z", - "startTimeStamp": "2019-10-10T00:20:00Z", - "endTimeStamp": "2019-10-10T00:30:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 7.00, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:20:00Z", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId2", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:10:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - }, - { - "planId": "2", - "updatedTimeStamp": "2019-10-10T00:10:00Z", - "startTimeStamp": "2019-10-10T00:10:00Z", - "endTimeStamp": "2019-10-10T00:20:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem3", - "extLineItemId": "extLineItem3", - "dealId": "dealId3", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "rubicon", - "price": { - "cpm": 15.00, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:20:00Z", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "2019-10-10T00:00:00Z", - "startTimeStamp": "2019-10-10T00:00:00Z", - "endTimeStamp": "2019-10-10T00:10:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - }, - { - "planId": "2", - "updatedTimeStamp": "2019-10-10T00:10:00Z", - "startTimeStamp": "2019-10-10T00:10:00Z", - "endTimeStamp": "2019-10-10T00:20:00Z", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - } -] diff --git a/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-register-request-1.json b/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-register-request-1.json deleted file mode 100644 index c8aa1a6e300..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/simulation/test-planner-register-request-1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "healthIndex": 0.43, - "hostInstanceId": "localhost", - "region": "local", - "vendor": "local" -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/test-auction-request.json b/src/test/resources/org/prebid/server/it/deals/test-auction-request.json deleted file mode 100644 index bfc31ef4604..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-auction-request.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "id": "tid", - "regs": { - "gdpr": 0 - }, - "imp": [ - { - "id": "impId1", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - }, - { - "id": "impId2", - "banner": { - "format": [ - { - "w": 320, - "h": 320 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - }, - { - "id": "impId3", - "banner": { - "format": [ - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001, - "dealsonly": true, - "pgdealsonly": true - } - } - } - } - }, - { - "id": "impId4", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "cur": [ - "USD" - ], - "source": { - "tid": "someTid" - }, - "site": { - "publisher": { - "id": "2001" - } - }, - "user": { - "ext": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA" - } - }, - "ext": { - "prebid": { - "debug": 1, - "trace": "verbose", - "targeting": { - }, - "cache": { - "bids": {}, - "vastxml": { - "ttlseconds": 120 - } - }, - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-auction-response.json b/src/test/resources/org/prebid/server/it/deals/test-auction-response.json deleted file mode 100644 index d4e5d0690eb..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-auction-response.json +++ /dev/null @@ -1,877 +0,0 @@ -{ - "id": "tid", - "seatbid": [ - { - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "price": 8.43, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_deal_generic": "dealId1", - "hb_cache_id": "3f37ff80-b395-449f-a80e-c21a38bb6eec", - "hb_cache_path_generic": "/cache", - "hb_cache_host_generic": "{{ cache.host }}", - "hb_pb": "8.40", - "hb_pb_generic": "8.40", - "hb_cache_id_generic": "3f37ff80-b395-449f-a80e-c21a38bb6eec", - "hb_cache_path": "/cache", - "hb_size": "300x250", - "hb_bidder": "generic", - "hb_size_generic": "300x250", - "hb_bidder_generic": "generic", - "hb_cache_host": "{{ cache.host }}", - "hb_deal": "dealId1" - }, - "cache": { - "bids": { - "url": "{{ cache.resource_url }}3f37ff80-b395-449f-a80e-c21a38bb6eec", - "cacheId": "3f37ff80-b395-449f-a80e-c21a38bb6eec" - } - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1" - } - }, - "origbidcpm": 8.43 - } - }, - { - "id": "bidId2", - "impid": "impId2", - "price": 8.43, - "adm": "", - "crid": "crid2", - "dealid": "dealId2", - "w": 320, - "h": 320, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_deal_generic": "dealId2", - "hb_size_generic": "320x320", - "hb_cache_id": "13e78248-7339-4e35-b297-874d0031bc1a", - "hb_cache_path_generic": "/cache", - "hb_cache_host_generic": "{{ cache.host }}", - "hb_pb": "8.40", - "hb_pb_generic": "8.40", - "hb_cache_id_generic": "13e78248-7339-4e35-b297-874d0031bc1a", - "hb_cache_path": "/cache", - "hb_size": "320x320", - "hb_bidder": "generic", - "hb_bidder_generic": "generic", - "hb_cache_host": "{{ cache.host }}", - "hb_deal": "dealId2" - }, - "cache": { - "bids": { - "url": "{{ cache.resource_url }}13e78248-7339-4e35-b297-874d0031bc1a", - "cacheId": "13e78248-7339-4e35-b297-874d0031bc1a" - } - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2", - "imp": "http://localhost:8080/event?t=imp&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2" - } - }, - "origbidcpm": 8.43 - } - }, - { - "id": "bidId4", - "impid": "impId4", - "price": 8.43, - "adm": "", - "crid": "crid1", - "dealid": "dealId3", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner", - "targeting": { - "hb_deal_generic": "dealId3", - "hb_size_generic": "300x250", - "hb_cache_id": "1cdcf339-e59b-4e2c-8382-1fb845d4961c", - "hb_cache_path_generic": "/cache", - "hb_cache_host_generic": "{{ cache.host }}", - "hb_pb": "8.40", - "hb_pb_generic": "8.40", - "hb_cache_id_generic": "1cdcf339-e59b-4e2c-8382-1fb845d4961c", - "hb_cache_path": "/cache", - "hb_size": "300x250", - "hb_bidder": "generic", - "hb_bidder_generic": "generic", - "hb_cache_host": "{{ cache.host }}", - "hb_deal": "dealId3" - }, - "cache": { - "bids": { - "url": "{{ cache.resource_url }}1cdcf339-e59b-4e2c-8382-1fb845d4961c", - "cacheId": "1cdcf339-e59b-4e2c-8382-1fb845d4961c" - } - }, - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3", - "imp": "http://localhost:8080/event?t=imp&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3" - } - }, - "origbidcpm": 8.43 - } - } - ], - "seat": "generic", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "debug": { - "httpcalls": { - "cache": [ - { - "uri": "{{ cache.endpoint }}", - "requestheaders": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"puts\":[{\"type\":\"json\",\"value\":{\"id\":\"bidId1\",\"impid\":\"impId1\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid1\",\"dealid\":\"dealId1\",\"w\":300,\"h\":250,\"ext\":{\"origbidcpm\":8.43,\"prebid\":{\"type\":\"banner\",\"events\":{\"win\":\"http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1\",\"imp\":\"http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1\"}}},\"wurl\":\"http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1\"},\"aid\":\"tid\"},{\"type\":\"json\",\"value\":{\"id\":\"bidId4\",\"impid\":\"impId4\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid1\",\"dealid\":\"dealId3\",\"w\":300,\"h\":250,\"ext\":{\"origbidcpm\":8.43,\"prebid\":{\"type\":\"banner\",\"events\":{\"win\":\"http://localhost:8080/event?t=win&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3\",\"imp\":\"http://localhost:8080/event?t=imp&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3\"}}},\"wurl\":\"http://localhost:8080/event?t=win&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3\"},\"aid\":\"tid\"},{\"type\":\"json\",\"value\":{\"id\":\"bidId2\",\"impid\":\"impId2\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid2\",\"dealid\":\"dealId2\",\"w\":320,\"h\":320,\"ext\":{\"origbidcpm\":8.43,\"prebid\":{\"type\":\"banner\",\"events\":{\"win\":\"http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2\",\"imp\":\"http://localhost:8080/event?t=imp&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2\"}}},\"wurl\":\"http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2\"},\"aid\":\"tid\"}]}", - "responsebody": "{\"responses\":[{\"uuid\":\"13e78248-7339-4e35-b297-874d0031bc1a\"},{\"uuid\":\"3f37ff80-b395-449f-a80e-c21a38bb6eec\"},{\"uuid\":\"1cdcf339-e59b-4e2c-8382-1fb845d4961c\"}]}", - "status": 200 - } - ], - "generic": [ - { - "uri": "{{ generic.exchange_uri }}", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId4\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId4\",\"seatbid\":[{\"seat\":\"seatId4\",\"bid\":[{\"id\":\"bidId4\",\"impid\":\"impId4\",\"dealid\":\"dealId3\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ generic.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem1\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId1\",\"seatbid\":[{\"seat\":\"seatId1\",\"bid\":[{\"id\":\"bidId1\",\"impid\":\"impId1\",\"dealid\":\"dealId1\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid1\",\"w\":300,\"h\":250}]}]}", - "status": 200 - }, - { - "uri": "{{ generic.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId2\",\"banner\":{\"format\":[{\"w\":320,\"h\":320}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId2\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem2\",\"extlineitemid\":\"extLineItem2\",\"sizes\":[{\"w\":320,\"h\":320}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem2\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId2\",\"seatbid\":[{\"seat\":\"seatId2\",\"bid\":[{\"id\":\"bidId2\",\"impid\":\"impId2\",\"dealid\":\"dealId2\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid2\",\"w\":320,\"h\":320}]}]}", - "status": 200 - }, - { - "uri": "{{ generic.exchange_uri }}?tk_xint=rp-pbs", - "requestheaders": { - "Accept": [ - "application/json" - ], - "x-prebid": [ - "pbs-java/1.70.0" - ], - "User-Agent": [ - "prebid-server/1.0" - ], - "Content-Type": [ - "application/json;charset=utf-8" - ] - }, - "requestbody": "{\"id\":\"tid\",\"imp\":[{\"id\":\"impId1\",\"banner\":{\"format\":[{\"w\":300,\"h\":250}],\"ext\":{\"rp\":{\"mime\":\"text/html\"}}},\"pmp\":{\"deals\":[{\"id\":\"dealId1\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem1\",\"extlineitemid\":\"extLineItem1\",\"sizes\":[{\"w\":300,\"h\":250}]}}},{\"id\":\"dealId3\",\"ext\":{\"line\":{\"lineitemid\":\"lineItem3\",\"extlineitemid\":\"extLineItem3\",\"sizes\":[{\"w\":300,\"h\":250}]}}}]},\"secure\":1,\"ext\":{\"rp\":{\"zone_id\":4001,\"target\":{\"page\":[\"http://www.example.com\"],\"line_item\":\"extLineItem3\"},\"track\":{\"mint\":\"\",\"mint_version\":\"\"}},\"maxbids\":1}}],\"site\":{\"domain\":\"www.example.com\",\"page\":\"http://www.example.com\",\"publisher\":{\"ext\":{\"rp\":{\"account_id\":2001}}},\"ext\":{\"amp\":0,\"rp\":{\"site_id\":3001}}},\"device\":{\"ua\":\"userAgent\",\"ip\":\"185.199.110.0\",\"ext\":{\"rp\":{}}},\"user\":{\"buyeruid\":\"J5VLCWQP-26-CWFT\",\"consent\":\"CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA\",\"ext\":{\"fcapids\":[\"fcapId3\"],\"time\":{\"userdow\":{{ userdow }},\"userhour\":{{ userhour }}}}},\"at\":1,\"tmax\":5000,\"source\":{\"tid\":\"someTid\"}}", - "responsebody": "{\"id\":\"bidResponseId3\",\"seatbid\":[{\"seat\":\"seatId3\",\"bid\":[{\"id\":\"bidId3\",\"impid\":\"impId1\",\"dealid\":\"dealId3\",\"price\":8.43,\"adm\":\"\",\"crid\":\"crid3\",\"w\":300,\"h\":250}]}]}", - "status": 200 - } - ], - "userservice": [ - { - "uri": "{{ userservice_uri }}", - "requestbody": "{\"time\":\"{{ userservice_time }}\",\"ids\":[{\"type\":\"khaos\",\"id\":\"J5VLCWQP-26-CWFT\"}]}", - "responsebody": "{\"user\":{\"data\":[{\"id\":\"1111\",\"name\":\"generic\",\"segment\":[{\"id\":\"2222\"},{\"id\":\"3333\"}]},{\"id\":\"4444\",\"name\":\"bluekai\",\"segment\":[{\"id\":\"5555\"},{\"id\":\"6666\"}]}],\"ext\":{\"fcapIds\":[\"fcapId3\"]}}}", - "status": 200 - } - ] - }, - "resolvedrequest": { - "id": "tid", - "regs": { - "gdpr": 0 - }, - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "generic" - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "generic" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - }, - { - "id": "impId2", - "secure": 1, - "banner": { - "format": [ - { - "w": 320, - "h": 320 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 320, - "h": 320 - } - ], - "bidder": "generic" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - }, - { - "id": "impId3", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001, - "dealsonly": true, - "pgdealsonly": true - } - } - } - } - }, - { - "id": "impId4", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "bidder": "generic" - } - } - } - ] - }, - "ext": { - "tid": "someTid", - "prebid": { - "bidder": { - "generic": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - } - } - } - } - } - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "id": "2001", - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "user": { - "data": [ - { - "id": "generic", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "ext": { - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "{{ userdow }}", - "userhour": "{{ userhour }}" - } - } - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "ext": { - "prebid": { - "debug": 1, - "server": { - "externalurl": "http://localhost:8080", - "gvlid": 1, - "datacenter": "local", - "endpoint": "/openrtb2/auction" - }, - "trace": "verbose", - "targeting": { - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "max": 20, - "increment": 0.1 - } - ] - }, - "includewinners": true, - "includebidderkeys": true - }, - "cache": { - "bids": {}, - "vastxml": { - "ttlseconds": 120 - } - }, - "auctiontimestamp": 1000, - "channel": { - "name": "web" - } - } - } - }, - "pgmetrics": { - "sent_to_client": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_client_as_top_match": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "matched_whole_targeting": [ - "lineItem3", - "lineItem4", - "lineItem1", - "lineItem2" - ], - "matched_targeting_fcapped": [ - "lineItem4" - ], - "ready_to_serve": [ - "lineItem3", - "lineItem1", - "lineItem2" - ], - "sent_to_bidder": { - "generic": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "sent_to_bidder_as_top_match": { - "generic": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - }, - "received_from_bidder": { - "generic": [ - "lineItem3", - "lineItem1", - "lineItem2" - ] - } - }, - "trace": { - "lineitems": { - "lineItem3": [ - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:03.963Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:03.981Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder generic ready to serve. relPriority 3" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:03.992Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting did not match imp with id impId2" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:04.009Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting did not match imp with id impId3" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:04.029Z", - "category": "targeting", - "message": "Line Item lineItem3 targeting matched imp with id impId4" - }, - { - "lineitemid": "lineItem3", - "time": "2020-04-27T13:08:04.043Z", - "category": "pacing", - "message": "Matched Line Item lineItem3 for bidder generic ready to serve. relPriority 3" - } - ], - "lineItem4": [ - { - "lineitemid": "lineItem4", - "time": "2020-04-27T13:08:03.967Z", - "category": "targeting", - "message": "Line Item lineItem4 targeting did not match imp with id impId1" - }, - { - "lineitemid": "lineItem4", - "time": "2020-04-27T13:08:03.995Z", - "category": "targeting", - "message": "Line Item lineItem4 targeting did not match imp with id impId2" - }, - { - "lineitemid": "lineItem4", - "time": "2020-04-27T13:08:04.014Z", - "category": "targeting", - "message": "Line Item lineItem4 targeting matched imp with id impId3" - }, - { - "lineitemid": "lineItem4", - "time": "2020-04-27T13:08:04.024Z", - "category": "pacing", - "message": "Matched Line Item lineItem4 for bidder generic is frequency capped by fcap id fcapId3." - }, - { - "lineitemid": "lineItem4", - "time": "2020-04-27T13:08:04.033Z", - "category": "targeting", - "message": "Line Item lineItem4 targeting did not match imp with id impId4" - } - ], - "lineItem1": [ - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:03.971Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId1" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:03.981Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder generic ready to serve. relPriority 3" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:03.999Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting did not match imp with id impId2" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:04.019Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting did not match imp with id impId3" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:04.038Z", - "category": "targeting", - "message": "Line Item lineItem1 targeting matched imp with id impId4" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:04.043Z", - "category": "pacing", - "message": "Matched Line Item lineItem1 for bidder generic ready to serve. relPriority 3" - }, - { - "lineitemid": "lineItem1", - "time": "2020-04-27T13:08:04.044Z", - "category": "cleanup", - "message": "LineItem lineItem1 was dropped from imp with id impId4 because it was top match in another imp" - } - ], - "lineItem2": [ - { - "lineitemid": "lineItem2", - "time": "2020-04-27T13:08:03.975Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting did not match imp with id impId1" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-27T13:08:04.004Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting matched imp with id impId2" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-27T13:08:04.004Z", - "category": "pacing", - "message": "Matched Line Item lineItem2 for bidder generic ready to serve. relPriority 3" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-27T13:08:04.024Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting did not match imp with id impId3" - }, - { - "lineitemid": "lineItem2", - "time": "2020-04-27T13:08:04.043Z", - "category": "targeting", - "message": "Line Item lineItem2 targeting did not match imp with id impId4" - } - ] - }, - "activity_infrastructure": [ - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "fetchBids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "fetchBids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitUfpd", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitUfpd", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitEids", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitEids", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitPreciseGeo", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitPreciseGeo", - "allowed": true - }, - { - "description": "Invocation of Activity Infrastructure.", - "activity": "transmitTid", - "activity_invocation_payload": { - "component_type": "BIDDER", - "component_name": "generic" - } - }, - { - "description": "Setting the default invocation result.", - "allow_by_default": true - }, - { - "description": "Activity Infrastructure invocation result.", - "activity": "transmitTid", - "allowed": true - } - ] - } - }, - "warnings": { - "prebid": [ - { - "code": 999, - "message": "Not calling generic bidder for impressions impId3 due to pgdealsonly flag and no available PG line items." - } - ] - }, - "responsetimemillis": { - "generic": "{{ generic.response_time_ms }}", - "cache": "{{ cache.response_time_ms }}" - }, - "tmaxrequest": 5000, - "prebid": { - "auctiontimestamp": 1000 - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-cache-deals-request.json b/src/test/resources/org/prebid/server/it/deals/test-cache-deals-request.json deleted file mode 100644 index 5461e5a9cd7..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-cache-deals-request.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "puts": [ - { - "type": "json", - "value": { - "id": "bidId4", - "impid": "impId4", - "price": 8.43, - "adm": "", - "crid": "crid1", - "dealid": "dealId3", - "w": 300, - "h": 250, - "ext": { - "origbidcpm": 8.43, - "prebid": { - "type": "banner", - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3", - "imp": "http://localhost:8080/event?t=imp&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3" - } - } - }, - "wurl": "http://localhost:8080/event?t=win&b=bidId4&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem3" - }, - "aid": "tid" - }, - { - "type": "json", - "value": { - "id": "bidId2", - "impid": "impId2", - "price": 8.43, - "adm": "", - "crid": "crid2", - "dealid": "dealId2", - "w": 320, - "h": 320, - "ext": { - "origbidcpm": 8.43, - "prebid": { - "type": "banner", - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2", - "imp": "http://localhost:8080/event?t=imp&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2" - } - } - }, - "wurl": "http://localhost:8080/event?t=win&b=bidId2&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem2" - }, - "aid": "tid" - }, - { - "type": "json", - "value": { - "id": "bidId1", - "impid": "impId1", - "price": 8.43, - "adm": "", - "crid": "crid1", - "dealid": "dealId1", - "w": 300, - "h": 250, - "ext": { - "origbidcpm": 8.43, - "prebid": { - "type": "banner", - "events": { - "win": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1", - "imp": "http://localhost:8080/event?t=imp&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1" - } - } - }, - "wurl": "http://localhost:8080/event?t=win&b=bidId1&a=2001&aid=tid&ts=1000&bidder=generic&f=i&int=&x=0&l=lineItem1" - }, - "aid": "tid" - } - ] -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-cache-matcher.json b/src/test/resources/org/prebid/server/it/deals/test-cache-matcher.json deleted file mode 100644 index 6ce206a9f25..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-cache-matcher.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "bidId2@8.43": "13e78248-7339-4e35-b297-874d0031bc1a", - "bidId1@8.43": "3f37ff80-b395-449f-a80e-c21a38bb6eec", - "bidId4@8.43": "1cdcf339-e59b-4e2c-8382-1fb845d4961c" -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/test-deals-application.properties b/src/test/resources/org/prebid/server/it/deals/test-deals-application.properties deleted file mode 100644 index 4f6d1b5ab41..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-deals-application.properties +++ /dev/null @@ -1,46 +0,0 @@ -server.http.port=8070 -admin.port=9060 -hostname=localhost -auction.ad-server-currency=USD -admin-endpoints.currency-rates.enabled=true -admin-endpoints.currency-rates.on-application-port=true -admin-endpoints.currency-rates.protected=false -admin-endpoints.e2eadmin.enabled=true -admin-endpoints.e2eadmin.on-application-port=true -admin-endpoints.e2eadmin.protected=false -admin-endpoints.lineitem-status.enabled=true -admin-endpoints.lineitem-status.on-application-port=true -admin-endpoints.lineitem-status.protected=false -admin-endpoints.deals-status.enabled=true -admin-endpoints.deals-status.on-application-port=true -admin-endpoints.deals-status.protected=false -deals.enabled=true -deals.planner.plan-endpoint=http://localhost:8090/planner-plan -deals.planner.register-endpoint=http://localhost:8090/planner-register -deals.planner.username=username -deals.planner.password=password -deals.planner.update-period=*/1 * * * * * -deals.delivery-stats.endpoint=http://localhost:8090/delivery-stats-progress -deals.delivery-stats.delivery-period=*/5 * * * * * -deals.delivery-stats.timeout-ms=1000 -deals.delivery-stats.username=username -deals.delivery-stats.password=password -deals.delivery-stats.reports-interval-ms=0 -deals.delivery-progress.report-reset-period=*/5 * * * * * -deals.user-data.user-details-endpoint=http://localhost:8090/user-data-details -deals.user-data.win-event-endpoint=http://localhost:8090/user-data-win-event -deals.user-data.timeout=1000 -deals.user-data.user-ids[0].type=khaos -deals.user-data.user-ids[0].source=uid -deals.user-data.user-ids[0].location=rubicon -deals.max-deals-per-bidder=3 -deals.alert-proxy.enabled=false -deals.alert-proxy.url=http://localhost -deals.alert-proxy.timeout-sec=5 -deals.alert-proxy.username=username -deals.alert-proxy.password=password -profile=test -infra=vm -data-center=aws -system=PBS -sub-system=Prebid Server diff --git a/src/test/resources/org/prebid/server/it/deals/test-deals-simulation-application.properties b/src/test/resources/org/prebid/server/it/deals/test-deals-simulation-application.properties deleted file mode 100644 index fe11da5609d..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-deals-simulation-application.properties +++ /dev/null @@ -1,3 +0,0 @@ -server.http.port=10080 -admin.port=10060 -deals.simulation.enabled=true diff --git a/src/test/resources/org/prebid/server/it/deals/test-delivery-stats-progress-request.json b/src/test/resources/org/prebid/server/it/deals/test-delivery-stats-progress-request.json deleted file mode 100644 index 1fd1cbf6c7a..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-delivery-stats-progress-request.json +++ /dev/null @@ -1,203 +0,0 @@ -{ - "instanceId": "localhost", - "vendor": "local", - "region": "local", - "clientAuctions": 1, - "lineItemStatus": [ - { - "lineItemSource": "generic", - "lineItemId": "lineItem4", - "dealId": "dealId4", - "extLineItemId": "extLineItem4", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 1, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 0, - "sentToBidderAsTopMatch": 0, - "receivedFromBidder": 0, - "receivedFromBidderInvalidated": 0, - "sentToClient": 0, - "sentToClientAsTopMatch": 0, - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "tokens": [ - { - "class": 1, - "total": 5000, - "spent": 0 - }, - { - "class": 2, - "total": 125, - "spent": 0 - } - ] - } - ] - }, - { - "lineItemSource": "generic", - "lineItemId": "lineItem1", - "dealId": "dealId1", - "extLineItemId": "extLineItem1", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 1, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 1, - "sentToClientAsTopMatch": 1, - "events": [ - { - "type": "win", - "count": 1 - } - ], - "deliverySchedule": [ - { - "planId": "1", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0, - "totalSpent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 1, - "totalSpent": 1 - } - ] - } - ] - }, - { - "lineItemSource": "generic", - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 1, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 1, - "sentToClientAsTopMatch": 1, - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0, - "totalSpent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 1, - "totalSpent": 1 - } - ] - } - ] - }, - { - "lineItemSource": "generic", - "lineItemId": "lineItem5", - "dealId": "dealId5", - "extLineItemId": "extLineItem5", - "domainMatched": 0, - "targetMatched": 0, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 0, - "sentToBidderAsTopMatch": 0, - "receivedFromBidder": 0, - "receivedFromBidderInvalidated": 0, - "sentToClient": 0, - "sentToClientAsTopMatch": 0, - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "tokens": [ - { - "class": 2, - "total": 125, - "spent": 0 - }, - { - "class": 1, - "total": 5000, - "spent": 0 - } - ] - } - ] - }, - { - "lineItemSource": "generic", - "lineItemId": "lineItem3", - "dealId": "dealId3", - "extLineItemId": "extLineItem3", - "accountAuctions": 1, - "domainMatched": 0, - "targetMatched": 1, - "targetMatchedButFcapped": 0, - "targetMatchedButFcapLookupFailed": 0, - "pacingDeferred": 0, - "sentToBidder": 1, - "sentToBidderAsTopMatch": 1, - "receivedFromBidder": 1, - "receivedFromBidderInvalidated": 0, - "sentToClient": 1, - "sentToClientAsTopMatch": 1, - "lostToLineItems": [ - { - "lineItemSource": "generic", - "lineItemId": "lineItem1", - "count": 1 - } - ], - "events": [], - "deliverySchedule": [ - { - "planId": "1", - "tokens": [ - { - "class": 1, - "total": 5000, - "spent": 1 - }, - { - "class": 2, - "total": 125, - "spent": 0 - } - ] - } - ] - } - ] -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-generic-bid-request.json b/src/test/resources/org/prebid/server/it/deals/test-generic-bid-request.json deleted file mode 100644 index feed83c02c2..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-generic-bid-request.json +++ /dev/null @@ -1,236 +0,0 @@ -{ - "id": "tid", - "imp": [ - { - "id": "impId1", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId1", - "ext": { - "line": { - "lineitemid": "lineItem1", - "extlineitemid": "extLineItem1", - "sizes": [ - { - "w": 300, - "h": 250 - } - ] - } - } - }, - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ] - } - } - } - ] - }, - "ext": { - "bidder": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - }, - "tid": "someTid" - } - }, - { - "id": "impId2", - "secure": 1, - "banner": { - "format": [ - { - "w": 320, - "h": 320 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId2", - "ext": { - "line": { - "lineitemid": "lineItem2", - "extlineitemid": "extLineItem2", - "sizes": [ - { - "w": 320, - "h": 320 - } - ] - } - } - } - ] - }, - "ext": { - "bidder": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - }, - "tid": "someTid" - } - }, - { - "id": "impId4", - "secure": 1, - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "pmp": { - "deals": [ - { - "id": "dealId3", - "ext": { - "line": { - "lineitemid": "lineItem3", - "extlineitemid": "extLineItem3", - "sizes": [ - { - "w": 300, - "h": 250 - } - ] - } - } - } - ] - }, - "ext": { - "bidder": { - "accountId": 2001, - "siteId": 3001, - "zoneId": 4001 - }, - "tid": "someTid" - } - } - ], - "cur": [ - "USD" - ], - "source": { - "tid": "someTid" - }, - "site": { - "domain": "www.example.com", - "ext": { - "amp": 0 - }, - "page": "http://www.example.com", - "publisher": { - "domain": "example.com", - "id": "2001" - } - }, - "user": { - "data": [ - { - "id": "generic", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "ext": { - "consent": "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA", - "fcapids": [ - "fcapId3" - ], - "time": { - "userdow": "${json-unit.any-number}", - "userhour": "${json-unit.any-number}" - } - } - }, - "device": { - "ua": "userAgent", - "ip": "185.199.110.0" - }, - "regs": { - "ext": { - "gdpr": 0 - } - }, - "at": 1, - "tmax": "${json-unit.any-number}", - "ext": { - "prebid": { - "debug": 1, - "trace": "verbose", - "targeting": { - "includebidderkeys": true, - "includewinners": true, - "pricegranularity": { - "precision": 2, - "ranges": [ - { - "increment": 0.1, - "max": 20 - } - ] - } - }, - "cache": { - "bids": {}, - "vastxml": { - "ttlseconds": 120 - } - }, - "auctiontimestamp": 1000, - "channel": { - "name": "web" - }, - "server": { - "datacenter": "local", - "endpoint": "/openrtb2/auction", - "externalurl": "http://localhost:8080", - "gvlid": 1 - } - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-generic-bid-response.json b/src/test/resources/org/prebid/server/it/deals/test-generic-bid-response.json deleted file mode 100644 index 95a6159efab..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-generic-bid-response.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "bidResponseId", - "seatbid": [ - { - "seat": "seatId1", - "bid": [ - { - "id": "bidId1", - "impid": "impId1", - "dealid": "dealId1", - "price": 8.43, - "adm": "", - "crid": "crid1", - "w": 300, - "h": 250 - }, - { - "id": "bidId2", - "impid": "impId2", - "dealid": "dealId2", - "price": 8.43, - "adm": "", - "crid": "crid2", - "w": 320, - "h": 320 - }, - { - "id": "bidId4", - "impid": "impId4", - "dealid": "dealId3", - "price": 8.43, - "adm": "", - "crid": "crid1", - "w": 300, - "h": 250 - } - ] - } - ] -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-planner-plan-response.json b/src/test/resources/org/prebid/server/it/deals/test-planner-plan-response.json deleted file mode 100644 index 462a5d6f1f2..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-planner-plan-response.json +++ /dev/null @@ -1,347 +0,0 @@ -[ - { - "lineItemId": "lineItem1", - "extLineItemId": "extLineItem1", - "dealId": "dealId1", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "generic", - "price": { - "cpm": 5.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem2", - "dealId": "dealId2", - "extLineItemId": "extLineItem2", - "status": "active", - "sizes": [ - { - "w": 320, - "h": 320 - } - ], - "accountId": "2001", - "source": "generic", - "price": { - "cpm": 5.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 320, - "h": 320 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId2", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem3", - "extLineItemId": "extLineItem3", - "dealId": "dealId3", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 250 - } - ], - "accountId": "2001", - "source": "generic", - "price": { - "cpm": 4.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 250 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem4", - "extLineItemId": "extLineItem4", - "dealId": "dealId4", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 600 - } - ], - "accountId": "2001", - "source": "generic", - "price": { - "cpm": 5.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 600 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId3", - "count": 10, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - }, - { - "lineItemId": "lineItem5", - "extLineItemId": "extLineItem5", - "dealId": "dealId5", - "status": "active", - "sizes": [ - { - "w": 300, - "h": 600 - } - ], - "accountId": "2002", - "source": "generic", - "price": { - "cpm": 5.60, - "currency": "USD" - }, - "relativePriority": 3, - "startTimeStamp": "{{ lineItem.startTime }}", - "endTimeStamp": "{{ lineItem.endTime }}", - "updatedTimeStamp": "{{ now }}", - "targeting": { - "$and": [ - { - "adunit.size": { - "$intersects": [ - { - "w": 300, - "h": 600 - } - ] - } - }, - { - "adunit.mediatype": { - "$intersects": [ - "banner" - ] - } - } - ] - }, - "frequencyCaps": [ - { - "fcapId": "fcapId5", - "count": 10, - "periods": 7, - "periodType": "day" - } - ], - "deliverySchedules": [ - { - "planId": "1", - "updatedTimeStamp": "{{ now }}", - "startTimeStamp": "{{ plan.startTime }}", - "endTimeStamp": "{{ plan.endTime }}", - "tokens": [ - { - "class": 1, - "total": 5000 - }, - { - "class": 2, - "total": 125 - } - ] - } - ] - } -] diff --git a/src/test/resources/org/prebid/server/it/deals/test-planner-register-request.json b/src/test/resources/org/prebid/server/it/deals/test-planner-register-request.json deleted file mode 100644 index ca88dd51e89..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-planner-register-request.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "healthIndex": 1, - "status": { - "dealsStatus": { - "instanceId": "localhost", - "vendor": "local", - "region": "local", - "clientAuctions": 0, - "lineItemStatus": [] - } - }, - "hostInstanceId": "localhost", - "region": "local", - "vendor": "local" -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/test-planner-register-response.json b/src/test/resources/org/prebid/server/it/deals/test-planner-register-response.json deleted file mode 100644 index 456c5fa32f7..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-planner-register-response.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "tracer": { - "cmd": "start", - "raw": "true", - "durationInSeconds": "300", - "filters": { - "accountId": "1001", - "bidderCode": "pgRubicon", - "lineItemId": "642534" - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-generic-response.json b/src/test/resources/org/prebid/server/it/deals/test-user-data-details-generic-response.json deleted file mode 100644 index ef7c135d760..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-generic-response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "user": { - "data": [ - { - "id": "1111", - "name": "generic", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "4444", - "name": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "ext": { - "fcapIds": [ - "fcapId3" - ] - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-request.json b/src/test/resources/org/prebid/server/it/deals/test-user-data-details-request.json deleted file mode 100644 index 57e3a12ceec..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-request.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "ids": [ - { - "type": "khaos", - "id": "J5VLCWQP-26-CWFT" - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-rubicon-response.json b/src/test/resources/org/prebid/server/it/deals/test-user-data-details-rubicon-response.json deleted file mode 100644 index 098785643ee..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-user-data-details-rubicon-response.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "user": { - "data": [ - { - "id": "1111", - "name": "rubicon", - "segment": [ - { - "id": "2222" - }, - { - "id": "3333" - } - ] - }, - { - "id": "4444", - "name": "bluekai", - "segment": [ - { - "id": "5555" - }, - { - "id": "6666" - } - ] - } - ], - "ext": { - "fcapIds": [ - "fcapId3" - ] - } - } -} diff --git a/src/test/resources/org/prebid/server/it/deals/test-user-data-win-event-request.json b/src/test/resources/org/prebid/server/it/deals/test-user-data-win-event-request.json deleted file mode 100644 index 71f6551cc46..00000000000 --- a/src/test/resources/org/prebid/server/it/deals/test-user-data-win-event-request.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "bidderCode": "generic", - "bidId": "bidId", - "lineItemId": "lineItem1", - "region" : "local", - "userIds": [ - { - "type": "khaos", - "id": "J5VLCWQP-26-CWFT" - } - ], - "frequencyCaps": [ - { - "fcapId": "fcapId1", - "count": 3, - "periods": 7, - "periodType": "day" - } - ] -} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 93200a51b51..29114f9d3fb 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -505,8 +505,6 @@ admin-endpoints.logging-changelevel.protected=false admin-endpoints.tracelog.enabled=true admin-endpoints.tracelog.protected=false admin-endpoints.e2eadmin.enabled=false -admin-endpoints.lineitem-status.enabled=false -admin-endpoints.deals-status.enabled=false status-response=ok analytics.log.enabled=true gdpr.host-vendor-id=1 From 538c3e5096009fe8258394efa7cc74d8694c5120 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko Date: Mon, 8 Apr 2024 10:17:49 -0400 Subject: [PATCH 06/58] Remove unused properties (#3110) --- src/main/resources/application.yaml | 37 ----------------------------- 1 file changed, 37 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index af936e77b8a..b31305ace9f 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -296,42 +296,5 @@ analytics: size-bytes: 2097152 count: 100 report-ttl-ms: 900000 - -device-info: - enabled: false -deals: - enabled: false - simulation: - enabled: false - ready-at-adjustment-ms: 0 - planner: - plan-advance-period: "0 */1 * * * *" - update-period: "0 */1 * * * *" - timeout-ms: 4000 - register-period-sec: 60 - delivery-stats: - delivery-period: "0 */1 * * * *" - cached-reports-number: 20 - line-item-status-ttl-sec: 3600 - line-items-per-report: 25 - reports-interval-ms: 0 - batches-interval-ms: 1000 - request-compression-enabled: true - delivery-progress: - line-item-status-ttl-sec: 3600 - cached-plans-number: 20 - report-reset-period: "0 */1 * * * *" - delivery-progress-report: - competitors-number: 10 - max-deals-per-bidder: 3 - alert-proxy: - enabled: false - url: http://localhost - timeout-sec: 5 - alert-types: - pbs-planner-client-error: 15 - pbs-planner-empty-response-error: 15 - pbs-register-client-error: 15 - pbs-delivery-stats-client-error: 15 price-floors: enabled: false From 4ab3caea2316a5ff04d0961be9a4e3c4896d517b Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Tue, 9 Apr 2024 01:56:22 +0300 Subject: [PATCH 07/58] Migrate PBS from using embedded Vert.x to verticles (#2306) * Started rewriting old usage of embedded vertx to verticles deployment style * Remove PG code. * Verticles: Make deployment synchronous (#2313) * Delete tests. * Simplified deployment * Simplified routing * Refactor `ContextRunner`. (#3037) * Verticles: Refactoring. (#3047) * Remove `LocalMessageCodec` --------- Co-authored-by: Danylo Co-authored-by: ddubyk Co-authored-by: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Co-authored-by: Oleksandr Zhevedenko --- .../pubstack/PubstackAnalyticsReporter.java | 4 +- .../pubstack/PubstackEventHandler.java | 4 +- .../requestfactory/Ortb2RequestFactory.java | 2 - .../server/bidder/BidderErrorNotifier.java | 4 +- .../server/bidder/HttpBidderRequester.java | 4 +- .../org/prebid/server/cache/CacheService.java | 4 +- .../currency/CurrencyConversionService.java | 4 +- .../server/floors/PriceFloorFetcher.java | 4 +- .../server/handler/BidderParamHandler.java | 13 +- .../server/handler/CookieSyncHandler.java | 13 +- .../handler/CustomizedAdminEndpoint.java | 79 --------- .../prebid/server/handler/GetuidsHandler.java | 13 +- .../handler/NotificationEventHandler.java | 13 +- .../prebid/server/handler/OptoutHandler.java | 14 +- .../prebid/server/handler/SetuidHandler.java | 11 +- .../prebid/server/handler/StatusHandler.java | 12 +- .../prebid/server/handler/VtrackHandler.java | 12 +- .../AccountCacheInvalidationHandler.java | 2 +- .../handler/admin/AdminResourceWrapper.java | 45 +++++ .../{ => admin}/CollectedMetricsHandler.java | 2 +- .../{ => admin}/CurrencyRatesHandler.java | 2 +- .../HttpInteractionLogHandler.java | 2 +- .../{ => admin}/LoggerControlKnobHandler.java | 2 +- .../SettingsCacheNotificationHandler.java | 2 +- .../handler/{ => admin}/TracerLogHandler.java | 2 +- .../handler/{ => admin}/VersionHandler.java | 2 +- .../handler/info/BidderDetailsHandler.java | 13 +- .../server/handler/info/BiddersHandler.java | 12 +- .../server/handler/openrtb2/AmpHandler.java | 11 +- .../handler/openrtb2/AuctionHandler.java | 11 +- .../server/handler/openrtb2/VideoHandler.java | 11 +- .../optout/GoogleRecaptchaVerifier.java | 4 +- .../gdpr/vendorlist/VendorListService.java | 4 +- .../settings/HttpApplicationSettings.java | 4 +- .../service/HttpPeriodicRefreshService.java | 4 +- .../config/AdminServerConfiguration.java | 61 ------- .../spring/config/AnalyticsConfiguration.java | 2 +- .../spring/config/AopConfiguration.java | 2 +- .../config/InitializationConfiguration.java | 4 +- .../config/PriceFloorsConfiguration.java | 2 +- .../config/PrivacyServiceConfiguration.java | 2 +- .../spring/config/ServiceConfiguration.java | 6 +- .../spring/config/SettingsConfiguration.java | 2 +- .../server/spring/config/VerticleStarter.java | 29 ++++ .../database/DatabaseConfiguration.java | 8 +- .../metrics/PrometheusConfiguration.java | 83 ++++----- .../model/ExternalConversionProperties.java | 2 +- .../server/HttpServerConfiguration.java | 63 ------- .../server/UnixSocketServerConfiguration.java | 63 ------- .../admin}/AdminEndpointsConfiguration.java | 157 +++++++++--------- .../server/admin/AdminResourcesBinder.java | 50 ++++++ .../server/admin/AdminServerAuthProvider.java | 39 +++++ .../admin/AdminServerConfiguration.java | 40 +++++ .../ApplicationServerConfiguration.java} | 102 +++++++----- .../prebid/server/vertx/ContextRunner.java | 78 +++------ .../{http => httpclient}/BasicHttpClient.java | 4 +- .../CircuitBreakerSecuredHttpClient.java | 4 +- .../{http => httpclient}/HttpClient.java | 4 +- .../model/HttpClientResponse.java | 2 +- .../vertx/verticles/VerticleDefinition.java | 22 +++ .../vertx/verticles/server/HttpEndpoint.java | 12 ++ .../verticles/server/ServerVerticle.java | 73 ++++++++ .../verticles/server/admin/AdminResource.java | 13 ++ .../application/ApplicationResource.java | 12 ++ .../PubstackAnalyticsReporterTest.java | 4 +- .../pubstack/PubstackEventHandlerTest.java | 4 +- .../CurrencyConversionServiceTest.java | 4 +- .../bidder/BidderErrorNotifierTest.java | 4 +- .../bidder/HttpBidderRequesterTest.java | 4 +- .../prebid/server/cache/CacheServiceTest.java | 4 +- .../server/floors/PriceFloorFetcherTest.java | 4 +- .../AccountCacheInvalidationHandlerTest.java | 1 + .../handler/CollectedMetricsHandlerTest.java | 1 + .../handler/CurrencyRatesHandlerTest.java | 1 + .../handler/CustomizedAdminEndpointTest.java | 118 ------------- .../HttpInteractionLogHandlerTest.java | 1 + .../handler/LoggerControlKnobHandlerTest.java | 1 + .../SettingsCacheNotificationHandlerTest.java | 1 + .../server/handler/TracerLogHandlerTest.java | 1 + .../server/handler/VersionHandlerTest.java | 1 + .../optout/GoogleRecaptchaVerifierTest.java | 4 +- .../vendorlist/VendorListServiceTest.java | 4 +- .../settings/HttpApplicationSettingsTest.java | 4 +- .../HttpPeriodicRefreshServiceTest.java | 4 +- .../BasicHttpClientTest.java | 2 +- .../CircuitBreakerSecuredHttpClientTest.java | 4 +- 86 files changed, 746 insertions(+), 716 deletions(-) delete mode 100644 src/main/java/org/prebid/server/handler/CustomizedAdminEndpoint.java rename src/main/java/org/prebid/server/handler/{ => admin}/AccountCacheInvalidationHandler.java (97%) create mode 100644 src/main/java/org/prebid/server/handler/admin/AdminResourceWrapper.java rename src/main/java/org/prebid/server/handler/{ => admin}/CollectedMetricsHandler.java (98%) rename src/main/java/org/prebid/server/handler/{ => admin}/CurrencyRatesHandler.java (98%) rename src/main/java/org/prebid/server/handler/{ => admin}/HttpInteractionLogHandler.java (99%) rename src/main/java/org/prebid/server/handler/{ => admin}/LoggerControlKnobHandler.java (98%) rename src/main/java/org/prebid/server/handler/{ => admin}/SettingsCacheNotificationHandler.java (98%) rename src/main/java/org/prebid/server/handler/{ => admin}/TracerLogHandler.java (98%) rename src/main/java/org/prebid/server/handler/{ => admin}/VersionHandler.java (98%) delete mode 100644 src/main/java/org/prebid/server/spring/config/AdminServerConfiguration.java create mode 100644 src/main/java/org/prebid/server/spring/config/VerticleStarter.java delete mode 100644 src/main/java/org/prebid/server/spring/config/server/HttpServerConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/server/UnixSocketServerConfiguration.java rename src/main/java/org/prebid/server/spring/config/{ => server/admin}/AdminEndpointsConfiguration.java (63%) create mode 100644 src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java create mode 100644 src/main/java/org/prebid/server/spring/config/server/admin/AdminServerAuthProvider.java create mode 100644 src/main/java/org/prebid/server/spring/config/server/admin/AdminServerConfiguration.java rename src/main/java/org/prebid/server/spring/config/{WebConfiguration.java => server/application/ApplicationServerConfiguration.java} (84%) rename src/main/java/org/prebid/server/vertx/{http => httpclient}/BasicHttpClient.java (97%) rename src/main/java/org/prebid/server/vertx/{http => httpclient}/CircuitBreakerSecuredHttpClient.java (98%) rename src/main/java/org/prebid/server/vertx/{http => httpclient}/HttpClient.java (94%) rename src/main/java/org/prebid/server/vertx/{http => httpclient}/model/HttpClientResponse.java (87%) create mode 100644 src/main/java/org/prebid/server/vertx/verticles/VerticleDefinition.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/HttpEndpoint.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/admin/AdminResource.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/application/ApplicationResource.java delete mode 100644 src/test/java/org/prebid/server/handler/CustomizedAdminEndpointTest.java rename src/test/java/org/prebid/server/vertx/{http => httpclient}/BasicHttpClientTest.java (99%) rename src/test/java/org/prebid/server/vertx/{http => httpclient}/CircuitBreakerSecuredHttpClientTest.java (98%) diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java index 47e5a506a5d..87e52034472 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java @@ -22,8 +22,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.Arrays; import java.util.Collections; diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java index 235677ad61e..0dd4eb229e9 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java @@ -13,8 +13,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 61fe2069a60..7d819f82618 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -233,7 +233,6 @@ public Future enrichBidRequestWithGeolocationData(AuctionContext auc .build(); return Future.succeededFuture(bidRequest.toBuilder().device(updatedDevice).build()); - } public Future enrichBidRequestWithAccountAndPrivacyData(AuctionContext auctionContext) { @@ -259,7 +258,6 @@ public Future enrichBidRequestWithAccountAndPrivacyData(AuctionConte .device(ObjectUtils.defaultIfNull(enrichedDevice, device)) .regs(ObjectUtils.defaultIfNull(enrichedRegs, regs)) .build()); - } private static Regs enrichRegs(Regs regs, PrivacyContext privacyContext, Account account) { diff --git a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java index 38fa9ec8ede..4fde2bbbcd5 100644 --- a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java +++ b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java @@ -7,8 +7,8 @@ import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java index 42976d52256..2514c6c86df 100644 --- a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java +++ b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java @@ -32,8 +32,8 @@ import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/src/main/java/org/prebid/server/cache/CacheService.java b/src/main/java/org/prebid/server/cache/CacheService.java index 9656dd38501..cb4c48a6c6c 100644 --- a/src/main/java/org/prebid/server/cache/CacheService.java +++ b/src/main/java/org/prebid/server/cache/CacheService.java @@ -43,8 +43,8 @@ import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ObjectUtil; import org.prebid.server.vast.VastModifier; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.net.MalformedURLException; import java.net.URL; diff --git a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java index 87f1916c640..9b6d81f77ee 100644 --- a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java +++ b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java @@ -17,8 +17,8 @@ import org.prebid.server.spring.config.model.ExternalConversionProperties; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.IOException; import java.math.BigDecimal; diff --git a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java index 3d88078c5a8..39f95f63860 100644 --- a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java +++ b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java @@ -31,8 +31,8 @@ import org.prebid.server.settings.model.AccountPriceFloorsFetchConfig; import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ObjectUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/handler/BidderParamHandler.java b/src/main/java/org/prebid/server/handler/BidderParamHandler.java index 26366130cd1..f27137a2e1e 100644 --- a/src/main/java/org/prebid/server/handler/BidderParamHandler.java +++ b/src/main/java/org/prebid/server/handler/BidderParamHandler.java @@ -1,14 +1,18 @@ package org.prebid.server.handler; -import io.vertx.core.Handler; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import org.prebid.server.model.Endpoint; import org.prebid.server.util.HttpUtil; import org.prebid.server.validation.BidderParamValidator; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; +import java.util.Collections; +import java.util.List; import java.util.Objects; -public class BidderParamHandler implements Handler { +public class BidderParamHandler implements ApplicationResource { private final BidderParamValidator bidderParamValidator; @@ -16,6 +20,11 @@ public BidderParamHandler(BidderParamValidator bidderParamValidator) { this.bidderParamValidator = Objects.requireNonNull(bidderParamValidator); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.bidder_params.value())); + } + @Override public void handle(RoutingContext routingContext) { HttpUtil.executeSafely(routingContext, Endpoint.bidder_params, diff --git a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java index c020ea5adde..343aa09fcef 100644 --- a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java +++ b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java @@ -3,8 +3,8 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; @@ -40,12 +40,16 @@ import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.model.Account; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.Optional; -public class CookieSyncHandler implements Handler { +public class CookieSyncHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(CookieSyncHandler.class); private static final ConditionalLogger BAD_REQUEST_LOGGER = new ConditionalLogger(logger); @@ -93,6 +97,11 @@ public CookieSyncHandler(long defaultTimeout, this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.POST, Endpoint.cookie_sync.value())); + } + @Override public void handle(RoutingContext routingContext) { metrics.updateCookieSyncRequestMetric(); diff --git a/src/main/java/org/prebid/server/handler/CustomizedAdminEndpoint.java b/src/main/java/org/prebid/server/handler/CustomizedAdminEndpoint.java deleted file mode 100644 index 4ac49624277..00000000000 --- a/src/main/java/org/prebid/server/handler/CustomizedAdminEndpoint.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.prebid.server.handler; - -import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.ext.auth.AuthProvider; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.handler.BasicAuthHandler; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; - -import java.util.Map; -import java.util.Objects; - -public class CustomizedAdminEndpoint { - - private final String path; - private final Handler handler; - private final boolean isOnApplicationPort; - private final boolean isProtected; - private Map credentials; - - public CustomizedAdminEndpoint(String path, Handler handler, boolean isOnApplicationPort, - boolean isProtected) { - this.path = Objects.requireNonNull(path); - this.handler = Objects.requireNonNull(handler); - this.isOnApplicationPort = isOnApplicationPort; - this.isProtected = isProtected; - } - - public CustomizedAdminEndpoint withCredentials(Map credentials) { - this.credentials = credentials; - return this; - } - - public boolean isOnApplicationPort() { - return isOnApplicationPort; - } - - public void router(Router router) { - if (isProtected) { - routeToHandlerWithCredentials(router); - } else { - routeToHandler(router); - } - } - - private void routeToHandlerWithCredentials(Router router) { - if (credentials == null) { - throw new IllegalArgumentException("Credentials for admin endpoint is empty."); - } - - final AuthProvider authProvider = createAuthProvider(credentials); - router.route(path).handler(BasicAuthHandler.create(authProvider)).handler(handler); - } - - private void routeToHandler(Router router) { - router.route(path).handler(handler); - } - - private AuthProvider createAuthProvider(Map credentials) { - return (authInfo, resultHandler) -> { - if (MapUtils.isEmpty(credentials)) { - resultHandler.handle(Future.failedFuture("Credentials not set in configuration.")); - return; - } - - final String requestUsername = authInfo.getString("username"); - final String requestPassword = StringUtils.chomp(authInfo.getString("password")); - - final String storedPassword = credentials.get(requestUsername); - if (StringUtils.isNotBlank(requestPassword) && Objects.equals(storedPassword, requestPassword)) { - resultHandler.handle(Future.succeededFuture()); - } else { - resultHandler.handle(Future.failedFuture("No such user, or password incorrect.")); - } - }; - } -} diff --git a/src/main/java/org/prebid/server/handler/GetuidsHandler.java b/src/main/java/org/prebid/server/handler/GetuidsHandler.java index deb3822e4a9..705c5f94e27 100644 --- a/src/main/java/org/prebid/server/handler/GetuidsHandler.java +++ b/src/main/java/org/prebid/server/handler/GetuidsHandler.java @@ -1,7 +1,7 @@ package org.prebid.server.handler; import com.fasterxml.jackson.annotation.JsonInclude; -import io.vertx.core.Handler; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import lombok.AllArgsConstructor; import lombok.Value; @@ -10,12 +10,16 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.model.Endpoint; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -public class GetuidsHandler implements Handler { +public class GetuidsHandler implements ApplicationResource { private final UidsCookieService uidsCookieService; private final JacksonMapper mapper; @@ -25,6 +29,11 @@ public GetuidsHandler(UidsCookieService uidsCookieService, JacksonMapper mapper) this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.getuids.value())); + } + @Override public void handle(RoutingContext routingContext) { final Map uids = uidsFrom(routingContext); diff --git a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java index ef26b9d09da..61c986c12cc 100644 --- a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java +++ b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java @@ -3,9 +3,9 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpHeaders; +import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; @@ -29,15 +29,19 @@ import org.prebid.server.settings.model.AccountEventsConfig; import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ResourceUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.io.IOException; +import java.util.Collections; +import java.util.List; import java.util.Objects; /** * Accepts notifications from browsers and mobile application for further processing by {@link AnalyticsReporter} * and responding with tracking pixel when requested. */ -public class NotificationEventHandler implements Handler { +public class NotificationEventHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(NotificationEventHandler.class); @@ -77,6 +81,11 @@ private static TrackingPixel createTrackingPixel() { return TrackingPixel.of(PNG_CONTENT_TYPE, bytes); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.event.value())); + } + @Override public void handle(RoutingContext routingContext) { try { diff --git a/src/main/java/org/prebid/server/handler/OptoutHandler.java b/src/main/java/org/prebid/server/handler/OptoutHandler.java index c4360fb003a..e8ee98b2683 100644 --- a/src/main/java/org/prebid/server/handler/OptoutHandler.java +++ b/src/main/java/org/prebid/server/handler/OptoutHandler.java @@ -2,8 +2,8 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; import io.vertx.core.http.Cookie; +import io.vertx.core.http.HttpMethod; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; @@ -14,12 +14,15 @@ import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.optout.model.RecaptchaResponse; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.net.MalformedURLException; import java.net.URL; +import java.util.List; import java.util.Objects; -public class OptoutHandler implements Handler { +public class OptoutHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(OptoutHandler.class); @@ -41,6 +44,13 @@ public OptoutHandler(GoogleRecaptchaVerifier googleRecaptchaVerifier, UidsCookie this.optinUrl = Objects.requireNonNull(optinUrl); } + @Override + public List endpoints() { + return List.of( + HttpEndpoint.of(HttpMethod.GET, Endpoint.optout.value()), + HttpEndpoint.of(HttpMethod.POST, Endpoint.optout.value())); + } + @Override public void handle(RoutingContext routingContext) { final String recaptcha = getRequestParam(routingContext, RECAPTCHA_PARAM); diff --git a/src/main/java/org/prebid/server/handler/SetuidHandler.java b/src/main/java/org/prebid/server/handler/SetuidHandler.java index 55edbb5bc17..3f119079d83 100644 --- a/src/main/java/org/prebid/server/handler/SetuidHandler.java +++ b/src/main/java/org/prebid/server/handler/SetuidHandler.java @@ -3,9 +3,9 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpHeaders; +import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerRequest; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.logging.Logger; @@ -51,6 +51,8 @@ import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.model.Account; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.util.Collections; import java.util.List; @@ -63,7 +65,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class SetuidHandler implements Handler { +public class SetuidHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(SetuidHandler.class); @@ -126,6 +128,11 @@ private static Map collectMap(BidderCatalog bidderCa .collect(Collectors.toMap(Usersyncer::getCookieFamilyName, SetuidHandler::preferredUserSyncType)); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.setuid.value())); + } + private static UsersyncMethodType preferredUserSyncType(Usersyncer usersyncer) { return Stream.of(usersyncer.getIframe(), usersyncer.getRedirect()) .filter(Objects::nonNull) diff --git a/src/main/java/org/prebid/server/handler/StatusHandler.java b/src/main/java/org/prebid/server/handler/StatusHandler.java index f356971d598..ac4a9983fe7 100644 --- a/src/main/java/org/prebid/server/handler/StatusHandler.java +++ b/src/main/java/org/prebid/server/handler/StatusHandler.java @@ -2,7 +2,7 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.health.HealthChecker; @@ -10,13 +10,16 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.model.Endpoint; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.TreeMap; import java.util.stream.Collectors; -public class StatusHandler implements Handler { +public class StatusHandler implements ApplicationResource { private final List healthCheckers; private final JacksonMapper mapper; @@ -26,6 +29,11 @@ public StatusHandler(List healthCheckers, JacksonMapper mapper) { this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.status.value())); + } + @Override public void handle(RoutingContext routingContext) { if (CollectionUtils.isEmpty(healthCheckers)) { diff --git a/src/main/java/org/prebid/server/handler/VtrackHandler.java b/src/main/java/org/prebid/server/handler/VtrackHandler.java index d433867b01e..3a50ee05cfd 100644 --- a/src/main/java/org/prebid/server/handler/VtrackHandler.java +++ b/src/main/java/org/prebid/server/handler/VtrackHandler.java @@ -5,8 +5,8 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; @@ -30,13 +30,16 @@ import org.prebid.server.settings.model.AccountAuctionConfig; import org.prebid.server.settings.model.AccountEventsConfig; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; -public class VtrackHandler implements Handler { +public class VtrackHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(VtrackHandler.class); @@ -72,6 +75,11 @@ public VtrackHandler(long defaultTimeout, this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.POST, Endpoint.vtrack.value())); + } + @Override public void handle(RoutingContext routingContext) { final String accountId; diff --git a/src/main/java/org/prebid/server/handler/AccountCacheInvalidationHandler.java b/src/main/java/org/prebid/server/handler/admin/AccountCacheInvalidationHandler.java similarity index 97% rename from src/main/java/org/prebid/server/handler/AccountCacheInvalidationHandler.java rename to src/main/java/org/prebid/server/handler/admin/AccountCacheInvalidationHandler.java index 8ad70ec3bd0..afe07e9aa67 100644 --- a/src/main/java/org/prebid/server/handler/AccountCacheInvalidationHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/AccountCacheInvalidationHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; diff --git a/src/main/java/org/prebid/server/handler/admin/AdminResourceWrapper.java b/src/main/java/org/prebid/server/handler/admin/AdminResourceWrapper.java new file mode 100644 index 00000000000..e75920659d6 --- /dev/null +++ b/src/main/java/org/prebid/server/handler/admin/AdminResourceWrapper.java @@ -0,0 +1,45 @@ +package org.prebid.server.handler.admin; + +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; +import org.prebid.server.vertx.verticles.server.admin.AdminResource; + +import java.util.Objects; + +public class AdminResourceWrapper implements AdminResource { + + private final String path; + private final Handler handler; + private final boolean isOnApplicationPort; + private final boolean isSecured; + + public AdminResourceWrapper(String path, + boolean isOnApplicationPort, + boolean isProtected, + Handler handler) { + + this.path = Objects.requireNonNull(path); + this.isOnApplicationPort = isOnApplicationPort; + this.isSecured = isProtected; + this.handler = Objects.requireNonNull(handler); + } + + @Override + public String path() { + return path; + } + + public boolean isOnApplicationPort() { + return isOnApplicationPort; + } + + @Override + public boolean isSecured() { + return isSecured; + } + + @Override + public void handle(RoutingContext routingContext) { + handler.handle(routingContext); + } +} diff --git a/src/main/java/org/prebid/server/handler/CollectedMetricsHandler.java b/src/main/java/org/prebid/server/handler/admin/CollectedMetricsHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/CollectedMetricsHandler.java rename to src/main/java/org/prebid/server/handler/admin/CollectedMetricsHandler.java index 0a789d87d92..c9db54e21fa 100644 --- a/src/main/java/org/prebid/server/handler/CollectedMetricsHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/CollectedMetricsHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import com.codahale.metrics.Counter; import com.codahale.metrics.Gauge; diff --git a/src/main/java/org/prebid/server/handler/CurrencyRatesHandler.java b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/CurrencyRatesHandler.java rename to src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java index fa7d54cafd4..f9b52a807e4 100644 --- a/src/main/java/org/prebid/server/handler/CurrencyRatesHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import com.fasterxml.jackson.annotation.JsonProperty; import io.netty.handler.codec.http.HttpHeaderValues; diff --git a/src/main/java/org/prebid/server/handler/HttpInteractionLogHandler.java b/src/main/java/org/prebid/server/handler/admin/HttpInteractionLogHandler.java similarity index 99% rename from src/main/java/org/prebid/server/handler/HttpInteractionLogHandler.java rename to src/main/java/org/prebid/server/handler/admin/HttpInteractionLogHandler.java index a6c17f0c4cd..b3573a5c4c5 100644 --- a/src/main/java/org/prebid/server/handler/HttpInteractionLogHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/HttpInteractionLogHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; diff --git a/src/main/java/org/prebid/server/handler/LoggerControlKnobHandler.java b/src/main/java/org/prebid/server/handler/admin/LoggerControlKnobHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/LoggerControlKnobHandler.java rename to src/main/java/org/prebid/server/handler/admin/LoggerControlKnobHandler.java index 61b6e305718..7875c7a52dd 100644 --- a/src/main/java/org/prebid/server/handler/LoggerControlKnobHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/LoggerControlKnobHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; diff --git a/src/main/java/org/prebid/server/handler/SettingsCacheNotificationHandler.java b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/SettingsCacheNotificationHandler.java rename to src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java index 08aec26922b..42eb8368bd3 100644 --- a/src/main/java/org/prebid/server/handler/SettingsCacheNotificationHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; diff --git a/src/main/java/org/prebid/server/handler/TracerLogHandler.java b/src/main/java/org/prebid/server/handler/admin/TracerLogHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/TracerLogHandler.java rename to src/main/java/org/prebid/server/handler/admin/TracerLogHandler.java index 53064a59264..d2414012b60 100644 --- a/src/main/java/org/prebid/server/handler/TracerLogHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/TracerLogHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; diff --git a/src/main/java/org/prebid/server/handler/VersionHandler.java b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java similarity index 98% rename from src/main/java/org/prebid/server/handler/VersionHandler.java rename to src/main/java/org/prebid/server/handler/admin/VersionHandler.java index eeeecae349a..adf8088e423 100644 --- a/src/main/java/org/prebid/server/handler/VersionHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java @@ -1,4 +1,4 @@ -package org.prebid.server.handler; +package org.prebid.server.handler.admin; import com.fasterxml.jackson.core.JsonProcessingException; import io.netty.handler.codec.http.HttpResponseStatus; diff --git a/src/main/java/org/prebid/server/handler/info/BidderDetailsHandler.java b/src/main/java/org/prebid/server/handler/info/BidderDetailsHandler.java index 4a35cd8a9fc..007dd187db3 100644 --- a/src/main/java/org/prebid/server/handler/info/BidderDetailsHandler.java +++ b/src/main/java/org/prebid/server/handler/info/BidderDetailsHandler.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import lombok.Value; import org.apache.commons.collections4.map.CaseInsensitiveMap; @@ -13,8 +13,11 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.model.Endpoint; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.TreeMap; @@ -22,7 +25,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class BidderDetailsHandler implements Handler { +public class BidderDetailsHandler implements ApplicationResource { private static final String BIDDER_NAME_PARAM = "bidderName"; private static final String ALL_PARAM_VALUE = "all"; @@ -67,6 +70,12 @@ private ObjectNode allInfos(Map nameToInfo) { return mapper.mapper().valueToTree(new TreeMap<>(nameToInfo)); } + @Override + public List endpoints() { + return Collections.singletonList( + HttpEndpoint.of(HttpMethod.GET, "%s/:%s".formatted(Endpoint.info_bidders.value(), BIDDER_NAME_PARAM))); + } + @Override public void handle(RoutingContext routingContext) { final String bidderName = routingContext.request().getParam(BIDDER_NAME_PARAM); diff --git a/src/main/java/org/prebid/server/handler/info/BiddersHandler.java b/src/main/java/org/prebid/server/handler/info/BiddersHandler.java index a212f2b8c04..ff186e5d63c 100644 --- a/src/main/java/org/prebid/server/handler/info/BiddersHandler.java +++ b/src/main/java/org/prebid/server/handler/info/BiddersHandler.java @@ -2,14 +2,17 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; -import io.vertx.core.Handler; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.handler.info.filters.BidderInfoFilterStrategy; import org.prebid.server.json.JacksonMapper; import org.prebid.server.model.Endpoint; import org.prebid.server.util.HttpUtil; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; @@ -17,7 +20,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -public class BiddersHandler implements Handler { +public class BiddersHandler implements ApplicationResource { private final BidderCatalog bidderCatalog; private final List filterStrategies; @@ -32,6 +35,11 @@ public BiddersHandler(BidderCatalog bidderCatalog, this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.info_bidders.value())); + } + @Override public void handle(RoutingContext routingContext) { try { diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index 55f61a554f7..e50e6018293 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -12,8 +12,8 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.MultiMap; +import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; @@ -56,6 +56,8 @@ import org.prebid.server.proto.response.ExtAmpVideoResponse; import org.prebid.server.util.HttpUtil; import org.prebid.server.version.PrebidVersionProvider; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.time.Clock; import java.util.Collections; @@ -67,7 +69,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -public class AmpHandler implements Handler { +public class AmpHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(AmpHandler.class); private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger); @@ -115,6 +117,11 @@ public AmpHandler(AmpRequestFactory ampRequestFactory, this.logSamplingRate = logSamplingRate; } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.openrtb2_amp.value())); + } + @Override public void handle(RoutingContext routingContext) { // Prebid Server interprets request.tmax to be the maximum amount of time that a caller is willing to wait diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index a7c036a1f4c..c5a463dce95 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -5,8 +5,8 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; import io.vertx.core.MultiMap; +import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; @@ -33,6 +33,8 @@ import org.prebid.server.privacy.model.PrivacyContext; import org.prebid.server.util.HttpUtil; import org.prebid.server.version.PrebidVersionProvider; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.time.Clock; import java.util.Collections; @@ -40,7 +42,7 @@ import java.util.Objects; import java.util.function.Consumer; -public class AuctionHandler implements Handler { +public class AuctionHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(AuctionHandler.class); private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger); @@ -76,6 +78,11 @@ public AuctionHandler(double logSamplingRate, this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.POST, Endpoint.openrtb2_auction.value())); + } + @Override public void handle(RoutingContext routingContext) { // Prebid Server interprets request.tmax to be the maximum amount of time that a caller is willing to wait diff --git a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java index a68eb39eb45..76831745c47 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java @@ -3,8 +3,8 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; import io.vertx.core.MultiMap; +import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; @@ -33,6 +33,8 @@ import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ObjectUtil; import org.prebid.server.version.PrebidVersionProvider; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import java.time.Clock; import java.util.ArrayList; @@ -42,7 +44,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -public class VideoHandler implements Handler { +public class VideoHandler implements ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(VideoHandler.class); @@ -78,6 +80,11 @@ public VideoHandler(VideoRequestFactory videoRequestFactory, this.mapper = Objects.requireNonNull(mapper); } + @Override + public List endpoints() { + return Collections.singletonList(HttpEndpoint.of(HttpMethod.POST, Endpoint.openrtb2_video.value())); + } + @Override public void handle(RoutingContext routingContext) { // Prebid Server interprets request.tmax to be the maximum amount of time that a caller is willing to wait diff --git a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java index dcff4bade72..a37533586e7 100644 --- a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java +++ b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java @@ -10,8 +10,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.optout.model.RecaptchaResponse; import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java index 019da5e36b4..7aa8583b131 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java @@ -22,8 +22,8 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.vendorlist.proto.Vendor; import org.prebid.server.privacy.gdpr.vendorlist.proto.VendorList; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.File; import java.io.IOException; diff --git a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java index 262cceda164..72daa7e938d 100644 --- a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java @@ -22,8 +22,8 @@ import org.prebid.server.settings.proto.response.HttpAccountsResponse; import org.prebid.server.settings.proto.response.HttpFetcherResponse; import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/org/prebid/server/settings/service/HttpPeriodicRefreshService.java b/src/main/java/org/prebid/server/settings/service/HttpPeriodicRefreshService.java index ef53df54ec2..b50d2512953 100644 --- a/src/main/java/org/prebid/server/settings/service/HttpPeriodicRefreshService.java +++ b/src/main/java/org/prebid/server/settings/service/HttpPeriodicRefreshService.java @@ -15,8 +15,8 @@ import org.prebid.server.settings.proto.response.HttpRefreshResponse; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.time.Instant; import java.util.ArrayList; diff --git a/src/main/java/org/prebid/server/spring/config/AdminServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/AdminServerConfiguration.java deleted file mode 100644 index 4cc83bdfc5d..00000000000 --- a/src/main/java/org/prebid/server/spring/config/AdminServerConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.prebid.server.spring.config; - -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.handler.BodyHandler; -import org.prebid.server.handler.CustomizedAdminEndpoint; -import org.prebid.server.vertx.ContextRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import javax.annotation.PostConstruct; -import java.util.List; - -@Configuration -@ConditionalOnProperty(prefix = "admin", name = "port") -public class AdminServerConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(AdminServerConfiguration.class); - - @Autowired - private ContextRunner contextRunner; - - @Autowired - private Vertx vertx; - - @Autowired - @Qualifier("adminRouter") - private Router adminRouter; - - @Value("${admin.port}") - private int adminPort; - - @Bean(name = "adminRouter") - Router adminRouter(BodyHandler bodyHandler, List customizedAdminEndpoints) { - final Router router = Router.router(vertx); - router.route().handler(bodyHandler); - - customizedAdminEndpoints.stream() - .filter(customizedAdminEndpoint -> !customizedAdminEndpoint.isOnApplicationPort()) - .forEach(customizedAdminEndpoint -> customizedAdminEndpoint.router(router)); - - return router; - } - - @PostConstruct - public void startAdminServer() { - logger.info("Starting Admin Server to serve requests on port {0,number,#}", adminPort); - - contextRunner.runOnServiceContext(future -> - vertx.createHttpServer().requestHandler(adminRouter).listen(adminPort, future)); - - logger.info("Successfully started Admin Server"); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java index 46b98597121..21ee67ac125 100644 --- a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java @@ -13,7 +13,7 @@ import org.prebid.server.auction.privacy.enforcement.mask.UserFpdActivityMask; import org.prebid.server.json.JacksonMapper; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; diff --git a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java b/src/main/java/org/prebid/server/spring/config/AopConfiguration.java index cdad8883732..736ca55a494 100644 --- a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AopConfiguration.java @@ -25,7 +25,7 @@ static class HealthMonitorAspect { @Autowired HealthMonitor healthMonitor; - @Around(value = "execution(* org.prebid.server.vertx.http.HttpClient.*(..)) " + @Around(value = "execution(* org.prebid.server.vertx.httpclient.HttpClient.*(..)) " + "|| execution(* org.prebid.server.settings.ApplicationSettings.*(..)) " + "|| execution(* org.prebid.server.geolocation.GeoLocationService.*(..))") public Future around(ProceedingJoinPoint joinPoint) { diff --git a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java index a0b0498e16b..d52de58ac63 100644 --- a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java @@ -3,7 +3,7 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.ContextRunner; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.context.event.ContextRefreshedEvent; @@ -35,7 +35,7 @@ public class InitializationConfiguration { @EventListener(ContextRefreshedEvent.class) public void initializeServices() { - contextRunner.runOnServiceContext(promise -> { + contextRunner.runBlocking(promise -> { initializables.forEach(Initializable::initialize); promise.complete(); }); diff --git a/src/main/java/org/prebid/server/spring/config/PriceFloorsConfiguration.java b/src/main/java/org/prebid/server/spring/config/PriceFloorsConfiguration.java index 67b4ce379ea..09be2779e22 100644 --- a/src/main/java/org/prebid/server/spring/config/PriceFloorsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PriceFloorsConfiguration.java @@ -18,7 +18,7 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.ApplicationSettings; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index 61df84ee7bf..db8251b9b42 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -45,7 +45,7 @@ import org.prebid.server.settings.model.SpecialFeature; import org.prebid.server.settings.model.SpecialFeatures; import org.prebid.server.spring.config.retry.RetryPolicyConfigurationProperties; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index 1180f622661..de4e7fddff6 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -114,9 +114,9 @@ import org.prebid.server.validation.VideoRequestValidator; import org.prebid.server.vast.VastModifier; import org.prebid.server.version.PrebidVersionProvider; -import org.prebid.server.vertx.http.BasicHttpClient; -import org.prebid.server.vertx.http.CircuitBreakerSecuredHttpClient; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.BasicHttpClient; +import org.prebid.server.vertx.httpclient.CircuitBreakerSecuredHttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 4a3ce154ab4..374edb1d2be 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -24,7 +24,7 @@ import org.prebid.server.settings.service.HttpPeriodicRefreshService; import org.prebid.server.settings.service.JdbcPeriodicRefreshService; import org.prebid.server.spring.config.database.DatabaseConfiguration; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.prebid.server.vertx.jdbc.JdbcClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; diff --git a/src/main/java/org/prebid/server/spring/config/VerticleStarter.java b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java new file mode 100644 index 00000000000..49bdae234ae --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java @@ -0,0 +1,29 @@ +package org.prebid.server.spring.config; + +import io.vertx.core.DeploymentOptions; +import io.vertx.core.Vertx; +import org.prebid.server.vertx.ContextRunner; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Configuration +public class VerticleStarter { + + @Autowired + public void start(Vertx vertx, ContextRunner contextRunner, List definitions) { + for (VerticleDefinition definition : definitions) { + if (definition.getAmount() <= 0) { + continue; + } + + contextRunner.runBlocking(promise -> + vertx.deployVerticle( + definition.getFactory(), + new DeploymentOptions().setInstances(definition.getAmount()), + promise)); + } + } +} diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index 69570b59622..065241e7aab 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -118,7 +118,11 @@ CircuitBreakerProperties databaseCircuitBreakerProperties() { @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "true") CircuitBreakerSecuredJdbcClient circuitBreakerSecuredJdbcClient( - Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner, + Vertx vertx, + JDBCClient vertxJdbcClient, + Metrics metrics, + Clock clock, + ContextRunner contextRunner, @Qualifier("databaseCircuitBreakerProperties") CircuitBreakerProperties circuitBreakerProperties) { final JdbcClient jdbcClient = createBasicJdbcClient(vertx, vertxJdbcClient, metrics, clock, contextRunner); @@ -131,7 +135,7 @@ private static BasicJdbcClient createBasicJdbcClient( Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); - contextRunner.runOnServiceContext(promise -> basicJdbcClient.initialize().onComplete(promise)); + contextRunner.runBlocking(promise -> basicJdbcClient.initialize().onComplete(promise)); return basicJdbcClient; } diff --git a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java index 77e0b942817..72a15515864 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java @@ -7,18 +7,17 @@ import io.prometheus.client.dropwizard.samplebuilder.SampleBuilder; import io.prometheus.client.vertx.MetricsHandler; import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; +import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import lombok.Data; import lombok.NoArgsConstructor; import org.prebid.server.metric.CounterType; import org.prebid.server.metric.Metrics; import org.prebid.server.metric.prometheus.NamespaceSubsystemSampleBuilder; -import org.prebid.server.vertx.ContextRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.prebid.server.vertx.verticles.server.ServerVerticle; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -26,15 +25,32 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; import javax.validation.constraints.NotNull; import java.util.List; @Configuration +@ConditionalOnProperty(prefix = "metrics.prometheus", name = "enabled", havingValue = "true") public class PrometheusConfiguration { + private static final Logger logger = LoggerFactory.getLogger(PrometheusConfiguration.class); + + // TODO: Decide how to integrate this with ability to serve requests on unix domain socket + @Bean + public VerticleDefinition prometheusHttpServerVerticleDefinition( + PrometheusConfigurationProperties prometheusConfigurationProperties, + Router prometheusRouter, + DropwizardExports dropwizardExports) { + + CollectorRegistry.defaultRegistry.register(dropwizardExports); + + return VerticleDefinition.ofSingleInstance( + () -> new ServerVerticle( + "Prometheus Http Server", + SocketAddress.inetSocketAddress(prometheusConfigurationProperties.getPort(), "0.0.0.0"), + prometheusRouter)); + } + @Bean - @ConditionalOnBean(PrometheusConfigurationProperties.class) public SampleBuilder sampleBuilder(PrometheusConfigurationProperties prometheusConfigurationProperties, List mapperConfigs) { @@ -44,51 +60,20 @@ public SampleBuilder sampleBuilder(PrometheusConfigurationProperties prometheusC mapperConfigs); } - @Configuration - @ConditionalOnBean(PrometheusConfigurationProperties.class) - public static class PrometheusServerConfiguration { - private static final Logger logger = LoggerFactory.getLogger(PrometheusServerConfiguration.class); - - @Autowired - private ContextRunner contextRunner; - - @Autowired - private Vertx vertx; - - @Autowired - private MetricRegistry metricRegistry; - - @Autowired - private Metrics metrics; - - @Autowired - private PrometheusConfigurationProperties prometheusConfigurationProperties; - - @Autowired - private SampleBuilder sampleBuilder; - - @PostConstruct - public void startPrometheusServer() { - logger.info( - "Starting Prometheus Server on port {0,number,#}", - prometheusConfigurationProperties.getPort()); - - if (metrics.getCounterType() == CounterType.flushingCounter) { - logger.warn("Prometheus metric system: Metric type is flushingCounter."); - } - - final Router router = Router.router(vertx); - router.route("/metrics").handler(new MetricsHandler()); - - CollectorRegistry.defaultRegistry.register(new DropwizardExports(metricRegistry, sampleBuilder)); + @Bean + DropwizardExports dropwizardExports(Metrics metrics, MetricRegistry metricRegistry, SampleBuilder sampleBuilder) { + if (metrics.getCounterType() == CounterType.flushingCounter) { + logger.warn("Prometheus metric system: Metric type is flushingCounter."); + } - contextRunner.runOnServiceContext(promise -> - vertx.createHttpServer() - .requestHandler(router) - .listen(prometheusConfigurationProperties.getPort(), promise)); + return new DropwizardExports(metricRegistry, sampleBuilder); + } - logger.info("Successfully started Prometheus Server"); - } + @Bean + Router prometheusRouter(Vertx vertx) { + final Router router = Router.router(vertx); + router.route("/metrics").handler(new MetricsHandler()); + return router; } @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java index b0206149f0d..914e1bcfc18 100644 --- a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java @@ -5,7 +5,7 @@ import lombok.Data; import org.prebid.server.json.JacksonMapper; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; +import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.Min; diff --git a/src/main/java/org/prebid/server/spring/config/server/HttpServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/HttpServerConfiguration.java deleted file mode 100644 index c14dcf9c408..00000000000 --- a/src/main/java/org/prebid/server/spring/config/server/HttpServerConfiguration.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.prebid.server.spring.config.server; - -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.http.HttpServerOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.ext.web.Router; -import org.prebid.server.handler.ExceptionHandler; -import org.prebid.server.vertx.ContextRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Configuration; - -import javax.annotation.PostConstruct; - -@Configuration -@ConditionalOnProperty(name = "server.http.enabled", havingValue = "true") -public class HttpServerConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(HttpServerConfiguration.class); - - @Autowired - private ContextRunner contextRunner; - - @Autowired - private Vertx vertx; - - @Autowired - private HttpServerOptions httpServerOptions; - - @Autowired - private ExceptionHandler exceptionHandler; - - @Autowired - @Qualifier("router") - private Router router; - - @Value("#{'${http.port:${server.http.port}}'}") - private Integer httpPort; - - // TODO: remove support for properties with http prefix after transition period - @Value("#{'${vertx.http-server-instances:${server.http.server-instances}}'}") - private Integer httpServerNum; - - @PostConstruct - public void startHttpServer() { - logger.info( - "Starting {0} instances of Http Server to serve requests on port {1,number,#}", - httpServerNum, - httpPort); - - contextRunner.runOnNewContext(httpServerNum, promise -> - vertx.createHttpServer(httpServerOptions) - .exceptionHandler(exceptionHandler) - .requestHandler(router) - .listen(httpPort, promise)); - - logger.info("Successfully started {0} instances of Http Server", httpServerNum); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/server/UnixSocketServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/UnixSocketServerConfiguration.java deleted file mode 100644 index 54ae616f496..00000000000 --- a/src/main/java/org/prebid/server/spring/config/server/UnixSocketServerConfiguration.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.prebid.server.spring.config.server; - -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.http.HttpServerOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.core.net.SocketAddress; -import io.vertx.ext.web.Router; -import org.prebid.server.handler.ExceptionHandler; -import org.prebid.server.vertx.ContextRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Configuration; - -import javax.annotation.PostConstruct; - -@Configuration -@ConditionalOnProperty(name = "server.unix-socket.enabled", havingValue = "true") -public class UnixSocketServerConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(UnixSocketServerConfiguration.class); - - @Autowired - private ContextRunner contextRunner; - - @Autowired - private Vertx vertx; - - @Autowired - private HttpServerOptions httpServerOptions; - - @Autowired - private ExceptionHandler exceptionHandler; - - @Autowired - @Qualifier("router") - private Router router; - - @Value("${server.unix-socket.path}") - private String socketPath; - - @Value("${server.unix-socket.server-instances}") - private Integer serverNum; - - @PostConstruct - public void startUnixSocketServer() { - logger.info( - "Starting {0} instances of Unix Socket Server to serve requests on socket {1}", - serverNum, - socketPath); - - contextRunner.runOnNewContext(serverNum, promise -> - vertx.createHttpServer(httpServerOptions) - .exceptionHandler(exceptionHandler) - .requestHandler(router) - .listen(SocketAddress.domainSocketAddress(socketPath), promise)); - - logger.info("Successfully started {0} instances of Unix Socket Server", serverNum); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminEndpointsConfiguration.java similarity index 63% rename from src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java rename to src/main/java/org/prebid/server/spring/config/server/admin/AdminEndpointsConfiguration.java index 93c8b1f61b4..31f50e8db6d 100644 --- a/src/main/java/org/prebid/server/spring/config/AdminEndpointsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminEndpointsConfiguration.java @@ -1,19 +1,19 @@ -package org.prebid.server.spring.config; +package org.prebid.server.spring.config.server.admin; import com.codahale.metrics.MetricRegistry; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.currency.CurrencyConversionService; -import org.prebid.server.handler.AccountCacheInvalidationHandler; -import org.prebid.server.handler.CollectedMetricsHandler; -import org.prebid.server.handler.CurrencyRatesHandler; -import org.prebid.server.handler.CustomizedAdminEndpoint; -import org.prebid.server.handler.HttpInteractionLogHandler; -import org.prebid.server.handler.LoggerControlKnobHandler; -import org.prebid.server.handler.SettingsCacheNotificationHandler; -import org.prebid.server.handler.TracerLogHandler; -import org.prebid.server.handler.VersionHandler; +import org.prebid.server.handler.admin.AccountCacheInvalidationHandler; +import org.prebid.server.handler.admin.AdminResourceWrapper; +import org.prebid.server.handler.admin.CollectedMetricsHandler; +import org.prebid.server.handler.admin.CurrencyRatesHandler; +import org.prebid.server.handler.admin.HttpInteractionLogHandler; +import org.prebid.server.handler.admin.LoggerControlKnobHandler; +import org.prebid.server.handler.admin.SettingsCacheNotificationHandler; +import org.prebid.server.handler.admin.TracerLogHandler; +import org.prebid.server.handler.admin.VersionHandler; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.CriteriaManager; import org.prebid.server.log.HttpInteractionLogger; @@ -21,6 +21,7 @@ import org.prebid.server.settings.CachingApplicationSettings; import org.prebid.server.settings.SettingsCache; import org.prebid.server.util.VersionInfo; +import org.prebid.server.vertx.verticles.server.admin.AdminResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; @@ -31,180 +32,180 @@ import org.springframework.stereotype.Component; import java.util.Collections; +import java.util.List; import java.util.Map; +import java.util.function.Predicate; @Configuration public class AdminEndpointsConfiguration { @Bean @ConditionalOnExpression("${admin-endpoints.version.enabled} == true") - CustomizedAdminEndpoint versionEndpoint( + AdminResource versionEndpoint( VersionInfo versionInfo, JacksonMapper mapper, @Value("${admin-endpoints.version.path}") String path, @Value("${admin-endpoints.version.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.version.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.version.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new VersionHandler(versionInfo.getVersion(), versionInfo.getCommitHash(), mapper, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new VersionHandler(versionInfo.getVersion(), versionInfo.getCommitHash(), mapper, path)); } @Bean @ConditionalOnExpression("${currency-converter.external-rates.enabled} == true" + " and ${admin-endpoints.currency-rates.enabled} == true") - CustomizedAdminEndpoint currencyConversionRatesEndpoint( + AdminResource currencyConversionRatesEndpoint( CurrencyConversionService currencyConversionRates, JacksonMapper mapper, @Value("${admin-endpoints.currency-rates.path}") String path, @Value("${admin-endpoints.currency-rates.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.currency-rates.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.currency-rates.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new CurrencyRatesHandler(currencyConversionRates, path, mapper), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new CurrencyRatesHandler(currencyConversionRates, path, mapper)); } @Bean @ConditionalOnExpression("${settings.in-memory-cache.notification-endpoints-enabled:false}" + " and ${admin-endpoints.storedrequest.enabled} == true") - CustomizedAdminEndpoint cacheNotificationEndpoint( + AdminResource cacheNotificationEndpoint( SettingsCache settingsCache, JacksonMapper mapper, @Value("${admin-endpoints.storedrequest.path}") String path, @Value("${admin-endpoints.storedrequest.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.storedrequest.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.storedrequest.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new SettingsCacheNotificationHandler(settingsCache, mapper, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new SettingsCacheNotificationHandler(settingsCache, mapper, path)); } @Bean @ConditionalOnExpression("${settings.in-memory-cache.notification-endpoints-enabled:false}" + " and ${admin-endpoints.storedrequest-amp.enabled} == true") - CustomizedAdminEndpoint ampCacheNotificationEndpoint( + AdminResource ampCacheNotificationEndpoint( SettingsCache ampSettingsCache, JacksonMapper mapper, @Value("${admin-endpoints.storedrequest-amp.path}") String path, @Value("${admin-endpoints.storedrequest-amp.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.storedrequest-amp.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.storedrequest-amp.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new SettingsCacheNotificationHandler(ampSettingsCache, mapper, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new SettingsCacheNotificationHandler(ampSettingsCache, mapper, path)); } @Bean @ConditionalOnExpression("${settings.in-memory-cache.notification-endpoints-enabled:false}" + " and ${admin-endpoints.cache-invalidation.enabled} == true") - CustomizedAdminEndpoint cacheInvalidateNotificationEndpoint( + AdminResource cacheInvalidateNotificationEndpoint( CachingApplicationSettings cachingApplicationSettings, @Value("${admin-endpoints.cache-invalidation.path}") String path, @Value("${admin-endpoints.cache-invalidation.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.cache-invalidation.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.cache-invalidation.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new AccountCacheInvalidationHandler(cachingApplicationSettings, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new AccountCacheInvalidationHandler(cachingApplicationSettings, path)); } @Bean @ConditionalOnExpression("${admin-endpoints.logging-httpinteraction.enabled} == true") - CustomizedAdminEndpoint loggingHttpInteractionEndpoint( + AdminResource loggingHttpInteractionEndpoint( @Value("${logging.http-interaction.max-limit}") int maxLimit, HttpInteractionLogger httpInteractionLogger, @Value("${admin-endpoints.logging-httpinteraction.path}") String path, @Value("${admin-endpoints.logging-httpinteraction.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.logging-httpinteraction.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.logging-httpinteraction.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new HttpInteractionLogHandler(maxLimit, httpInteractionLogger, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new HttpInteractionLogHandler(maxLimit, httpInteractionLogger, path)); } @Bean @ConditionalOnExpression("${admin-endpoints.logging-changelevel.enabled} == true") - CustomizedAdminEndpoint loggingChangeLevelEndpoint( + AdminResource loggingChangeLevelEndpoint( @Value("${logging.change-level.max-duration-ms}") long maxDuration, LoggerControlKnob loggerControlKnob, @Value("${admin-endpoints.logging-changelevel.path}") String path, @Value("${admin-endpoints.logging-changelevel.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.logging-changelevel.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.logging-changelevel.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new LoggerControlKnobHandler(maxDuration, loggerControlKnob, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new LoggerControlKnobHandler(maxDuration, loggerControlKnob, path)); } @Bean @ConditionalOnProperty(prefix = "admin-endpoints.tracelog", name = "enabled", havingValue = "true") - CustomizedAdminEndpoint tracerLogEndpoint( + AdminResource tracerLogEndpoint( CriteriaManager criteriaManager, @Value("${admin-endpoints.tracelog.path}") String path, @Value("${admin-endpoints.tracelog.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.tracelog.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.tracelog.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( - path, - new TracerLogHandler(criteriaManager), - isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + return new AdminResourceWrapper(path, isOnApplicationPort, isProtected, new TracerLogHandler(criteriaManager)); } @Bean @ConditionalOnExpression("${admin-endpoints.collected-metrics.enabled} == true") - CustomizedAdminEndpoint collectedMetricsAdminEndpoint( + AdminResource collectedMetricsAdminEndpoint( MetricRegistry metricRegistry, JacksonMapper mapper, @Value("${admin-endpoints.collected-metrics.path}") String path, @Value("${admin-endpoints.collected-metrics.on-application-port}") boolean isOnApplicationPort, - @Value("${admin-endpoints.collected-metrics.protected}") boolean isProtected, - @Autowired(required = false) Map adminEndpointCredentials) { + @Value("${admin-endpoints.collected-metrics.protected}") boolean isProtected) { - return new CustomizedAdminEndpoint( + return new AdminResourceWrapper( path, - new CollectedMetricsHandler(metricRegistry, mapper, path), isOnApplicationPort, - isProtected) - .withCredentials(adminEndpointCredentials); + isProtected, + new CollectedMetricsHandler(metricRegistry, mapper, path)); } @Bean - Map adminEndpointCredentials( - @Autowired(required = false) AdminEndpointCredentials adminEndpointCredentials) { + AdminResourcesBinder applicationPortAdminResourcesBinder(Map adminEndpointCredentials, + List resources) { + + final List applicationPortAdminResources = resources.stream() + .filter(AdminResource::isOnApplicationPort) + .toList(); - return ObjectUtils.defaultIfNull(adminEndpointCredentials.getCredentials(), Collections.emptyMap()); + return new AdminResourcesBinder(adminEndpointCredentials, applicationPortAdminResources); + } + + @Bean + AdminResourcesBinder adminPortAdminResourcesBinder(Map adminEndpointCredentials, + List resources) { + + final List adminPortAdminResources = resources.stream() + .filter(Predicate.not(AdminResource::isOnApplicationPort)) + .toList(); + + return new AdminResourcesBinder(adminEndpointCredentials, adminPortAdminResources); + } + + @Bean + Map adminEndpointCredentials(@Autowired(required = false) AdminEndpointCredentials credentials) { + return ObjectUtils.defaultIfNull(credentials.getCredentials(), Collections.emptyMap()); } @Component diff --git a/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java new file mode 100644 index 00000000000..11d096d5666 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java @@ -0,0 +1,50 @@ +package org.prebid.server.spring.config.server.admin; + +import io.vertx.core.Handler; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.AuthHandler; +import io.vertx.ext.web.handler.BasicAuthHandler; +import org.prebid.server.vertx.verticles.server.admin.AdminResource; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class AdminResourcesBinder { + + private final Map credentials; + private final List resources; + + public AdminResourcesBinder(Map credentials, List resources) { + this.credentials = credentials; + this.resources = Objects.requireNonNull(resources); + } + + public void bind(Router router) { + for (AdminResource resource : resources) { + router + .route(resource.path()) + .handler(resource.isSecured() ? securedAuthHandler() : PassNextHandler.INSTANCE) + .handler(resource); + } + } + + private AuthHandler securedAuthHandler() { + if (credentials == null) { + throw new IllegalArgumentException("Credentials for admin endpoint is empty."); + } + + return BasicAuthHandler.create(new AdminServerAuthProvider(credentials)); + } + + private static class PassNextHandler implements Handler { + + private static final Handler INSTANCE = new PassNextHandler(); + + @Override + public void handle(RoutingContext event) { + event.next(); + } + } +} diff --git a/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerAuthProvider.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerAuthProvider.java new file mode 100644 index 00000000000..f95980d1a60 --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerAuthProvider.java @@ -0,0 +1,39 @@ +package org.prebid.server.spring.config.server.admin; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Future; +import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.auth.AuthProvider; +import io.vertx.ext.auth.User; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; + +public class AdminServerAuthProvider implements AuthProvider { + + private final Map credentials; + + public AdminServerAuthProvider(Map credentials) { + this.credentials = credentials; + } + + @Override + public void authenticate(JsonObject authInfo, Handler> resultHandler) { + if (MapUtils.isEmpty(credentials)) { + resultHandler.handle(Future.failedFuture("Credentials not set in configuration.")); + return; + } + + final String requestUsername = authInfo.getString("username"); + final String requestPassword = StringUtils.chomp(authInfo.getString("password")); + + final String storedPassword = credentials.get(requestUsername); + if (StringUtils.isNotBlank(requestPassword) && StringUtils.equals(storedPassword, requestPassword)) { + resultHandler.handle(Future.succeededFuture()); + } else { + resultHandler.handle(Future.failedFuture("No such user, or password incorrect.")); + } + } +} diff --git a/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerConfiguration.java new file mode 100644 index 00000000000..e88e04be03d --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminServerConfiguration.java @@ -0,0 +1,40 @@ +package org.prebid.server.spring.config.server.admin; + +import io.vertx.core.Vertx; +import io.vertx.core.net.SocketAddress; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.handler.BodyHandler; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.prebid.server.vertx.verticles.server.ServerVerticle; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConditionalOnProperty(prefix = "admin", name = "port") +public class AdminServerConfiguration { + + @Bean + Router adminPortAdminServerRouter(Vertx vertx, + AdminResourcesBinder adminPortAdminResourcesBinder, + BodyHandler bodyHandler) { + + final Router router = Router.router(vertx); + router.route().handler(bodyHandler); + + adminPortAdminResourcesBinder.bind(router); + return router; + } + + @Bean + VerticleDefinition adminPortAdminHttpServerVerticleDefinition(Router adminPortAdminServerRouter, + @Value("${admin.port}") int port) { + + return VerticleDefinition.ofSingleInstance( + () -> new ServerVerticle( + "Admin Http Server", + SocketAddress.inetSocketAddress(port, "0.0.0.0"), + adminPortAdminServerRouter)); + } +} diff --git a/src/main/java/org/prebid/server/spring/config/WebConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java similarity index 84% rename from src/main/java/org/prebid/server/spring/config/WebConfiguration.java rename to src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java index fd5e6b95ee3..4740f025320 100644 --- a/src/main/java/org/prebid/server/spring/config/WebConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java @@ -1,9 +1,10 @@ -package org.prebid.server.spring.config; +package org.prebid.server.spring.config.server.application; import io.vertx.core.Vertx; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.net.JksOptions; +import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import io.vertx.ext.web.handler.BodyHandler; import io.vertx.ext.web.handler.CorsHandler; @@ -30,7 +31,6 @@ import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.handler.BidderParamHandler; import org.prebid.server.handler.CookieSyncHandler; -import org.prebid.server.handler.CustomizedAdminEndpoint; import org.prebid.server.handler.ExceptionHandler; import org.prebid.server.handler.GetuidsHandler; import org.prebid.server.handler.NoCacheHandler; @@ -54,11 +54,15 @@ import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.privacy.HostVendorTcfDefinerService; import org.prebid.server.settings.ApplicationSettings; +import org.prebid.server.spring.config.server.admin.AdminResourcesBinder; import org.prebid.server.util.HttpUtil; import org.prebid.server.validation.BidderParamValidator; import org.prebid.server.version.PrebidVersionProvider; -import org.springframework.beans.factory.annotation.Autowired; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.prebid.server.vertx.verticles.server.ServerVerticle; +import org.prebid.server.vertx.verticles.server.application.ApplicationResource; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -73,13 +77,48 @@ import java.util.Set; @Configuration -public class WebConfiguration { +public class ApplicationServerConfiguration { @Value("${logging.sampling-rate:0.01}") private double logSamplingRate; - @Autowired - private Vertx vertx; + @Bean + @ConditionalOnProperty(name = "server.http.enabled", havingValue = "true") + VerticleDefinition httpApplicationServerVerticleDefinition( + HttpServerOptions httpServerOptions, + @Value("#{'${http.port:${server.http.port}}'}") Integer port, + Router applicationServerRouter, + ExceptionHandler exceptionHandler, + @Value("#{'${vertx.http-server-instances:${server.http.server-instances}}'}") Integer instances) { + + return VerticleDefinition.ofMultiInstance( + () -> new ServerVerticle( + "Application Http Server", + httpServerOptions, + SocketAddress.inetSocketAddress(port, "0.0.0.0"), + applicationServerRouter, + exceptionHandler), + instances); + } + + @Bean + @ConditionalOnProperty(name = "server.unix-socket.enabled", havingValue = "true") + VerticleDefinition unixSocketApplicationServerVerticleDefinition( + HttpServerOptions httpServerOptions, + @Value("${server.unix-socket.path}") String path, + Router applicationServerRouter, + ExceptionHandler exceptionHandler, + @Value("${server.unix-socket.server-instances}") Integer instances) { + + return VerticleDefinition.ofMultiInstance( + () -> new ServerVerticle( + "Application Unix Socket Server", + httpServerOptions, + SocketAddress.domainSocketAddress(path), + applicationServerRouter, + exceptionHandler), + instances); + } // TODO: remove support for properties with http prefix after transition period @Bean @@ -120,48 +159,25 @@ ExceptionHandler exceptionHandler(Metrics metrics) { return ExceptionHandler.create(metrics); } - @Bean("router") - Router router(BodyHandler bodyHandler, - NoCacheHandler noCacheHandler, - CorsHandler corsHandler, - org.prebid.server.handler.openrtb2.AuctionHandler openrtbAuctionHandler, - AmpHandler openrtbAmpHandler, - VideoHandler openrtbVideoHandler, - StatusHandler statusHandler, - CookieSyncHandler cookieSyncHandler, - SetuidHandler setuidHandler, - GetuidsHandler getuidsHandler, - VtrackHandler vtrackHandler, - OptoutHandler optoutHandler, - BidderParamHandler bidderParamHandler, - BiddersHandler biddersHandler, - BidderDetailsHandler bidderDetailsHandler, - NotificationEventHandler notificationEventHandler, - List customizedAdminEndpoints, - StaticHandler staticHandler) { + @Bean + Router applicationServerRouter(Vertx vertx, + BodyHandler bodyHandler, + NoCacheHandler noCacheHandler, + CorsHandler corsHandler, + List resources, + AdminResourcesBinder applicationPortAdminResourcesBinder, + StaticHandler staticHandler) { final Router router = Router.router(vertx); router.route().handler(bodyHandler); router.route().handler(noCacheHandler); router.route().handler(corsHandler); - router.post("/openrtb2/auction").handler(openrtbAuctionHandler); - router.get("/openrtb2/amp").handler(openrtbAmpHandler); - router.post("/openrtb2/video").handler(openrtbVideoHandler); - router.get("/status").handler(statusHandler); - router.post("/cookie_sync").handler(cookieSyncHandler); - router.get("/setuid").handler(setuidHandler); - router.get("/getuids").handler(getuidsHandler); - router.post("/vtrack").handler(vtrackHandler); - router.post("/optout").handler(optoutHandler); - router.get("/optout").handler(optoutHandler); - router.get("/bidders/params").handler(bidderParamHandler); - router.get("/info/bidders").handler(biddersHandler); - router.get("/info/bidders/:bidderName").handler(bidderDetailsHandler); - router.get("/event").handler(notificationEventHandler); - - customizedAdminEndpoints.stream() - .filter(CustomizedAdminEndpoint::isOnApplicationPort) - .forEach(customizedAdminEndpoint -> customizedAdminEndpoint.router(router)); + + resources.forEach(resource -> + resource.endpoints().forEach(endpoint -> + router.route(endpoint.getMethod(), endpoint.getPath()).handler(resource))); + + applicationPortAdminResourcesBinder.bind(router); router.get("/static/*").handler(staticHandler); router.get("/").handler(staticHandler); // serves index.html by default diff --git a/src/main/java/org/prebid/server/vertx/ContextRunner.java b/src/main/java/org/prebid/server/vertx/ContextRunner.java index ad18e40476c..43dc35c3683 100644 --- a/src/main/java/org/prebid/server/vertx/ContextRunner.java +++ b/src/main/java/org/prebid/server/vertx/ContextRunner.java @@ -1,89 +1,49 @@ package org.prebid.server.vertx; -import io.vertx.core.Context; +import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Supplier; -/** - * Component that manages Vertx contexts and provides interface to run arbitrary code on them. - *

- * Needed mostly to replace verticle deployment model provided by Vertx because it doesn't play nicely when using - * Vertx in embedded mode within Spring application. - */ public class ContextRunner { - private static final Logger logger = LoggerFactory.getLogger(ContextRunner.class); - private final Vertx vertx; private final long timeoutMs; - private final Context serviceContext; - public ContextRunner(Vertx vertx, long timeoutMs) { - this.vertx = Objects.requireNonNull(vertx); + this.vertx = vertx; this.timeoutMs = timeoutMs; - - this.serviceContext = vertx.getOrCreateContext(); - } - - /** - * Runs provided action specified number of times each in a new context. This method is handy for - * running several instances of {@link io.vertx.core.http.HttpServer} on different event loop threads. - */ - public void runOnNewContext(int times, Handler> action) { - runOnContext(vertx::getOrCreateContext, times, action); - } - - /** - * Runs provided action on a dedicated service context. - */ - public void runOnServiceContext(Handler> action) { - runOnContext(() -> serviceContext, 1, action); } - private void runOnContext(Supplier contextFactory, int times, Handler> action) { - final CountDownLatch completionLatch = new CountDownLatch(times); - final AtomicBoolean actionFailed = new AtomicBoolean(false); - for (int i = 0; i < times; i++) { - final Context context = contextFactory.get(); - - final Promise promise = Promise.promise(); - promise.future().onComplete(ar -> { - if (ar.failed()) { - logger.fatal("Fatal error occurred while running action on Vertx context", ar.cause()); - actionFailed.compareAndSet(false, true); - } - completionLatch.countDown(); - }); - - context.runOnContext(v -> { - try { - action.handle(promise); - } catch (RuntimeException e) { - promise.fail(e); - } - }); - } + public void runBlocking(Handler> action) { + final CountDownLatch completionLatch = new CountDownLatch(1); + final Promise promise = Promise.promise(); + final Future future = promise.future(); + + future.onComplete(ignored -> completionLatch.countDown()); + vertx.runOnContext(v -> { + try { + action.handle(promise); + } catch (RuntimeException e) { + promise.fail(e); + } + }); try { if (!completionLatch.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new RuntimeException( "Action has not completed within defined timeout %d ms".formatted(timeoutMs)); - } else if (actionFailed.get()) { - throw new RuntimeException("Action failed"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Interrupted while waiting for action to complete", e); } + + if (future.failed()) { + throw new RuntimeException(future.cause()); + } } } diff --git a/src/main/java/org/prebid/server/vertx/http/BasicHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java similarity index 97% rename from src/main/java/org/prebid/server/vertx/http/BasicHttpClient.java rename to src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java index dfeb5c4a32e..bfdd4337fc1 100644 --- a/src/main/java/org/prebid/server/vertx/http/BasicHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.http; +package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; import io.vertx.core.MultiMap; @@ -9,7 +9,7 @@ import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; import org.prebid.server.exception.PreBidException; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.Objects; import java.util.concurrent.TimeoutException; diff --git a/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java similarity index 98% rename from src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java rename to src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java index 767398b37ad..ad957912dac 100644 --- a/src/main/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.http; +package org.prebid.server.vertx.httpclient; import com.github.benmanes.caffeine.cache.Caffeine; import io.vertx.core.Future; @@ -11,7 +11,7 @@ import org.prebid.server.log.ConditionalLogger; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.net.MalformedURLException; import java.net.URL; diff --git a/src/main/java/org/prebid/server/vertx/http/HttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/HttpClient.java similarity index 94% rename from src/main/java/org/prebid/server/vertx/http/HttpClient.java rename to src/main/java/org/prebid/server/vertx/httpclient/HttpClient.java index d448f58b4bb..467cd43157c 100644 --- a/src/main/java/org/prebid/server/vertx/http/HttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/HttpClient.java @@ -1,9 +1,9 @@ -package org.prebid.server.vertx.http; +package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; /** * Interface describes HTTP interactions. diff --git a/src/main/java/org/prebid/server/vertx/http/model/HttpClientResponse.java b/src/main/java/org/prebid/server/vertx/httpclient/model/HttpClientResponse.java similarity index 87% rename from src/main/java/org/prebid/server/vertx/http/model/HttpClientResponse.java rename to src/main/java/org/prebid/server/vertx/httpclient/model/HttpClientResponse.java index 654d987d8b4..7ed9056e62e 100644 --- a/src/main/java/org/prebid/server/vertx/http/model/HttpClientResponse.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/model/HttpClientResponse.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.http.model; +package org.prebid.server.vertx.httpclient.model; import io.vertx.core.MultiMap; import lombok.AllArgsConstructor; diff --git a/src/main/java/org/prebid/server/vertx/verticles/VerticleDefinition.java b/src/main/java/org/prebid/server/vertx/verticles/VerticleDefinition.java new file mode 100644 index 00000000000..52334bf3c97 --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/VerticleDefinition.java @@ -0,0 +1,22 @@ +package org.prebid.server.vertx.verticles; + +import io.vertx.core.Verticle; +import lombok.Value; + +import java.util.function.Supplier; + +@Value(staticConstructor = "of") +public class VerticleDefinition { + + Supplier factory; + + int amount; + + public static VerticleDefinition ofSingleInstance(Supplier factory) { + return of(factory, 1); + } + + public static VerticleDefinition ofMultiInstance(Supplier factory, int amount) { + return of(factory, amount); + } +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/HttpEndpoint.java b/src/main/java/org/prebid/server/vertx/verticles/server/HttpEndpoint.java new file mode 100644 index 00000000000..811f6a1aa1a --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/HttpEndpoint.java @@ -0,0 +1,12 @@ +package org.prebid.server.vertx.verticles.server; + +import io.vertx.core.http.HttpMethod; +import lombok.Value; + +@Value(staticConstructor = "of") +public class HttpEndpoint { + + HttpMethod method; + + String path; +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java new file mode 100644 index 00000000000..eed48d09cde --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java @@ -0,0 +1,73 @@ +package org.prebid.server.vertx.verticles.server; + +import io.vertx.core.AbstractVerticle; +import io.vertx.core.AsyncResult; +import io.vertx.core.Promise; +import io.vertx.core.http.HttpServer; +import io.vertx.core.http.HttpServerOptions; +import io.vertx.core.logging.Logger; +import io.vertx.core.logging.LoggerFactory; +import io.vertx.core.net.SocketAddress; +import io.vertx.ext.web.Router; +import org.apache.commons.lang3.ObjectUtils; +import org.prebid.server.handler.ExceptionHandler; + +import java.util.Objects; + +public class ServerVerticle extends AbstractVerticle { + + private static final Logger logger = LoggerFactory.getLogger(ServerVerticle.class); + + private final String name; + private final HttpServerOptions serverOptions; + private final SocketAddress address; + private final Router router; + private final ExceptionHandler exceptionHandler; + + public ServerVerticle(String name, + HttpServerOptions serverOptions, + SocketAddress address, + Router router, + ExceptionHandler exceptionHandler) { + + this.name = Objects.requireNonNull(name); + this.serverOptions = Objects.requireNonNull(serverOptions); + this.address = Objects.requireNonNull(address); + this.router = Objects.requireNonNull(router); + this.exceptionHandler = Objects.requireNonNull(exceptionHandler); + } + + public ServerVerticle(String name, SocketAddress address, Router router) { + this.name = Objects.requireNonNull(name); + this.serverOptions = null; + this.address = Objects.requireNonNull(address); + this.router = Objects.requireNonNull(router); + this.exceptionHandler = null; + } + + @Override + public void start(Promise startPromise) { + final HttpServerOptions httpServerOptions = ObjectUtils.getIfNull(serverOptions, HttpServerOptions::new); + final HttpServer server = vertx.createHttpServer(httpServerOptions) + .requestHandler(router); + + if (exceptionHandler != null) { + server.exceptionHandler(exceptionHandler); + } + + server.listen(address, result -> onServerStarted(result, startPromise)); + } + + private void onServerStarted(AsyncResult result, Promise startPromise) { + if (result.succeeded()) { + startPromise.tryComplete(); + logger.info( + "Successfully started {0} instance on address: {1}, thread: {2}", + name, + address, + Thread.currentThread().getName()); + } else { + startPromise.tryFail(result.cause()); + } + } +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/admin/AdminResource.java b/src/main/java/org/prebid/server/vertx/verticles/server/admin/AdminResource.java new file mode 100644 index 00000000000..0f901ec1167 --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/admin/AdminResource.java @@ -0,0 +1,13 @@ +package org.prebid.server.vertx.verticles.server.admin; + +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; + +public interface AdminResource extends Handler { + + String path(); + + boolean isOnApplicationPort(); + + boolean isSecured(); +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/application/ApplicationResource.java b/src/main/java/org/prebid/server/vertx/verticles/server/application/ApplicationResource.java new file mode 100644 index 00000000000..ee352dc9c99 --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/application/ApplicationResource.java @@ -0,0 +1,12 @@ +package org.prebid.server.vertx.verticles.server.application; + +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; +import org.prebid.server.vertx.verticles.server.HttpEndpoint; + +import java.util.List; + +public interface ApplicationResource extends Handler { + + List endpoints(); +} diff --git a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java index d12201b0df4..69f1f46a4af 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java @@ -19,8 +19,8 @@ import org.prebid.server.analytics.reporter.pubstack.model.PubstackAnalyticsProperties; import org.prebid.server.analytics.reporter.pubstack.model.PubstackConfig; import org.prebid.server.exception.PreBidException; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import org.springframework.test.util.ReflectionTestUtils; import java.util.Collections; diff --git a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java index 98fd998571b..739e3b38b36 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandlerTest.java @@ -18,8 +18,8 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.cookie.UidsCookie; import org.prebid.server.execution.Timeout; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import org.springframework.test.util.ReflectionTestUtils; import java.util.Set; diff --git a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java index 643e2b53301..361c0ed72b8 100644 --- a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java +++ b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java @@ -21,8 +21,8 @@ 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; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.math.BigDecimal; import java.time.Clock; diff --git a/src/test/java/org/prebid/server/bidder/BidderErrorNotifierTest.java b/src/test/java/org/prebid/server/bidder/BidderErrorNotifierTest.java index f95ffb6d6d4..9a2f49eefed 100644 --- a/src/test/java/org/prebid/server/bidder/BidderErrorNotifierTest.java +++ b/src/test/java/org/prebid/server/bidder/BidderErrorNotifierTest.java @@ -15,8 +15,8 @@ import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.concurrent.TimeoutException; diff --git a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java index 222fe74882d..6a7aeeb25bd 100644 --- a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java +++ b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java @@ -40,8 +40,8 @@ import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; import org.prebid.server.util.HttpUtil; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.time.Clock; import java.time.Instant; diff --git a/src/test/java/org/prebid/server/cache/CacheServiceTest.java b/src/test/java/org/prebid/server/cache/CacheServiceTest.java index 4e4410b7b1c..e82e74342e6 100644 --- a/src/test/java/org/prebid/server/cache/CacheServiceTest.java +++ b/src/test/java/org/prebid/server/cache/CacheServiceTest.java @@ -44,8 +44,8 @@ import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountAuctionConfig; import org.prebid.server.vast.VastModifier; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/org/prebid/server/floors/PriceFloorFetcherTest.java b/src/test/java/org/prebid/server/floors/PriceFloorFetcherTest.java index f84de82dbed..b0e5365f180 100644 --- a/src/test/java/org/prebid/server/floors/PriceFloorFetcherTest.java +++ b/src/test/java/org/prebid/server/floors/PriceFloorFetcherTest.java @@ -28,8 +28,8 @@ import org.prebid.server.settings.model.AccountAuctionConfig; import org.prebid.server.settings.model.AccountPriceFloorsConfig; import org.prebid.server.settings.model.AccountPriceFloorsFetchConfig; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.math.BigDecimal; import java.util.concurrent.TimeoutException; diff --git a/src/test/java/org/prebid/server/handler/AccountCacheInvalidationHandlerTest.java b/src/test/java/org/prebid/server/handler/AccountCacheInvalidationHandlerTest.java index ccde1aa16f2..9a6f07d7a83 100644 --- a/src/test/java/org/prebid/server/handler/AccountCacheInvalidationHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/AccountCacheInvalidationHandlerTest.java @@ -10,6 +10,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; +import org.prebid.server.handler.admin.AccountCacheInvalidationHandler; import org.prebid.server.settings.CachingApplicationSettings; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/org/prebid/server/handler/CollectedMetricsHandlerTest.java b/src/test/java/org/prebid/server/handler/CollectedMetricsHandlerTest.java index 59e3bdb0bf7..342c4b33ad0 100644 --- a/src/test/java/org/prebid/server/handler/CollectedMetricsHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/CollectedMetricsHandlerTest.java @@ -17,6 +17,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; +import org.prebid.server.handler.admin.CollectedMetricsHandler; import org.prebid.server.util.HttpUtil; import java.util.Collections; diff --git a/src/test/java/org/prebid/server/handler/CurrencyRatesHandlerTest.java b/src/test/java/org/prebid/server/handler/CurrencyRatesHandlerTest.java index bce27ba876a..fabb4bcb61b 100644 --- a/src/test/java/org/prebid/server/handler/CurrencyRatesHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/CurrencyRatesHandlerTest.java @@ -13,6 +13,7 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; import org.prebid.server.currency.CurrencyConversionService; +import org.prebid.server.handler.admin.CurrencyRatesHandler; import java.math.BigDecimal; import java.time.ZonedDateTime; diff --git a/src/test/java/org/prebid/server/handler/CustomizedAdminEndpointTest.java b/src/test/java/org/prebid/server/handler/CustomizedAdminEndpointTest.java deleted file mode 100644 index 65a54d77a4c..00000000000 --- a/src/test/java/org/prebid/server/handler/CustomizedAdminEndpointTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.prebid.server.handler; - -import io.vertx.core.Handler; -import io.vertx.ext.web.Route; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.handler.AuthHandler; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.prebid.server.VertxTest; - -import java.util.Collections; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -public class CustomizedAdminEndpointTest extends VertxTest { - - private static final String PATH = "test"; - - @Rule - public final MockitoRule mockitoRule = MockitoJUnit.rule(); - - private CustomizedAdminEndpoint target; - - @Mock - private Handler handler; - - @Mock - private Router router; - - @Mock - private Route route; - - private final Map adminEndpointCredentials = Collections.singletonMap("user", "pass"); - - @Before - public void setUp() { - target = new CustomizedAdminEndpoint(PATH, handler, true, true); - - given(router.route(any())).willReturn(route); - given(route.handler(any())).willReturn(route); - } - - @Test - public void routeShouldThrowExceptionWhenProtectedButCredentialsNotProvided() { - // when and then - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> target.router(router)) - .withMessage("Credentials for admin endpoint is empty."); - } - - @Test - public void routeShouldCallAuthAndHandlerWhenProtectedAndCredentialsProvided() { - // given - target.withCredentials(adminEndpointCredentials); - - // when - target.router(router); - - // then - verify(router).route(PATH); - verify(route).handler(any(AuthHandler.class)); - verify(route).handler(handler); - - verifyNoMoreInteractions(route); - verifyNoMoreInteractions(router); - } - - @Test - public void routeShouldCallRouterWhenProtectedAndNoCredentials() { - // given - target.withCredentials(Collections.emptyMap()); - - // when - target.router(router); - - // then - verify(router).route(PATH); - verify(route).handler(any(AuthHandler.class)); - verify(route).handler(handler); - - verifyNoMoreInteractions(route); - verifyNoMoreInteractions(router); - } - - @Test - public void routeShouldCallRouterWhenNotProtectedAndCredentialsProvided() { - // given - target = new CustomizedAdminEndpoint(PATH, handler, true, false); - target.withCredentials(adminEndpointCredentials); - - // when - target.router(router); - - // then - verify(router).route(PATH); - verify(route).handler(handler); - - verifyNoMoreInteractions(route); - verifyNoMoreInteractions(router); - } - - @Test - public void isOnApplicationPortShouldReturnTrue() { - // when and then - assertThat(target.isOnApplicationPort()).isTrue(); - } -} diff --git a/src/test/java/org/prebid/server/handler/HttpInteractionLogHandlerTest.java b/src/test/java/org/prebid/server/handler/HttpInteractionLogHandlerTest.java index 3ac0f223ba1..669b235971a 100644 --- a/src/test/java/org/prebid/server/handler/HttpInteractionLogHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/HttpInteractionLogHandlerTest.java @@ -10,6 +10,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; +import org.prebid.server.handler.admin.HttpInteractionLogHandler; import org.prebid.server.log.HttpInteractionLogger; import org.prebid.server.log.model.HttpLogSpec; diff --git a/src/test/java/org/prebid/server/handler/LoggerControlKnobHandlerTest.java b/src/test/java/org/prebid/server/handler/LoggerControlKnobHandlerTest.java index 6d244c0a0bc..5386e80835c 100644 --- a/src/test/java/org/prebid/server/handler/LoggerControlKnobHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/LoggerControlKnobHandlerTest.java @@ -10,6 +10,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; +import org.prebid.server.handler.admin.LoggerControlKnobHandler; import org.prebid.server.log.LoggerControlKnob; import java.time.Duration; diff --git a/src/test/java/org/prebid/server/handler/SettingsCacheNotificationHandlerTest.java b/src/test/java/org/prebid/server/handler/SettingsCacheNotificationHandlerTest.java index e8aa1cb8925..f309751fc6f 100644 --- a/src/test/java/org/prebid/server/handler/SettingsCacheNotificationHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/SettingsCacheNotificationHandlerTest.java @@ -13,6 +13,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; +import org.prebid.server.handler.admin.SettingsCacheNotificationHandler; import org.prebid.server.settings.CacheNotificationListener; import org.prebid.server.settings.proto.request.InvalidateSettingsCacheRequest; import org.prebid.server.settings.proto.request.UpdateSettingsCacheRequest; diff --git a/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java b/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java index 0d94217fea3..4cddd8219a2 100644 --- a/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/TracerLogHandlerTest.java @@ -11,6 +11,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; +import org.prebid.server.handler.admin.TracerLogHandler; import org.prebid.server.log.CriteriaManager; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/org/prebid/server/handler/VersionHandlerTest.java b/src/test/java/org/prebid/server/handler/VersionHandlerTest.java index 5d3b9f62128..aba9e183ee8 100644 --- a/src/test/java/org/prebid/server/handler/VersionHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/VersionHandlerTest.java @@ -11,6 +11,7 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; +import org.prebid.server.handler.admin.VersionHandler; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; diff --git a/src/test/java/org/prebid/server/optout/GoogleRecaptchaVerifierTest.java b/src/test/java/org/prebid/server/optout/GoogleRecaptchaVerifierTest.java index 112235f9089..876cc216bfa 100644 --- a/src/test/java/org/prebid/server/optout/GoogleRecaptchaVerifierTest.java +++ b/src/test/java/org/prebid/server/optout/GoogleRecaptchaVerifierTest.java @@ -11,8 +11,8 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; import org.prebid.server.exception.PreBidException; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceTest.java b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceTest.java index af2969794ac..81c2cd3b55c 100644 --- a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceTest.java +++ b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceTest.java @@ -24,8 +24,8 @@ import org.prebid.server.privacy.gdpr.vendorlist.proto.SpecialPurpose; import org.prebid.server.privacy.gdpr.vendorlist.proto.Vendor; import org.prebid.server.privacy.gdpr.vendorlist.proto.VendorList; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.io.File; import java.util.Date; diff --git a/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java index 2b90e48b926..9723f3b45a7 100644 --- a/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java @@ -20,8 +20,8 @@ import org.prebid.server.settings.model.StoredResponseDataResult; import org.prebid.server.settings.proto.response.HttpAccountsResponse; import org.prebid.server.settings.proto.response.HttpFetcherResponse; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.time.Clock; import java.time.Instant; diff --git a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java index 7184a1968b4..547d1484199 100644 --- a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java @@ -14,8 +14,8 @@ import org.prebid.server.VertxTest; import org.prebid.server.settings.CacheNotificationListener; import org.prebid.server.settings.proto.response.HttpRefreshResponse; -import org.prebid.server.vertx.http.HttpClient; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.util.Map; diff --git a/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java similarity index 99% rename from src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java rename to src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java index 5cb36c68ccb..a11a4cb2265 100644 --- a/src/test/java/org/prebid/server/vertx/http/BasicHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.http; +package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; import io.vertx.core.Handler; diff --git a/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java b/src/test/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClientTest.java similarity index 98% rename from src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java rename to src/test/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClientTest.java index 9a1d4e72882..f46af11e7a3 100644 --- a/src/test/java/org/prebid/server/vertx/http/CircuitBreakerSecuredHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.http; +package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -18,7 +18,7 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.exception.PreBidException; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.http.model.HttpClientResponse; +import org.prebid.server.vertx.httpclient.model.HttpClientResponse; import java.time.Clock; import java.time.Instant; From 35f990b5c35b4b571d90280f73d8e5191ef17d49 Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Fri, 12 Apr 2024 17:05:15 +0300 Subject: [PATCH 08/58] Dependencies: Updates (#3054) --- .editorconfig | 2 +- checkstyle.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- .../confiant/adquality/core/RedisClient.java | 6 +- .../confiant/adquality/core/RedisParser.java | 4 +- .../model/PbRichMediaFilterProperties.java | 2 +- extra/pom.xml | 3 +- pom.xml | 65 ++-- .../activity/ActivitiesConfigResolver.java | 2 +- .../ActivityInfrastructureCreator.java | 4 +- .../reporter/AnalyticsReporterDelegator.java | 8 +- .../reporter/log/LogAnalyticsReporter.java | 4 +- .../pubstack/PubstackAnalyticsReporter.java | 12 +- .../pubstack/PubstackEventHandler.java | 10 +- .../server/auction/ExchangeService.java | 6 +- .../auction/GeoLocationServiceWrapper.java | 4 +- .../server/auction/IpAddressHelper.java | 6 +- .../server/auction/OrtbTypesResolver.java | 4 +- .../server/auction/SupplyChainResolver.java | 6 +- .../auction/VideoStoredRequestProcessor.java | 4 +- .../auction/model/BidRejectionTracker.java | 4 +- .../privacy/enforcement/TcfEnforcement.java | 4 +- .../Ortb2ImplicitParametersResolver.java | 6 +- .../requestfactory/Ortb2RequestFactory.java | 6 +- .../requestfactory/VideoRequestFactory.java | 2 +- .../server/bidder/BidderErrorNotifier.java | 4 +- .../server/bidder/HttpBidderRequester.java | 10 +- .../bidder/appnexus/AppnexusBidder.java | 2 +- .../bidder/bidstack/BidstackBidder.java | 2 +- .../bidder/intertech/IntertechBidder.java | 2 +- .../server/bidder/openx/OpenxBidder.java | 4 +- .../bidder/rtbhouse/RtbhouseBidder.java | 2 +- .../server/bidder/rubicon/RubiconBidder.java | 4 +- .../server/bidder/yandex/YandexBidder.java | 2 +- .../bidder/yieldlab/YieldlabBidder.java | 4 +- .../org/prebid/server/cache/CacheService.java | 8 +- .../cookie/PrioritizedCoopSyncProvider.java | 10 +- .../server/cookie/UidsCookieService.java | 6 +- .../currency/CurrencyConversionService.java | 13 +- .../server/execution/RemoteFileSyncer.java | 239 ++++----------- .../floors/BasicPriceFloorEnforcer.java | 4 +- .../floors/BasicPriceFloorProcessor.java | 4 +- .../floors/BasicPriceFloorResolver.java | 4 +- .../server/floors/PriceFloorFetcher.java | 4 +- .../floors/PriceFloorsConfigResolver.java | 4 +- .../model/PriceFloorDebugProperties.java | 2 +- ...rcuitBreakerSecuredGeoLocationService.java | 4 +- .../server/handler/CookieSyncHandler.java | 4 +- .../server/handler/ExceptionHandler.java | 6 +- .../handler/NotificationEventHandler.java | 4 +- .../prebid/server/handler/OptoutHandler.java | 4 +- .../prebid/server/handler/SetuidHandler.java | 4 +- .../prebid/server/handler/VtrackHandler.java | 4 +- .../handler/admin/CurrencyRatesHandler.java | 4 +- .../SettingsCacheNotificationHandler.java | 12 +- .../server/handler/admin/VersionHandler.java | 4 +- .../server/handler/openrtb2/AmpHandler.java | 6 +- .../handler/openrtb2/AuctionHandler.java | 6 +- .../server/handler/openrtb2/VideoHandler.java | 10 +- .../server/hooks/execution/GroupExecutor.java | 2 +- .../server/hooks/execution/GroupResult.java | 2 +- .../prebid/server/log/ConditionalLogger.java | 1 - .../java/org/prebid/server/log/Criteria.java | 1 - .../prebid/server/log/CriteriaLogManager.java | 4 +- .../prebid/server/log/CriteriaManager.java | 1 - .../server/log/HttpInteractionLogger.java | 8 +- .../java/org/prebid/server/log/Logger.java | 141 +++++++++ .../org/prebid/server/log/LoggerFactory.java | 22 ++ .../optout/GoogleRecaptchaVerifier.java | 4 +- .../privacy/HostVendorTcfDefinerService.java | 4 +- .../server/privacy/PrivacyExtractor.java | 4 +- .../privacy/gdpr/TcfDefinerService.java | 4 +- .../BasicEnforcePurposeStrategy.java | 6 +- .../gdpr/vendorlist/VendorListService.java | 8 +- .../settings/CachingApplicationSettings.java | 6 +- .../settings/HttpApplicationSettings.java | 4 +- .../helper/JdbcStoredDataResultMapper.java | 6 +- .../server/settings/model/GdprConfig.java | 2 +- .../service/HttpPeriodicRefreshService.java | 9 +- .../service/JdbcPeriodicRefreshService.java | 8 +- .../spring/config/AnalyticsConfiguration.java | 2 +- .../config/GeoLocationConfiguration.java | 5 +- .../config/InitializationConfiguration.java | 22 +- .../config/PrivacyServiceConfiguration.java | 6 +- .../spring/config/ServiceConfiguration.java | 6 +- .../spring/config/SettingsConfiguration.java | 4 +- .../server/spring/config/VerticleStarter.java | 13 +- .../spring/config/VertxConfiguration.java | 6 +- .../spring/config/VertxContextScope.java | 4 +- .../config/bidder/AaxConfiguration.java | 2 +- .../config/bidder/AceexConfiguration.java | 2 +- .../config/bidder/AcuityadsConfiguration.java | 2 +- .../config/bidder/AdQueryConfiguration.java | 2 +- .../config/bidder/AdelementConfiguration.java | 2 +- .../config/bidder/AdfConfiguration.java | 2 +- .../bidder/AdgenerationConfiguration.java | 2 +- .../config/bidder/AdheseConfiguration.java | 2 +- .../bidder/AdkernelAdnConfiguration.java | 2 +- .../config/bidder/AdkernelConfiguration.java | 2 +- .../config/bidder/AdmanConfiguration.java | 2 +- .../config/bidder/AdmixerConfiguration.java | 2 +- .../bidder/AdnuntiusBidderConfiguration.java | 2 +- .../config/bidder/AdoceanConfiguration.java | 2 +- .../config/bidder/AdopplerConfiguration.java | 2 +- .../config/bidder/AdotConfiguration.java | 2 +- .../config/bidder/AdponeConfiguration.java | 2 +- .../config/bidder/AdprimeConfiguration.java | 2 +- .../config/bidder/AdrinoConfiguration.java | 2 +- .../config/bidder/AdtargetConfiguration.java | 2 +- .../bidder/AdtelligentConfiguration.java | 2 +- .../config/bidder/AdtrgtmeConfiguration.java | 2 +- .../bidder/AdvangelistsConfiguration.java | 2 +- .../config/bidder/AdviewConfiguration.java | 2 +- .../config/bidder/AdxcgConfiguration.java | 2 +- .../config/bidder/AdyoulikeConfiguration.java | 2 +- .../config/bidder/AidemConfiguration.java | 2 +- .../config/bidder/AjaConfiguration.java | 2 +- .../config/bidder/AlgorixConfiguration.java | 2 +- .../config/bidder/AlkimiConfiguration.java | 22 +- .../config/bidder/AmxConfiguration.java | 2 +- .../config/bidder/ApacdexConfiguration.java | 2 +- .../config/bidder/AppnexusConfiguration.java | 2 +- .../config/bidder/AppushConfiguration.java | 2 +- .../bidder/AudienceNetworkConfiguration.java | 2 +- .../bidder/AutomatadBidderConfiguration.java | 2 +- .../config/bidder/AvocetConfiguration.java | 2 +- .../config/bidder/AxisConfiguration.java | 2 +- .../config/bidder/AxonixConfiguration.java | 2 +- .../bidder/BeachfrontConfiguration.java | 2 +- .../config/bidder/BeintooConfiguration.java | 2 +- .../bidder/BematterfullConfiguration.java | 2 +- .../config/bidder/BetweenConfiguration.java | 2 +- .../bidder/BeyondMediaConfiguration.java | 2 +- .../bidder/BidmachineConfiguration.java | 2 +- .../config/bidder/BidmyadzConfiguration.java | 2 +- .../config/bidder/BidscubeConfiguration.java | 2 +- .../config/bidder/BidstackConfiguration.java | 2 +- .../config/bidder/BizzclickConfiguration.java | 2 +- .../bidder/BliinkBidderConfiguration.java | 2 +- .../config/bidder/BlueSeaConfiguration.java | 2 +- .../config/bidder/BmtmConfiguration.java | 2 +- .../config/bidder/BoldwinConfiguration.java | 2 +- .../config/bidder/BraveConfiguration.java | 2 +- .../config/bidder/CcxConfiguration.java | 2 +- .../config/bidder/CoinzillaConfiguration.java | 2 +- .../config/bidder/ColossusConfiguration.java | 2 +- .../config/bidder/CompassConfiguration.java | 2 +- .../config/bidder/ConnectAdConfiguration.java | 2 +- .../bidder/ConsumableConfiguration.java | 2 +- .../config/bidder/CpmStarConfiguration.java | 2 +- .../config/bidder/CriteoConfiguration.java | 2 +- .../bidder/DatablocksConfiguration.java | 2 +- .../bidder/DecenteradsConfiguration.java | 2 +- .../bidder/DeepintentConfiguration.java | 2 +- .../bidder/DianomiBidderConfiguration.java | 2 +- .../config/bidder/DmxConfiguration.java | 2 +- .../bidder/DxKultureBidderConfiguration.java | 2 +- .../config/bidder/Edge226Configuration.java | 2 +- .../config/bidder/EmtvConfiguration.java | 2 +- .../bidder/EmxDigitalConfiguration.java | 2 +- .../config/bidder/EplanningConfiguration.java | 2 +- .../config/bidder/EpomConfiguration.java | 2 +- .../config/bidder/EpsilonConfiguration.java | 4 +- .../config/bidder/EvolutionConfiguration.java | 2 +- .../config/bidder/FlippConfiguration.java | 2 +- .../bidder/FreewheelSSPConfiguration.java | 2 +- .../bidder/FrvrAdnBidderConfiguration.java | 2 +- .../config/bidder/GammaConfiguration.java | 2 +- .../config/bidder/GamoshiConfiguration.java | 2 +- .../bidder/GenericBidderConfiguration.java | 2 +- .../config/bidder/GlobalsunConfiguration.java | 2 +- .../config/bidder/GothamAdsConfiguration.java | 2 +- .../config/bidder/GridConfiguration.java | 2 +- .../config/bidder/GumgumConfiguration.java | 2 +- .../config/bidder/HuaweiAdsConfiguration.java | 6 +- .../config/bidder/ImdsConfiguration.java | 2 +- .../config/bidder/ImpactifyConfiguration.java | 2 +- .../bidder/ImprovedigitalConfiguration.java | 2 +- .../config/bidder/InfytvConfiguration.java | 2 +- .../config/bidder/InmobiConfiguration.java | 2 +- .../InteractiveOffersConfiguration.java | 2 +- .../config/bidder/IntertechConfiguration.java | 2 +- .../config/bidder/InvibesConfiguration.java | 2 +- .../config/bidder/IqxConfiguration.java | 2 +- .../config/bidder/IqzoneConfiguration.java | 2 +- .../spring/config/bidder/IxConfiguration.java | 2 +- .../config/bidder/JixieConfiguration.java | 2 +- .../config/bidder/KargoConfiguration.java | 2 +- .../config/bidder/KayzenConfiguration.java | 2 +- .../config/bidder/KidozConfiguration.java | 2 +- .../bidder/KiviAdsBidderConfiguration.java | 2 +- .../bidder/KrushmediaConfiguration.java | 2 +- .../bidder/LemmaDigitalConfiguration.java | 2 +- .../config/bidder/LiftoffConfiguration.java | 2 +- .../bidder/LimeLightDigitalConfiguration.java | 2 +- .../bidder/LmKiviAdsBidderConfiguration.java | 2 +- .../bidder/LockerdomeConfiguration.java | 2 +- .../config/bidder/LoganConfiguration.java | 2 +- .../config/bidder/LogicadConfiguration.java | 2 +- .../config/bidder/LoopmeConfiguration.java | 2 +- .../config/bidder/LunamediaConfiguration.java | 2 +- .../bidder/MadvertiseConfiguration.java | 2 +- .../config/bidder/MarsmediaConfiguration.java | 2 +- .../config/bidder/MedianetConfiguration.java | 2 +- .../config/bidder/MgidConfiguration.java | 2 +- .../config/bidder/MgidxConfiguration.java | 2 +- .../bidder/MinuteMediaConfiguration.java | 2 +- .../config/bidder/MobfoxpbConfiguration.java | 2 +- .../bidder/MobilefuseConfiguration.java | 2 +- .../config/bidder/MotorikConfiguration.java | 2 +- .../bidder/NextMillenniumConfiguration.java | 2 +- .../config/bidder/NobidConfiguration.java | 2 +- .../config/bidder/OmsBidderConfiguration.java | 2 +- .../config/bidder/OnetagConfiguration.java | 2 +- .../config/bidder/OpenWebConfiguration.java | 2 +- .../config/bidder/OpenxConfiguration.java | 2 +- .../config/bidder/OperaadsConfiguration.java | 2 +- .../config/bidder/OrbidderConfiguration.java | 2 +- .../config/bidder/OutbrainConfiguration.java | 2 +- .../config/bidder/PangleConfiguration.java | 2 +- .../config/bidder/PgamSspConfiguration.java | 2 +- .../config/bidder/PrecisoConfiguration.java | 2 +- .../config/bidder/PubmaticConfiguration.java | 2 +- .../config/bidder/PubnativeConfiguration.java | 2 +- .../bidder/PulsepointConfiguration.java | 2 +- .../config/bidder/PwbidConfiguration.java | 2 +- .../bidder/RelevantDigitalConfiguration.java | 2 +- .../bidder/ResetDigitalConfiguration.java | 2 +- .../bidder/RevcontentConfiguration.java | 2 +- .../bidder/RichaudienceConfiguration.java | 2 +- .../config/bidder/RiseConfiguration.java | 2 +- .../config/bidder/RtbhouseConfiguration.java | 2 +- .../config/bidder/RubiconConfiguration.java | 6 +- .../bidder/SaLunamediaConfiguration.java | 2 +- .../bidder/ScreencoreConfiguration.java | 2 +- .../SeedingAllianceBidderConfiguration.java | 2 +- .../bidder/SharethroughConfiguration.java | 2 +- .../bidder/SilverPushConfiguration.java | 2 +- .../config/bidder/SilvermobConfiguration.java | 2 +- .../bidder/SimpleWantedConfiguration.java | 2 +- .../config/bidder/SmaatoConfiguration.java | 2 +- .../bidder/SmartadserverConfiguration.java | 2 +- .../config/bidder/SmarthubConfiguration.java | 2 +- .../config/bidder/SmartrtbConfiguration.java | 2 +- .../config/bidder/SmartxConfiguration.java | 2 +- .../config/bidder/SmartyAdsConfiguration.java | 2 +- .../config/bidder/SonobiConfiguration.java | 2 +- .../config/bidder/SovrnConfiguration.java | 2 +- .../config/bidder/SovrnXspConfiguration.java | 2 +- .../bidder/SspbcBidderConfiguration.java | 2 +- .../bidder/StroeerCoreConfiguration.java | 2 +- .../config/bidder/TaboolaConfiguration.java | 2 +- .../config/bidder/TappxConfiguration.java | 2 +- .../config/bidder/TeadsConfiguration.java | 2 +- .../config/bidder/TelariaConfiguration.java | 2 +- .../ThirtyThreeAcrossConfiguration.java | 2 +- .../bidder/TpmnAdnBidderConfiguration.java | 2 +- .../bidder/TrafficGateConfiguration.java | 2 +- .../bidder/TripleliftConfiguration.java | 2 +- .../bidder/TripleliftNativeConfiguration.java | 4 +- .../config/bidder/UcfunnelConfiguration.java | 2 +- .../config/bidder/UndertoneConfiguration.java | 2 +- .../config/bidder/UnicornConfiguration.java | 2 +- .../config/bidder/UnrulyConfiguration.java | 2 +- .../bidder/VideoHeroesConfiguration.java | 2 +- .../config/bidder/VideobyteConfiguration.java | 2 +- .../config/bidder/VidoomyConfiguration.java | 2 +- .../bidder/VisibleMeasuresConfiguration.java | 2 +- .../config/bidder/VisxConfiguration.java | 2 +- .../config/bidder/VoxConfiguration.java | 2 +- .../config/bidder/VrtcalConfiguration.java | 2 +- .../bidder/XeworksBidderConfiguration.java | 2 +- .../config/bidder/YahooAdsConfiguration.java | 2 +- .../config/bidder/YandexConfiguration.java | 2 +- .../config/bidder/YeahmobiConfiguration.java | 2 +- .../config/bidder/YearxeroConfiguration.java | 2 +- .../config/bidder/YieldlabConfiguration.java | 2 +- .../config/bidder/YieldmoConfiguration.java | 2 +- .../config/bidder/YieldoneConfiguration.java | 2 +- .../bidder/ZeroclickfraudConfiguration.java | 2 +- .../bidder/ZetaGlobalSspConfiguration.java | 2 +- .../model/BidderConfigurationProperties.java | 6 +- .../spring/config/bidder/model/Debug.java | 2 +- .../DefaultBidderConfigurationProperties.java | 2 +- .../spring/config/bidder/model/MetaInfo.java | 4 +- .../spring/config/bidder/model/Ortb.java | 2 +- .../UsersyncConfigurationProperties.java | 2 +- ...UsersyncMethodConfigurationProperties.java | 4 +- .../DatabaseConfigurationProperties.java | 6 +- .../config/metrics/MetricsConfiguration.java | 23 +- .../metrics/PrometheusConfiguration.java | 6 +- .../PrometheusMapperConfiguration.java | 2 +- .../model/CircuitBreakerProperties.java | 4 +- .../model/ExternalConversionProperties.java | 6 +- .../HttpClientCircuitBreakerProperties.java | 4 +- .../config/model/HttpClientProperties.java | 4 +- .../model/RemoteFileSyncerProperties.java | 6 +- ...offRetryPolicyConfigurationProperties.java | 4 +- ...valRetryPolicyConfigurationProperties.java | 2 +- .../server/admin/AdminResourcesBinder.java | 4 +- .../spring/env/YamlPropertySourceFactory.java | 4 +- .../java/org/prebid/server/util/HttpUtil.java | 6 +- .../org/prebid/server/util/VersionInfo.java | 6 +- .../util/system/CpuLoadAverageStats.java | 4 +- .../server/validation/RequestValidator.java | 2 +- .../validation/ResponseBidValidator.java | 4 +- .../prebid/server/vertx/CircuitBreaker.java | 4 +- .../prebid/server/vertx/CloseableAdapter.java | 17 +- .../prebid/server/vertx/Initializable.java | 3 +- .../vertx/httpclient/BasicHttpClient.java | 130 ++++---- .../CircuitBreakerSecuredHttpClient.java | 8 +- .../server/vertx/jdbc/BasicJdbcClient.java | 4 +- .../jdbc/CircuitBreakerSecuredJdbcClient.java | 4 +- .../verticles/server/DaemonVerticle.java | 63 ++++ .../verticles/server/ServerVerticle.java | 6 +- .../server/functional/model/db/Account.groovy | 14 +- .../functional/model/db/StoredImp.groovy | 14 +- .../functional/model/db/StoredRequest.groovy | 14 +- .../functional/model/db/StoredResponse.groovy | 14 +- .../AccountConfigTypeConverter.groovy | 2 +- .../AccountStatusTypeConverter.groovy | 2 +- .../ImpConfigTypeConverter.groovy | 2 +- ...dAuctionResponseConfigTypeConverter.groovy | 2 +- ...toredBidResponseConfigTypeConverter.groovy | 2 +- .../StoredRequestConfigTypeConverter.groovy | 2 +- .../repository/EntityManagerUtil.groovy | 2 +- .../service/PrebidServerService.groovy | 3 +- .../functional/tests/BidderParamsSpec.groovy | 2 +- .../PubstackAnalyticsReporterTest.java | 13 +- .../auction/BidResponseCreatorTest.java | 5 +- .../CurrencyConversionServiceTest.java | 3 +- .../auction/model/CachedDebugLogTest.java | 10 +- .../VideoRequestFactoryTest.java | 2 +- .../adtelligent/AdtelligentBidderTest.java | 9 +- .../execution/RemoteFileSyncerTest.java | 288 ++++++++---------- .../org/prebid/server/it/ApplicationTest.java | 4 +- .../server/log/ConditionalLoggerTest.java | 1 - .../org/prebid/server/log/CriteriaTest.java | 1 - .../server/log/HttpInteractionLoggerTest.java | 7 +- .../JdbcStoredDataResultMapperTest.java | 9 +- .../HttpPeriodicRefreshServiceTest.java | 3 +- .../JdbcPeriodicRefreshServiceTest.java | 3 +- .../server/vertx/CloseableAdapterTest.java | 13 +- .../vertx/httpclient/BasicHttpClientTest.java | 92 +++--- 344 files changed, 1125 insertions(+), 1086 deletions(-) create mode 100644 src/main/java/org/prebid/server/log/Logger.java create mode 100644 src/main/java/org/prebid/server/log/LoggerFactory.java create mode 100644 src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java diff --git a/.editorconfig b/.editorconfig index 23e7176794a..7b8947ec3c6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -115,7 +115,7 @@ ij_java_for_statement_wrap = off ij_java_generate_final_locals = false ij_java_generate_final_parameters = false ij_java_if_brace_force = never -ij_java_imports_layout = *,|,javax.**,java.**,|,$* +ij_java_imports_layout = *,|,javax.**,jakarta.**,java.**,|,$* ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true diff --git a/checkstyle.xml b/checkstyle.xml index aac9ec01cfe..b93d0402c9e 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -75,7 +75,7 @@ - + diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 0bb36be1d10..51a81049e5e 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -17,7 +17,7 @@ io.vertx vertx-redis-client - 3.9.10 + ${vertx.version} diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java index f03d07ca33c..7c943c888dd 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisClient.java @@ -4,8 +4,8 @@ import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import io.vertx.redis.client.Redis; import io.vertx.redis.client.RedisAPI; import io.vertx.redis.client.RedisConnection; @@ -45,7 +45,7 @@ public RedisClient( public void start(Promise startFuture) { createRedisClient(onCreate -> { if (onCreate.succeeded()) { - logger.info("Confiant Redis {0} connection is established", type); + logger.info("Confiant Redis {} connection is established", type); startFuture.tryComplete(); } }, false); diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java index a516497146d..95ed2a2814f 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/core/RedisParser.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.hooks.modules.com.confiant.adquality.model.BidScanResult; import org.prebid.server.hooks.modules.com.confiant.adquality.model.RedisError; diff --git a/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java b/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java index e22419d1702..e7db7870721 100644 --- a/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java +++ b/extra/modules/pb-richmedia-filter/src/main/java/org/prebid/server/hooks/modules/pb/richmedia/filter/model/PbRichMediaFilterProperties.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Value; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Value(staticConstructor = "of") public class PbRichMediaFilterProperties { diff --git a/extra/pom.xml b/extra/pom.xml index 0ef8a94ae56..0afb89a0b85 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -19,7 +19,8 @@ UTF-8 17 17 - 1.18.24 + 4.5.5 + 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index abbd1a513e1..638bf87e9f5 100644 --- a/pom.xml +++ b/pom.xml @@ -27,9 +27,8 @@ Dockerfile - 2.5.6 + 3.2.3 2.0.1.Final - 3.9.10 3.14.0 4.4 1.26.0 @@ -37,23 +36,22 @@ 4.5.14 5.3.1 6.4.5 - 2.14.1 + 2.16.2 1.0.76 1.13 8.0.28 42.7.2 2.2.0 1.2.2 + 0.16.0 2.0.2 2.0.7 2.12.0 - 1.2.13 5.0.1 3.0.10 3.21.7 3.17.3 1.0.7 - 1.7.32 4.13.2 @@ -63,9 +61,9 @@ 2.35.1 4.2.0 9.4.53.v20231009 - 4.4.0 + 5.4.0 2.2.220 - 2.4-M1-groovy-3.0 + 2.4-M2-groovy-4.0 3.0.14 1.17.4 5.14.0 @@ -76,7 +74,7 @@ 3.1.2 10.3 1.2.0 - 0.8.7 + 0.8.11 2.2.4 3.10.1 2.22.2 @@ -135,8 +133,8 @@ spring-boot-starter-aop - javax.annotation - javax.annotation-api + jakarta.annotation + jakarta.annotation-api javax.validation @@ -338,41 +336,19 @@ io.prometheus - simpleclient_vertx + simpleclient_vertx4 + ${vertx.prometheus.version} io.prometheus simpleclient_dropwizard + ${vertx.prometheus.version} com.maxmind.geoip2 geoip2 ${maxmind-client.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.apache.logging.log4j - log4j-to-slf4j - - - org.apache.logging.log4j - log4j-api - com.zaxxer HikariCP @@ -524,6 +500,18 @@ ${restassured.version} test + + io.rest-assured + json-path + ${restassured.version} + test + + + io.rest-assured + xml-path + ${restassured.version} + test + net.bytebuddy byte-buddy @@ -549,7 +537,7 @@ test - org.hibernate + org.hibernate.orm hibernate-core test @@ -600,6 +588,11 @@ org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} + + + -parameters + + org.apache.maven.plugins diff --git a/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java b/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java index df267438a4a..aae688556bf 100644 --- a/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java +++ b/src/main/java/org/prebid/server/activity/ActivitiesConfigResolver.java @@ -1,7 +1,7 @@ package org.prebid.server.activity; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountPrivacyConfig; import org.prebid.server.settings.model.activity.AccountActivityConfiguration; diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java index 9339582f1e1..f3a0b515a3c 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java @@ -1,7 +1,5 @@ package org.prebid.server.activity.infrastructure.creator; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.prebid.server.activity.Activity; import org.prebid.server.activity.infrastructure.ActivityController; @@ -11,6 +9,8 @@ import org.prebid.server.activity.infrastructure.rule.Rule; import org.prebid.server.auction.gpp.model.GppContext; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.TraceLevel; diff --git a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java index 9856f6e1a26..a65b2293a8d 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java @@ -10,8 +10,6 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.activity.Activity; import org.prebid.server.activity.ComponentType; @@ -31,6 +29,8 @@ import org.prebid.server.auction.privacy.enforcement.mask.UserFpdActivityMask; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.model.PrivacyEnforcementAction; @@ -126,8 +126,8 @@ private void delegateEvent(T event, } } else { final Throwable privacyEnforcementException = privacyEnforcementMapResult.cause(); - logger.error("Analytics TCF enforcement check failed for consentString: {0} and " - + "delegates with vendorIds {1}", privacyEnforcementException, + logger.error("Analytics TCF enforcement check failed for consentString: {} and " + + "delegates with vendorIds {}", privacyEnforcementException, tcfContext.getConsentString(), delegates); } } diff --git a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java index 61931743085..070bea19992 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java @@ -1,8 +1,6 @@ package org.prebid.server.analytics.reporter.log; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.analytics.AnalyticsReporter; import org.prebid.server.analytics.model.AmpEvent; import org.prebid.server.analytics.model.AuctionEvent; @@ -12,6 +10,8 @@ import org.prebid.server.analytics.model.VideoEvent; import org.prebid.server.analytics.reporter.log.model.LogEvent; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java index 87e52034472..09daf73343d 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java @@ -2,9 +2,8 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.prebid.server.analytics.AnalyticsReporter; @@ -20,6 +19,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.Initializable; import org.prebid.server.vertx.httpclient.HttpClient; @@ -124,9 +125,10 @@ public String name() { } @Override - public void initialize() { + public void initialize(Promise initializePromise) { vertx.setPeriodic(configurationRefreshDelay, id -> fetchRemoteConfig()); fetchRemoteConfig(); + initializePromise.tryComplete(); } void shutdown() { @@ -134,7 +136,7 @@ void shutdown() { } private void fetchRemoteConfig() { - logger.info("[pubstack] Updating config: {0}", pubstackConfig); + logger.info("[pubstack] Updating config: {}", pubstackConfig); httpClient.get(makeEventEndpointUrl(pubstackConfig.getEndpoint(), pubstackConfig.getScopeId()), timeout) .map(this::processRemoteConfigurationResponse) .onComplete(this::updateConfigsOnChange); @@ -156,7 +158,7 @@ private PubstackConfig processRemoteConfigurationResponse(HttpClientResponse res private void updateConfigsOnChange(AsyncResult asyncConfigResult) { if (asyncConfigResult.failed()) { - logger.error("[pubstask] Fail to fetch remote configuration: {0}", asyncConfigResult.cause().getMessage()); + logger.error("[pubstask] Fail to fetch remote configuration: {}", asyncConfigResult.cause().getMessage()); } else if (!Objects.equals(pubstackConfig, asyncConfigResult.result())) { final PubstackConfig pubstackConfig = asyncConfigResult.result(); eventHandlers.values().forEach(PubstackEventHandler::reportEvents); diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java index 0dd4eb229e9..8c77665bede 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java @@ -7,11 +7,11 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.analytics.reporter.pubstack.model.PubstackAnalyticsProperties; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.httpclient.HttpClient; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; @@ -118,7 +118,7 @@ private boolean reportEventsOnCondition(Predicate conditionToSend, T cond sendEvents(events); } } catch (Exception exception) { - logger.error("[pubstack] Failed to send analytics report to endpoint {0} with a reason {1}", + logger.error("[pubstack] Failed to send analytics report to endpoint {} with a reason {}", endpoint, exception.getMessage()); } finally { lockOnSend.unlock(); @@ -163,13 +163,13 @@ private static byte[] gzip(String value) { private void handleReportResponse(AsyncResult result) { if (result.failed()) { - logger.error("[pubstack] Failed to send events to endpoint {0} with a reason: {1}", + logger.error("[pubstack] Failed to send events to endpoint {} with a reason: {}", endpoint, result.cause().getMessage()); } else { final HttpClientResponse httpClientResponse = result.result(); final int statusCode = httpClientResponse.getStatusCode(); if (statusCode != HttpResponseStatus.OK.code()) { - logger.error("[pubstack] Wrong code received {0} instead of 200", statusCode); + logger.error("[pubstack] Wrong code received {} instead of 200", statusCode); } } } diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index 967046d3ae8..be303320f51 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -20,8 +20,6 @@ import com.iab.openrtb.response.SeatBid; import io.vertx.core.CompositeFuture; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.map.CaseInsensitiveMap; @@ -46,8 +44,8 @@ import org.prebid.server.auction.model.BidderResponse; import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.StoredResponseResult; -import org.prebid.server.auction.privacy.enforcement.PrivacyEnforcementService; import org.prebid.server.auction.model.TimeoutContext; +import org.prebid.server.auction.privacy.enforcement.PrivacyEnforcementService; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConversionManager; import org.prebid.server.auction.versionconverter.OrtbVersion; import org.prebid.server.bidder.Bidder; @@ -83,6 +81,8 @@ import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.CriteriaLogManager; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.CaseInsensitiveMultiMap; diff --git a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java index ddafc42fd53..ce1c33a1304 100644 --- a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java +++ b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.Device; import com.iab.openrtb.request.Geo; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.model.AuctionContext; @@ -13,6 +11,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.GeoLocationService; import org.prebid.server.geolocation.model.GeoInfo; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.settings.model.Account; diff --git a/src/main/java/org/prebid/server/auction/IpAddressHelper.java b/src/main/java/org/prebid/server/auction/IpAddressHelper.java index f99e75cb985..523219fd511 100644 --- a/src/main/java/org/prebid/server/auction/IpAddressHelper.java +++ b/src/main/java/org/prebid/server/auction/IpAddressHelper.java @@ -4,11 +4,11 @@ import inet.ipaddr.IPAddress; import inet.ipaddr.IPAddressString; import inet.ipaddr.IPAddressStringParameters; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.apache.http.conn.util.InetAddressUtils; import org.prebid.server.auction.model.IpAddress; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.List; @@ -43,7 +43,7 @@ public String anonymizeIpv6(String ip) { ? ipAddressString.toAddress().mask(ipv6AnonLeftMaskAddress).toCanonicalString() : null; } catch (AddressStringException e) { - logger.debug("Exception occurred while anonymizing IPv6 address: {0}", e.getMessage()); + logger.debug("Exception occurred while anonymizing IPv6 address: {}", e.getMessage()); return null; } } diff --git a/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java b/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java index 3a0063f66ea..35668bbf0f4 100644 --- a/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java +++ b/src/main/java/org/prebid/server/auction/OrtbTypesResolver.java @@ -6,14 +6,14 @@ import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/org/prebid/server/auction/SupplyChainResolver.java b/src/main/java/org/prebid/server/auction/SupplyChainResolver.java index 2faa20174d4..6c7246ced6f 100644 --- a/src/main/java/org/prebid/server/auction/SupplyChainResolver.java +++ b/src/main/java/org/prebid/server/auction/SupplyChainResolver.java @@ -4,13 +4,13 @@ import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.SupplyChainNode; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebidSchain; @@ -72,7 +72,7 @@ private SupplyChain existingSchainOrNull(String bidder, } if (existingSchain != null) { - logger.debug("Schain bidder {0} is rejected since it was defined more than once", bidder); + logger.debug("Schain bidder {} is rejected since it was defined more than once", bidder); return null; } diff --git a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java index 91ded451731..6b6cb533c72 100644 --- a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java +++ b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java @@ -17,8 +17,6 @@ import com.iab.openrtb.request.video.Podconfig; import io.vertx.core.Future; import io.vertx.core.file.FileSystem; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -29,6 +27,8 @@ import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.ExtIncludeBrandCategory; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; diff --git a/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java b/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java index 62cd645bcf3..b0504ec13a3 100644 --- a/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java +++ b/src/main/java/org/prebid/server/auction/model/BidRejectionTracker.java @@ -1,10 +1,10 @@ package org.prebid.server.auction.model; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.MapUtil; import java.util.Collection; diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java index afa0c83e8b1..042e130132b 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.Device; import com.iab.openrtb.request.User; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.auction.BidderAliases; @@ -12,6 +10,8 @@ import org.prebid.server.auction.model.BidderPrivacyResult; import org.prebid.server.auction.privacy.enforcement.mask.UserFpdTcfMask; import org.prebid.server.bidder.BidderCatalog; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.TcfDefinerService; diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java index c1b346b0f73..0fdf6497141 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java @@ -15,8 +15,6 @@ import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.SetUtils; @@ -41,6 +39,8 @@ import org.prebid.server.identity.IdGenerator; import org.prebid.server.json.JacksonMapper; import org.prebid.server.json.JsonMerger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.proto.openrtb.ext.request.ExtDevice; @@ -440,7 +440,7 @@ private String getDomainOrNull(String url) { try { return paramsExtractor.domainFrom(url); } catch (PreBidException e) { - logger.warn("Error occurred while populating bid request: {0}", e.getMessage()); + logger.warn("Error occurred while populating bid request: {}", e.getMessage()); return null; } } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 7d819f82618..761bd1d8434 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -10,8 +10,6 @@ import com.iab.openrtb.request.Site; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Getter; import org.apache.commons.collections4.CollectionUtils; @@ -43,6 +41,8 @@ import org.prebid.server.hooks.v1.auction.AuctionRequestPayload; import org.prebid.server.hooks.v1.entrypoint.EntrypointPayload; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.CaseInsensitiveMultiMap; @@ -496,7 +496,7 @@ private Future wrapFailure(Throwable exception, String accountId, HttpR UNKNOWN_ACCOUNT_LOGGER.warn(accountErrorMessage(exception.getMessage(), httpRequest), 100); } else { metrics.updateAccountRequestRejectedByFailedFetch(accountId); - logger.warn("Error occurred while fetching account: {0}", exception.getMessage()); + logger.warn("Error occurred while fetching account: {}", exception.getMessage()); logger.debug("Error occurred while fetching account", exception); } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java index 31e150f78cf..17724deaa03 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/VideoRequestFactory.java @@ -21,8 +21,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.auction.model.CachedDebugLog; import org.prebid.server.auction.model.WithPodErrors; -import org.prebid.server.auction.privacy.contextfactory.AuctionPrivacyContextFactory; import org.prebid.server.auction.model.debug.DebugContext; +import org.prebid.server.auction.privacy.contextfactory.AuctionPrivacyContextFactory; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConversionManager; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.json.DecodeException; diff --git a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java index 4fde2bbbcd5..0560ba01e77 100644 --- a/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java +++ b/src/main/java/org/prebid/server/bidder/BidderErrorNotifier.java @@ -1,11 +1,11 @@ package org.prebid.server.bidder; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.model.BidderCall; import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.httpclient.HttpClient; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; diff --git a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java index 2514c6c86df..b751cd3aea4 100644 --- a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java +++ b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java @@ -7,8 +7,6 @@ import io.vertx.core.CompositeFuture; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.BidderAliases; @@ -28,6 +26,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.CaseInsensitiveMultiMap; import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall; import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig; @@ -159,7 +159,7 @@ private boolean isStoredResponse(List> httpRequests, String s if (httpRequests.size() > 1) { logger.warn(""" More than one request was created for stored response, when only single stored response \ - per bidder is supported for the moment. Request to real {0} bidder will be performed.""", + per bidder is supported for the moment. Request to real {} bidder will be performed.""", bidder); return false; } @@ -239,9 +239,9 @@ private static byte[] gzip(byte[] value) { * Produces {@link Future} with {@link BidderCall} containing request and error description. */ private static Future> failResponse(Throwable exception, HttpRequest httpRequest) { - logger.warn("Error occurred while sending HTTP request to a bidder url: {0} with message: {1}", + logger.warn("Error occurred while sending HTTP request to a bidder url: {} with message: {}", httpRequest.getUri(), exception.getMessage()); - logger.debug("Error occurred while sending HTTP request to a bidder url: {0}", + logger.debug("Error occurred while sending HTTP request to a bidder url: {}", exception, httpRequest.getUri()); final BidderError.Type errorType = diff --git a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java index 584a72cf67f..053b87c5ec2 100644 --- a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java +++ b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java @@ -54,7 +54,7 @@ import org.prebid.server.util.HttpUtil; import org.prebid.server.util.ObjectUtil; -import javax.validation.ValidationException; +import jakarta.validation.ValidationException; import java.math.BigDecimal; import java.net.URISyntaxException; import java.util.ArrayList; diff --git a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java index f1b9613ebc8..201c782c409 100644 --- a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java +++ b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java @@ -28,8 +28,8 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collections; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java index 686a865dfbb..60f05103c1f 100644 --- a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java +++ b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java @@ -16,8 +16,8 @@ import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; diff --git a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java index 395ab3a7532..9c3fd9818aa 100644 --- a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java +++ b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java @@ -5,10 +5,9 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; -import org.apache.commons.collections4.MapUtils; -import org.prebid.server.bidder.openx.proto.OpenxBidResponse; import com.iab.openrtb.response.SeatBid; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; @@ -18,6 +17,7 @@ import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.bidder.openx.model.OpenxImpType; +import org.prebid.server.bidder.openx.proto.OpenxBidResponse; import org.prebid.server.bidder.openx.proto.OpenxBidResponseExt; import org.prebid.server.bidder.openx.proto.OpenxRequestExt; import org.prebid.server.bidder.openx.proto.OpenxVideoExt; diff --git a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java index 311e2e1ee69..296071b0765 100644 --- a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java +++ b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java @@ -5,9 +5,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import com.iab.openrtb.response.Bid; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.bidder.Bidder; diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 4f4e8b455b3..27d6dc59ff9 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -29,8 +29,6 @@ import com.iab.openrtb.response.Bid; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -80,6 +78,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.FlexibleExtension; import org.prebid.server.proto.openrtb.ext.request.ExtApp; diff --git a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java index b5794ce7368..3a9bbf1ce88 100644 --- a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java +++ b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java @@ -17,8 +17,8 @@ import org.apache.http.client.utils.URIBuilder; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.HttpRequest; import org.prebid.server.bidder.model.Result; import org.prebid.server.exception.PreBidException; diff --git a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java index 6a547009892..f6868ef878f 100644 --- a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java +++ b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java @@ -16,8 +16,6 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -33,6 +31,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; diff --git a/src/main/java/org/prebid/server/cache/CacheService.java b/src/main/java/org/prebid/server/cache/CacheService.java index cb4c48a6c6c..be8ff4a3f89 100644 --- a/src/main/java/org/prebid/server/cache/CacheService.java +++ b/src/main/java/org/prebid/server/cache/CacheService.java @@ -7,8 +7,6 @@ import com.iab.openrtb.response.Bid; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -35,6 +33,8 @@ import org.prebid.server.identity.UUIDIdGenerator; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.response.BidType; @@ -185,7 +185,7 @@ private Future makeRequest(BidCacheRequest bidCacheRequest, private Future failResponse(Throwable exception, String accountId, long startTime) { metrics.updateCacheRequestFailedTime(accountId, clock.millis() - startTime); - logger.warn("Error occurred while interacting with cache service: {0}", exception.getMessage()); + logger.warn("Error occurred while interacting with cache service: {}", exception.getMessage()); logger.debug("Error occurred while interacting with cache service", exception); return Future.failedFuture(exception); @@ -423,7 +423,7 @@ private CacheServiceResult failResponseOpenrtb(Throwable exception, CacheHttpRequest request, long startTime) { - logger.warn("Error occurred while interacting with cache service: {0}", exception.getMessage()); + logger.warn("Error occurred while interacting with cache service: {}", exception.getMessage()); logger.debug("Error occurred while interacting with cache service", exception); metrics.updateCacheRequestFailedTime(accountId, clock.millis() - startTime); diff --git a/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java b/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java index 9a2cd932a09..d3c0dae7150 100644 --- a/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java +++ b/src/main/java/org/prebid/server/cookie/PrioritizedCoopSyncProvider.java @@ -1,8 +1,8 @@ package org.prebid.server.cookie; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.bidder.BidderCatalog; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.AccountCookieSyncConfig; @@ -39,15 +39,15 @@ private static Set validCoopSyncBidders(Set bidders, BidderCatal for (String bidder : bidders) { if (!bidderCatalog.isValidName(bidder)) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but is invalid bidder name, ignoring""", bidder); } else if (!bidderCatalog.isActive(bidder)) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but disabled in current pbs instance, ignoring""", bidder); } else if (bidderCatalog.usersyncerByName(bidder).isEmpty()) { logger.info(""" - bidder {0} is provided for prioritized coop-syncing, \ + bidder {} is provided for prioritized coop-syncing, \ but has no user-sync configuration, ignoring""", bidder); } else { validBidders.add(bidder); diff --git a/src/main/java/org/prebid/server/cookie/UidsCookieService.java b/src/main/java/org/prebid/server/cookie/UidsCookieService.java index 7416abfdfa2..6b608f06307 100644 --- a/src/main/java/org/prebid/server/cookie/UidsCookieService.java +++ b/src/main/java/org/prebid/server/cookie/UidsCookieService.java @@ -3,8 +3,6 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.http.Cookie; import io.vertx.core.http.CookieSameSite; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.cookie.model.UidWithExpiry; @@ -12,6 +10,8 @@ import org.prebid.server.cookie.proto.Uids; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.util.HttpUtil; @@ -131,7 +131,7 @@ public Uids parseUids(Map cookies) { try { return mapper.decodeValue(Buffer.buffer(Base64.getUrlDecoder().decode(cookieValue)), Uids.class); } catch (IllegalArgumentException | DecodeException e) { - logger.debug("Could not decode or parse {0} cookie value {1}", e, COOKIE_NAME, cookieValue); + logger.debug("Could not decode or parse {} cookie value {}", e, COOKIE_NAME, cookieValue); } } return null; diff --git a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java index 9b6d81f77ee..09f5c16f46d 100644 --- a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java +++ b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java @@ -2,15 +2,16 @@ import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.currency.proto.CurrencyConversionRates; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; 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; @@ -67,19 +68,23 @@ public CurrencyConversionService(ExternalConversionProperties externalConversion * Must be called on Vertx event loop thread. */ @Override - public void initialize() { + public void initialize(Promise initializePromise) { if (externalConversionProperties != null) { final Long refreshPeriod = externalConversionProperties.getRefreshPeriodMs(); final Long defaultTimeout = externalConversionProperties.getDefaultTimeoutMs(); final HttpClient httpClient = externalConversionProperties.getHttpClient(); final Vertx vertx = externalConversionProperties.getVertx(); - vertx.setPeriodic(refreshPeriod, ignored -> populatesLatestCurrencyRates(currencyServerUrl, defaultTimeout, + vertx.setPeriodic(refreshPeriod, ignored -> populatesLatestCurrencyRates( + currencyServerUrl, + defaultTimeout, httpClient)); populatesLatestCurrencyRates(currencyServerUrl, defaultTimeout, httpClient); externalConversionProperties.getMetrics().createCurrencyRatesGauge(this::isRatesStale); } + + initializePromise.tryComplete(); } /** diff --git a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java index f47faf082a7..9a6416ba44c 100644 --- a/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java +++ b/src/main/java/org/prebid/server/execution/RemoteFileSyncer.java @@ -1,48 +1,50 @@ package org.prebid.server.execution; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.file.AsyncFile; import io.vertx.core.file.CopyOptions; import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; import io.vertx.core.file.OpenOptions; import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import io.vertx.core.http.HttpHeaders; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; -import io.vertx.core.streams.Pump; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; -import org.prebid.server.execution.retry.Retryable; import org.prebid.server.execution.retry.RetryPolicy; +import org.prebid.server.execution.retry.Retryable; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Paths; import java.util.Objects; -import java.util.concurrent.TimeoutException; public class RemoteFileSyncer { private static final Logger logger = LoggerFactory.getLogger(RemoteFileSyncer.class); + private final RemoteFileProcessor processor; private final String downloadUrl; private final String saveFilePath; private final String tmpFilePath; private final RetryPolicy retryPolicy; - private final long timeout; private final long updatePeriod; private final HttpClient httpClient; private final Vertx vertx; private final FileSystem fileSystem; + private final RequestOptions getFileRequestOptions; + private final RequestOptions isUpdateRequiredRequestOptions; - public RemoteFileSyncer(String downloadUrl, + public RemoteFileSyncer(RemoteFileProcessor processor, + String downloadUrl, String saveFilePath, String tmpFilePath, RetryPolicy retryPolicy, @@ -51,11 +53,11 @@ public RemoteFileSyncer(String downloadUrl, HttpClient httpClient, Vertx vertx) { + this.processor = Objects.requireNonNull(processor); this.downloadUrl = HttpUtil.validateUrl(downloadUrl); this.saveFilePath = Objects.requireNonNull(saveFilePath); this.tmpFilePath = Objects.requireNonNull(tmpFilePath); this.retryPolicy = Objects.requireNonNull(retryPolicy); - this.timeout = timeout; this.updatePeriod = updatePeriod; this.httpClient = Objects.requireNonNull(httpClient); this.vertx = Objects.requireNonNull(vertx); @@ -63,6 +65,16 @@ public RemoteFileSyncer(String downloadUrl, createAndCheckWritePermissionsFor(fileSystem, saveFilePath); createAndCheckWritePermissionsFor(fileSystem, tmpFilePath); + + getFileRequestOptions = new RequestOptions() + .setMethod(HttpMethod.GET) + .setTimeout(timeout) + .setAbsoluteURI(downloadUrl); + + isUpdateRequiredRequestOptions = new RequestOptions() + .setMethod(HttpMethod.HEAD) + .setTimeout(timeout) + .setAbsoluteURI(downloadUrl); } private static void createAndCheckWritePermissionsFor(FileSystem fileSystem, String filePath) { @@ -79,197 +91,80 @@ private static void createAndCheckWritePermissionsFor(FileSystem fileSystem, Str } } - public void sync(RemoteFileProcessor processor) { - isFileExists(saveFilePath) - .compose(exists -> exists ? processSavedFile(processor) : syncRemoteFiles(retryPolicy)) - .onComplete(syncResult -> handleSync(processor, syncResult)); - } - - private Future isFileExists(String filePath) { - final Promise promise = Promise.promise(); - fileSystem.exists(filePath, async -> { - if (async.succeeded()) { - promise.complete(async.result()); - } else { - promise.fail("Cant check if file exists " + filePath); - } - }); - return promise.future(); + public void sync() { + fileSystem.exists(saveFilePath) + .compose(exists -> exists ? processSavedFile() : syncRemoteFile(retryPolicy)) + .onComplete(ignored -> setUpDeferredUpdate()); } - private Future processSavedFile(RemoteFileProcessor processor) { + private Future processSavedFile() { return processor.setDataPath(saveFilePath) - .map(false) - .recover(ignored -> removeCorruptedSaveFile()); + .onFailure(error -> logger.error("Can't process saved file: " + saveFilePath)) + .recover(ignored -> deleteFile(saveFilePath).mapEmpty()) + .mapEmpty(); } - private Future removeCorruptedSaveFile() { - return deleteFileIfExists(saveFilePath) - .compose(ignored -> syncRemoteFiles(retryPolicy)) - .recover(error -> Future.failedFuture(new PreBidException( - "Corrupted file %s can't be deleted. Please check permission or delete manually." - .formatted(saveFilePath), error))); + private Future deleteFile(String filePath) { + return fileSystem.delete(filePath) + .onFailure(error -> logger.error("Can't delete corrupted file: " + saveFilePath)); } - private Future syncRemoteFiles(RetryPolicy retryPolicy) { - return deleteFileIfExists(tmpFilePath) - .compose(ignored -> downloadToTempFile()) - .recover(error -> retrySync(retryPolicy)) - .compose(downloadResult -> swapFiles()) - .map(true); - } + private Future syncRemoteFile(RetryPolicy retryPolicy) { + return fileSystem.open(tmpFilePath, new OpenOptions()) - private Future deleteFileIfExists(String filePath) { - return isFileExists(filePath) - .compose(exists -> exists ? deleteFile(filePath) : Future.succeededFuture()); - } + .compose(tmpFile -> httpClient.request(getFileRequestOptions) + .compose(HttpClientRequest::send) + .compose(response -> response.pipeTo(tmpFile)) + .onComplete(result -> tmpFile.close())) - private Future deleteFile(String filePath) { - final Promise promise = Promise.promise(); - fileSystem.delete(filePath, promise); - return promise.future(); - } + .compose(ignored -> fileSystem.move( + tmpFilePath, saveFilePath, new CopyOptions().setReplaceExisting(true))) - private Future downloadToTempFile() { - return openFile(tmpFilePath) - .compose(tmpFile -> requestData() - .compose(response -> pumpToFile(response, tmpFile))); - } + .compose(ignored -> processSavedFile()) + .onFailure(ignored -> deleteFile(tmpFilePath)) + .onFailure(error -> logger.error("Could not sync remote file", error)) + + .recover(error -> retrySync(retryPolicy).mapEmpty()) + .mapEmpty(); - private Future requestData() { - final Promise promise = Promise.promise(); - httpClient.getAbs(downloadUrl, promise::complete).end(); - return promise.future(); } private Future retrySync(RetryPolicy retryPolicy) { if (retryPolicy instanceof Retryable policy) { - logger.info("Retrying file download from {0} with policy: {1}", downloadUrl, retryPolicy); + logger.info("Retrying file download from {} with policy: {}", downloadUrl, retryPolicy); final Promise promise = Promise.promise(); - vertx.setTimer(policy.delay(), timerId -> - syncRemoteFiles(policy.next()) - .onFailure(promise::fail) - .onSuccess(ignored -> promise.complete())); - + vertx.setTimer(policy.delay(), timerId -> syncRemoteFile(policy.next()).onComplete(promise)); return promise.future(); } else { return Future.failedFuture(new PreBidException("File sync failed")); } } - private Future openFile(String path) { - final Promise promise = Promise.promise(); - fileSystem.open(path, new OpenOptions().setCreateNew(true), promise); - return promise.future(); - } - - private Future pumpToFile(HttpClientResponse httpClientResponse, AsyncFile asyncFile) { - final Promise promise = Promise.promise(); - logger.info("Trying to download file from {0}", downloadUrl); - httpClientResponse.pause(); - - final Pump pump = Pump.pump(httpClientResponse, asyncFile); - pump.start(); - - httpClientResponse.resume(); - final long timeoutTimerId = setTimeoutTimer(asyncFile, pump, promise); - httpClientResponse.endHandler(responseEndResult -> handleResponseEnd(asyncFile, timeoutTimerId, promise)); - - return promise.future(); - } - - private long setTimeoutTimer(AsyncFile asyncFile, Pump pump, Promise promise) { - return vertx.setTimer(timeout, timerId -> handleTimeout(asyncFile, pump, promise)); - } - - private void handleTimeout(AsyncFile asyncFile, Pump pump, Promise promise) { - pump.stop(); - asyncFile.close(); - if (!promise.future().isComplete()) { - promise.fail(new TimeoutException("Timeout on download")); - } - } - - private void handleResponseEnd(AsyncFile asyncFile, long idTimer, Promise promise) { - vertx.cancelTimer(idTimer); - asyncFile.flush().close(promise); - } - - private Future swapFiles() { - final Promise promise = Promise.promise(); - logger.info("Sync {0} to {1}", tmpFilePath, saveFilePath); - - final CopyOptions copyOptions = new CopyOptions().setReplaceExisting(true); - fileSystem.move(tmpFilePath, saveFilePath, copyOptions, promise); - return promise.future(); - } - - private void handleSync(RemoteFileProcessor remoteFileProcessor, AsyncResult syncResult) { - if (syncResult.succeeded()) { - if (syncResult.result()) { - logger.info("Sync service for {0}", saveFilePath); - remoteFileProcessor.setDataPath(saveFilePath) - .onComplete(this::logFileProcessStatus); - } else { - logger.info("Sync is not required for {0}", saveFilePath); - } - } else { - logger.error("Cant sync file from {0}", syncResult.cause(), downloadUrl); - } - - // setup new update regardless of the result + private void setUpDeferredUpdate() { if (updatePeriod > 0) { - vertx.setTimer(updatePeriod, idUpdateNew -> configureAutoUpdates(remoteFileProcessor)); + vertx.setPeriodic(updatePeriod, ignored -> updateIfNeeded()); } } - private void logFileProcessStatus(AsyncResult serviceRespond) { - if (serviceRespond.succeeded()) { - logger.info("Service successfully received file {0}.", saveFilePath); - } else { - logger.error("Service cant process file {0} and still unavailable.", saveFilePath); - } - } - - private void configureAutoUpdates(RemoteFileProcessor remoteFileProcessor) { - logger.info("Check for updated for {0}", saveFilePath); - tryUpdate().onComplete(asyncUpdate -> { - if (asyncUpdate.failed()) { - logger.warn("File {0} update failed", asyncUpdate.cause(), saveFilePath); - } - handleSync(remoteFileProcessor, asyncUpdate); - }); + private void updateIfNeeded() { + httpClient.request(isUpdateRequiredRequestOptions) + .compose(HttpClientRequest::send) + .compose(response -> fileSystem.exists(saveFilePath) + .compose(exists -> exists + ? isLengthChanged(response) + : Future.succeededFuture(true))) + .onSuccess(shouldUpdate -> { + if (shouldUpdate) { + syncRemoteFile(retryPolicy); + } + }); } - private Future tryUpdate() { - return isFileExists(saveFilePath) - .compose(fileExists -> fileExists ? isUpdateRequired() : Future.succeededFuture(true)) - .compose(needUpdate -> needUpdate ? syncRemoteFiles(retryPolicy) : Future.succeededFuture(false)); - } - - private Future isUpdateRequired() { - final Promise isUpdateRequired = Promise.promise(); - httpClient.headAbs(downloadUrl, response -> checkNewVersion(response, isUpdateRequired)) - .exceptionHandler(isUpdateRequired::fail) - .end(); - return isUpdateRequired.future(); - } - - private void checkNewVersion(HttpClientResponse response, Promise isUpdateRequired) { + private Future isLengthChanged(HttpClientResponse response) { final String contentLengthParameter = response.getHeader(HttpHeaders.CONTENT_LENGTH); - if (StringUtils.isNumeric(contentLengthParameter) && !contentLengthParameter.equals("0")) { - final long contentLength = Long.parseLong(contentLengthParameter); - fileSystem.props(saveFilePath, filePropsResult -> { - if (filePropsResult.succeeded()) { - logger.info("Prev length = {0}, new length = {1}", filePropsResult.result().size(), contentLength); - isUpdateRequired.complete(filePropsResult.result().size() != contentLength); - } else { - isUpdateRequired.fail(filePropsResult.cause()); - } - }); - } else { - isUpdateRequired.fail("ContentLength is invalid: " + contentLengthParameter); - } + return StringUtils.isNumeric(contentLengthParameter) && !contentLengthParameter.equals("0") + ? fileSystem.props(saveFilePath).map(props -> props.size() != Long.parseLong(contentLengthParameter)) + : Future.failedFuture("ContentLength is invalid: " + contentLengthParameter); } } diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java index 9e8734576bb..c5bb0e5aa1e 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.BooleanUtils; @@ -24,6 +22,8 @@ import org.prebid.server.floors.model.PriceFloorEnforcement; import org.prebid.server.floors.model.PriceFloorRules; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java index f5cf62aeb72..c8b6dd17969 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java @@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -22,6 +20,8 @@ import org.prebid.server.floors.proto.FetchStatus; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebidFloors; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java index 6ce588f9c68..87e293d3b7d 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java @@ -15,8 +15,6 @@ import com.iab.openrtb.request.Publisher; import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Video; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; @@ -35,6 +33,8 @@ import org.prebid.server.geolocation.CountryCodeMapper; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; diff --git a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java index 39f95f63860..f06d136df48 100644 --- a/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java +++ b/src/main/java/org/prebid/server/floors/PriceFloorFetcher.java @@ -6,8 +6,6 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpHeaders; import io.vertx.core.impl.ConcurrentHashSet; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -22,6 +20,8 @@ import org.prebid.server.floors.proto.FetchStatus; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.ApplicationSettings; diff --git a/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java b/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java index f8d5f3baa3c..d47ed2da32c 100644 --- a/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java +++ b/src/main/java/org/prebid/server/floors/PriceFloorsConfigResolver.java @@ -1,11 +1,11 @@ package org.prebid.server.floors; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.EnrichingApplicationSettings; diff --git a/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java b/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java index 77c2e1c0cab..c75af39004d 100644 --- a/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java +++ b/src/main/java/org/prebid/server/floors/model/PriceFloorDebugProperties.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; @Validated @Data diff --git a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java index f7a2c6ca6b9..791a1da06c1 100755 --- a/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java +++ b/src/main/java/org/prebid/server/geolocation/CircuitBreakerSecuredGeoLocationService.java @@ -2,11 +2,11 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.model.GeoInfo; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; diff --git a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java index 343aa09fcef..5ce337fe134 100644 --- a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java +++ b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java @@ -5,8 +5,6 @@ import io.vertx.core.Future; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.BooleanUtils; import org.prebid.server.activity.infrastructure.creator.ActivityInfrastructureCreator; @@ -31,6 +29,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; import org.prebid.server.privacy.gdpr.model.TcfContext; diff --git a/src/main/java/org/prebid/server/handler/ExceptionHandler.java b/src/main/java/org/prebid/server/handler/ExceptionHandler.java index 952d46dd47e..f56a21d8e5c 100644 --- a/src/main/java/org/prebid/server/handler/ExceptionHandler.java +++ b/src/main/java/org/prebid/server/handler/ExceptionHandler.java @@ -1,9 +1,9 @@ package org.prebid.server.handler; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import java.io.IOException; @@ -26,7 +26,7 @@ public static ExceptionHandler create(Metrics metrics) { @Override public void handle(Throwable exception) { if (shouldLogException(exception)) { - logger.warn("Generic error handler: {0}, cause: {1}", + logger.warn("Generic error handler: {}, cause: {}", errorMessageFrom(exception), errorMessageFrom(exception.getCause())); } metrics.updateConnectionAcceptErrors(); diff --git a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java index 61c986c12cc..971cb82204f 100644 --- a/src/main/java/org/prebid/server/handler/NotificationEventHandler.java +++ b/src/main/java/org/prebid/server/handler/NotificationEventHandler.java @@ -7,8 +7,6 @@ import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Value; import org.prebid.server.activity.infrastructure.ActivityInfrastructure; @@ -21,6 +19,8 @@ import org.prebid.server.events.EventUtil; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.model.HttpRequestContext; import org.prebid.server.settings.ApplicationSettings; diff --git a/src/main/java/org/prebid/server/handler/OptoutHandler.java b/src/main/java/org/prebid/server/handler/OptoutHandler.java index e8ee98b2683..48551d37b03 100644 --- a/src/main/java/org/prebid/server/handler/OptoutHandler.java +++ b/src/main/java/org/prebid/server/handler/OptoutHandler.java @@ -4,12 +4,12 @@ import io.vertx.core.AsyncResult; import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.cookie.UidsCookie; import org.prebid.server.cookie.UidsCookieService; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.optout.model.RecaptchaResponse; diff --git a/src/main/java/org/prebid/server/handler/SetuidHandler.java b/src/main/java/org/prebid/server/handler/SetuidHandler.java index 3f119079d83..bbe0244cc1b 100644 --- a/src/main/java/org/prebid/server/handler/SetuidHandler.java +++ b/src/main/java/org/prebid/server/handler/SetuidHandler.java @@ -8,8 +8,6 @@ import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerRequest; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; @@ -41,6 +39,8 @@ import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; import org.prebid.server.privacy.HostVendorTcfDefinerService; diff --git a/src/main/java/org/prebid/server/handler/VtrackHandler.java b/src/main/java/org/prebid/server/handler/VtrackHandler.java index 3a50ee05cfd..3059365103b 100644 --- a/src/main/java/org/prebid/server/handler/VtrackHandler.java +++ b/src/main/java/org/prebid/server/handler/VtrackHandler.java @@ -7,8 +7,6 @@ import io.vertx.core.Future; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; @@ -24,6 +22,8 @@ import org.prebid.server.json.DecodeException; import org.prebid.server.json.EncodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.model.Account; diff --git a/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java index f9b52a807e4..c57e61b9b71 100644 --- a/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/CurrencyRatesHandler.java @@ -4,13 +4,13 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.AllArgsConstructor; import lombok.Value; import org.prebid.server.currency.CurrencyConversionService; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.io.IOException; diff --git a/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java index 42eb8368bd3..d237a542ed7 100644 --- a/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/SettingsCacheNotificationHandler.java @@ -3,6 +3,7 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.RoutingContext; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; @@ -31,10 +32,13 @@ public SettingsCacheNotificationHandler(CacheNotificationListener cacheNotificat @Override public void handle(RoutingContext routingContext) { - switch (routingContext.request().method()) { - case POST -> doSave(routingContext); - case DELETE -> doInvalidate(routingContext); - default -> doFail(routingContext); + final HttpMethod method = routingContext.request().method(); + if (method.equals(HttpMethod.POST)) { + doSave(routingContext); + } else if (method.equals(HttpMethod.DELETE)) { + doInvalidate(routingContext); + } else { + doFail(routingContext); } } diff --git a/src/main/java/org/prebid/server/handler/admin/VersionHandler.java b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java index adf8088e423..1c48f79a74a 100644 --- a/src/main/java/org/prebid/server/handler/admin/VersionHandler.java +++ b/src/main/java/org/prebid/server/handler/admin/VersionHandler.java @@ -3,13 +3,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Handler; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.AllArgsConstructor; import lombok.Value; import org.apache.commons.lang3.StringUtils; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.util.HttpUtil; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index e50e6018293..b6fb1ea046c 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -15,8 +15,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -39,6 +37,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -401,7 +401,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable exception) { - logger.warn("Failed to send amp response: {0}", exception.getMessage()); + logger.warn("Failed to send amp response: {}", exception.getMessage()); metrics.updateRequestTypeMetric(REQUEST_TYPE_METRIC, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index c5a463dce95..4bbc18c53c3 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -8,8 +8,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.prebid.server.analytics.model.AuctionEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; @@ -25,6 +23,8 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -254,7 +254,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable throwable, MetricName requestType) { - logger.warn("Failed to send auction response: {0}", throwable.getMessage()); + logger.warn("Failed to send auction response: {}", throwable.getMessage()); metrics.updateRequestTypeMetric(requestType, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java index 76831745c47..7ee8f4206ae 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/VideoHandler.java @@ -6,8 +6,6 @@ import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.prebid.server.analytics.model.VideoEvent; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; @@ -21,6 +19,8 @@ import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.Endpoint; @@ -147,7 +147,7 @@ private void handleResult(AsyncResult responseResult, if (exception instanceof InvalidRequestException) { metricRequestStatus = MetricName.badinput; errorMessages = ((InvalidRequestException) exception).getMessages(); - logger.info("Invalid request format: {0}", errorMessages); + logger.info("Invalid request format: {}", errorMessages); status = HttpResponseStatus.BAD_REQUEST; body = errorMessages.stream() @@ -156,7 +156,7 @@ private void handleResult(AsyncResult responseResult, } else if (exception instanceof UnauthorizedAccountException) { metricRequestStatus = MetricName.badinput; final String errorMessage = exception.getMessage(); - logger.info("Unauthorized: {0}", errorMessage); + logger.info("Unauthorized: {}", errorMessage); errorMessages = Collections.singletonList(errorMessage); status = HttpResponseStatus.UNAUTHORIZED; @@ -236,7 +236,7 @@ private void respondWith(RoutingContext routingContext, } private void handleResponseException(Throwable throwable) { - logger.warn("Failed to send video response: {0}", throwable.getMessage()); + logger.warn("Failed to send video response: {}", throwable.getMessage()); metrics.updateRequestTypeMetric(REQUEST_TYPE_METRIC, MetricName.networkerr); } diff --git a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java index 394477d1be4..2525651f872 100644 --- a/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java +++ b/src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java @@ -4,7 +4,6 @@ import io.vertx.core.Future; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.hooks.execution.model.ExecutionGroup; import org.prebid.server.hooks.execution.model.HookExecutionContext; import org.prebid.server.hooks.execution.model.HookId; @@ -12,6 +11,7 @@ import org.prebid.server.hooks.v1.InvocationContext; import org.prebid.server.hooks.v1.InvocationResult; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import java.time.Clock; import java.util.concurrent.TimeoutException; diff --git a/src/main/java/org/prebid/server/hooks/execution/GroupResult.java b/src/main/java/org/prebid/server/hooks/execution/GroupResult.java index 47ee0cc3019..a4487e3a60b 100644 --- a/src/main/java/org/prebid/server/hooks/execution/GroupResult.java +++ b/src/main/java/org/prebid/server/hooks/execution/GroupResult.java @@ -1,6 +1,5 @@ package org.prebid.server.hooks.execution; -import io.vertx.core.logging.LoggerFactory; import lombok.Getter; import lombok.experimental.Accessors; import org.prebid.server.hooks.execution.model.ExecutionAction; @@ -13,6 +12,7 @@ import org.prebid.server.hooks.v1.InvocationStatus; import org.prebid.server.hooks.v1.PayloadUpdate; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/prebid/server/log/ConditionalLogger.java b/src/main/java/org/prebid/server/log/ConditionalLogger.java index 899c0d25251..f3e17bb9ed0 100644 --- a/src/main/java/org/prebid/server/log/ConditionalLogger.java +++ b/src/main/java/org/prebid/server/log/ConditionalLogger.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import com.github.benmanes.caffeine.cache.Caffeine; -import io.vertx.core.logging.Logger; import org.apache.commons.lang3.ObjectUtils; import java.time.Instant; diff --git a/src/main/java/org/prebid/server/log/Criteria.java b/src/main/java/org/prebid/server/log/Criteria.java index 7ad5c3039fd..dd6f3cd123f 100644 --- a/src/main/java/org/prebid/server/log/Criteria.java +++ b/src/main/java/org/prebid/server/log/Criteria.java @@ -1,6 +1,5 @@ package org.prebid.server.log; -import io.vertx.core.logging.Logger; import org.apache.commons.lang3.StringUtils; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/log/CriteriaLogManager.java b/src/main/java/org/prebid/server/log/CriteriaLogManager.java index 20344901a31..75ca28f5f81 100644 --- a/src/main/java/org/prebid/server/log/CriteriaLogManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaLogManager.java @@ -3,8 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.response.BidResponse; import io.vertx.core.impl.ConcurrentHashSet; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.json.EncodeException; import org.prebid.server.json.JacksonMapper; @@ -38,7 +36,7 @@ public BidResponse traceResponse(Logger logger, jsonBidResponse = mapper.encodeToString(bidResponse); jsonBidRequest = debugEnabled ? null : mapper.encodeToString(bidRequest); } catch (EncodeException e) { - CriteriaLogManager.logger.warn("Failed to parse bidResponse or bidRequest to json string: {0}", e); + CriteriaLogManager.logger.warn("Failed to parse bidResponse or bidRequest to json string: {}", e); return bidResponse; } diff --git a/src/main/java/org/prebid/server/log/CriteriaManager.java b/src/main/java/org/prebid/server/log/CriteriaManager.java index e55087ce50a..8602f182d2e 100644 --- a/src/main/java/org/prebid/server/log/CriteriaManager.java +++ b/src/main/java/org/prebid/server/log/CriteriaManager.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; import java.util.function.BiConsumer; diff --git a/src/main/java/org/prebid/server/log/HttpInteractionLogger.java b/src/main/java/org/prebid/server/log/HttpInteractionLogger.java index 15cf54303c0..cc89b9cb57b 100644 --- a/src/main/java/org/prebid/server/log/HttpInteractionLogger.java +++ b/src/main/java/org/prebid/server/log/HttpInteractionLogger.java @@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import lombok.Value; import org.apache.commons.collections4.CollectionUtils; @@ -47,7 +45,7 @@ public void maybeLogOpenrtb2Auction(AuctionContext auctionContext, if (interactionSatisfiesSpec(HttpLogSpec.Endpoint.auction, statusCode, auctionContext)) { logger.info( - "Requested URL: \"{0}\", request body: \"{1}\", response status: \"{2}\", response body: \"{3}\"", + "Requested URL: \"{}\", request body: \"{}\", response status: \"{}\", response body: \"{}\"", routingContext.request().uri(), toOneLineString(routingContext.getBodyAsString()), statusCode, @@ -72,7 +70,7 @@ public void maybeLogOpenrtb2Amp(AuctionContext auctionContext, if (interactionSatisfiesSpec(HttpLogSpec.Endpoint.amp, statusCode, auctionContext)) { logger.info( - "Requested URL: \"{0}\", response status: \"{1}\", response body: \"{2}\"", + "Requested URL: \"{}\", response status: \"{}\", response body: \"{}\"", routingContext.request().uri(), statusCode, responseBody); @@ -87,7 +85,7 @@ public void maybeLogBidderRequest(AuctionContext context, BidderRequest bidderRe final BidRequest bidRequest = bidderRequest.getBidRequest(); final BidRequest updatedBidRequest = bidRequestWithBidderName(bidder, bidRequest); final String jsonBidRequest = mapper.encodeToString(updatedBidRequest); - logger.info("Request body to {0}: \"{1}\"", bidder, jsonBidRequest); + logger.info("Request body to {}: \"{}\"", bidder, jsonBidRequest); incLoggedInteractions(); } diff --git a/src/main/java/org/prebid/server/log/Logger.java b/src/main/java/org/prebid/server/log/Logger.java new file mode 100644 index 00000000000..9a595f0de2e --- /dev/null +++ b/src/main/java/org/prebid/server/log/Logger.java @@ -0,0 +1,141 @@ +package org.prebid.server.log; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.message.FormattedMessage; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.spi.ExtendedLogger; + +public class Logger { + + private static final String FQCN = Logger.class.getCanonicalName(); + + private final ExtendedLogger delegate; + + Logger(ExtendedLogger delegate) { + this.delegate = delegate; + } + + public boolean isWarnEnabled() { + return delegate.isWarnEnabled(); + } + + public boolean isInfoEnabled() { + return delegate.isInfoEnabled(); + } + + public boolean isDebugEnabled() { + return delegate.isDebugEnabled(); + } + + public boolean isTraceEnabled() { + return delegate.isTraceEnabled(); + } + + public void fatal(Object message) { + log(Level.FATAL, message); + } + + public void fatal(Object message, Throwable t) { + log(Level.FATAL, message, t); + } + + public void error(Object message) { + log(Level.ERROR, message); + } + + public void error(Object message, Object... params) { + log(Level.ERROR, message.toString(), params); + } + + public void error(Object message, Throwable t) { + log(Level.ERROR, message, t); + } + + public void error(Object message, Throwable t, Object... params) { + log(Level.ERROR, message.toString(), t, params); + } + + public void warn(Object message) { + log(Level.WARN, message); + } + + public void warn(Object message, Object... params) { + log(Level.WARN, message.toString(), params); + } + + public void warn(Object message, Throwable t) { + log(Level.WARN, message, t); + } + + public void warn(Object message, Throwable t, Object... params) { + log(Level.WARN, message.toString(), t, params); + } + + public void info(Object message) { + log(Level.INFO, message); + } + + public void info(Object message, Object... params) { + log(Level.INFO, message.toString(), params); + } + + public void info(Object message, Throwable t) { + log(Level.INFO, message, t); + } + + public void info(Object message, Throwable t, Object... params) { + log(Level.INFO, message.toString(), t, params); + } + + public void debug(Object message) { + log(Level.DEBUG, message); + } + + public void debug(Object message, Object... params) { + log(Level.DEBUG, message.toString(), params); + } + + public void debug(Object message, Throwable t) { + log(Level.DEBUG, message, t); + } + + public void debug(Object message, Throwable t, Object... params) { + log(Level.DEBUG, message.toString(), t, params); + } + + public void trace(Object message) { + log(Level.TRACE, message); + } + + public void trace(Object message, Object... params) { + log(Level.TRACE, message.toString(), params); + } + + public void trace(Object message, Throwable t) { + log(Level.TRACE, message.toString(), t); + } + + public void trace(Object message, Throwable t, Object... params) { + log(Level.TRACE, message.toString(), t, params); + } + + private void log(Level level, Object message) { + log(level, message, null); + } + + private void log(Level level, Object message, Throwable t) { + if (message instanceof Message) { + delegate.logIfEnabled(FQCN, level, null, (Message) message, t); + } else { + delegate.logIfEnabled(FQCN, level, null, message, t); + } + } + + private void log(Level level, String message, Object... params) { + delegate.logIfEnabled(FQCN, level, null, message, params); + } + + private void log(Level level, String message, Throwable t, Object... params) { + delegate.logIfEnabled(FQCN, level, null, new FormattedMessage(message, params), t); + } +} diff --git a/src/main/java/org/prebid/server/log/LoggerFactory.java b/src/main/java/org/prebid/server/log/LoggerFactory.java new file mode 100644 index 00000000000..7e10b4ac234 --- /dev/null +++ b/src/main/java/org/prebid/server/log/LoggerFactory.java @@ -0,0 +1,22 @@ +package org.prebid.server.log; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.spi.ExtendedLogger; + +public class LoggerFactory { + + private LoggerFactory() { + } + + public static Logger getLogger(Class clazz) { + final String name = clazz.isAnonymousClass() + ? clazz.getEnclosingClass().getCanonicalName() + : clazz.getCanonicalName(); + + return getLogger(name); + } + + public static Logger getLogger(String name) { + return new Logger((ExtendedLogger) LogManager.getLogger(name)); + } +} diff --git a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java index a37533586e7..184f7033f7f 100644 --- a/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java +++ b/src/main/java/org/prebid/server/optout/GoogleRecaptchaVerifier.java @@ -3,11 +3,11 @@ import io.netty.handler.codec.http.HttpHeaderValues; import io.vertx.core.Future; import io.vertx.core.MultiMap; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.exception.PreBidException; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.optout.model.RecaptchaResponse; import org.prebid.server.util.HttpUtil; import org.prebid.server.vertx.httpclient.HttpClient; diff --git a/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java b/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java index a555f60608b..471eb5715e3 100644 --- a/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java +++ b/src/main/java/org/prebid/server/privacy/HostVendorTcfDefinerService.java @@ -1,9 +1,9 @@ package org.prebid.server.privacy; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.experimental.Delegate; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.gdpr.TcfDefinerService; import org.prebid.server.privacy.gdpr.model.HostVendorTcfResponse; import org.prebid.server.privacy.gdpr.model.TcfContext; diff --git a/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java b/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java index 5f2e6df2025..bae5cf4370b 100644 --- a/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java +++ b/src/main/java/org/prebid/server/privacy/PrivacyExtractor.java @@ -4,13 +4,13 @@ import com.iab.openrtb.request.Regs; import com.iab.openrtb.request.User; import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.ccpa.Ccpa; import org.prebid.server.privacy.model.Privacy; import org.prebid.server.proto.request.CookieSyncRequest; diff --git a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java index ee9b13eb4cc..27f6b25b96a 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java @@ -2,8 +2,6 @@ import com.iabtcf.decoder.TCString; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.Value; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; @@ -15,6 +13,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.geolocation.model.GeoInfo; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.model.PrivacyEnforcementAction; diff --git a/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java b/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java index 8324d606e79..ce9fcd2dc70 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/tcfstrategies/purpose/typestrategies/BasicEnforcePurposeStrategy.java @@ -1,8 +1,8 @@ package org.prebid.server.privacy.gdpr.tcfstrategies.purpose.typestrategies; import com.iabtcf.decoder.TCString; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.privacy.gdpr.model.VendorPermission; import org.prebid.server.privacy.gdpr.model.VendorPermissionWithGvl; import org.prebid.server.privacy.gdpr.vendorlist.proto.PurposeCode; @@ -20,7 +20,7 @@ public Stream allowedByTypeStrategy(PurposeCode purpose, Collection excludedVendors, boolean isEnforceVendors) { - logger.debug("Basic strategy used for purpose {0}", purpose); + logger.debug("Basic strategy used for purpose {}", purpose); final Stream allowedVendorPermissions = toVendorPermissions(vendorsForPurpose) .filter(vendorPermission -> vendorPermission.getVendorId() != null) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java index 7aa8583b131..671bdb39170 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java @@ -9,8 +9,6 @@ import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.AllArgsConstructor; import lombok.Value; import org.apache.commons.collections4.MapUtils; @@ -19,6 +17,8 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.privacy.gdpr.vendorlist.proto.Vendor; import org.prebid.server.privacy.gdpr.vendorlist.proto.VendorList; @@ -153,7 +153,7 @@ public Future> forVersion(int version) { metrics.updatePrivacyTcfVendorListMissingMetric(tcf); if (fetchThrottler.registerFetchAttempt(version)) { - logger.info("TCF {0} vendor list for version {1}.{2} not found, started downloading.", + logger.info("TCF {} vendor list for version {}.{} not found, started downloading.", tcf, generationVersion, version); fetchNewVendorListFor(version); } @@ -346,7 +346,7 @@ private Void updateCache(VendorListResult vendorListResult) { metrics.updatePrivacyTcfVendorListOkMetric(tcf); - logger.info("Created new TCF {0} vendor list for version {1}.{2}", tcf, generationVersion, version); + logger.info("Created new TCF {} vendor list for version {}.{}", tcf, generationVersion, version); stopUsingFallbackForVersion(version); diff --git a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java index 3b71936c7cd..7fb363a0ff0 100644 --- a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java @@ -1,11 +1,11 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.helper.StoredDataFetcher; @@ -243,7 +243,7 @@ private static Map getFromCacheOrAddMissedIds(String accountId, public void invalidateAccountCache(String accountId) { accountCache.remove(accountId); - logger.debug("Account with id {0} was invalidated", accountId); + logger.debug("Account with id {} was invalidated", accountId); } public void invalidateAllAccountCache() { diff --git a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java index 72daa7e938d..1c78e4693c5 100644 --- a/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/HttpApplicationSettings.java @@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.Future; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -14,6 +12,8 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.Category; import org.prebid.server.settings.model.StoredDataResult; diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java index 3cb710193e2..6ea14d294d0 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java @@ -1,11 +1,11 @@ package org.prebid.server.settings.helper; import io.vertx.core.json.JsonArray; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.sql.ResultSet; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.exception.PreBidException; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; @@ -85,7 +85,7 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set initializePromise) { getAll(); if (refreshPeriod > 0) { vertx.setPeriodic(refreshPeriod, aLong -> refresh()); } + + initializePromise.tryComplete(); } private void getAll() { diff --git a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java b/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java index c479c2a0168..13e76bc9c89 100644 --- a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java +++ b/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java @@ -1,12 +1,13 @@ package org.prebid.server.settings.service; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.lang3.StringUtils; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; @@ -103,11 +104,12 @@ public JdbcPeriodicRefreshService(String initQuery, } @Override - public void initialize() { + public void initialize(Promise initializePromise) { getAll(); if (refreshPeriod > 0) { vertx.setPeriodic(refreshPeriod, aLong -> refresh()); } + initializePromise.tryComplete(); } private void getAll() { diff --git a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java index 21ee67ac125..d22378eea64 100644 --- a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java b/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java index 05f510983b8..bf9f387aa73 100644 --- a/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/GeoLocationConfiguration.java @@ -82,12 +82,14 @@ CircuitBreakerSecuredGeoLocationService circuitBreakerSecuredGeoLocationService( } private GeoLocationService createGeoLocationService(RemoteFileSyncerProperties properties, Vertx vertx) { + final MaxMindGeoLocationService maxMindGeoLocationService = new MaxMindGeoLocationService(); final HttpClientProperties httpClientProperties = properties.getHttpClient(); final HttpClientOptions httpClientOptions = new HttpClientOptions() .setConnectTimeout(httpClientProperties.getConnectTimeoutMs()) .setMaxRedirects(httpClientProperties.getMaxRedirects()); final RemoteFileSyncer remoteFileSyncer = new RemoteFileSyncer( + maxMindGeoLocationService, properties.getDownloadUrl(), properties.getSaveFilepath(), properties.getTmpFilepath(), @@ -96,9 +98,8 @@ private GeoLocationService createGeoLocationService(RemoteFileSyncerProperties p properties.getUpdateIntervalMs(), vertx.createHttpClient(httpClientOptions), vertx); - final MaxMindGeoLocationService maxMindGeoLocationService = new MaxMindGeoLocationService(); - remoteFileSyncer.sync(maxMindGeoLocationService); + remoteFileSyncer.sync(); return maxMindGeoLocationService; } } diff --git a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java index d52de58ac63..7bce3c5358e 100644 --- a/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/InitializationConfiguration.java @@ -1,13 +1,14 @@ package org.prebid.server.spring.config; +import com.codahale.metrics.ScheduledReporter; import org.prebid.server.metric.Metrics; -import org.prebid.server.vertx.ContextRunner; import org.prebid.server.vertx.Initializable; import org.prebid.server.vertx.httpclient.HttpClient; +import org.prebid.server.vertx.verticles.VerticleDefinition; +import org.prebid.server.vertx.verticles.server.DaemonVerticle; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; import java.util.List; @@ -27,17 +28,10 @@ @Configuration public class InitializationConfiguration { - @Autowired - private ContextRunner contextRunner; + @Bean + VerticleDefinition daemonVerticleDefinition(@Autowired(required = false) List initializables, + @Autowired(required = false) List reporters) { - @Autowired - private List initializables; - - @EventListener(ContextRefreshedEvent.class) - public void initializeServices() { - contextRunner.runBlocking(promise -> { - initializables.forEach(Initializable::initialize); - promise.complete(); - }); + return VerticleDefinition.ofSingleInstance(() -> new DaemonVerticle(initializables, reporters)); } } diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index db8251b9b42..2fa66398e28 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -52,9 +52,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.Arrays; import java.util.HashSet; diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index de4e7fddff6..edf2f45b665 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -5,8 +5,6 @@ import io.vertx.core.Vertx; import io.vertx.core.file.FileSystem; import io.vertx.core.http.HttpClientOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.JksOptions; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -95,7 +93,9 @@ import org.prebid.server.log.CriteriaLogManager; import org.prebid.server.log.CriteriaManager; import org.prebid.server.log.HttpInteractionLogger; +import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerControlKnob; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.optout.GoogleRecaptchaVerifier; import org.prebid.server.privacy.HostVendorTcfDefinerService; @@ -127,7 +127,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; import java.io.IOException; import java.time.Clock; import java.util.ArrayList; diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 374edb1d2be..5a6dcac39a5 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -37,8 +37,8 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.List; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/spring/config/VerticleStarter.java b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java index 49bdae234ae..cb519b88477 100644 --- a/src/main/java/org/prebid/server/spring/config/VerticleStarter.java +++ b/src/main/java/org/prebid/server/spring/config/VerticleStarter.java @@ -6,6 +6,8 @@ import org.prebid.server.vertx.verticles.VerticleDefinition; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; import java.util.List; @@ -13,7 +15,16 @@ public class VerticleStarter { @Autowired - public void start(Vertx vertx, ContextRunner contextRunner, List definitions) { + private Vertx vertx; + + @Autowired + private ContextRunner contextRunner; + + @Autowired + private List definitions; + + @EventListener(ContextRefreshedEvent.class) + public void start() { for (VerticleDefinition definition : definitions) { if (definition.getAmount() <= 0) { continue; diff --git a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java index 5dc0f08fc19..9b5250a4233 100644 --- a/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/VertxConfiguration.java @@ -3,12 +3,12 @@ import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.file.FileSystem; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.dropwizard.DropwizardMetricsOptions; import io.vertx.ext.dropwizard.Match; import io.vertx.ext.dropwizard.MatchType; import io.vertx.ext.web.handler.BodyHandler; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.spring.config.metrics.MetricsConfiguration; import org.prebid.server.vertx.ContextRunner; import org.springframework.beans.factory.annotation.Value; @@ -38,7 +38,7 @@ Vertx vertx(@Value("${vertx.worker-pool-size}") int workerPoolSize, .setMetricsOptions(metricsOptions); final Vertx vertx = Vertx.vertx(vertxOptions); - logger.info("Native transport enabled: {0}", vertx.isNativeTransportEnabled()); + logger.info("Native transport enabled: {}", vertx.isNativeTransportEnabled()); return vertx; } diff --git a/src/main/java/org/prebid/server/spring/config/VertxContextScope.java b/src/main/java/org/prebid/server/spring/config/VertxContextScope.java index b1d79b1a0aa..8dbc6869695 100644 --- a/src/main/java/org/prebid/server/spring/config/VertxContextScope.java +++ b/src/main/java/org/prebid/server/spring/config/VertxContextScope.java @@ -1,8 +1,8 @@ package org.prebid.server.spring.config; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.springframework.beans.factory.ObjectFactory; import org.springframework.context.support.SimpleThreadScope; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java index 3e6e38cee29..83cc2694122 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aax.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java index d93b5428a19..f8a168d86b8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AceexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aceex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java index 14aeb9c023d..77bec41b1c2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AcuityadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/acuityads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java index 8c68cc8422c..0f5dda54587 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdQueryConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adquery.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java index d3d1a0e0e7a..c38ca1c1fbe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdelementConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adelement.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java index 43d1f0fd4f6..64091a95ef0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdfConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adf.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java index 3d551f7fe34..b377b46d1f2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdgenerationConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adgeneration.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java index 33cb3fbf6a7..d0ac8674d9a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdheseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adhese.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java index 23974f5a2ff..ca4ff6cbd07 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelAdnConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adkerneladn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java index 3defba5f55c..cc360ff91f8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdkernelConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adkernel.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java index 0be512c5930..c4b5f011268 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdmanConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adman.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java index f981511bd4b..2a7a4cc8596 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdmixerConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/admixer.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java index d31a23ade02..687c2897b8f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdnuntiusBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java index 2d41d75e914..d16984e3c5e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdoceanConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adocean.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java index aabbf780e6a..89163bceeab 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdopplerConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adoppler.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java index 8c7eb644316..9c0ac457d71 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdotConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adot.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java index 2a41025ce3e..3792a998ea8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdponeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adpone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java index 4792b91ec5b..c9f6f950059 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdprimeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adprime.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java index 601b108e571..415835e1b10 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adrino.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java index 04d87dbb076..2b3996f7fef 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtargetConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtarget.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java index b45262b6a70..de3713761b0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtelligentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtelligent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java index b544af026a6..7a578330380 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdtrgtmeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adtrgtme.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java index a5b9b8b2278..7b58430ee4c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdvangelistsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/advangelists.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java index 40b81bf434f..58b17ef619f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdviewConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adview.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java index 197ca9b4d0a..6e6c4659e36 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdxcgConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adxcg.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java index 37f41f487d3..d1350a9f53a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AdyoulikeConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/adyoulike.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java index 3e61efb79eb..7689a338302 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AidemConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aidem.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java index 76894a12476..216aa69047e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AjaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/aja.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java index 57f7395f478..1082e4c0b5a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AlgorixConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/algorix.yaml", diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java index 70bb071c850..44f8e0d50d8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AlkimiConfiguration.java @@ -7,15 +7,13 @@ import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/alkimi.yaml", factory = YamlPropertySourceFactory.class) @@ -23,17 +21,6 @@ public class AlkimiConfiguration { private static final String BIDDER_NAME = "alkimi"; - @Value("${external-url}") - @NotBlank - private String externalUrl; - - @Autowired - private JacksonMapper mapper; - - @Autowired - @Qualifier("alkimiConfigurationProperties") - private BidderConfigurationProperties configProperties; - @Bean("alkimiConfigurationProperties") @ConfigurationProperties("adapters.alkimi") BidderConfigurationProperties configurationProperties() { @@ -41,9 +28,12 @@ BidderConfigurationProperties configurationProperties() { } @Bean - BidderDeps alkimiBidderDeps() { + BidderDeps alkimiBidderDeps(BidderConfigurationProperties alkimiConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(configProperties) + .withConfig(alkimiConfigurationProperties) .usersyncerCreator(UsersyncerCreator.create(externalUrl)) .bidderCreator(config -> new AlkimiBidder(config.getEndpoint(), mapper)) .assemble(); diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java index efdc07c829d..d90cafd1fa8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AmxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/amx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java index c65595c6055..1d8c5882416 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ApacdexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/apacdex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java index 17d293b98bf..87ca781f346 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AppnexusConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.util.Map; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java index 977fd84a330..af0c97490cd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AppushConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/appush.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java index 3e984b575e3..49b0d3ff049 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AudienceNetworkConfiguration.java @@ -18,7 +18,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.function.Function; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java index 95d564260dc..18f2e1a62bc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AutomatadBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/automatad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java index 722e2f13d0b..87bb0b24f1a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AvocetConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/avocet.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java index 292df8b9edb..93b896371af 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AxisConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/axis.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java index 69643f1bb45..8423eb76cf2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/AxonixConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/axonix.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java index 71b24f5861a..e34cf171976 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeachfrontConfiguration.java @@ -18,7 +18,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beachfront.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java index b9d44061493..b7113c8bbcc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeintooConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beintoo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java index 9de51f3d6cc..bef7077d93c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BematterfullConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bematterfull.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java index ab7fdeab33b..448104e62ba 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BetweenConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/between.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java index cf2c0729d52..541a70fa294 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BeyondMediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/beyondmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java index 8eed33412ae..d5171cff6fb 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidmachineConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidmachine.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java index bcdcbe438e9..ebd9305906f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidmyadzConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidmyadz.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java index 235c24cc161..389200d09c0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidscubeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidscube.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java index af6f47d68b9..1103ac66853 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BidstackConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bidstack.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java index 90b8491f55e..c65702aa9fa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BizzclickConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bizzclick.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java index fcbbf49122e..6ce0d022f04 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BliinkBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bliink.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java index aa988d6c75f..823396b8b5d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BlueSeaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bluesea.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java index 91fd517a133..c9c7bcbebfa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BmtmConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/bmtm.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java index bb648cf6b0b..f062311c4fa 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BoldwinConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/boldwin.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java index 5dc013e8f7b..de364ab4bc0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/BraveConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/brave.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java index de7e92ad89c..91b0c7646ec 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ccx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java index cd402e4ec76..896bd31ff10 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CoinzillaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/coinzilla.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java index 4187c7649b5..8d466e2e842 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ColossusConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/colossus.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java index 3f45046b918..e638d721fd0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CompassConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/compass.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java index ebf4225dedb..34e38d7cec3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ConnectAdConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/connectad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java index 5de2e87645c..70a31dfdddf 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ConsumableConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/consumable.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java index 33bd952d33f..b247970937b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CpmStarConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/cpmstar.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java index 698f5c3b83a..5693167b62e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/CriteoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/criteo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java index 49b28ee132a..9d5d4fd9b08 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DatablocksConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/datablocks.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java index 2e7da078a2c..c1eb0e2b1e3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DecenteradsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/decenterads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java index 146989a2ef7..ac14dd71c2e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DeepintentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/deepintent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java index 7fe68311380..e9938a9d632 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DianomiBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dianomi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java index 506a4105a11..a80323c031c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DmxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dmx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java index e4ef4b92a64..658a2c8743c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/DxKultureBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/dxkulture.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java b/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java index 754a07a970c..03ecfc2add9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/Edge226Configuration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/edge226.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java index 6bd8f2125d1..3c5a934a8bc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EmtvConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/emtv.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java index 0ecde28142a..64855592dbe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EmxDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/emxdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java index 491813e0596..f67ab6d9ff5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EplanningConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/eplanning.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java index f3c011f4146..88776cd74ad 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EpomConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/epom.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java index 3025a45289c..71e90054c01 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EpsilonConfiguration.java @@ -17,8 +17,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Configuration @PropertySource(value = "classpath:/bidder-config/epsilon.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java index ef32fda4196..9757923928e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/EvolutionConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/evolution.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java index 1f3ab8db2d3..e2e36373073 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FlippConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/flipp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java index d58278d9e64..0ac29fb2ad0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FreewheelSSPConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/freewheelssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java index 5c772da6eca..f4c903a4968 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/FrvrAdnBidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/frvradn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java index 5f4e871d55f..141c4ddd313 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GammaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gamma.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java index 13bf512b415..15d37d3b5b8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GamoshiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gamoshi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java index 0b5b46f2b81..23f1e2f2928 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GenericBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/generic.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java index dfd0a7ffc18..2eca33cefcd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GlobalsunConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/globalsun.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java index 029f9423886..97691f8f563 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GothamAdsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gothamads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java index a39811d4e5e..f7ddefef701 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GridConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/grid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java index 72b2f86ec71..7970022d1e3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/GumgumConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/gumgum.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java index 9030d5934c7..ba69ed885b1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/HuaweiAdsConfiguration.java @@ -27,9 +27,9 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.Clock; import java.util.List; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java index 3128eab5de9..020dd0e6936 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImdsConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/imds.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java index 6daed5621b3..af1fe09228f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImpactifyConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/impactify.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java index 54631f271e0..4003ed66438 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ImprovedigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/improvedigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java index 979ba6f7fcb..7b28f464742 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/infytv.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java index 981654fc9a2..1b2f21ec06e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InmobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/inmobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java index fb2cf581f15..4dbc0a2ab0b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InteractiveOffersConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/interactiveoffers.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java index 066560a4e17..a6a5ea7c736 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IntertechConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/intertech.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java index 2d864f17c14..2111af79fb2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/InvibesConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/invibes.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java index ff59d0298f0..189ad72adda 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IqxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/iqx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java index 87e7b5aabd1..4b9ddff193c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IqzoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/iqzone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java index 9d6218b3293..49a1bdbea69 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/IxConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ix.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java index 313fdeee64d..a3110e233ff 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/JixieConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/jixie.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java index e434ebeb907..d01076cae25 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KargoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kargo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java index 555b75fa6e1..94e953d2506 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KayzenConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kayzen.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java index 49e026b92c0..c7c5b689c0c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KidozConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kidoz.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java index a2472886876..816ff86dac5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KiviAdsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/kiviads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java index 581f3c3da33..4b271d5cfac 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/KrushmediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/krushmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java index c36ad73abc4..3cdc83faed4 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LemmaDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lemmadigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java index 70bab296c4e..0111858f8e5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LiftoffConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/liftoff.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java index cedf0ec590a..a94fc4020a2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LimeLightDigitalConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/limelightDigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java index 568b922a644..cca3ccf4dfe 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LmKiviAdsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lmkiviads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java index a4a9ccd5cae..b18f98fd753 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LockerdomeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lockerdome.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java index 7b218776294..424c64cd7a0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LoganConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/logan.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java index 02a59440a50..5063fd1c040 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LogicadConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/logicad.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java index 9de12f3a137..a100493fbee 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/loopme.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java index cad75586f80..96076560f70 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/LunamediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/lunamedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java index 2d1ff24a6ef..938bc20e96c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MadvertiseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/madvertise.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java index 53e9c19d7c9..99012d82a84 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MarsmediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/marsmedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java index 6f5a10c5e32..359f630febf 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MedianetConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/medianet.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java index 192ff7a9083..893e30c424f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MgidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mgid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java index 521e0692120..f891d3f44d7 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MgidxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mgidx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java index 6584d277a2c..3b01a2f482a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MinuteMediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/minutemedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java index fdebfa6fa42..bb8c80c037d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MobfoxpbConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mobfoxpb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java index 4c78c3310f8..6496f517007 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MobilefuseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/mobilefuse.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java index 690c6468e45..e68ba630872 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/MotorikConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/motorik.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java index 320f0a249ec..16fbbb37aca 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/NextMillenniumConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java index 840d5c647d3..52079d032ef 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/NobidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/nobid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java index e9ac40cc76a..47cdeb08045 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OmsBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/oms.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java index 8c5a86e9ec9..ce37fc92ce2 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OnetagConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/onetag.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java index 2c3ed5daac1..370839be501 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OpenWebConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/openweb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java index a936202776e..5e3886d5814 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OpenxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/openx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java index 9eae2d808af..8b5055b4c29 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OperaadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/operaads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java index e41814195fd..0e9bbcb29a6 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OrbidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/orbidder.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java index 1e5353a989a..194dd8ca14a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/OutbrainConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/outbrain.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java index e3ba1595664..2cd2c3b361c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PangleConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pangle.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java index 80304cbc659..1e449c950d6 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PgamSspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pgamssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java index a83140b7868..dfa65428aac 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PrecisoConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/preciso.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java index 607b10b532a..2fa5477630f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PubmaticConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pubmatic.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java index 32409c06aaa..5e1ec608cc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PubnativeConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pubnative.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java index bbf00524f65..91ca1b19220 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PulsepointConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pulsepoint.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java index 24888ef7d7f..d076873bdf0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/PwbidConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/pwbid.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java index 15f39a644c1..b25ca14eb32 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RelevantDigitalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/relevantdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java index 7111d8ad9ff..4e4de161f66 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ResetDigitalConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/resetdigital.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java index 6435aa150c3..c21bf079b70 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RevcontentConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/revcontent.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java index c343830ace4..fe8c2a00523 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RichaudienceConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/richaudience.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java index 87a2af115f0..c54c39cd6c8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RiseConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/rise.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java index 3834fa0b878..2b99afafad9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RtbhouseConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/rtbhouse.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java index feb9f1c87c3..75a8a316d7a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/RubiconConfiguration.java @@ -19,9 +19,9 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Configuration @PropertySource(value = "classpath:/bidder-config/rubicon.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java index f7d7248cbef..ab466600f26 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SaLunamediaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/salunamedia.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java index 74e1f39ff52..3cf155022e9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ScreencoreConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/screencore.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java index 5ba2c7ae1ae..426950a684a 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SeedingAllianceBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/seedingAlliance.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java index dd0a0abcbf1..3e75a34f8cc 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SharethroughConfiguration.java @@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sharethrough.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java index b26e78fcd64..b3dcb5baf90 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SilverPushConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/silverpush.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java index 98acc635472..e26433fb580 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SilvermobConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/silvermob.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java index 28c50df1619..0b72987e6f9 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SimpleWantedConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smilewanted.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java index 06ff89f6ee7..0851bd87d7d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmaatoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java index 7cf0551db62..5264a6a3e77 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartadserverConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartadserver.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java index a19e364b949..218f7f8ae96 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmarthubConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smarthub.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java index 33728c7499e..f0a5f22622c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartrtbConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartrtb.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java index ebf11d6a804..5b6c08b6dd3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java index 730d822633b..a5de7f27094 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SmartyAdsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/smartyads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java index 039a57f74b5..eaab8a70ef5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SonobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sonobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java index 281987c0bc6..4de292e9184 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SovrnConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sovrn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java index 3dcd9a2a53e..a494790bb71 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SovrnXspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sovrnXsp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java index 8d2e8a01459..95ff7edcf08 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/SspbcBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/sspbc.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java index 242a52f941c..f33c72e5027 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/StroeerCoreConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/stroeercore.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java index 99d30628a61..ef917b09bc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TaboolaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/taboola.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java index 846ad2f1057..352ec244ecd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TappxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java index 699cd016b9a..a1cb6c26c99 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TeadsConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/teads.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java index 2f12146901c..9be27f6bc33 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TelariaConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/telaria.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java index c114867c505..1a04588e973 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ThirtyThreeAcrossConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/thirtythreeacross.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java index 224f0fab7bd..0a40807f424 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TpmnAdnBidderConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/tpmn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java index 56a25a94d7e..33e0ecaa1e8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TrafficGateConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/trafficgate.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java index b730143bc95..301b26478c1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/triplelift.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java index c1a7ee5b1ca..11ef984aa78 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/TripleliftNativeConfiguration.java @@ -18,8 +18,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java index 3fc172aeab4..6e2e4067b7d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UcfunnelConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/ucfunnel.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java index 60a1dc415c5..a51380096ea 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UndertoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/undertone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java index 21d9e820f3d..7905fc384f0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UnicornConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/unicorn.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java index e57d436165c..44ed956b391 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/UnrulyConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/unruly.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java index e7ef3ddfc65..f501af44cf4 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VideoHeroesConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/videoheroes.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java index 59bf7326947..a25f213c6a1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VideobyteConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/videobyte.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java index aeaf95f1ccc..45806a99bf0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VidoomyConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vidoomy.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java index 21a4ecd20a5..9dfc739b5ff 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VisibleMeasuresConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/visiblemeasures.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java index 57fbb9c8987..a3585633163 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VisxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/visx.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java index 2524a5b2fce..0d0974c87d0 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VoxConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vox.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java index 1343e007a68..73e0b9bacc5 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/VrtcalConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/vrtcal.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java index ddedb314725..be4681a98e7 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/XeworksBidderConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/xeworks.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java index 14b0397a148..9cd3ed1249b 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YahooAdsConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yahooAds.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java index 629f8f63b11..5f1afa3398f 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YandexConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yandex.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java index 8dc6c20d857..1bc55fd4ef8 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YeahmobiConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yeahmobi.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java index 2a278e1d88a..1ce349de7dd 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YearxeroConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yearxero.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java index 0d2dc0a31ad..5bf1f496477 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldlabConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import java.time.Clock; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java index 3562e02acfe..255e9676924 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldmoConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yieldmo.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java index aa1c028b653..8e32a38e2d3 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/YieldoneConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/yieldone.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java index 87fb61aa20c..3430977f4db 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ZeroclickfraudConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/zeroclickfraud.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java index b2bd0662251..a886d2bab8e 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Configuration @PropertySource(value = "classpath:/bidder-config/zeta_global_ssp.yaml", factory = YamlPropertySourceFactory.class) diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java index 63499df3804..0f5fde1d480 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/BidderConfigurationProperties.java @@ -10,9 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.annotation.PostConstruct; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java b/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java index 2a88fc91e66..c1e44593d0d 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/Debug.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java index 99b0ca38829..7996a2e220c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/DefaultBidderConfigurationProperties.java @@ -4,7 +4,7 @@ import org.prebid.server.auction.versionconverter.OrtbVersion; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java b/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java index 0e46906f528..c25236dd799 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/MetaInfo.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.List; @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java b/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java index e3153ff8654..9d22bbd1de1 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/Ortb.java @@ -6,7 +6,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java index 6acd9c68ce0..e67debfad6c 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java index bba6fbc6826..fc9b685b339 100644 --- a/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncMethodConfigurationProperties.java @@ -5,8 +5,8 @@ import org.prebid.server.bidder.UsersyncFormat; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index e5b6198fb66..174bf82f35c 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -5,9 +5,9 @@ import org.prebid.server.spring.config.database.model.DatabasePoolType; import org.prebid.server.spring.config.database.model.DatabaseType; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Data @NoArgsConstructor diff --git a/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java index 999b80ef47a..db0d072ebaa 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/MetricsConfiguration.java @@ -11,7 +11,6 @@ import com.izettle.metrics.influxdb.InfluxDbHttpSender; import com.izettle.metrics.influxdb.InfluxDbReporter; import com.izettle.metrics.influxdb.InfluxDbSender; -import io.vertx.core.Vertx; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; @@ -20,8 +19,6 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.metric.model.AccountMetricsVerbosityLevel; import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.prebid.server.vertx.CloseableAdapter; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -31,10 +28,9 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,12 +43,6 @@ public class MetricsConfiguration { public static final String METRIC_REGISTRY_NAME = "metric-registry"; - @Autowired(required = false) - private List reporters = Collections.emptyList(); - - @Autowired - private Vertx vertx; - @Bean @ConditionalOnProperty(prefix = "metrics.graphite", name = "enabled", havingValue = "true") ScheduledReporter graphiteReporter(GraphiteProperties graphiteProperties, MetricRegistry metricRegistry) { @@ -128,13 +118,6 @@ AccountMetricsVerbosityResolver accountMetricsVerbosity(AccountsProperties accou accountsProperties.getDetailedVerbosity()); } - @PostConstruct - void registerReporterCloseHooks() { - reporters.stream() - .map(CloseableAdapter::new) - .forEach(closeable -> vertx.getOrCreateContext().addCloseHook(closeable)); - } - @Component @ConfigurationProperties(prefix = "metrics.graphite") @ConditionalOnProperty(prefix = "metrics.graphite", name = "enabled", havingValue = "true") diff --git a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java index 72a15515864..174db85731f 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusConfiguration.java @@ -7,12 +7,12 @@ import io.prometheus.client.dropwizard.samplebuilder.SampleBuilder; import io.prometheus.client.vertx.MetricsHandler; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import lombok.Data; import lombok.NoArgsConstructor; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.CounterType; import org.prebid.server.metric.Metrics; import org.prebid.server.metric.prometheus.NamespaceSubsystemSampleBuilder; @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; @Configuration diff --git a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java index e9ea4ac3b29..ea7bb3989f7 100644 --- a/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/metrics/PrometheusMapperConfiguration.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java b/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java index cbc3e22f81e..969b5f35784 100644 --- a/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/CircuitBreakerProperties.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java index 914e1bcfc18..6e0373fba11 100644 --- a/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/ExternalConversionProperties.java @@ -8,9 +8,9 @@ import org.prebid.server.vertx.httpclient.HttpClient; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.Clock; @Validated diff --git a/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java b/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java index 26830122dda..9693e78bb93 100644 --- a/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/HttpClientCircuitBreakerProperties.java @@ -5,8 +5,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java b/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java index a2981e02849..06ec12bac87 100644 --- a/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/HttpClientProperties.java @@ -4,8 +4,8 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java b/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java index a354dd46b3e..5075b1dbdf7 100644 --- a/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java +++ b/src/main/java/org/prebid/server/spring/config/model/RemoteFileSyncerProperties.java @@ -4,9 +4,9 @@ import lombok.NoArgsConstructor; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; @Validated @Data diff --git a/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java index af6d94c490b..ca584979578 100644 --- a/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/retry/ExponentialBackoffRetryPolicyConfigurationProperties.java @@ -4,8 +4,8 @@ import org.prebid.server.execution.retry.ExponentialBackoffRetryPolicy; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; -import javax.validation.constraints.Positive; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Positive; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java index 332d6c5787c..bc55c9f6c03 100644 --- a/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/retry/FixedIntervalRetryPolicyConfigurationProperties.java @@ -4,7 +4,7 @@ import org.prebid.server.execution.retry.FixedIntervalRetryPolicy; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; @Data @Validated diff --git a/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java index 11d096d5666..41b695bb2c6 100644 --- a/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java +++ b/src/main/java/org/prebid/server/spring/config/server/admin/AdminResourcesBinder.java @@ -3,7 +3,7 @@ import io.vertx.core.Handler; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.handler.AuthHandler; +import io.vertx.ext.web.handler.AuthenticationHandler; import io.vertx.ext.web.handler.BasicAuthHandler; import org.prebid.server.vertx.verticles.server.admin.AdminResource; @@ -30,7 +30,7 @@ public void bind(Router router) { } } - private AuthHandler securedAuthHandler() { + private AuthenticationHandler securedAuthHandler() { if (credentials == null) { throw new IllegalArgumentException("Credentials for admin endpoint is empty."); } diff --git a/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java b/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java index 6e599602b9e..fcff6e0a397 100644 --- a/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java +++ b/src/main/java/org/prebid/server/spring/env/YamlPropertySourceFactory.java @@ -7,8 +7,8 @@ import org.springframework.core.io.support.EncodedResource; import org.springframework.core.io.support.PropertySourceFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; diff --git a/src/main/java/org/prebid/server/util/HttpUtil.java b/src/main/java/org/prebid/server/util/HttpUtil.java index b848f1a4d41..005230166e7 100644 --- a/src/main/java/org/prebid/server/util/HttpUtil.java +++ b/src/main/java/org/prebid/server/util/HttpUtil.java @@ -6,11 +6,11 @@ import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.model.Endpoint; import org.prebid.server.model.HttpRequestContext; @@ -185,7 +185,7 @@ public static boolean executeSafely(RoutingContext routingContext, responseConsumer.accept(response); return true; } catch (Exception e) { - logger.warn("Failed to send {0} response: {1}", endpoint, e.getMessage()); + logger.warn("Failed to send {} response: {}", endpoint, e.getMessage()); return false; } } diff --git a/src/main/java/org/prebid/server/util/VersionInfo.java b/src/main/java/org/prebid/server/util/VersionInfo.java index b163be55f3c..f7240ea38bb 100644 --- a/src/main/java/org/prebid/server/util/VersionInfo.java +++ b/src/main/java/org/prebid/server/util/VersionInfo.java @@ -1,11 +1,11 @@ package org.prebid.server.util; import com.fasterxml.jackson.annotation.JsonProperty; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import lombok.AllArgsConstructor; import lombok.Value; import org.prebid.server.json.JacksonMapper; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.io.IOException; import java.util.regex.Matcher; @@ -31,7 +31,7 @@ public static VersionInfo create(String revisionFilePath, JacksonMapper jacksonM revision = jacksonMapper.mapper().readValue(ResourceUtil.readFromClasspath(revisionFilePath), Revision.class); } catch (IllegalArgumentException | IOException e) { - logger.error("Was not able to read revision file {0}. Reason: {1}", revisionFilePath, e.getMessage()); + logger.error("Was not able to read revision file {}. Reason: {}", revisionFilePath, e.getMessage()); return new VersionInfo(UNDEFINED, UNDEFINED); } final String pbsVersion = revision.getPbsVersion(); diff --git a/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java b/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java index 43ac4177b91..6be897cd1d4 100644 --- a/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java +++ b/src/main/java/org/prebid/server/util/system/CpuLoadAverageStats.java @@ -1,5 +1,6 @@ package org.prebid.server.util.system; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.prebid.server.vertx.Initializable; import oshi.SystemInfo; @@ -30,9 +31,10 @@ public CpuLoadAverageStats(Vertx vertx, long measurementIntervalMillis) { } @Override - public void initialize() { + public void initialize(Promise initializePromise) { measureCpuLoad(); vertx.setPeriodic(measurementIntervalMillis, timerId -> measureCpuLoad()); + initializePromise.tryComplete(); } private void measureCpuLoad() { diff --git a/src/main/java/org/prebid/server/validation/RequestValidator.java b/src/main/java/org/prebid/server/validation/RequestValidator.java index 147ffd60208..4b0c1ddfe7f 100644 --- a/src/main/java/org/prebid/server/validation/RequestValidator.java +++ b/src/main/java/org/prebid/server/validation/RequestValidator.java @@ -33,7 +33,6 @@ import com.iab.openrtb.request.ntv.EventType; import com.iab.openrtb.request.ntv.PlacementType; import com.iab.openrtb.request.ntv.Protocol; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -42,6 +41,7 @@ import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.json.JacksonMapper; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.model.HttpRequestContext; diff --git a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java index e3e405cb710..17132e1bc35 100644 --- a/src/main/java/org/prebid/server/validation/ResponseBidValidator.java +++ b/src/main/java/org/prebid/server/validation/ResponseBidValidator.java @@ -6,8 +6,6 @@ import com.iab.openrtb.request.Imp; import com.iab.openrtb.request.Site; import com.iab.openrtb.response.Bid; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -15,6 +13,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.proto.openrtb.ext.response.BidType; diff --git a/src/main/java/org/prebid/server/vertx/CircuitBreaker.java b/src/main/java/org/prebid/server/vertx/CircuitBreaker.java index e62e3dddc98..104545470f5 100644 --- a/src/main/java/org/prebid/server/vertx/CircuitBreaker.java +++ b/src/main/java/org/prebid/server/vertx/CircuitBreaker.java @@ -6,8 +6,8 @@ import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.time.Clock; import java.util.Objects; diff --git a/src/main/java/org/prebid/server/vertx/CloseableAdapter.java b/src/main/java/org/prebid/server/vertx/CloseableAdapter.java index 480e2e6b453..708796c63c7 100644 --- a/src/main/java/org/prebid/server/vertx/CloseableAdapter.java +++ b/src/main/java/org/prebid/server/vertx/CloseableAdapter.java @@ -1,8 +1,7 @@ package org.prebid.server.vertx; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; +import io.vertx.core.Promise; import java.io.Closeable; import java.io.IOException; @@ -14,19 +13,19 @@ */ public class CloseableAdapter implements io.vertx.core.Closeable { - private final Closeable adaptee; + private final Closeable closeable; - public CloseableAdapter(Closeable adaptee) { - this.adaptee = Objects.requireNonNull(adaptee); + public CloseableAdapter(Closeable closeable) { + this.closeable = Objects.requireNonNull(closeable); } @Override - public void close(Handler> completionHandler) { + public void close(Promise promise) { try { - adaptee.close(); - completionHandler.handle(Future.succeededFuture()); + closeable.close(); + promise.handle(Future.succeededFuture()); } catch (IOException e) { - completionHandler.handle(Future.failedFuture(e)); + promise.handle(Future.failedFuture(e)); } } } diff --git a/src/main/java/org/prebid/server/vertx/Initializable.java b/src/main/java/org/prebid/server/vertx/Initializable.java index 3c8bfd22c55..5c12c30e47d 100644 --- a/src/main/java/org/prebid/server/vertx/Initializable.java +++ b/src/main/java/org/prebid/server/vertx/Initializable.java @@ -1,6 +1,7 @@ package org.prebid.server.vertx; import io.vertx.core.Handler; +import io.vertx.core.Promise; /** * Denotes components requiring initialization after they have been created. @@ -11,5 +12,5 @@ @FunctionalInterface public interface Initializable { - void initialize(); + void initialize(Promise initializePromise); } diff --git a/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java index bfdd4337fc1..35dd808c97d 100644 --- a/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/BasicHttpClient.java @@ -8,12 +8,15 @@ import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import org.prebid.server.exception.PreBidException; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Objects; import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; /** * Simple wrapper around {@link HttpClient} with general functionality. @@ -31,100 +34,79 @@ public BasicHttpClient(Vertx vertx, io.vertx.core.http.HttpClient httpClient) { @Override public Future request(HttpMethod method, String url, MultiMap headers, String body, long timeoutMs, long maxResponseSize) { - return request(method, url, headers, timeoutMs, maxResponseSize, body, - (HttpClientRequest httpClientRequest) -> httpClientRequest.end(body)); + + return request(method, url, headers, timeoutMs, maxResponseSize, body != null ? body.getBytes() : null); } @Override public Future request(HttpMethod method, String url, MultiMap headers, byte[] body, long timeoutMs, long maxResponseSize) { - return request(method, url, headers, timeoutMs, maxResponseSize, body, - (HttpClientRequest httpClientRequest) -> httpClientRequest.end(Buffer.buffer(body))); + + return request(method, url, headers, timeoutMs, maxResponseSize, body); } - private Future request(HttpMethod method, String url, MultiMap headers, - long timeoutMs, long maxResponseSize, T body, - Consumer requestBodySetter) { - final Promise promise = Promise.promise(); + private Future request(HttpMethod method, String url, MultiMap headers, + long timeoutMs, long maxResponseSize, byte[] body) { if (timeoutMs <= 0) { - failResponse(new TimeoutException("Timeout has been exceeded"), promise); - } else { - final HttpClientRequest httpClientRequest; - try { - httpClientRequest = httpClient.requestAbs(method, url); - } catch (Exception e) { - failResponse(e, promise); - return promise.future(); - } - - // Vert.x HttpClientRequest timeout doesn't aware of case when a part of the response body is received, - // but remaining part is delayed. So, overall request/response timeout is involved to fix it. - final long timerId = vertx.setTimer(timeoutMs, id -> handleTimeout(promise, timeoutMs, httpClientRequest)); - - httpClientRequest - .setFollowRedirects(true) - .handler(response -> handleResponse(response, promise, timerId, maxResponseSize)) - .exceptionHandler(exception -> failResponse(exception, promise, timerId)); - - if (headers != null) { - httpClientRequest.headers().addAll(headers); - } - - if (body != null) { - requestBodySetter.accept(httpClientRequest); - } else { - httpClientRequest.end(); - } + return Future.failedFuture(new TimeoutException("Timeout has been exceeded")); } - return promise.future(); - } - private void handleTimeout(Promise promise, - long timeoutMs, - HttpClientRequest httpClientRequest) { + final URL absoluteUrl; + try { + absoluteUrl = new URL(url); + } catch (MalformedURLException e) { + return Future.failedFuture(e); + } - if (!promise.future().isComplete()) { - failResponse( - new TimeoutException("Timeout period of %dms has been exceeded".formatted(timeoutMs)), promise); + final Promise responsePromise = Promise.promise(); + final long timerId = vertx.setTimer(timeoutMs, ignored -> + responsePromise.tryFail( + new TimeoutException("Timeout period of %dms has been exceeded".formatted(timeoutMs)))); + + final RequestOptions options = new RequestOptions() + .setFollowRedirects(true) + .setConnectTimeout(timeoutMs) + .setMethod(method) + .setAbsoluteURI(absoluteUrl) + .setHeaders(headers); + + final Future requestFuture = makeRequest(options); + + requestFuture + .compose(request -> body != null ? request.send(Buffer.buffer(body)) : request.send()) + .compose(response -> toInternalResponse(response, maxResponseSize)) + .onSuccess(responsePromise::tryComplete) + .onFailure(responsePromise::tryFail); + + return responsePromise.future() + .onComplete(ignored -> vertx.cancelTimer(timerId)) + .onFailure(ignored -> requestFuture.onSuccess(HttpClientRequest::reset)); + } - // Explicitly close connection, inspired by https://github.com/eclipse-vertx/vert.x/issues/2745 - httpClientRequest.reset(); + private Future makeRequest(RequestOptions options) { + try { + return httpClient.request(options); + } catch (Throwable e) { + return Future.failedFuture(e); } } - private void handleResponse(io.vertx.core.http.HttpClientResponse response, - Promise promise, long timerId, long maxResponseSize) { + private Future toInternalResponse(io.vertx.core.http.HttpClientResponse response, + long maxResponseSize) { + final String contentLength = response.getHeader(HttpHeaders.CONTENT_LENGTH); final long responseBodySize = contentLength != null ? Long.parseLong(contentLength) : 0; if (responseBodySize > maxResponseSize) { - failResponse( - new PreBidException( - "Response size %d exceeded %d bytes limit".formatted(responseBodySize, maxResponseSize)), - promise, - timerId); - return; + return Future.failedFuture(new PreBidException( + "Response size %d exceeded %d bytes limit".formatted(responseBodySize, maxResponseSize))); } - response - .bodyHandler(buffer -> successResponse(buffer.toString(), response, promise, timerId)) - .exceptionHandler(exception -> failResponse(exception, promise, timerId)); - } - - private void successResponse(String body, io.vertx.core.http.HttpClientResponse response, - Promise promise, long timerId) { - vertx.cancelTimer(timerId); - - promise.tryComplete(HttpClientResponse.of(response.statusCode(), response.headers(), body)); - } - - private void failResponse(Throwable exception, Promise promise, long timerId) { - vertx.cancelTimer(timerId); - - failResponse(exception, promise); - } + return response.body() + .map(body -> HttpClientResponse.of( + response.statusCode(), + response.headers(), + body.toString(StandardCharsets.UTF_8))); - private static void failResponse(Throwable exception, Promise promise) { - promise.tryFail(exception); } } diff --git a/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java index ad957912dac..0843a04de12 100644 --- a/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java +++ b/src/main/java/org/prebid/server/vertx/httpclient/CircuitBreakerSecuredHttpClient.java @@ -5,10 +5,10 @@ import io.vertx.core.MultiMap; import io.vertx.core.Vertx; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; import org.prebid.server.vertx.httpclient.model.HttpClientResponse; @@ -127,11 +127,11 @@ private void circuitOpened(String name) { } private void circuitHalfOpened(String name) { - logger.warn("Http client request to {0} will try again, circuit half-opened.", name); + logger.warn("Http client request to {} will try again, circuit half-opened.", name); } private void circuitClosed(String name) { - logger.warn("Http client request to {0} becomes succeeded, circuit closed.", name); + logger.warn("Http client request to {} becomes succeeded, circuit closed.", name); } private static String nameFrom(String urlAsString) { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java index 71fd24bd166..9988efbdb7f 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java @@ -5,12 +5,12 @@ import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.json.JsonArray; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.jdbc.JDBCClient; import io.vertx.ext.sql.ResultSet; import io.vertx.ext.sql.SQLConnection; import org.prebid.server.execution.Timeout; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import java.time.Clock; diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java index be662e057c9..fef375a741a 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java @@ -2,11 +2,11 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.sql.ResultSet; import org.prebid.server.execution.Timeout; import org.prebid.server.log.ConditionalLogger; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import org.prebid.server.metric.Metrics; import org.prebid.server.vertx.CircuitBreaker; diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java b/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java new file mode 100644 index 00000000000..fe954cd3354 --- /dev/null +++ b/src/main/java/org/prebid/server/vertx/verticles/server/DaemonVerticle.java @@ -0,0 +1,63 @@ +package org.prebid.server.vertx.verticles.server; + +import com.codahale.metrics.ScheduledReporter; +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Closeable; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import org.apache.commons.collections4.ListUtils; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; +import org.prebid.server.vertx.CloseableAdapter; +import org.prebid.server.vertx.Initializable; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; + +public class DaemonVerticle extends AbstractVerticle { + + private static final Logger logger = LoggerFactory.getLogger(DaemonVerticle.class); + + private final List initializables; + private final List closeables; + + public DaemonVerticle(List initializables, List reporters) { + this.initializables = ListUtils.emptyIfNull(initializables); + this.closeables = ListUtils.emptyIfNull(reporters).stream() + .map(CloseableAdapter::new) + .toList(); + } + + @Override + public void start(Promise startPromise) { + startPromise.handle(all(initializables, initializable -> initializable::initialize)); + } + + @Override + public void stop(Promise stopPromise) { + stopPromise.handle(all(closeables, closeable -> closeable::close)); + } + + private static Future all(Collection entries, + Function>> entryToPromiseConsumerMapper) { + + final List> entriesFutures = new ArrayList<>(); + + for (E entry : entries) { + final Promise entryPromise = Promise.promise(); + entriesFutures.add(entryPromise.future()); + + entryToPromiseConsumerMapper.apply(entry).accept(entryPromise); + } + + return Future.all(entriesFutures) + .onSuccess(r -> logger.info( + "Successfully started {} instance on thread: {}", + DaemonVerticle.class.getSimpleName(), + Thread.currentThread().getName())) + .mapEmpty(); + } +} diff --git a/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java index eed48d09cde..147de2210c4 100644 --- a/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java +++ b/src/main/java/org/prebid/server/vertx/verticles/server/ServerVerticle.java @@ -5,12 +5,12 @@ import io.vertx.core.Promise; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import org.apache.commons.lang3.ObjectUtils; import org.prebid.server.handler.ExceptionHandler; +import org.prebid.server.log.Logger; +import org.prebid.server.log.LoggerFactory; import java.util.Objects; @@ -62,7 +62,7 @@ private void onServerStarted(AsyncResult result, Promise start if (result.succeeded()) { startPromise.tryComplete(); logger.info( - "Successfully started {0} instance on address: {1}, thread: {2}", + "Successfully started {} instance on address: {}, thread: {}", name, address, Thread.currentThread().getName()); diff --git a/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy b/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy index bb089280334..834cb57c114 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/Account.groovy @@ -1,12 +1,12 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.AccountStatus import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.db.typeconverter.AccountConfigTypeConverter @@ -14,7 +14,7 @@ import org.prebid.server.functional.model.db.typeconverter.AccountStatusTypeConv import java.sql.Timestamp -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "accounts_account") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy index 9be9b7a237f..27f66fb03d6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredImp.groovy @@ -1,17 +1,17 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.ImpConfigTypeConverter import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_imps") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy index 30a43912297..69264aa04eb 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredRequest.groovy @@ -1,17 +1,17 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.StoredRequestConfigTypeConverter import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_requests") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy index 51d59ce0959..b57e793d22e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/StoredResponse.groovy @@ -1,18 +1,18 @@ package org.prebid.server.functional.model.db import groovy.transform.ToString -import javax.persistence.Column -import javax.persistence.Convert -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.Id -import javax.persistence.Table +import jakarta.persistence.Column +import jakarta.persistence.Convert +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.Id +import jakarta.persistence.Table import org.prebid.server.functional.model.db.typeconverter.StoredAuctionResponseConfigTypeConverter import org.prebid.server.functional.model.db.typeconverter.StoredBidResponseConfigTypeConverter import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.SeatBid -import static javax.persistence.GenerationType.IDENTITY +import static jakarta.persistence.GenerationType.IDENTITY @Entity @Table(name = "stored_responses") diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy index da0a7e6d1ec..e12009cb569 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy index 005aae09d1c..b18aa387203 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/AccountStatusTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.AccountStatus class AccountStatusTypeConverter implements AttributeConverter { diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy index 5a7ac8bb54c..1dd3227b38c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/ImpConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy index 2f920559c38..e9423f02def 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredAuctionResponseConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.response.auction.SeatBid import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy index 6a1ddb05da8..43120fcad65 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredBidResponseConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy index 8668b292d8c..3e968d39565 100644 --- a/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/db/typeconverter/StoredRequestConfigTypeConverter.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.model.db.typeconverter -import javax.persistence.AttributeConverter +import jakarta.persistence.AttributeConverter import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.util.ObjectMapperWrapper diff --git a/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy b/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy index a7712d6430f..cb0a89e3a02 100644 --- a/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy +++ b/src/test/groovy/org/prebid/server/functional/repository/EntityManagerUtil.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.repository -import javax.persistence.EntityManager +import jakarta.persistence.EntityManager import org.hibernate.SessionFactory import java.util.function.Consumer diff --git a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy index ca9efffb62a..fc1b4784c70 100644 --- a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy +++ b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy @@ -263,7 +263,6 @@ class PrebidServerService implements ObjectMapperWrapper { decode(response.asString(), new TypeReference>() {}) } - String sendPrometheusMetricsRequest() { def response = given(prometheusRequestSpecification).get(PROMETHEUS_METRICS_ENDPOINT) @@ -347,7 +346,7 @@ class PrebidServerService implements ObjectMapperWrapper { if (testEnd.isBefore(testStart)) { throw new IllegalArgumentException("The end time of the test is less than the start time") } - def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") + def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss") .withZone(ZoneId.from(UTC)) def logs = Arrays.asList(pbsContainer.logs.split("\n")) def filteredLogs = [] diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy index 0e5328dc3ae..404cf1b5b15 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy @@ -284,7 +284,7 @@ class BidderParamsSpec extends BaseSpec { then: "Response should contain error" assert response.ext?.errors[ErrorType.GENERIC]*.code == [999] - assert response.ext?.errors[ErrorType.GENERIC]*.message == ["no empty host accepted"] + assert response.ext?.errors[ErrorType.GENERIC]*.message == ["host name must not be empty"] } def "PBS should reject bidder when bidder params from request doesn't satisfy json-schema for auction request"() { diff --git a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java index 69f1f46a4af..be853e77049 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporterTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -93,7 +94,7 @@ public void initializeShouldFetchConfigAndSetPeriodicTimerForConfigUpdate() thro Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); @@ -114,7 +115,7 @@ public void initializeShouldFailUpdateSendBuffersAndSetTimerWhenEndpointFromRemo Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when and then - assertThatThrownBy(() -> pubstackAnalyticsReporter.initialize()) + assertThatThrownBy(() -> pubstackAnalyticsReporter.initialize(Promise.promise())) .hasMessage("[pubstack] Failed to create event report url for endpoint: invalid") .isInstanceOf(PreBidException.class); verify(auctionHandler).reportEvents(); @@ -133,8 +134,8 @@ public void initializeShouldNotUpdateEventsIfFetchedConfigIsSameAsPrevious() thr Future.succeededFuture(HttpClientResponse.of(200, null, mapper.writeValueAsString(pubstackConfig)))); // when - pubstackAnalyticsReporter.initialize(); - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(httpClient, times(2)).get(anyString(), anyLong()); @@ -152,7 +153,7 @@ public void initializeShouldNotSendEventsAndUpdateConfigsWhenResponseStatusIsNot Future.succeededFuture(HttpClientResponse.of(400, null, null))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); @@ -168,7 +169,7 @@ public void initializeShouldNotSendEventsAndUpdateConfigsWhenCantParseResponse() Future.succeededFuture(HttpClientResponse.of(200, null, "{\"endpoint\" : {}}"))); // when - pubstackAnalyticsReporter.initialize(); + pubstackAnalyticsReporter.initialize(Promise.promise()); // then verify(vertx).setPeriodic(anyLong(), any()); diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index 58a9386de55..f96251f16be 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -2652,7 +2652,8 @@ public void shouldPopulateBidResponseExtension() { ExtBidderError.of(3, "Failed to decode: Cannot deserialize value" + " of type `com.iab.openrtb.response.Response` from Array value " + "(token `JsonToken.START_ARRAY`)\n" - + " at [Source: (String)\"[]\"; line: 1, column: 1]"))), + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION`" + + " disabled); line: 1, column: 1]"))), entry("cache", singletonList(ExtBidderError.of(999, "cacheError")))); assertThat(responseExt.getResponsetimemillis()).hasSize(2) @@ -3150,7 +3151,7 @@ public void shouldThrowExceptionWhenNativeRequestIsInvalid() throws JsonProcessi .extracting(error -> error.get(bidder1)) .extracting(extBidderErrors -> extBidderErrors.get(0)) .isEqualTo(ExtBidderError.of(3, "No content to map due to end-of-input\n" - + " at [Source: (String)\"\"; line: 1, column: 0]")); + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]")); } @Test diff --git a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java index 361c0ed72b8..343d6debd50 100644 --- a/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java +++ b/src/test/java/org/prebid/server/auction/CurrencyConversionServiceTest.java @@ -4,6 +4,7 @@ import com.iab.openrtb.request.BidRequest; import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -399,7 +400,7 @@ private CurrencyConversionService createInitializedService(String url, clock, jacksonMapper)); - currencyService.initialize(); + currencyService.initialize(Promise.promise()); return currencyService; } diff --git a/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java b/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java index da586c970f2..c104aa79675 100644 --- a/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java +++ b/src/test/java/org/prebid/server/auction/model/CachedDebugLogTest.java @@ -56,8 +56,8 @@ public void setHeadersShouldAddHeadersToLogBody() { - header1: value1 - header2: value2 + header1=value1 + header2=value2 """); } @@ -254,7 +254,7 @@ public void buildCacheBodyShouldLogRequestHeaderResponseAndErrors() { Errors: error1 error2 - headerkey: headervalue + headerkey=headervalue """); } @@ -284,7 +284,7 @@ public void buildCacheBodyShouldIgnoreDeprecatedXmlSymbolsInAllParts() { Errors: error1 error2 - headerkey: headervalue + headerkey=headervalue """); } @@ -316,7 +316,7 @@ public void buildCacheBodyShouldNotEscapeSymbolsIfPatternIsNull() { Errors: - : + = """); } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java index f406293ad38..4988a6f2792 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/VideoRequestFactoryTest.java @@ -490,7 +490,7 @@ public void fromRequestShouldCreateDebugCacheAndIncludeRequestWithHeaders() thro .containsSequence(""" {"device":{"ua":"123"}} - header1: value1 + header1=value1 """); } diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index c279492e5ed..2628aabb755 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -401,9 +401,12 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { // then assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( - "Failed to decode: Unexpected end-of-input: expected close marker for Object (start marker at" - + " [Source: (String)\"{\"; line: 1, column: 1])\n at [Source: (String)\"{\"; line: 1, " - + "column: 2]")); + "Failed to decode: Unexpected end-of-input: expected close marker" + + " for Object (start marker at [Source: REDACTED " + + "(`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); " + + "line: 1, column: 1])\n" + + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled);" + + " line: 1, column: 2]")); } private static BidderCall givenHttpCall(String body) { diff --git a/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java b/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java index b1b728aa646..f64ad993014 100644 --- a/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java +++ b/src/test/java/org/prebid/server/execution/RemoteFileSyncerTest.java @@ -2,9 +2,9 @@ import io.vertx.core.Future; import io.vertx.core.Handler; -import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.file.AsyncFile; +import io.vertx.core.file.CopyOptions; import io.vertx.core.file.FileProps; import io.vertx.core.file.FileSystem; import io.vertx.core.file.FileSystemException; @@ -33,7 +33,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -86,31 +85,31 @@ public class RemoteFileSyncerTest extends VertxTest { @Before public void setUp() { when(vertx.fileSystem()).thenReturn(fileSystem); - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, 0, httpClient, vertx); } @Test public void shouldThrowNullPointerExceptionWhenIllegalArgumentsWhenNullArguments() { assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, null, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, null, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, null, vertx)); assertThatNullPointerException().isThrownBy( - () -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, null)); } @Test public void shouldThrowIllegalArgumentExceptionWhenIllegalArguments() { assertThatIllegalArgumentException().isThrownBy( - () -> new RemoteFileSyncer(null, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + () -> new RemoteFileSyncer(remoteFileProcessor, null, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); assertThatIllegalArgumentException().isThrownBy( - () -> new RemoteFileSyncer("bad url", FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, - UPDATE_INTERVAL, httpClient, vertx)); + () -> new RemoteFileSyncer(remoteFileProcessor, "bad url", FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)); } @Test @@ -120,7 +119,7 @@ public void creteShouldCreateDirWithWritePermissionIfDirNotExist() { when(fileSystem.existsBlocking(eq(DIR_PATH))).thenReturn(false); // when - new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); // then @@ -137,7 +136,7 @@ public void createShouldCreateDirWithWritePermissionIfItsNotDir() { when(fileProps.isDirectory()).thenReturn(false); // when - new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, + new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); // then @@ -152,205 +151,187 @@ public void createShouldThrowPreBidExceptionWhenPropsThrowException() { when(fileSystem.propsBlocking(eq(DIR_PATH))).thenThrow(FileSystemException.class); // when and then - assertThatThrownBy(() -> new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, - UPDATE_INTERVAL, httpClient, vertx)) + assertThatThrownBy(() -> new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, + RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx)) .isInstanceOf(PreBidException.class); } @Test public void syncForFilepathShouldNotTriggerServiceWhenCantCheckIfUsableFileExist() { // given - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()))); + given(fileSystem.exists(anyString())) + .willReturn(Future.failedFuture(new RuntimeException())); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem).exists(eq(FILE_PATH), any()); + verify(fileSystem).exists(eq(FILE_PATH)); verifyNoInteractions(remoteFileProcessor); verifyNoInteractions(httpClient); } - @Test - public void syncForFilepathShouldRetryWhenRemoteFileProcessorIsFailed() { - // given - given(remoteFileProcessor.setDataPath(FILE_PATH)) - .willReturn(Future.failedFuture("Bad db file")); - - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))) - // Mock removal of file - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); - - // when - remoteFileSyncer.sync(remoteFileProcessor); - - // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(remoteFileProcessor).setDataPath(FILE_PATH); - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verifyNoInteractions(httpClient); - } - @Test public void syncForFilepathShouldNotUpdateWhenHeadRequestReturnInvalidHead() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); - given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn("notnumber"); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.getHeader(HttpHeaders.CONTENT_LENGTH)) + .willReturn("notnumber"); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(remoteFileProcessor).setDataPath(any()); verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldNotUpdateWhenPropsIsFailed() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new IllegalArgumentException("ERROR")))); + given(fileSystem.props(anyString())) + .willReturn(Future.failedFuture(new IllegalArgumentException("ERROR"))); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldNotUpdateServiceWhenSizeEqualsContentLength() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer(remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(fileProps))); + given(fileSystem.props(anyString())) + .willReturn(Future.succeededFuture(fileProps)); doReturn(FILE_SIZE).when(fileProps).size(); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem, times(2)).exists(eq(FILE_PATH), any()); - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(fileSystem, times(2)).exists(eq(FILE_PATH)); + verify(httpClient).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); + verify(fileSystem, never()).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldUpdateServiceWhenSizeNotEqualsContentLength() { // given - remoteFileSyncer = new RemoteFileSyncer(SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, + remoteFileSyncer = new RemoteFileSyncer( + remoteFileProcessor, SOURCE_URL, FILE_PATH, TMP_FILE_PATH, RETRY_POLICY, TIMEOUT, UPDATE_INTERVAL, httpClient, vertx); givenTriggerUpdate(); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(any())).willReturn(Future.succeededFuture()); given(httpClientResponse.getHeader(any(CharSequence.class))).willReturn(FILE_SIZE.toString()); - given(fileSystem.props(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(fileProps))); + given(fileSystem.props(anyString())) + .willReturn(Future.succeededFuture(fileProps)); - doAnswer(invocation -> { - invocation.getArgument(1, Promise.class).complete(); - return null; - }).when(fileSystem).delete(anyString(), any()); + given(fileSystem.delete(anyString())) + .willReturn(Future.succeededFuture()); doReturn(123L).when(fileProps).size(); - // Download - final long timerId = 22L; - when(vertx.setTimer(eq(TIMEOUT), any())).thenReturn(timerId); - when(asyncFile.flush()).thenReturn(asyncFile); - - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); - - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(fileSystem.open(anyString(), any())) + .willReturn(Future.succeededFuture(asyncFile)); - given(httpClientResponse.endHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(null, 0)); + given(fileSystem.move(anyString(), any(), any(CopyOptions.class))) + .willReturn(Future.succeededFuture()); - doAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 0)) - .when(asyncFile).close(any()); - - given(fileSystem.move(anyString(), any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 3)); + given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(httpClient).headAbs(eq(SOURCE_URL), any()); + verify(httpClient, times(2)).request(any()); verify(httpClientResponse).getHeader(eq(HttpHeaders.CONTENT_LENGTH)); - verify(fileSystem).props(eq(FILE_PATH), any()); + verify(fileSystem).props(eq(FILE_PATH)); // Download - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verify(vertx).setTimer(eq(TIMEOUT), any()); - verify(httpClient).getAbs(eq(SOURCE_URL), any()); - verify(httpClientResponse).endHandler(any()); - verify(asyncFile).close(any()); - verify(vertx).cancelTimer(timerId); + verify(fileSystem).open(eq(TMP_FILE_PATH), any()); + verify(asyncFile).close(); verify(remoteFileProcessor, times(2)).setDataPath(any()); - verify(vertx, times(2)).setTimer(eq(UPDATE_INTERVAL), any()); - verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); + verify(vertx).setPeriodic(eq(UPDATE_INTERVAL), any()); + verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); verifyNoMoreInteractions(httpClient); } @Test public void syncForFilepathShouldRetryAfterFailedDownload() { // given - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); + given(fileSystem.exists(any())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.failedFuture(new RuntimeException())); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any(), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any()); verifyNoInteractions(httpClient); verifyNoInteractions(remoteFileProcessor); @@ -359,12 +340,13 @@ public void syncForFilepathShouldRetryAfterFailedDownload() { @Test public void syncForFilepathShouldRetryWhenFileOpeningFailed() { // then - given(fileSystem.exists(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(any())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.failedFuture(new RuntimeException()), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.failedFuture(new RuntimeException())); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); @@ -376,11 +358,11 @@ public void syncForFilepathShouldRetryWhenFileOpeningFailed() { given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).delete(eq(TMP_FILE_PATH), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).delete(eq(TMP_FILE_PATH)); verifyNoInteractions(httpClient); verifyNoInteractions(remoteFileProcessor); @@ -389,42 +371,33 @@ public void syncForFilepathShouldRetryWhenFileOpeningFailed() { @Test public void syncForFilepathShouldDownloadFilesAndNotUpdateWhenUpdatePeriodIsNotSet() { // given - final long timerId = 22L; - when(vertx.setTimer(eq(TIMEOUT), any())).thenReturn(timerId); - when(asyncFile.flush()).thenReturn(asyncFile); - given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); + given(fileSystem.open(any(), any())) + .willReturn(Future.succeededFuture(asyncFile)); - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(asyncFile)) + .willReturn(Future.succeededFuture()); - given(httpClientResponse.endHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(null, 0)); - - doAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 0)) - .when(asyncFile).close(any()); - - given(fileSystem.move(anyString(), any(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(), 3)); + given(fileSystem.move(anyString(), anyString(), any(CopyOptions.class))) + .willReturn(Future.succeededFuture()); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then - verify(fileSystem).open(eq(TMP_FILE_PATH), any(), any()); - verify(vertx).setTimer(eq(TIMEOUT), any()); - verify(httpClient).getAbs(eq(SOURCE_URL), any()); - verify(httpClientResponse).endHandler(any()); - verify(asyncFile).close(any()); - verify(vertx).cancelTimer(timerId); + verify(fileSystem).open(eq(TMP_FILE_PATH), any()); + verify(httpClient).request(any()); + verify(asyncFile).close(); verify(remoteFileProcessor).setDataPath(any()); - verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(), any()); + verify(fileSystem).move(eq(TMP_FILE_PATH), eq(FILE_PATH), any(CopyOptions.class)); verify(vertx, never()).setTimer(eq(UPDATE_INTERVAL), any()); verifyNoMoreInteractions(httpClient); } @@ -432,54 +405,48 @@ public void syncForFilepathShouldDownloadFilesAndNotUpdateWhenUpdatePeriodIsNotS @Test public void syncForFilepathShouldRetryWhenTimeoutIsReached() { // given - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(false))) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(false)); - given(fileSystem.open(anyString(), any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(asyncFile), 2)); + given(fileSystem.open(anyString(), any())) + .willReturn(Future.succeededFuture(asyncFile)); given(vertx.setTimer(eq(RETRY_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(0L, 10L, 1)); - given(fileSystem.delete(any(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture())); - - given(httpClient.getAbs(any(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); + given(fileSystem.delete(any())) + .willReturn(Future.succeededFuture()); - given(vertx.setTimer(eq(TIMEOUT), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(null, 22L, 1)); + given(httpClient.request(any())) + .willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()) + .willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientResponse.pipeTo(asyncFile)) + .willReturn(Future.failedFuture("Timeout")); // when - remoteFileSyncer.sync(remoteFileProcessor); + remoteFileSyncer.sync(); // then verify(vertx, times(RETRY_COUNT)).setTimer(eq(RETRY_INTERVAL), any()); - verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any(), any()); + verify(fileSystem, times(RETRY_COUNT + 1)).open(eq(TMP_FILE_PATH), any()); // Response handled - verify(httpClient, times(RETRY_COUNT + 1)).getAbs(eq(SOURCE_URL), any()); - verify(vertx, times(RETRY_COUNT + 1)).setTimer(eq(TIMEOUT), any()); + verify(httpClient, times(RETRY_COUNT + 1)).request(any()); verify(asyncFile, times(RETRY_COUNT + 1)).close(); verifyNoInteractions(remoteFileProcessor); } private void givenTriggerUpdate() { - given(fileSystem.exists(anyString(), any())) - .willAnswer(withSelfAndPassObjectToHandler(Future.succeededFuture(true))); + given(fileSystem.exists(anyString())) + .willReturn(Future.succeededFuture(true)); given(remoteFileProcessor.setDataPath(anyString())).willReturn(Future.succeededFuture()); - given(vertx.setTimer(eq(UPDATE_INTERVAL), any())) + given(vertx.setPeriodic(eq(UPDATE_INTERVAL), any())) .willAnswer(withReturnObjectAndPassObjectToHandler(123L, 123L, 1)) .willReturn(123L); - - given(httpClient.headAbs(anyString(), any())) - .willAnswer(withReturnObjectAndPassObjectToHandler(httpClientResponse, httpClientRequest, 1)); - - given(httpClientRequest.exceptionHandler(any())).willReturn(httpClientRequest); } @SuppressWarnings("unchecked") @@ -504,4 +471,3 @@ private static Answer withReturnObjectAndPassObjectToHandler(T ob }; } } - diff --git a/src/test/java/org/prebid/server/it/ApplicationTest.java b/src/test/java/org/prebid/server/it/ApplicationTest.java index ac40c02648c..d870ca41bf2 100644 --- a/src/test/java/org/prebid/server/it/ApplicationTest.java +++ b/src/test/java/org/prebid/server/it/ApplicationTest.java @@ -420,14 +420,14 @@ public void vtrackShouldReturnJsonWithUids() throws JSONException, IOException { public void optionsRequestShouldRespondWithOriginalPolicyHeaders() { // when final Response response = given(SPEC) - .header("Origin", "origin.com") + .header("Origin", "http://origin.com") .header("Access-Control-Request-Method", "GET") .when() .options("/"); // then assertThat(response.header("Access-Control-Allow-Credentials")).isEqualTo("true"); - assertThat(response.header("Access-Control-Allow-Origin")).isEqualTo("origin.com"); + assertThat(response.header("Access-Control-Allow-Origin")).isEqualTo("http://origin.com"); assertThat(response.header("Access-Control-Allow-Methods")).contains(asList("HEAD", "OPTIONS", "GET", "POST")); assertThat(response.header("Access-Control-Allow-Headers")) .isEqualTo("Origin,Accept,X-Requested-With,Content-Type"); diff --git a/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java b/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java index 7623c7e273c..afff7a5d44f 100644 --- a/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java +++ b/src/test/java/org/prebid/server/log/ConditionalLoggerTest.java @@ -1,7 +1,6 @@ package org.prebid.server.log; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; diff --git a/src/test/java/org/prebid/server/log/CriteriaTest.java b/src/test/java/org/prebid/server/log/CriteriaTest.java index dd24d167fa0..fd11bf1fc55 100644 --- a/src/test/java/org/prebid/server/log/CriteriaTest.java +++ b/src/test/java/org/prebid/server/log/CriteriaTest.java @@ -1,6 +1,5 @@ package org.prebid.server.log; -import io.vertx.core.logging.Logger; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; diff --git a/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java b/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java index 9903e65b05a..6578a7edc82 100644 --- a/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java +++ b/src/test/java/org/prebid/server/log/HttpInteractionLoggerTest.java @@ -4,7 +4,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.logging.Logger; import io.vertx.ext.web.RoutingContext; import org.junit.Before; import org.junit.Rule; @@ -68,7 +67,7 @@ public void maybeLogOpenrtb2AuctionShouldLogWithExpectedParams() { // then verify(logger) - .info("Requested URL: \"{0}\", request body: \"{1}\", response status: \"{2}\", response body: \"{3}\"", + .info("Requested URL: \"{}\", request body: \"{}\", response status: \"{}\", response body: \"{}\"", "example.com", "{}", 200, @@ -198,7 +197,7 @@ public void maybeLogOpenrtb2AmpShouldLogWithExpectedParams() { // then verify(logger) - .info("Requested URL: \"{0}\", response status: \"{1}\", response body: \"{2}\"", + .info("Requested URL: \"{}\", response status: \"{}\", response body: \"{}\"", "example.com", 200, "responseBody"); @@ -292,7 +291,7 @@ public void maybeLogBidderRequestShouldLogWithExpectedParams() { target.maybeLogBidderRequest(givenAuctionContext, givenBidderRequest); // then - verify(logger).info("Request body to {0}: \"{1}\"", "bidderName", "{}"); + verify(logger).info("Request body to {}: \"{}\"", "bidderName", "{}"); } @Test diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java index 0ed1dd87a52..e10cd145d78 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java @@ -87,8 +87,8 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + assertThat(result.getErrors()) + .containsExactly("No stored request found for id: reqId"); } @Test @@ -257,7 +257,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH } @Test - public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedColumnType() { + public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalidDataType() { // given given(resultSet.getResults()).willReturn(singletonList( new JsonArray(asList("accountId", "id1", "data", 123)))); @@ -268,8 +268,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); - assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + assertThat(result.getErrors()).isEmpty(); } @Test diff --git a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java index 547d1484199..a858af44d74 100644 --- a/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/HttpPeriodicRefreshServiceTest.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -171,7 +172,7 @@ private static void createAndInitService(CacheNotificationListener notificationL Vertx vertx, HttpClient httpClient) { final HttpPeriodicRefreshService httpPeriodicRefreshService = new HttpPeriodicRefreshService( url, refreshPeriod, timeout, notificationListener, vertx, httpClient, jacksonMapper); - httpPeriodicRefreshService.initialize(); + httpPeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java index 5e49e305238..9857d048ad9 100644 --- a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java @@ -2,6 +2,7 @@ import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import org.junit.Before; import org.junit.Rule; @@ -157,7 +158,7 @@ private void createAndInitService(long refresh) { metrics, clock); - jdbcPeriodicRefreshService.initialize(); + jdbcPeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java b/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java index 52c6a7b41da..80b438ee21f 100644 --- a/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java +++ b/src/test/java/org/prebid/server/vertx/CloseableAdapterTest.java @@ -1,8 +1,7 @@ package org.prebid.server.vertx; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; +import io.vertx.core.Promise; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -26,7 +25,7 @@ public class CloseableAdapterTest { @Mock private Closeable closeable; @Mock - private Handler> completionHandler; + private Promise completionPromise; @Test public void creationShouldFailOnNullArguments() { @@ -36,10 +35,10 @@ public void creationShouldFailOnNullArguments() { @Test public void closeShouldInvokeHandlerWithSuccededFuture() { // when - new CloseableAdapter(closeable).close(completionHandler); + new CloseableAdapter(closeable).close(completionPromise); // then - verify(completionHandler).handle(eq(Future.succeededFuture())); + verify(completionPromise).handle(eq(Future.succeededFuture())); } @Test @@ -49,9 +48,9 @@ public void closeShouldInvokeHandlerWithFailedFutureIfIOExceptionThrown() throws willThrow(exception).given(closeable).close(); // when - new CloseableAdapter(closeable).close(completionHandler); + new CloseableAdapter(closeable).close(completionPromise); // then - verify(completionHandler).handle(argThat(future -> future.failed() && future.cause() == exception)); + verify(completionPromise).handle(argThat(future -> future.failed() && future.cause() == exception)); } } diff --git a/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java index a11a4cb2265..8ea24bdb5cf 100644 --- a/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java +++ b/src/test/java/org/prebid/server/vertx/httpclient/BasicHttpClientTest.java @@ -1,13 +1,13 @@ package org.prebid.server.vertx.httpclient; import io.vertx.core.Future; -import io.vertx.core.Handler; import io.vertx.core.MultiMap; import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.RequestOptions; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; @@ -15,14 +15,15 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.mockito.stubbing.Answer; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; +import java.net.MalformedURLException; import java.net.ServerSocket; import java.net.Socket; import java.util.concurrent.CountDownLatch; @@ -30,11 +31,10 @@ import java.util.concurrent.TimeoutException; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @RunWith(VertxUnitRunner.class) @@ -56,45 +56,41 @@ public class BasicHttpClientTest { @Before public void setUp() { - given(wrappedHttpClient.requestAbs(any(), any())).willReturn(httpClientRequest); - - given(httpClientRequest.setFollowRedirects(anyBoolean())).willReturn(httpClientRequest); - given(httpClientRequest.handler(any())).willReturn(httpClientRequest); - given(httpClientRequest.exceptionHandler(any())).willReturn(httpClientRequest); - given(httpClientRequest.headers()).willReturn(MultiMap.caseInsensitiveMultiMap()); - - given(httpClientResponse.bodyHandler(any())).willReturn(httpClientResponse); - given(httpClientResponse.exceptionHandler(any())).willReturn(httpClientResponse); + given(wrappedHttpClient.request(any())).willReturn(Future.succeededFuture(httpClientRequest)); + given(httpClientRequest.send()).willReturn(Future.succeededFuture(httpClientResponse)); + given(httpClientRequest.send(any(Buffer.class))).willReturn(Future.succeededFuture(httpClientResponse)); httpClient = new BasicHttpClient(vertx, wrappedHttpClient); } @Test public void requestShouldPerformHttpRequestWithExpectedParams() { - // given - final MultiMap headers = mock(MultiMap.class); - given(httpClientRequest.headers()).willReturn(headers); - - // when - httpClient.request(HttpMethod.POST, "url", headers, "body", 500L); + // given and when + httpClient.request(HttpMethod.POST, "http://www.example.com", MultiMap.caseInsensitiveMultiMap(), "body", 500L); // then - verify(wrappedHttpClient).requestAbs(eq(HttpMethod.POST), eq("url")); - verify(httpClientRequest.headers()).addAll(eq(headers)); - verify(httpClientRequest).end(eq("body")); + final ArgumentCaptor requestOptionsArgumentCaptor = + ArgumentCaptor.forClass(RequestOptions.class); + verify(wrappedHttpClient).request(requestOptionsArgumentCaptor.capture()); + + final RequestOptions expectedRequestOptions = new RequestOptions() + .setFollowRedirects(true) + .setConnectTimeout(500L) + .setMethod(HttpMethod.POST) + .setAbsoluteURI("http://www.example.com") + .setHeaders(MultiMap.caseInsensitiveMultiMap()); + assertThat(requestOptionsArgumentCaptor.getValue().toJson()).isEqualTo(expectedRequestOptions.toJson()); + + verify(httpClientRequest).send(eq(Buffer.buffer("body".getBytes()))); } @Test public void requestShouldSucceedIfHttpRequestSucceeds() { // given - given(httpClientRequest.handler(any())) - .willAnswer(withSelfAndPassObjectToHandler(httpClientResponse)); - - given(httpClientResponse.bodyHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(Buffer.buffer("response"))); + given(httpClientResponse.body()).willReturn(Future.succeededFuture(Buffer.buffer("response"))); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://www.example.com", null, (String) null, 1L); // then assertThat(future.succeeded()).isTrue(); @@ -102,34 +98,34 @@ public void requestShouldSucceedIfHttpRequestSucceeds() { @Test public void requestShouldAllowFollowingRedirections() { - // when - httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + // given and when + httpClient.request(HttpMethod.POST, "http://www.example.com", MultiMap.caseInsensitiveMultiMap(), "body", 500L); // then - verify(httpClientRequest).setFollowRedirects(true); + final ArgumentCaptor requestOptionsArgumentCaptor = + ArgumentCaptor.forClass(RequestOptions.class); + verify(wrappedHttpClient).request(requestOptionsArgumentCaptor.capture()); + assertTrue(requestOptionsArgumentCaptor.getValue().getFollowRedirects()); } @Test public void requestShouldFailIfInvalidUrlPassed() { - // given - given(wrappedHttpClient.requestAbs(any(), any())).willThrow(new RuntimeException("error")); - - // when + // given and when final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); - assertThat(future.cause()).hasMessage("error"); + assertThat(future.cause()).isInstanceOf(MalformedURLException.class); } @Test public void requestShouldFailIfHttpRequestFails() { // given - given(httpClientRequest.exceptionHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(new RuntimeException("Request exception"))); + given(wrappedHttpClient.request(any())) + .willReturn(Future.failedFuture("Request exception")); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://www.example.com", null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); @@ -139,14 +135,11 @@ public void requestShouldFailIfHttpRequestFails() { @Test public void requestShouldFailIfHttpResponseFails() { // given - given(httpClientRequest.handler(any())) - .willAnswer(withSelfAndPassObjectToHandler(httpClientResponse)); - - given(httpClientResponse.exceptionHandler(any())) - .willAnswer(withSelfAndPassObjectToHandler(new RuntimeException("Response exception"))); + given(wrappedHttpClient.request(any())) + .willReturn(Future.failedFuture("Response exception")); // when - final Future future = httpClient.request(HttpMethod.GET, null, null, (String) null, 1L); + final Future future = httpClient.request(HttpMethod.GET, "http://example.coom", null, (String) null, 1L); // then assertThat(future.failed()).isTrue(); @@ -254,13 +247,4 @@ private static void sleep(long millis) { throw new RuntimeException(e); } } - - @SuppressWarnings("unchecked") - private static Answer withSelfAndPassObjectToHandler(T obj) { - return inv -> { - // invoking handler right away passing mock to it - ((Handler) inv.getArgument(0)).handle(obj); - return inv.getMock(); - }; - } } From 2fea8e5fa17f7fdb6ebfea6f0029898620fc2f8a Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Thu, 18 Apr 2024 17:09:09 +0200 Subject: [PATCH 09/58] Core: Java upgrade (#3126) --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .github/workflows/docker-image-publish.yml | 2 +- .github/workflows/pr-functional-tests.yml | 2 +- .github/workflows/pr-java-ci.yml | 2 +- .../workflows/pr-module-functional-tests.yml | 2 +- .github/workflows/release-asset-publish.yml | 2 +- Dockerfile | 2 +- Dockerfile-modules | 2 +- extra/bundle/pom.xml | 2 +- extra/modules/pom.xml | 4 +-- extra/pom.xml | 4 +-- pom.xml | 22 ++++++++----- .../prebid/server/bidder/adot/AdotBidder.java | 2 +- .../server/bidder/algorix/AlgorixBidder.java | 6 ++-- .../java/org/prebid/server/util/HttpUtil.java | 11 +++++++ src/main/resources/bidder-config/adot.yaml | 2 +- src/main/resources/bidder-config/algorix.yaml | 2 +- .../bidder/HttpBidderRequesterTest.java | 31 +++++++++---------- .../server/bidder/adot/AdotBidderTest.java | 2 +- .../bidder/algorix/AlgorixBidderTest.java | 2 +- 21 files changed, 61 insertions(+), 47 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 74747d3fe15..f64a14137d4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,3 +1,3 @@ # From https://github.com/microsoft/vscode-dev-containers/blob/master/containers/go/.devcontainer/Dockerfile -ARG VARIANT="17-jdk-bookworm" +ARG VARIANT="21-jdk-bookworm" FROM mcr.microsoft.com/vscode/devcontainers/java:${VARIANT} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d167be89720..d9a309d3661 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "dockerfile": "Dockerfile", "args": { // Update the VARIANT arg to pick a version of Java - "VARIANT": "17-jdk-bookworm", + "VARIANT": "21-jdk-bookworm", } }, "containerEnv": { diff --git a/.github/workflows/docker-image-publish.yml b/.github/workflows/docker-image-publish.yml index 63d1961388d..4249a8370a9 100644 --- a/.github/workflows/docker-image-publish.yml +++ b/.github/workflows/docker-image-publish.yml @@ -19,7 +19,7 @@ jobs: packages: write strategy: matrix: - java: [ 17 ] + java: [ 21 ] dockerfile-path: [Dockerfile, extra/Dockerfile] include: - dockerfile-path: Dockerfile diff --git a/.github/workflows/pr-functional-tests.yml b/.github/workflows/pr-functional-tests.yml index 610c6693193..e3ac3ffcd10 100644 --- a/.github/workflows/pr-functional-tests.yml +++ b/.github/workflows/pr-functional-tests.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pr-java-ci.yml b/.github/workflows/pr-java-ci.yml index 79a904c3636..3ead6423d9f 100644 --- a/.github/workflows/pr-java-ci.yml +++ b/.github/workflows/pr-java-ci.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pr-module-functional-tests.yml b/.github/workflows/pr-module-functional-tests.yml index d8f1e925a07..d87fbe4857a 100644 --- a/.github/workflows/pr-module-functional-tests.yml +++ b/.github/workflows/pr-module-functional-tests.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-asset-publish.yml b/.github/workflows/release-asset-publish.yml index 1de13751c3a..fb1057d8ee8 100644 --- a/.github/workflows/release-asset-publish.yml +++ b/.github/workflows/release-asset-publish.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v4 - name: Set up JDK diff --git a/Dockerfile b/Dockerfile index d69d5346506..b1fab501fa9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM amazoncorretto:17 +FROM amazoncorretto:21 WORKDIR /app/prebid-server diff --git a/Dockerfile-modules b/Dockerfile-modules index a9cbfe71b31..d3338d2c376 100644 --- a/Dockerfile-modules +++ b/Dockerfile-modules @@ -1,4 +1,4 @@ -FROM amazoncorretto:17 +FROM amazoncorretto:21 WORKDIR /app/prebid-server diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 30748f5061f..2c66f1b22f2 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -17,7 +17,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} 2.5.6 diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 6a0d60bc391..0d442c3d4ef 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -25,7 +25,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} @@ -34,7 +34,7 @@ 4.13.2 4.7.0 - 3.10.1 + 3.11.0 2.22.2 diff --git a/extra/pom.xml b/extra/pom.xml index 0afb89a0b85..7b8a60f2108 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -17,8 +17,8 @@ UTF-8 UTF-8 - 17 - 17 + 21 + 21 4.5.5 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index 638bf87e9f5..753fd5f064b 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ UTF-8 UTF-8 - 17 + 21 ${java.version} ${java.version} Dockerfile @@ -64,7 +64,7 @@ 5.4.0 2.2.220 2.4-M2-groovy-4.0 - 3.0.14 + 4.0.15 1.17.4 5.14.0 1.9.9.1 @@ -76,11 +76,11 @@ 1.2.0 0.8.11 2.2.4 - 3.10.1 + 3.11.0 2.22.2 ${maven-surefire-plugin.version} 0.40.2 - 1.13.1 + 3.0.2 false true false @@ -523,15 +523,21 @@ spock-core ${spock.version} test + + + org.apache.groovy + groovy + + - org.codehaus.groovy + org.apache.groovy groovy ${groovy.version} test - org.codehaus.groovy + org.apache.groovy groovy-yaml ${groovy.version} test @@ -949,8 +955,8 @@ org.apache.maven.plugins maven-compiler-plugin - 17 - 17 + 21 + 21 diff --git a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java index 54b8cf8cf12..1c406402069 100644 --- a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java +++ b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java @@ -39,7 +39,7 @@ public class AdotBidder implements Bidder { private static final List ALLOWED_BID_TYPES = Arrays.asList(BidType.banner, BidType.video, BidType.xNative); private static final String PRICE_MACRO = "${AUCTION_PRICE}"; - private static final String PUBLISHER_MACRO = "{PUBLISHER_PATH}"; + private static final String PUBLISHER_MACRO = "{{PUBLISHER_PATH}}"; private static final TypeReference> ADOT_EXT_TYPE_REFERENCE = new TypeReference<>() { }; diff --git a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java index 43549c101e8..0ddf5827f9a 100644 --- a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java +++ b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java @@ -46,9 +46,9 @@ public class AlgorixBidder implements Bidder { new TypeReference<>() { }; - private static final String URL_REGION_MACRO = "{HOST}"; - private static final String URL_SID_MACRO = "{SID}"; - private static final String URL_TOKEN_MACRO = "{TOKEN}"; + private static final String URL_REGION_MACRO = "{{HOST}}"; + private static final String URL_SID_MACRO = "{{SID}}"; + private static final String URL_TOKEN_MACRO = "{{TOKEN}}"; private static final int FIRST_INDEX = 0; diff --git a/src/main/java/org/prebid/server/util/HttpUtil.java b/src/main/java/org/prebid/server/util/HttpUtil.java index 005230166e7..9a21fcc0681 100644 --- a/src/main/java/org/prebid/server/util/HttpUtil.java +++ b/src/main/java/org/prebid/server/util/HttpUtil.java @@ -74,6 +74,8 @@ public final class HttpUtil { public static final CharSequence SEC_CH_UA = HttpHeaders.createOptimized("Sec-CH-UA"); public static final CharSequence SEC_CH_UA_MOBILE = HttpHeaders.createOptimized("Sec-CH-UA-Mobile"); public static final CharSequence SEC_CH_UA_PLATFORM = HttpHeaders.createOptimized("Sec-CH-UA-Platform"); + public static final String MACROS_OPEN = "{{"; + public static final String MACROS_CLOSE = "}}"; private HttpUtil() { } @@ -82,6 +84,10 @@ private HttpUtil() { * Checks the input string for using as URL. */ public static String validateUrl(String url) { + if (containsMacrosses(url)) { + return url; + } + try { return new URL(url).toString(); } catch (MalformedURLException e) { @@ -89,6 +95,11 @@ public static String validateUrl(String url) { } } + // TODO: We need our own way to work with url macrosses + private static boolean containsMacrosses(String url) { + return StringUtils.contains(url, MACROS_OPEN) && StringUtils.contains(url, MACROS_CLOSE); + } + /** * Returns encoded URL for the given value. *

diff --git a/src/main/resources/bidder-config/adot.yaml b/src/main/resources/bidder-config/adot.yaml index 91a975e521f..fa4a5a5f489 100644 --- a/src/main/resources/bidder-config/adot.yaml +++ b/src/main/resources/bidder-config/adot.yaml @@ -1,6 +1,6 @@ adapters: adot: - endpoint: https://dsp.adotmob.com/headerbidding{PUBLISHER_PATH}/bidrequest + endpoint: https://dsp.adotmob.com/headerbidding{{PUBLISHER_PATH}}/bidrequest meta-info: maintainer-email: admin@we-are-adot.com app-media-types: diff --git a/src/main/resources/bidder-config/algorix.yaml b/src/main/resources/bidder-config/algorix.yaml index 70c56825fdd..f76db6420ce 100644 --- a/src/main/resources/bidder-config/algorix.yaml +++ b/src/main/resources/bidder-config/algorix.yaml @@ -1,6 +1,6 @@ adapters: algorix: - endpoint: https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN} + endpoint: https://{{HOST}}.svr-algorix.com/rtb/sa?sid={{SID}}&token={{TOKEN}} meta-info: maintainer-email: prebid@algorix.co app-media-types: diff --git a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java index 6a7aeeb25bd..35bd07a6881 100644 --- a/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java +++ b/src/test/java/org/prebid/server/bidder/HttpBidderRequesterTest.java @@ -48,7 +48,6 @@ import java.time.ZoneId; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.UnaryOperator; @@ -359,10 +358,9 @@ public void shouldReturnBidsCreatedByMakeBids() { // given givenSuccessfulBidderMakeHttpRequests(); - final List bids = asList( - BidderBid.of(Bid.builder().impid("1").build(), null, null), - BidderBid.of(Bid.builder().impid("2").build(), null, null)); - given(bidder.makeBids(any(), any())).willReturn(Result.of(bids, emptyList())); + final List bids = emptyList(); + given(bidder.makeBidderResponse(any(), any())) + .willReturn(CompositeBidderResponse.withBids(bids, null)); final BidderRequest bidderRequest = BidderRequest.builder() .bidder("bidder") @@ -383,8 +381,6 @@ public void shouldReturnBidsCreatedByMakeBids() { .result(); // then - verify(bidder, times(1)).makeBids(any(), any()); - verify(bidder, times(1)).makeBidderResponse(any(), any()); assertThat(bidderSeatBid.getBids()).hasSameElementsAs(bids); } @@ -727,20 +723,23 @@ public void shouldReturnRecordBidRejections() throws JsonProcessingException { } @Test - public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { + public void shouldNotReturnSensitiveHeadersInFullDebugInfo() + throws JsonProcessingException { // given final MultiMap headers = MultiMap.caseInsensitiveMultiMap(); headers.add("headerKey", "headerValue"); headers.add("Authorization", "authorizationValue"); + final BidRequest givenBidRequest = givenBidRequest(identity()); + final byte[] requestBody = mapper.writeValueAsBytes(givenBidRequest); given(bidder.makeHttpRequests(any())).willReturn(Result.of(singletonList( givenSimpleHttpRequest(httpRequestBuilder -> httpRequestBuilder .uri("uri1") - .headers(headers))), + .headers(headers) + .payload(givenBidRequest) + .body(requestBody))), emptyList())); - given(requestEnricher.enrichHeaders(anyString(), any(), any(), any(), any())).willReturn(headers); - givenHttpClientReturnsResponses( - HttpClientResponse.of(200, null, "responseBody1")); + given(requestEnricher.enrichHeaders(anyString(), any(), any(), any(), any())).willReturn(headers); final BidderRequest bidderRequest = BidderRequest.builder() .bidder("bidder") @@ -749,12 +748,11 @@ public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { // when final BidderSeatBid bidderSeatBid = - target - .requestBids( + target.requestBids( bidder, bidderRequest, bidRejectionTracker, - timeout, + expiredTimeout, CaseInsensitiveMultiMap.empty(), bidderAliases, true) @@ -763,8 +761,7 @@ public void shouldNotReturnSensitiveHeadersInFullDebugInfo() { // then assertThat(bidderSeatBid.getHttpCalls()) .extracting(ExtHttpCall::getRequestheaders) - .flatExtracting(Map::keySet) - .containsExactly("headerKey"); + .containsExactly(singletonMap("headerKey", singletonList("headerValue"))); } @Test diff --git a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java index fb05f8387c9..fea318e7022 100644 --- a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java @@ -37,7 +37,7 @@ public class AdotBidderTest extends VertxTest { - private static final String ENDPOINT_URL = "https://test.endpoint{PUBLISHER_PATH}.com"; + private static final String ENDPOINT_URL = "https://test.endpoint{{PUBLISHER_PATH}}.com"; private final AdotBidder target = new AdotBidder(ENDPOINT_URL, jacksonMapper); diff --git a/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java b/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java index 3ffe4ba86ff..72748cc8d35 100644 --- a/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/algorix/AlgorixBidderTest.java @@ -42,7 +42,7 @@ */ public class AlgorixBidderTest extends VertxTest { - private static final String ENDPOINT_URL = "https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}"; + private static final String ENDPOINT_URL = "https://{{HOST}}.svr-algorix.com/rtb/sa?sid={{SID}}&token={{TOKEN}}"; private final AlgorixBidder target = new AlgorixBidder(ENDPOINT_URL, jacksonMapper); From 9cd583c8cc7c39d512baeb6f5c8d5c3649c78f1b Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:35:27 +0200 Subject: [PATCH 10/58] Async DB Clients (#3118) --- pom.xml | 7 +- .../server/health/DatabaseHealthChecker.java | 14 +- .../settings/JdbcApplicationSettings.java | 76 +- .../helper/JdbcStoredDataResultMapper.java | 44 +- .../JdbcStoredResponseResultMapper.java | 31 +- .../helper/ParametrizedQueryHelper.java | 16 + .../helper/ParametrizedQueryMySqlHelper.java | 34 + .../ParametrizedQueryPostgresHelper.java | 45 ++ .../config/HealthCheckerConfiguration.java | 6 +- .../spring/config/SettingsConfiguration.java | 3 + .../database/DatabaseConfiguration.java | 180 ++--- .../server/vertx/jdbc/BasicJdbcClient.java | 88 +-- .../jdbc/CircuitBreakerSecuredJdbcClient.java | 5 +- .../prebid/server/vertx/jdbc/JdbcClient.java | 5 +- .../health/DatabaseHealthCheckerTest.java | 62 +- ...ntActivityRulesConfigDeserializerTest.java | 5 +- ...tringAsListOfIntegersDeserializerTest.java | 13 +- .../settings/JdbcApplicationSettingsTest.java | 650 ++++-------------- .../JdbcStoredDataResultMapperTest.java | 196 ++++-- .../JdbcStoredResponseResultMapperTest.java | 78 ++- .../ParametrizedQueryMySqlHelperTest.java | 106 +++ .../ParametrizedQueryPostgresHelperTest.java | 106 +++ .../vertx/jdbc/BasicJdbcClientTest.java | 150 ++-- .../CircuitBreakerSecuredJdbcClientTest.java | 56 +- 24 files changed, 988 insertions(+), 988 deletions(-) create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java create mode 100644 src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java create mode 100644 src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java create mode 100644 src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java diff --git a/pom.xml b/pom.xml index 753fd5f064b..79ae15fa03f 100644 --- a/pom.xml +++ b/pom.xml @@ -162,7 +162,12 @@ io.vertx - vertx-jdbc-client + vertx-mysql-client + ${vertx.version} + + + io.vertx + vertx-pg-client ${vertx.version} diff --git a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java index e27a72dd0db..6949aba2d12 100644 --- a/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java +++ b/src/main/java/org/prebid/server/health/DatabaseHealthChecker.java @@ -1,9 +1,7 @@ package org.prebid.server.health; -import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; import org.prebid.server.health.model.Status; import org.prebid.server.health.model.StatusResponse; @@ -15,13 +13,13 @@ public class DatabaseHealthChecker extends PeriodicHealthChecker { private static final String NAME = "database"; - private final JDBCClient jdbcClient; + private final Pool pool; private StatusResponse status; - public DatabaseHealthChecker(Vertx vertx, JDBCClient jdbcClient, long refreshPeriod) { + public DatabaseHealthChecker(Vertx vertx, Pool pool, long refreshPeriod) { super(vertx, refreshPeriod); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.pool = Objects.requireNonNull(pool); } @Override @@ -36,9 +34,7 @@ public String name() { @Override void updateStatus() { - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - connectionPromise.future().onComplete(result -> + pool.getConnection().onComplete(result -> status = StatusResponse.of( result.succeeded() ? Status.UP.name() : Status.DOWN.name(), ZonedDateTime.now(Clock.systemUTC()))); diff --git a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java b/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java index a922c3af898..6dd9f507ffa 100644 --- a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java @@ -1,8 +1,9 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.prebid.server.exception.PreBidException; @@ -11,9 +12,11 @@ import org.prebid.server.json.JacksonMapper; import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; import org.prebid.server.settings.helper.JdbcStoredResponseResultMapper; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; +import org.prebid.server.util.ObjectUtil; import org.prebid.server.vertx.jdbc.JdbcClient; import java.util.ArrayList; @@ -23,7 +26,6 @@ import java.util.Objects; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.IntStream; /** @@ -36,14 +38,9 @@ */ public class JdbcApplicationSettings implements ApplicationSettings { - private static final String ACCOUNT_ID_PLACEHOLDER = "%ACCOUNT_ID%"; - private static final String REQUEST_ID_PLACEHOLDER = "%REQUEST_ID_LIST%"; - private static final String IMP_ID_PLACEHOLDER = "%IMP_ID_LIST%"; - private static final String RESPONSE_ID_PLACEHOLDER = "%RESPONSE_ID_LIST%"; - private static final String QUERY_PARAM_PLACEHOLDER = "?"; - private final JdbcClient jdbcClient; private final JacksonMapper mapper; + private final ParametrizedQueryHelper parametrizedQueryHelper; /** * Query to select account by ids. @@ -86,6 +83,7 @@ public class JdbcApplicationSettings implements ApplicationSettings { public JdbcApplicationSettings(JdbcClient jdbcClient, JacksonMapper mapper, + ParametrizedQueryHelper parametrizedQueryHelper, String selectAccountQuery, String selectStoredRequestsQuery, String selectAmpStoredRequestsQuery, @@ -93,8 +91,9 @@ public JdbcApplicationSettings(JdbcClient jdbcClient, this.jdbcClient = Objects.requireNonNull(jdbcClient); this.mapper = Objects.requireNonNull(mapper); - this.selectAccountQuery = Objects.requireNonNull(selectAccountQuery) - .replace(ACCOUNT_ID_PLACEHOLDER, QUERY_PARAM_PLACEHOLDER); + this.parametrizedQueryHelper = Objects.requireNonNull(parametrizedQueryHelper); + this.selectAccountQuery = parametrizedQueryHelper.replaceAccountIdPlaceholder( + Objects.requireNonNull(selectAccountQuery)); this.selectStoredRequestsQuery = Objects.requireNonNull(selectStoredRequestsQuery); this.selectAmpStoredRequestsQuery = Objects.requireNonNull(selectAmpStoredRequestsQuery); this.selectStoredResponsesQuery = Objects.requireNonNull(selectStoredResponsesQuery); @@ -109,7 +108,7 @@ public Future getAccountById(String accountId, Timeout timeout) { return jdbcClient.executeQuery( selectAccountQuery, Collections.singletonList(accountId), - result -> mapToModelOrError(result, row -> toAccount(row.getString(0))), + result -> mapToModelOrError(result, this::toAccount), timeout) .compose(result -> failedIfNull(result, accountId, "Account")); } @@ -120,14 +119,15 @@ public Future> getCategories(String primaryAdServer, String } /** - * Transforms the first row of {@link ResultSet} to required object or returns null. + * Transforms the first row of {@link RowSet} to required object or returns null. *

* Note: mapper should never throws exception in case of using * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. */ - private T mapToModelOrError(ResultSet result, Function mapper) { - return result != null && CollectionUtils.isNotEmpty(result.getResults()) - ? mapper.apply(result.getResults().get(0)) + private T mapToModelOrError(RowSet rowSet, Function mapper) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + return rowIterator != null && rowIterator.hasNext() + ? mapper.apply(rowIterator.next()) : null; } @@ -141,7 +141,8 @@ private static Future failedIfNull(T value, String id, String errorPrefix : Future.failedFuture(new PreBidException("%s not found: %s".formatted(errorPrefix, id))); } - private Account toAccount(String source) { + private Account toAccount(Row row) { + final String source = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); try { return source != null ? mapper.decodeValue(source, Account.class) : null; } catch (DecodeException e) { @@ -185,11 +186,15 @@ public Future getVideoStoredData(String accountId, Set */ @Override public Future getStoredResponses(Set responseIds, Timeout timeout) { - final String queryResolvedWithParameters = selectStoredResponsesQuery.replaceAll(RESPONSE_ID_PLACEHOLDER, - parameterHolders(responseIds.size())); + final String queryResolvedWithParameters = parametrizedQueryHelper.replaceStoredResponseIdPlaceholders( + selectStoredResponsesQuery, + responseIds.size()); final List idsQueryParameters = new ArrayList<>(); - IntStream.rangeClosed(1, StringUtils.countMatches(selectStoredResponsesQuery, RESPONSE_ID_PLACEHOLDER)) + final int responseIdPlaceholderCount = StringUtils.countMatches( + selectStoredResponsesQuery, + ParametrizedQueryHelper.RESPONSE_ID_PLACEHOLDER); + IntStream.rangeClosed(1, responseIdPlaceholderCount) .forEach(i -> idsQueryParameters.addAll(responseIds)); return jdbcClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, @@ -208,12 +213,16 @@ private Future fetchStoredData(String query, String accountId, StoredDataResult.of(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList())); } else { final List idsQueryParameters = new ArrayList<>(); - IntStream.rangeClosed(1, StringUtils.countMatches(query, REQUEST_ID_PLACEHOLDER)) + IntStream.rangeClosed(1, StringUtils.countMatches(query, ParametrizedQueryHelper.REQUEST_ID_PLACEHOLDER)) .forEach(i -> idsQueryParameters.addAll(requestIds)); - IntStream.rangeClosed(1, StringUtils.countMatches(query, IMP_ID_PLACEHOLDER)) + IntStream.rangeClosed(1, StringUtils.countMatches(query, ParametrizedQueryHelper.IMP_ID_PLACEHOLDER)) .forEach(i -> idsQueryParameters.addAll(impIds)); - final String parametrizedQuery = createParametrizedQuery(query, requestIds.size(), impIds.size()); + final String parametrizedQuery = parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders( + query, + requestIds.size(), + impIds.size()); + future = jdbcClient.executeQuery(parametrizedQuery, idsQueryParameters, result -> JdbcStoredDataResultMapper.map(result, accountId, requestIds, impIds), timeout); @@ -221,25 +230,4 @@ private Future fetchStoredData(String query, String accountId, return future; } - - /** - * Creates parametrized query from query and variable templates, by replacing templateVariable - * with appropriate number of "?" placeholders. - */ - private static String createParametrizedQuery(String query, int requestIdsSize, int impIdsSize) { - return query - .replace(REQUEST_ID_PLACEHOLDER, parameterHolders(requestIdsSize)) - .replace(IMP_ID_PLACEHOLDER, parameterHolders(impIdsSize)); - } - - /** - * Returns string for parametrized placeholder. - */ - private static String parameterHolders(int paramsSize) { - return paramsSize == 0 - ? "NULL" - : IntStream.range(0, paramsSize) - .mapToObj(i -> QUERY_PARAM_PLACEHOLDER) - .collect(Collectors.joining(",")); - } } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java index 6ea14d294d0..c7e9ec820f8 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java @@ -1,14 +1,15 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; -import org.apache.commons.collections4.CollectionUtils; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.prebid.server.exception.PreBidException; import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerFactory; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; +import org.prebid.server.util.ObjectUtil; import java.util.ArrayList; import java.util.Collections; @@ -19,7 +20,7 @@ import java.util.Set; /** - * Utility class for mapping {@link ResultSet} to {@link StoredDataResult}. + * Utility class for mapping {@link RowSet} to {@link StoredDataResult}. */ public class JdbcStoredDataResultMapper { @@ -29,9 +30,9 @@ private JdbcStoredDataResultMapper() { } /** - * Maps {@link ResultSet} to {@link StoredDataResult} and creates an error for each missing ID and add it to result. + * Maps {@link RowSet} to {@link StoredDataResult} and creates an error for each missing ID and add it to result. * - * @param resultSet - incoming Result Set representing a result of SQL query + * @param rowSet - incoming Row Set representing a result of SQL query * @param accountId - an account ID extracted from request * @param requestIds - a specified set of stored requests' IDs. Adds error for each ID missing in result set * @param impIds - a specified set of stored imps' IDs. Adds error for each ID missing in result set @@ -40,13 +41,17 @@ private JdbcStoredDataResultMapper() { * Note: mapper should never throws exception in case of using * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. */ - public static StoredDataResult map(ResultSet resultSet, String accountId, Set requestIds, + public static StoredDataResult map(RowSet rowSet, + String accountId, + Set requestIds, Set impIds) { final Map storedIdToRequest; final Map storedIdToImp; final List errors = new ArrayList<>(); - if (resultSet == null || CollectionUtils.isEmpty(resultSet.getResults())) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + + if (rowIterator == null || !rowIterator.hasNext()) { storedIdToRequest = Collections.emptyMap(); storedIdToImp = Collections.emptyMap(); @@ -64,17 +69,24 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set> requestIdToStoredItems = new HashMap<>(); final Map> impIdToStoredItems = new HashMap<>(); - for (JsonArray result : resultSet.getResults()) { + while (rowIterator.hasNext()) { + final Row row = rowIterator.next(); + if (row.toJson().size() < 4) { + final String message = "Error occurred while mapping stored request data: some columns are missing"; + logger.error(message); + errors.add(message); + return StoredDataResult.of(Collections.emptyMap(), Collections.emptyMap(), errors); + } final String fetchedAccountId; final String id; final String data; final String typeAsString; try { - fetchedAccountId = result.getString(0); - id = result.getString(1); - data = result.getString(2); - typeAsString = result.getString(3); - } catch (IndexOutOfBoundsException | ClassCastException e) { + fetchedAccountId = row.getString(0); + id = row.getString(1); + data = ObjectUtil.getIfNotNull(row.getValue(2), Object::toString); + typeAsString = ObjectUtil.getIfNotNull(row.getValue(3), Object::toString); + } catch (ClassCastException e) { final String message = "Error occurred while mapping stored request data"; logger.error(message, e); errors.add(message); @@ -109,10 +121,10 @@ public static StoredDataResult map(ResultSet resultSet, String accountId, Set} representing a result of SQL query. * @return - a {@link StoredDataResult} object. */ - public static StoredDataResult map(ResultSet resultSet) { + public static StoredDataResult map(RowSet resultSet) { return map(resultSet, null, Collections.emptySet(), Collections.emptySet()); } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java b/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java index 4d6b5208cbd..6b6cc4462ae 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java @@ -1,8 +1,8 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; -import org.apache.commons.collections4.CollectionUtils; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; import org.prebid.server.settings.model.StoredResponseDataResult; import java.util.ArrayList; @@ -17,26 +17,29 @@ public class JdbcStoredResponseResultMapper { private JdbcStoredResponseResultMapper() { } - public static StoredResponseDataResult map(ResultSet resultSet, Set responseIds) { + public static StoredResponseDataResult map(RowSet rowSet, Set responseIds) { final Map storedIdToResponse = new HashMap<>(responseIds.size()); final List errors = new ArrayList<>(); - if (resultSet == null || CollectionUtils.isEmpty(resultSet.getResults())) { + final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; + if (rowIterator == null || !rowIterator.hasNext()) { handleEmptyResultError(responseIds, errors); - } else { - try { - for (JsonArray result : resultSet.getResults()) { - storedIdToResponse.put(result.getString(0), result.getString(1)); - } - } catch (IndexOutOfBoundsException e) { + return StoredResponseDataResult.of(storedIdToResponse, errors); + } + + while (rowIterator.hasNext()) { + final Row row = rowIterator.next(); + if (row.toJson().size() < 2) { errors.add("Result set column number is less than expected"); return StoredResponseDataResult.of(Collections.emptyMap(), errors); } - errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) - .map(id -> "No stored response found for id: " + id) - .toList()); + storedIdToResponse.put(row.getString(0), row.getString(1)); } + errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) + .map(id -> "No stored response found for id: " + id) + .toList()); + return StoredResponseDataResult.of(storedIdToResponse, errors); } diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java new file mode 100644 index 00000000000..1d7660e0b76 --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryHelper.java @@ -0,0 +1,16 @@ +package org.prebid.server.settings.helper; + +public interface ParametrizedQueryHelper { + + String ACCOUNT_ID_PLACEHOLDER = "%ACCOUNT_ID%"; + String REQUEST_ID_PLACEHOLDER = "%REQUEST_ID_LIST%"; + String IMP_ID_PLACEHOLDER = "%IMP_ID_LIST%"; + String RESPONSE_ID_PLACEHOLDER = "%RESPONSE_ID_LIST%"; + + String replaceAccountIdPlaceholder(String query); + + String replaceStoredResponseIdPlaceholders(String query, int idsNumber); + + String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber); + +} diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java new file mode 100644 index 00000000000..e6e6336afc8 --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelper.java @@ -0,0 +1,34 @@ +package org.prebid.server.settings.helper; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class ParametrizedQueryMySqlHelper implements ParametrizedQueryHelper { + + private static final String PARAMETER_PLACEHOLDER = "?"; + + @Override + public String replaceAccountIdPlaceholder(String query) { + return query.replace(ACCOUNT_ID_PLACEHOLDER, PARAMETER_PLACEHOLDER); + } + + @Override + public String replaceStoredResponseIdPlaceholders(String query, int idsNumber) { + return query.replaceAll(RESPONSE_ID_PLACEHOLDER, parameterHolders(idsNumber)); + } + + @Override + public String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber) { + return query + .replace(REQUEST_ID_PLACEHOLDER, parameterHolders(requestIdNumber)) + .replace(IMP_ID_PLACEHOLDER, parameterHolders(impIdNumber)); + } + + private static String parameterHolders(int paramsSize) { + return paramsSize == 0 + ? "NULL" + : IntStream.range(0, paramsSize) + .mapToObj(i -> PARAMETER_PLACEHOLDER) + .collect(Collectors.joining(",")); + } +} diff --git a/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java new file mode 100644 index 00000000000..c380b8e91df --- /dev/null +++ b/src/main/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelper.java @@ -0,0 +1,45 @@ +package org.prebid.server.settings.helper; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class ParametrizedQueryPostgresHelper implements ParametrizedQueryHelper { + + private static final Pattern PLACEHOLDER_PATTERN = + Pattern.compile("(%s)|(%s)".formatted(REQUEST_ID_PLACEHOLDER, IMP_ID_PLACEHOLDER)); + + @Override + public String replaceAccountIdPlaceholder(String query) { + return query.replace(ACCOUNT_ID_PLACEHOLDER, "$1"); + } + + @Override + public String replaceStoredResponseIdPlaceholders(String query, int idsNumber) { + return query.replaceAll(RESPONSE_ID_PLACEHOLDER, parameterHolders(idsNumber, 0)); + } + + @Override + public String replaceRequestAndImpIdPlaceholders(String query, int requestIdNumber, int impIdNumber) { + final Matcher matcher = PLACEHOLDER_PATTERN.matcher(query); + + int i = 0; + final StringBuilder queryBuilder = new StringBuilder(); + while (matcher.find()) { + final int paramsNumber = matcher.group(1) != null ? requestIdNumber : impIdNumber; + matcher.appendReplacement(queryBuilder, parameterHolders(paramsNumber, i)); + i += paramsNumber; + } + matcher.appendTail(queryBuilder); + return queryBuilder.toString(); + } + + private static String parameterHolders(int paramsSize, int start) { + return paramsSize == 0 + ? "NULL" + : IntStream.range(start, start + paramsSize) + .mapToObj(i -> "\\$" + (i + 1)) + .collect(Collectors.joining(",")); + } +} diff --git a/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java b/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java index 9f6669141f8..93eaeb48030 100644 --- a/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/HealthCheckerConfiguration.java @@ -1,7 +1,7 @@ package org.prebid.server.spring.config; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; +import io.vertx.sqlclient.Pool; import org.prebid.server.execution.TimeoutFactory; import org.prebid.server.geolocation.GeoLocationService; import org.prebid.server.health.ApplicationChecker; @@ -24,10 +24,10 @@ public class HealthCheckerConfiguration { @Bean @ConditionalOnProperty(prefix = "health-check.database", name = "enabled", havingValue = "true") HealthChecker databaseChecker(Vertx vertx, - JDBCClient jdbcClient, + Pool pool, @Value("${health-check.database.refresh-period-ms}") long refreshPeriod) { - return new DatabaseHealthChecker(vertx, jdbcClient, refreshPeriod); + return new DatabaseHealthChecker(vertx, pool, refreshPeriod); } @Bean diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 5a6dcac39a5..4929a67fca4 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -21,6 +21,7 @@ import org.prebid.server.settings.HttpApplicationSettings; import org.prebid.server.settings.JdbcApplicationSettings; import org.prebid.server.settings.SettingsCache; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.service.HttpPeriodicRefreshService; import org.prebid.server.settings.service.JdbcPeriodicRefreshService; import org.prebid.server.spring.config.database.DatabaseConfiguration; @@ -77,12 +78,14 @@ JdbcApplicationSettings jdbcApplicationSettings( @Value("${settings.database.stored-requests-query}") String storedRequestsQuery, @Value("${settings.database.amp-stored-requests-query}") String ampStoredRequestsQuery, @Value("${settings.database.stored-responses-query}") String storedResponsesQuery, + ParametrizedQueryHelper parametrizedQueryHelper, JdbcClient jdbcClient, JacksonMapper jacksonMapper) { return new JdbcApplicationSettings( jdbcClient, jacksonMapper, + parametrizedQueryHelper, accountQuery, storedRequestsQuery, ampStoredRequestsQuery, diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index 065241e7aab..56f2f045245 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -1,9 +1,16 @@ package org.prebid.server.spring.config.database; import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.jdbc.JDBCClient; +import io.vertx.mysqlclient.MySQLBuilder; +import io.vertx.mysqlclient.MySQLConnectOptions; +import io.vertx.pgclient.PgBuilder; +import io.vertx.pgclient.PgConnectOptions; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.PoolOptions; import org.prebid.server.metric.Metrics; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; +import org.prebid.server.settings.helper.ParametrizedQueryMySqlHelper; +import org.prebid.server.settings.helper.ParametrizedQueryPostgresHelper; import org.prebid.server.spring.config.database.model.ConnectionPoolSettings; import org.prebid.server.spring.config.database.model.DatabaseAddress; import org.prebid.server.spring.config.database.properties.DatabaseConfigurationProperties; @@ -11,7 +18,6 @@ import org.prebid.server.vertx.ContextRunner; import org.prebid.server.vertx.jdbc.BasicJdbcClient; import org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient; -import org.prebid.server.vertx.jdbc.JdbcClient; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -21,48 +27,12 @@ import org.springframework.validation.annotation.Validated; import java.time.Clock; +import java.util.concurrent.TimeUnit; @Configuration @ConditionalOnExpression("'${settings.database.type}' == 'postgres' or '${settings.database.type}' == 'mysql'") public class DatabaseConfiguration { - @Bean - @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") - DatabaseUrlFactory postgresUrlFactory() { - return "jdbc:postgresql://%s:%d/%s?ssl=false&socketTimeout=1&tcpKeepAlive=true"::formatted; - } - - @Bean - @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") - DatabaseUrlFactory mySqlUrlFactory() { - return "jdbc:mysql://%s:%d/%s?useSSL=false&socketTimeout=1000&tcpKeepAlive=true"::formatted; - } - - @Bean - @ConditionalOnProperty(name = "settings.database.provider-class", havingValue = "hikari") - ConnectionPoolConfigurationFactory hikariConfigurationFactory() { - return (url, connectionPoolSettings) -> new JsonObject() - .put("jdbcUrl", url + "&allowPublicKeyRetrieval=true") - .put("username", connectionPoolSettings.getUser()) - .put("password", connectionPoolSettings.getPassword()) - .put("minimumIdle", connectionPoolSettings.getPoolSize()) - .put("maximumPoolSize", connectionPoolSettings.getPoolSize()) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider"); - } - - @Bean - @ConditionalOnProperty(name = "settings.database.provider-class", havingValue = "c3p0") - ConnectionPoolConfigurationFactory c3p0ConfigurationFactory() { - return (url, connectionPoolSettings) -> new JsonObject() - .put("url", url) - .put("user", connectionPoolSettings.getUser()) - .put("password", connectionPoolSettings.getPassword()) - .put("initial_pool_size", connectionPoolSettings.getPoolSize()) - .put("min_pool_size", connectionPoolSettings.getPoolSize()) - .put("max_pool_size", connectionPoolSettings.getPoolSize()) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider"); - } - @Bean DatabaseAddress databaseAddress(DatabaseConfigurationProperties databaseConfigurationProperties) { return DatabaseAddress.of( @@ -81,31 +51,78 @@ ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties da } @Bean - JDBCClient vertxJdbcClient(Vertx vertx, - DatabaseAddress databaseAddress, - ConnectionPoolSettings connectionPoolSettings, - DatabaseUrlFactory urlFactory, - ConnectionPoolConfigurationFactory configurationFactory) { - - final String databaseUrl = urlFactory.createUrl( - databaseAddress.getHost(), databaseAddress.getPort(), databaseAddress.getDatabaseName()); - - final JsonObject connectionPoolConfigurationProperties = configurationFactory.create( - databaseUrl, connectionPoolSettings); - final JsonObject databaseConfigurationProperties = new JsonObject() - .put("driver_class", connectionPoolSettings.getDatabaseType().jdbcDriver); - databaseConfigurationProperties.mergeIn(connectionPoolConfigurationProperties); - - return JDBCClient.createShared(vertx, databaseConfigurationProperties); + @ConfigurationProperties(prefix = "settings.database") + @Validated + public DatabaseConfigurationProperties databaseConfigurationProperties() { + return new DatabaseConfigurationProperties(); } @Bean - @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", - matchIfMissing = true) - BasicJdbcClient basicJdbcClient( - Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { + @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") + ParametrizedQueryHelper mysqlParametrizedQueryHelper() { + return new ParametrizedQueryMySqlHelper(); + } + + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") + ParametrizedQueryHelper postgresParametrizedQueryHelper() { + return new ParametrizedQueryPostgresHelper(); + } + + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "mysql") + Pool mysqlConnectionPool(Vertx vertx, + DatabaseAddress databaseAddress, + ConnectionPoolSettings connectionPoolSettings) { + + final MySQLConnectOptions sqlConnectOptions = new MySQLConnectOptions() + .setHost(databaseAddress.getHost()) + .setPort(databaseAddress.getPort()) + .setDatabase(databaseAddress.getDatabaseName()) + .setUser(connectionPoolSettings.getUser()) + .setPassword(connectionPoolSettings.getPassword()) + .setSsl(false) + .setTcpKeepAlive(true) + .setIdleTimeout(1) + .setIdleTimeoutUnit(TimeUnit.SECONDS); + + final PoolOptions poolOptions = new PoolOptions() + .setMaxSize(connectionPoolSettings.getPoolSize()); + + return MySQLBuilder + .pool() + .with(poolOptions) + .connectingTo(sqlConnectOptions) + .using(vertx) + .build(); + } - return createBasicJdbcClient(vertx, vertxJdbcClient, metrics, clock, contextRunner); + @Bean + @ConditionalOnProperty(name = "settings.database.type", havingValue = "postgres") + Pool postgresConnectionPool(Vertx vertx, + DatabaseAddress databaseAddress, + ConnectionPoolSettings connectionPoolSettings) { + + final PgConnectOptions sqlConnectOptions = new PgConnectOptions() + .setHost(databaseAddress.getHost()) + .setPort(databaseAddress.getPort()) + .setDatabase(databaseAddress.getDatabaseName()) + .setUser(connectionPoolSettings.getUser()) + .setPassword(connectionPoolSettings.getPassword()) + .setSsl(false) + .setTcpKeepAlive(true) + .setIdleTimeout(1) + .setIdleTimeoutUnit(TimeUnit.SECONDS); + + final PoolOptions poolOptions = new PoolOptions() + .setMaxSize(connectionPoolSettings.getPoolSize()); + + return PgBuilder + .pool() + .with(poolOptions) + .connectingTo(sqlConnectOptions) + .using(vertx) + .build(); } @Bean @@ -115,35 +132,44 @@ CircuitBreakerProperties databaseCircuitBreakerProperties() { return new CircuitBreakerProperties(); } + @Bean + @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", + matchIfMissing = true) + BasicJdbcClient basicJdbcClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { + + return createBasicJdbcClient(pool, metrics, clock, contextRunner); + } + @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "true") - CircuitBreakerSecuredJdbcClient circuitBreakerSecuredJdbcClient( + CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( Vertx vertx, - JDBCClient vertxJdbcClient, + Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner, @Qualifier("databaseCircuitBreakerProperties") CircuitBreakerProperties circuitBreakerProperties) { - final JdbcClient jdbcClient = createBasicJdbcClient(vertx, vertxJdbcClient, metrics, clock, contextRunner); - return new CircuitBreakerSecuredJdbcClient(vertx, jdbcClient, metrics, - circuitBreakerProperties.getOpeningThreshold(), circuitBreakerProperties.getOpeningIntervalMs(), - circuitBreakerProperties.getClosingIntervalMs(), clock); + final BasicJdbcClient jdbcClient = createBasicJdbcClient(pool, metrics, clock, contextRunner); + return new CircuitBreakerSecuredJdbcClient( + vertx, + jdbcClient, + metrics, + circuitBreakerProperties.getOpeningThreshold(), + circuitBreakerProperties.getOpeningIntervalMs(), + circuitBreakerProperties.getClosingIntervalMs(), + clock); } - private static BasicJdbcClient createBasicJdbcClient( - Vertx vertx, JDBCClient vertxJdbcClient, Metrics metrics, Clock clock, ContextRunner contextRunner) { - final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); + private static BasicJdbcClient createBasicJdbcClient(Pool pool, + Metrics metrics, + Clock clock, + ContextRunner contextRunner) { + + final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(pool, metrics, clock); contextRunner.runBlocking(promise -> basicJdbcClient.initialize().onComplete(promise)); return basicJdbcClient; } - - @Bean - @ConfigurationProperties(prefix = "settings.database") - @Validated - public DatabaseConfigurationProperties databaseConfigurationProperties() { - return new DatabaseConfigurationProperties(); - } } diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java index 9988efbdb7f..6b6effa79a3 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java @@ -1,13 +1,11 @@ package org.prebid.server.vertx.jdbc; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Promise; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.ResultSet; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; +import io.vertx.sqlclient.SqlConnection; +import io.vertx.sqlclient.Tuple; import org.prebid.server.execution.Timeout; import org.prebid.server.log.Logger; import org.prebid.server.log.LoggerFactory; @@ -16,24 +14,23 @@ import java.time.Clock; import java.util.List; import java.util.Objects; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Function; /** - * Wrapper over {@link JDBCClient} that supports setting query timeout in milliseconds. + * Wrapper over {@link Pool} that supports setting query timeout in milliseconds. */ public class BasicJdbcClient implements JdbcClient { private static final Logger logger = LoggerFactory.getLogger(BasicJdbcClient.class); - private final Vertx vertx; - private final JDBCClient jdbcClient; + private final Pool pool; private final Metrics metrics; private final Clock clock; - public BasicJdbcClient(Vertx vertx, JDBCClient jdbcClient, Metrics metrics, Clock clock) { - this.vertx = Objects.requireNonNull(vertx); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { + this.pool = Objects.requireNonNull(pool); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); } @@ -45,49 +42,41 @@ public BasicJdbcClient(Vertx vertx, JDBCClient jdbcClient, Metrics metrics, Cloc * Must be called on Vertx event loop thread. */ public Future initialize() { - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - return connectionPromise.future() + return pool.getConnection() .recover(BasicJdbcClient::logConnectionError) .mapEmpty(); } @Override - public Future executeQuery(String query, List params, Function mapper, + public Future executeQuery(String query, + List params, + Function, T> mapper, Timeout timeout) { + final long remainingTimeout = timeout.remaining(); if (remainingTimeout <= 0) { return Future.failedFuture(timeoutException()); } final long startTime = clock.millis(); - final Promise queryResultPromise = Promise.promise(); - - // timeout implementation is inspired by this answer: - // https://groups.google.com/d/msg/vertx/eSf3AQagGGU/K7pztnjLc_EJ - final long timerId = vertx.setTimer(remainingTimeout, id -> timedOutResult(queryResultPromise, startTime)); - final Promise connectionPromise = Promise.promise(); - jdbcClient.getConnection(connectionPromise); - connectionPromise.future() + return pool.getConnection() .recover(BasicJdbcClient::logConnectionError) .compose(connection -> makeQuery(connection, query, params)) - .onComplete(result -> handleResult(result, queryResultPromise, timerId, startTime)); - - return queryResultPromise.future().map(mapper); + .timeout(remainingTimeout, TimeUnit.MILLISECONDS) + .recover(this::handleFailure) + .onComplete(result -> metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime)) + .map(mapper); } - /** - * Fails result {@link Promise} with timeout exception. - */ - private void timedOutResult(Promise queryResultPromise, long startTime) { - // no need for synchronization since timer is fired on the same event loop thread - if (!queryResultPromise.future().isComplete()) { - metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime); - queryResultPromise.fail(timeoutException()); + private Future> handleFailure(Throwable throwable) { + if (throwable instanceof TimeoutException) { + return Future.failedFuture(timeoutException()); } + + return Future.failedFuture(throwable); } - private static Future logConnectionError(Throwable exception) { + private static Future logConnectionError(Throwable exception) { logger.warn("Cannot connect to database", exception); return Future.failedFuture(exception); } @@ -95,29 +84,8 @@ private static Future logConnectionError(Throwable exception) { /** * Performs query to DB. */ - private static Future makeQuery(SQLConnection connection, String query, List params) { - final Promise resultSetPromise = Promise.promise(); - connection.queryWithParams(query, new JsonArray(params), - ar -> { - connection.close(); - resultSetPromise.handle(ar); - }); - return resultSetPromise.future(); - } - - /** - * Propagates responded {@link ResultSet} (or failure) to result {@link Promise}. - */ - private void handleResult( - AsyncResult result, Promise queryResultPromise, long timerId, long startTime) { - - vertx.cancelTimer(timerId); - - // check is to avoid harmless exception if timeout exceeds before successful result becomes ready - if (!queryResultPromise.future().isComplete()) { - metrics.updateDatabaseQueryTimeMetric(clock.millis() - startTime); - queryResultPromise.handle(result); - } + private static Future> makeQuery(SqlConnection connection, String query, List params) { + return connection.preparedQuery(query).execute(Tuple.tuple(params)).onComplete(ignored -> connection.close()); } private static TimeoutException timeoutException() { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java index fef375a741a..f85fa351941 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java @@ -2,7 +2,8 @@ import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; import org.prebid.server.execution.Timeout; import org.prebid.server.log.ConditionalLogger; import org.prebid.server.log.Logger; @@ -57,7 +58,7 @@ public CircuitBreakerSecuredJdbcClient(Vertx vertx, @Override public Future executeQuery(String query, List params, - Function mapper, + Function, T> mapper, Timeout timeout) { return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); diff --git a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java b/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java index b447ea98dc9..3fc7754b038 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java @@ -1,7 +1,8 @@ package org.prebid.server.vertx.jdbc; import io.vertx.core.Future; -import io.vertx.ext.sql.ResultSet; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowSet; import org.prebid.server.execution.Timeout; import java.util.List; @@ -17,5 +18,5 @@ public interface JdbcClient { * Executes query with parameters and returns {@link Future} eventually holding result mapped to a model * object by provided mapper. */ - Future executeQuery(String query, List params, Function mapper, Timeout timeout); + Future executeQuery(String query, List params, Function, T> mapper, Timeout timeout); } diff --git a/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java b/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java index c4b3836aee2..1a26ea5bb2e 100644 --- a/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java +++ b/src/test/java/org/prebid/server/health/DatabaseHealthCheckerTest.java @@ -3,15 +3,13 @@ import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.Vertx; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.SQLClient; +import io.vertx.sqlclient.Pool; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.mockito.stubbing.Answer; import org.prebid.server.health.model.StatusResponse; import java.time.Clock; @@ -38,50 +36,47 @@ public class DatabaseHealthCheckerTest { @Mock private Vertx vertx; @Mock - private JDBCClient jdbcClient; - @Mock - private SQLClient sqlClient; + private Pool pool; - private DatabaseHealthChecker databaseHealthCheck; + private DatabaseHealthChecker target; @Before public void setUp() { - databaseHealthCheck = new DatabaseHealthChecker(vertx, jdbcClient, TEST_REFRESH_PERIOD); + target = new DatabaseHealthChecker(vertx, pool, TEST_REFRESH_PERIOD); } @Test public void creationShouldFailWithNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(null, jdbcClient, 0)); + assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(null, pool, 0)); assertThatNullPointerException().isThrownBy(() -> new DatabaseHealthChecker(vertx, null, TEST_REFRESH_PERIOD)); } @Test public void creationShouldFailWhenRefreshPeriodIsZeroOrNegative() { - assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, jdbcClient, 0)); - assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, jdbcClient, -1)); + assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, pool, 0)); + assertThatIllegalArgumentException().isThrownBy(() -> new DatabaseHealthChecker(vertx, pool, -1)); } @Test public void getCheckNameShouldReturnExpectedResult() { - assertThat(databaseHealthCheck.name()).isEqualTo(DATABASE_CHECK_NAME); + assertThat(target.name()).isEqualTo(DATABASE_CHECK_NAME); } @Test public void getLastStatusShouldReturnNullStatusIfCheckWasNotInitialized() { - assertThat(databaseHealthCheck.status()).isNull(); + assertThat(target.status()).isNull(); } @Test public void getLastStatusShouldReturnStatusUpAndLastUpdatedAfterTestTime() { // given - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.succeededFuture())); + given(pool.getConnection()).willReturn(Future.succeededFuture()); // when - databaseHealthCheck.updateStatus(); + target.updateStatus(); // then - final StatusResponse lastStatus = databaseHealthCheck.status(); + final StatusResponse lastStatus = target.status(); assertThat(lastStatus.getStatus()).isEqualTo("UP"); assertThat(lastStatus.getLastUpdated()).isAfter(TEST_TIME_STRING); } @@ -89,14 +84,13 @@ public void getLastStatusShouldReturnStatusUpAndLastUpdatedAfterTestTime() { @Test public void getLastStatusShouldReturnStatusDownAndLastUpdatedAfterTestTime() { // given - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.failedFuture("fail"))); + given(pool.getConnection()).willReturn(Future.failedFuture("fail")); // when - databaseHealthCheck.updateStatus(); + target.updateStatus(); // then - final StatusResponse lastStatus = databaseHealthCheck.status(); + final StatusResponse lastStatus = target.status(); assertThat(lastStatus.getStatus()).isEqualTo("DOWN"); assertThat(lastStatus.getLastUpdated()).isAfter(TEST_TIME_STRING); } @@ -104,26 +98,18 @@ public void getLastStatusShouldReturnStatusDownAndLastUpdatedAfterTestTime() { @Test public void initializeShouldMakeOneInitialRequestAndTwoScheduledRequests() { // given - given(vertx.setPeriodic(anyLong(), any())) - .willAnswer(withSelfAndPassObjectToHandler(1, 0L, 1L, 2L)); - given(jdbcClient.getConnection(any())) - .willAnswer(withSelfAndPassObjectToHandler(0, sqlClient, Future.succeededFuture())); + given(vertx.setPeriodic(anyLong(), any())).willAnswer(inv -> { + final Handler handler = inv.getArgument(1); + handler.handle(1L); + handler.handle(2L); + return 0L; + }); + given(pool.getConnection()).willReturn(Future.succeededFuture()); // when - databaseHealthCheck.initialize(); + target.initialize(); // then - verify(jdbcClient, times(3)).getConnection(any()); - } - - @SuppressWarnings("unchecked") - private Answer withSelfAndPassObjectToHandler(int arg, Object result, T... objects) { - return inv -> { - // invoking handler right away passing mock to it - for (T obj : objects) { - ((Handler) inv.getArgument(arg)).handle(obj); - } - return result; - }; + verify(pool, times(3)).getConnection(); } } diff --git a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java index 5d6b3584a50..946a62d81b3 100644 --- a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java +++ b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.mchange.util.AssertException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -52,7 +51,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException // given given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_FALSE); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -60,7 +59,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException eq("Failed to parse field FIELD to array with a reason: Expected array.")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> target.deserialize(parser, context)); } diff --git a/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java b/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java index 3677135e632..3a12f27e5ca 100644 --- a/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java +++ b/src/test/java/org/prebid/server/json/deserializer/CommaSeparatedStringAsListOfIntegersDeserializerTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; -import com.mchange.util.AssertException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -44,7 +43,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException // given given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_FALSE); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -54,7 +53,7 @@ public void deserializeShouldThrowExceptionOnWrongJsonToken() throws IOException Expected comma-separated string.""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } @@ -64,7 +63,7 @@ public void deserializeShouldThrowExceptionOnNullValue() throws IOException { given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_STRING); given(parser.getValueAsString()).willReturn(null); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportWrongTokenException( eq(JsonToken.class), @@ -74,7 +73,7 @@ public void deserializeShouldThrowExceptionOnNullValue() throws IOException { Expected comma-separated string.""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } @@ -84,7 +83,7 @@ public void deserializeShouldThrowExceptionOnInvalidValue() throws IOException { given(parser.getCurrentToken()).willReturn(JsonToken.VALUE_STRING); given(parser.getValueAsString()).willReturn("invalid"); given(parser.getCurrentName()).willReturn("FIELD"); - doThrow(AssertException.class) + doThrow(RuntimeException.class) .when(context) .reportPropertyInputMismatch( eq(JsonToken.class), @@ -94,7 +93,7 @@ public void deserializeShouldThrowExceptionOnInvalidValue() throws IOException { NumberFormatException""")); // when and then - assertThatExceptionOfType(AssertException.class) + assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> commaSeparatedStringAsListOfIntegersDeserializer.deserialize(parser, context)); } diff --git a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java index b53b6943324..1871046b5d6 100644 --- a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java @@ -1,16 +1,8 @@ package org.prebid.server.settings; import io.vertx.core.Future; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,45 +13,26 @@ import org.prebid.server.exception.PreBidException; import org.prebid.server.execution.Timeout; import org.prebid.server.execution.TimeoutFactory; -import org.prebid.server.metric.Metrics; -import org.prebid.server.metric.model.AccountMetricsVerbosityLevel; +import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; -import org.prebid.server.settings.model.AccountAnalyticsConfig; -import org.prebid.server.settings.model.AccountAuctionConfig; -import org.prebid.server.settings.model.AccountAuctionEventConfig; -import org.prebid.server.settings.model.AccountBidValidationConfig; -import org.prebid.server.settings.model.AccountCookieSyncConfig; -import org.prebid.server.settings.model.AccountCoopSyncConfig; -import org.prebid.server.settings.model.AccountEventsConfig; -import org.prebid.server.settings.model.AccountGdprConfig; -import org.prebid.server.settings.model.AccountMetricsConfig; -import org.prebid.server.settings.model.AccountPrivacyConfig; -import org.prebid.server.settings.model.AccountStatus; -import org.prebid.server.settings.model.BidValidationEnforcement; -import org.prebid.server.settings.model.EnabledForRequestType; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; -import org.prebid.server.vertx.jdbc.BasicJdbcClient; import org.prebid.server.vertx.jdbc.JdbcClient; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; import java.time.Clock; import java.time.Instant; import java.time.ZoneId; -import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; @RunWith(VertxUnitRunner.class) public class JdbcApplicationSettingsTest extends VertxTest { @@ -67,8 +40,6 @@ public class JdbcApplicationSettingsTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); - private static final String JDBC_URL = "jdbc:h2:mem:test"; - private static final String SELECT_ACCOUNT_QUERY = "SELECT config FROM accounts_account where uuid = %ACCOUNT_ID% LIMIT 1"; @@ -79,578 +50,227 @@ public class JdbcApplicationSettingsTest extends VertxTest { + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + "WHERE impid IN (%IMP_ID_LIST%)"; - private static final String SELECT_UNION_QUERY = - "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " - + "WHERE reqid IN (%REQUEST_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " - + "WHERE reqid IN (%REQUEST_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " - + "WHERE impid IN (%IMP_ID_LIST%) " - + "UNION ALL " - + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " - + "WHERE impid IN (%IMP_ID_LIST%)"; - - private static final String SELECT_FROM_ONE_COLUMN_TABLE_QUERY = "SELECT reqid FROM one_column_table " - + "WHERE reqid IN (%REQUEST_ID_LIST%)"; - private static final String SELECT_RESPONSE_QUERY = "SELECT responseId, responseData FROM stored_responses " + "WHERE responseId IN (%RESPONSE_ID_LIST%)"; - private static final String SELECT_ONE_COLUMN_RESPONSE_QUERY = "SELECT responseId FROM stored_responses " - + "WHERE responseId IN (%RESPONSE_ID_LIST%)"; - - private static Connection connection; - - private Vertx vertx; @Mock - private Metrics metrics; + private ParametrizedQueryHelper parametrizedQueryHelper; - private Clock clock; + @Mock + private JdbcClient jdbcClient; - private JdbcApplicationSettings jdbcApplicationSettings; + private JdbcApplicationSettings target; private Timeout timeout; - @BeforeClass - public static void beforeClass() throws SQLException { - connection = DriverManager.getConnection(JDBC_URL); - connection.createStatement().execute( - "CREATE TABLE accounts_account (" - + "id SERIAL PRIMARY KEY, " - + "uuid varchar(40) NOT NULL, " - + "config varchar(4096)" - + ");"); - connection.createStatement().execute("CREATE TABLE stored_requests (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, reqid varchar(40) NOT NULL, requestData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_requests2 (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, reqid varchar(40) NOT NULL, requestData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_imps (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, impid varchar(40) NOT NULL, impData varchar(512));"); - connection.createStatement().execute("CREATE TABLE stored_imps2 (id SERIAL PRIMARY KEY, " - + "accountId varchar(40) NOT NULL, impid varchar(40) NOT NULL, impData varchar(512));"); - connection.createStatement().execute( - "CREATE TABLE stored_responses (id SERIAL PRIMARY KEY, responseId varchar(40) NOT NULL," - + " responseData varchar(512));"); - connection.createStatement().execute("CREATE TABLE one_column_table (id SERIAL PRIMARY KEY, reqid " - + "varchar(40) NOT NULL);"); - connection.createStatement().execute("insert into accounts_account (uuid, config) values (" - + "'1001'," - + "'{" - + "\"id\": \"1001\"," - + "\"status\": \"active\"," - + "\"auction\": {" - + "\"price-granularity\": \"med\"," - + "\"debug-allow\": true," - + "\"banner-cache-ttl\": 100," - + "\"video-cache-ttl\": 100," - + "\"truncate-target-attr\": 0," - + "\"default-integration\": \"web\"," - + "\"bid-validations\": {" - + "\"banner-creative-max-size\": \"enforce\"" - + "}," - + "\"events\": {" - + "\"enabled\": true" - + "}" - + "}," - + "\"privacy\": {" - + "\"gdpr\": {" - + "\"enabled\": true," - + "\"channel-enabled\": {\"amp\": true, \"app\": true, \"video\": true, \"web\": true, \"dooh\": true}" - + "}" - + "}," - + "\"metrics\": {\"verbosity-level\": \"detailed\"}," - + "\"analytics\": {" - + "\"auction-events\": {\"amp\": true}," - + "\"modules\": {\"some-analytics\": {\"supported-endpoints\": [\"auction\"]}}" - + "}," - + "\"cookie-sync\": {" - + "\"default-limit\": 5," - + "\"max-limit\": 8," - + "\"coop-sync\": {" - + "\"default\": true" - + "}" - + "}" - + "}'" - + ");"); - connection.createStatement().execute( - "insert into stored_requests (accountId, reqid, requestData) values ('1001', '1','value1');"); - connection.createStatement().execute( - "insert into stored_requests (accountId, reqid, requestData) values ('1001', '2','value2');"); - connection.createStatement().execute( - "insert into stored_requests2 (accountId, reqid, requestData) values ('1001', '3','value3');"); - connection.createStatement().execute( - "insert into stored_imps (accountId, impid, impData) values ('1001', '4','value4');"); - connection.createStatement().execute( - "insert into stored_imps (accountId, impid, impData) values ('1001', '5','value5');"); - connection.createStatement().execute( - "insert into stored_imps2 (accountId, impid, impData) values ('1001', '6','value6');"); - connection.createStatement().execute( - "insert into stored_responses (responseId, responseData) " - + "values ('1', 'response1');"); - connection.createStatement().execute( - "insert into stored_responses (responseId, responseData) " - + "values ('2', 'response2');"); - connection.createStatement().execute( - "insert into one_column_table (reqid) values ('3');"); - } - - @AfterClass - public static void afterClass() throws SQLException { - connection.close(); - } - @Before public void setUp() { - vertx = Vertx.vertx(); - clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); - timeout = new TimeoutFactory(clock).create(5000L); - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), + timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(5000L); + given(parametrizedQueryHelper.replaceAccountIdPlaceholder(SELECT_ACCOUNT_QUERY)).willReturn("query"); + target = new JdbcApplicationSettings( + jdbcClient, jacksonMapper, + parametrizedQueryHelper, SELECT_ACCOUNT_QUERY, SELECT_QUERY, SELECT_QUERY, SELECT_RESPONSE_QUERY); } - @After - public void tearDown(TestContext context) { - vertx.close(context.asyncAssertSuccess()); - } - @Test - public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAccountById("1001", timeout); - - // then - final Async async = context.async(); - final AccountAuctionEventConfig expectedEventsConfig = AccountAuctionEventConfig.builder().build(); - expectedEventsConfig.addEvent("amp", true); - future.onComplete(context.asyncAssertSuccess(account -> { - assertThat(account).isEqualTo(Account.builder() - .id("1001") - .status(AccountStatus.active) - .metrics(AccountMetricsConfig.of(AccountMetricsVerbosityLevel.detailed)) - .auction(AccountAuctionConfig.builder() - .priceGranularity("med") - .bannerCacheTtl(100) - .videoCacheTtl(100) - .truncateTargetAttr(0) - .defaultIntegration("web") - .debugAllow(true) - .bidValidations(AccountBidValidationConfig.of(BidValidationEnforcement.enforce)) - .events(AccountEventsConfig.of(true)) - .build()) - .privacy(AccountPrivacyConfig.builder() - .gdpr(AccountGdprConfig.builder() - .enabled(true) - .enabledForRequestType(EnabledForRequestType.of(true, true, true, true, true)) - .build()) - .build()) - .analytics(AccountAnalyticsConfig.of( - expectedEventsConfig, - singletonMap( - "some-analytics", - mapper.createObjectNode() - .set("supported-endpoints", mapper.createArrayNode().add("auction"))))) - .cookieSync(AccountCookieSyncConfig.of(5, 8, null, AccountCoopSyncConfig.of(true))) - .build()); - async.complete(); - })); - } - - @Test - public void getAccountByIdShouldFailIfAccountNotFound(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAccountById("non-existing", timeout); - - // then - final Async async = context.async(); - future.onComplete(context.asyncAssertFailure(exception -> { - assertThat(exception).isInstanceOf(PreBidException.class) - .hasMessage("Account not found: non-existing"); - async.complete(); - })); - } - - @Test - public void getStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getStoredData( - "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); - } - - @Test - public void getAmpStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getAmpStoredData( - "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("3", "4")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, emptyMap(), emptyList())); - async.complete(); - })); - } - - @Test - public void getVideoStoredDataShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getVideoStoredData("1001", - new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); - - // then - final Async async = context.async(); - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - future.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult) - .isEqualTo(StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); - } - - @Test - public void getVideoStoredDataShouldReturnStoredRequests(TestContext context) { + public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + final Account givenAccount = Account.builder().build(); + given(jdbcClient.executeQuery( + eq("query"), + eq(List.of("1001")), + any(), + eq(timeout))) + .willReturn(Future.succeededFuture(givenAccount)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getVideoStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); + final Future future = target.getAccountById("1001", timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - expectedImps.put("6", "value6"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenAccount); } @Test - public void getStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContext context) { + public void getAccountByIdShouldFailIfAccountNotFound() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + given(jdbcClient.executeQuery( + eq("query"), + eq(List.of("non-existing")), + any(), + eq(timeout))) + .willReturn(Future.succeededFuture(null)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); + final Future future = target.getAccountById("non-existing", timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - final Map expectedImps = new HashMap<>(); - expectedImps.put("4", "value4"); - expectedImps.put("5", "value5"); - expectedImps.put("6", "value6"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, expectedImps, emptyList())); - async.complete(); - })); + assertThat(future.failed()).isTrue(); + assertThat(future.cause()).hasMessage("Account not found: non-existing"); } @Test - public void getAmpStoredDataUnionSelectByIdShouldReturnStoredRequests(TestContext context) { + public void getStoredDataShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_UNION_QUERY, - SELECT_UNION_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 2)) + .willReturn("query"); - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "2", "3")), - new HashSet<>(asList("4", "5", "6")), timeout); - - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - final Map expectedRequests = new HashMap<>(); - expectedRequests.put("1", "value1"); - expectedRequests.put("2", "value2"); - expectedRequests.put("3", "value3"); - assertThat(storedRequestResult).isEqualTo( - StoredDataResult.of(expectedRequests, emptyMap(), emptyList())); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of("4", "value4", "5", "value5"), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); + final Future future = target.getStoredData( + "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - singletonList("No stored request found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredDataShouldReturnResultWithErrorIfNoStoredImpFound(TestContext context) { - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", emptySet(), new HashSet<>(asList("4", "6")), timeout); + public void getAmpStoredDataShouldReturnExpectedResult() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), singletonMap("4", "value4"), - singletonList("No stored imp found for id: 6"))); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of(), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getAmpStoredDataShouldReturnResultWithErrorIfNoStoredRequestFound(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), - timeout); + final Future future = target.getAmpStoredData( + "1001", new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - singletonList("No stored request found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getVideoStoredDataShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 2)) + .willReturn("query"); + + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1", "2", "value2"), + Map.of("4", "value4", "5", "value5"), + emptyList()); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("1", "2", "3")), emptySet(), - timeout); + final Future future = target.getVideoStoredData("1001", + new HashSet<>(asList("1", "2")), new HashSet<>(asList("4", "5")), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("Error occurred while mapping stored request data"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getAmpStoredDataShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getStoredDataShouldReturnResultWithError() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_FROM_ONE_COLUMN_TABLE_QUERY, - SELECT_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("1", "2", "3")), emptySet(), - timeout); + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("Error occurred while mapping stored request data"))); - async.complete(); - })); - } - - @Test - public void getStoredDataShouldReturnErrorAndEmptyResult(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getStoredData("1001", new HashSet<>(asList("3", "4")), - new HashSet<>(asList("6", "7")), timeout); + final Future future = + target.getStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("No stored requests for ids [3, 4] and stored imps for ids [6, 7] were found"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getAmpStoredDataShouldReturnErrorAndEmptyResult(TestContext context) { - // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", new HashSet<>(asList("3", "4")), emptySet(), - timeout); + public void getAmpStoredDataShouldReturnResultWithError() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(emptyMap(), emptyMap(), - singletonList("No stored requests for ids [3, 4] were found"))); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getAmpStoredDataShouldIgnoreImpIdsArgument(TestContext context) { // when - final Future storedRequestResultFuture = - jdbcApplicationSettings.getAmpStoredData("1001", singleton("1"), singleton("4"), timeout); + final Future future = + target.getAmpStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedRequestResultFuture.onComplete(context.asyncAssertSuccess(storedRequestResult -> { - assertThat(storedRequestResult).isEqualTo(StoredDataResult.of(singletonMap("1", "value1"), emptyMap(), - emptyList())); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredResponseShouldReturnExpectedResult(TestContext context) { - // when - final Future future = jdbcApplicationSettings.getStoredResponses( - new HashSet<>(asList("1", "2")), timeout); + public void getVideoStoredDataShouldReturnResultWithError() { + // given + given(parametrizedQueryHelper.replaceRequestAndImpIdPlaceholders(SELECT_QUERY, 2, 0)) + .willReturn("query"); - // then - final Async async = context.async(); - final Map expectedResponses = new HashMap<>(); - expectedResponses.put("1", "response1"); - expectedResponses.put("2", "response2"); - - future.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult) - .isEqualTo(StoredResponseDataResult.of(expectedResponses, emptyList())); - async.complete(); - })); - } + final StoredDataResult givenStoredDataResult = StoredDataResult.of( + Map.of("1", "value1"), + Map.of(), + List.of("No stored request found for id: 3")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredDataResult)); - @Test - public void getStoredResponseShouldReturnResultWithErrorIfNotAllStoredResponsesWereFound(TestContext context) { // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("1", "3")), timeout); + final Future future = + target.getVideoStoredData("1001", new HashSet<>(asList("1", "3")), emptySet(), timeout); // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(singletonMap("1", "response1"), - singletonList("No stored response found for id: 3"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredDataResult); } @Test - public void getStoredResponseShouldReturnErrorIfResultContainsLessColumnsThanExpected(TestContext context) { + public void getStoredResponseShouldReturnExpectedResult() { // given - jdbcApplicationSettings = new JdbcApplicationSettings( - jdbcClient(), - jacksonMapper, - SELECT_ACCOUNT_QUERY, - SELECT_QUERY, - SELECT_QUERY, - SELECT_ONE_COLUMN_RESPONSE_QUERY); + given(parametrizedQueryHelper.replaceStoredResponseIdPlaceholders(SELECT_RESPONSE_QUERY, 2)) + .willReturn("query"); - // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("1", "2", "3")), timeout); + final StoredResponseDataResult givenStoredResponseResult = StoredResponseDataResult.of( + Map.of("1", "response1"), + List.of("No stored response found for id: 2")); + given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + .willReturn(Future.succeededFuture(givenStoredResponseResult)); - // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), - singletonList("Result set column number is less than expected"))); - async.complete(); - })); - } - - @Test - public void getStoredResponseShouldReturnErrorAndEmptyResult(TestContext context) { // when - final Future storedResponseDataResultFuture = - jdbcApplicationSettings.getStoredResponses(new HashSet<>(asList("3", "4")), timeout); + final Future future = target.getStoredResponses( + new HashSet<>(asList("1", "2")), timeout); // then - final Async async = context.async(); - storedResponseDataResultFuture.onComplete(context.asyncAssertSuccess(storedResponseDataResult -> { - assertThat(storedResponseDataResult).isEqualTo(StoredResponseDataResult.of(emptyMap(), - singletonList("No stored responses were found for ids: 3,4"))); - async.complete(); - })); + assertThat(future.succeeded()).isTrue(); + assertThat(future.result()).isEqualTo(givenStoredResponseResult); } @Test public void getCategoriesShouldReturnFailedFutureWithUnsupportedPrebidException() { // given and when - final Future> result = jdbcApplicationSettings.getCategories("adServer", "publisher", + final Future> result = target.getCategories("adServer", "publisher", timeout); // then @@ -658,14 +278,4 @@ public void getCategoriesShouldReturnFailedFutureWithUnsupportedPrebidException( assertThat(result.cause()).isInstanceOf(PreBidException.class) .hasMessage("Not supported"); } - - private JdbcClient jdbcClient() { - return new BasicJdbcClient(vertx, JDBCClient.createShared(vertx, - new JsonObject() - .put("jdbcUrl", JDBC_URL) - .put("driver_class", "org.h2.Driver") - .put("max_pool_size", 10) - .put("provider_class", "io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider")), - metrics, clock); - } } diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java index e10cd145d78..305335705d3 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java @@ -1,7 +1,10 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.core.json.JsonObject; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import lombok.Value; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -9,14 +12,17 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.settings.model.StoredDataResult; -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.IntStream; + import static java.util.Collections.emptySet; import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; public class JdbcStoredDataResultMapperTest { @@ -24,15 +30,15 @@ public class JdbcStoredDataResultMapperTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private ResultSet resultSet; + private RowSet rowSet; @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, emptySet(), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -44,11 +50,14 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResultForGivenIds() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, - singleton("reqId"), singleton("impId")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + null, + singleton("reqId"), + singleton("impId")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -60,29 +69,33 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data")))); + givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("reqId"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("reqId"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + .containsOnly("Error occurred while mapping stored request data: some columns are missing"); } @Test public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedColumnType() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data", 123)))); + givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("reqId"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("reqId"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -94,13 +107,16 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC @Test public void mapShouldSkipStoredResultWithInvalidType() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id1", "data2", "invalid")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id1", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("id1"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -112,11 +128,13 @@ public void mapShouldSkipStoredResultWithInvalidType() { @Test public void mapShouldReturnStoredResultWithErrorForMissingId() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data1", "request")))); + givenRowSet(givenRow("accountId", "id1", "data1", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", singleton("id1"), + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), singleton("id2")); // then @@ -130,13 +148,16 @@ public void mapShouldReturnStoredResultWithErrorForMissingId() { @Test public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiffers() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "otherAccountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "otherAccountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -150,13 +171,16 @@ public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiff @Test public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundButNoAccountIdIsDefined() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId1", "id1", "data1", "request")), - new JsonArray(asList("accountId2", "id1", "data2", "request")))); + givenRowSet( + givenRow("accountId1", "id1", "data1", "request"), + givenRow("accountId2", "id1", "data2", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, null, - singleton("id1"), emptySet()); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + null, + singleton("id1"), + emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -168,15 +192,18 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB @Test public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundButNoAccountIdIsDiffers() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId1", "id1", "data-accountId", "request")), - new JsonArray(asList("accountId2", "id1", "data-otherAccountId", "request")), - new JsonArray(asList("accountId1", "id2", "data-accountId", "imp")), - new JsonArray(asList("accountId2", "id2", "data-otherAccountId", "imp")))); + givenRowSet( + givenRow("accountId1", "id1", "data-accountId", "request"), + givenRow("accountId2", "id1", "data-otherAccountId", "request"), + givenRow("accountId1", "id2", "data-accountId", "imp"), + givenRow("accountId2", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "otherAccountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "otherAccountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -190,15 +217,18 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB @Test public void mapShouldReturnExpectedStoredResultForGivenAccount() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data-accountId", "request")), - new JsonArray(asList("otherAccountId", "id1", "data-otherAccountId", "request")), - new JsonArray(asList("accountId", "id2", "data-accountId", "imp")), - new JsonArray(asList("otherAccountId", "id2", "data-otherAccountId", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data-accountId", "request"), + givenRow("otherAccountId", "id1", "data-otherAccountId", "request"), + givenRow("accountId", "id2", "data-accountId", "imp"), + givenRow("otherAccountId", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet, "accountId", - singleton("id1"), singleton("id2")); + final StoredDataResult result = JdbcStoredDataResultMapper.map( + rowSet, + "accountId", + singleton("id1"), + singleton("id2")); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -211,10 +241,10 @@ public void mapShouldReturnExpectedStoredResultForGivenAccount() { @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -226,12 +256,12 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH @Test public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "invalid")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -243,27 +273,25 @@ public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data")))); + givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); assertThat(result.getStoredIdToImp()).isEmpty(); assertThat(result.getErrors()).hasSize(1) - .containsOnly("Error occurred while mapping stored request data"); + .containsOnly("Error occurred while mapping stored request data: some columns are missing"); } @Test public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalidDataType() { // given - given(resultSet.getResults()).willReturn(singletonList( - new JsonArray(asList("accountId", "id1", "data", 123)))); + givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -274,12 +302,12 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalid @Test public void mapWithoutParamsShouldReturnExpectedStoredResult() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("accountId", "id1", "data1", "request")), - new JsonArray(asList("accountId", "id2", "data2", "imp")))); + givenRowSet( + givenRow("accountId", "id1", "data1", "request"), + givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(resultSet); + final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -288,4 +316,34 @@ public void mapWithoutParamsShouldReturnExpectedStoredResult() { .containsOnly(entry("id2", "data2")); assertThat(result.getErrors()).isEmpty(); } + + private void givenRowSet(Row... rows) { + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + final JsonObject json = new JsonObject(); + IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); + given(row.toJson()).willReturn(json); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java index ba9d7e18d1f..3f6ee8ecd8e 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java @@ -1,7 +1,10 @@ package org.prebid.server.settings.helper; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.sql.ResultSet; +import io.vertx.core.json.JsonObject; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import lombok.Value; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -10,15 +13,17 @@ import org.prebid.server.settings.model.StoredResponseDataResult; import java.util.AbstractMap; -import java.util.HashSet; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Set; +import java.util.stream.IntStream; -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; public class JdbcStoredResponseResultMapperTest { @@ -26,15 +31,15 @@ public class JdbcStoredResponseResultMapperTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private ResultSet resultSet; + private RowSet rowSet; @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetIsEmpty() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetIsEmpty() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, emptySet()); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -43,12 +48,12 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetIsEmpt } @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasLessColumns() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasLessColumns() { // given - given(resultSet.getResults()).willReturn(singletonList(new JsonArray(singletonList("id1")))); + givenRowSet(givenRow("id1")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, emptySet()); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -59,11 +64,10 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasLes @Test public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { // given - given(resultSet.getResults()).willReturn(singletonList(new JsonArray(asList("id1", "data")))); + givenRowSet(givenRow("id1", "data")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper - .map(resultSet, new HashSet<>(asList("id1", "id2"))); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(1) @@ -73,12 +77,12 @@ public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { } @Test - public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasEmptyResultForGivenIDs() { + public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasEmptyResultForGivenIDs() { // given - given(resultSet.getResults()).willReturn(emptyList()); + givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, singleton("id")); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, singleton("id")); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -89,17 +93,43 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenResultSetHasEmp @Test public void mapShouldReturnFilledStoredResponseResultWithoutErrors() { // given - given(resultSet.getResults()).willReturn(asList( - new JsonArray(asList("id1", "data1")), - new JsonArray(asList("id2", "data2")))); + givenRowSet(givenRow("id1", "data1"), givenRow("id2", "data2")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(resultSet, - new HashSet<>(asList("id1", "id2"))); + final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(2) .contains(new AbstractMap.SimpleEntry<>("id1", "data1"), new AbstractMap.SimpleEntry<>("id2", "data2")); assertThat(result.getErrors()).isEmpty(); } + + private void givenRowSet(Row... rows) { + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + final JsonObject json = new JsonObject(); + IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); + given(row.toJson()).willReturn(json); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java new file mode 100644 index 00000000000..f4d799250d0 --- /dev/null +++ b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryMySqlHelperTest.java @@ -0,0 +1,106 @@ +package org.prebid.server.settings.helper; + +import org.junit.Test; +import org.prebid.server.VertxTest; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ParametrizedQueryMySqlHelperTest extends VertxTest { + + private final ParametrizedQueryMySqlHelper target = new ParametrizedQueryMySqlHelper(); + + @Test + public void replaceAccountIdPlaceholderShouldReplacePlaceholderWithWildCard() { + // when + final String result = target.replaceAccountIdPlaceholder("SELECT * FROM table WHERE id = %ACCOUNT_ID%"); + + // then + assertThat(result).isEqualTo("SELECT * FROM table WHERE id = ?"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 3); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (?,?,?)"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithNullWhenParamsNumberAreZero() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 0); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (NULL)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 2, 3); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (?,?) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (?,?) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (?,?,?) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (?,?,?)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithNullsWhenIdsNumberIsZero() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 0, 0); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (NULL)"); + } +} diff --git a/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java new file mode 100644 index 00000000000..e457b9c52e3 --- /dev/null +++ b/src/test/java/org/prebid/server/settings/helper/ParametrizedQueryPostgresHelperTest.java @@ -0,0 +1,106 @@ +package org.prebid.server.settings.helper; + +import org.junit.Test; +import org.prebid.server.VertxTest; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ParametrizedQueryPostgresHelperTest extends VertxTest { + + private final ParametrizedQueryPostgresHelper target = new ParametrizedQueryPostgresHelper(); + + @Test + public void replaceAccountIdPlaceholderShouldReplacePlaceholderWithWildCard() { + // when + final String result = target.replaceAccountIdPlaceholder("SELECT * FROM table WHERE id = %ACCOUNT_ID%"); + + // then + assertThat(result).isEqualTo("SELECT * FROM table WHERE id = $1"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 3); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN ($1,$2,$3)"); + } + + @Test + public void replaceStoredResponseIdPlaceholdersShouldReplacePlaceholderWithNullWhenParamsNumberAreZero() { + // when + final String result = target.replaceStoredResponseIdPlaceholders( + "SELECT responseId, responseData FROM stored_responses WHERE responseId IN (%RESPONSE_ID_LIST%)", + 0); + + // then + assertThat(result) + .isEqualTo("SELECT responseId, responseData FROM stored_responses WHERE responseId IN (NULL)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithWildCards() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 2, 3); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN ($1,$2) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN ($3,$4) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN ($5,$6,$7) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN ($8,$9,$10)"); + } + + @Test + public void replaceRequestAndImpIdPlaceholdersShouldReplacePlaceholderWithNullsWhenIdsNumberIsZero() { + // when + final String result = target.replaceRequestAndImpIdPlaceholders( + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (%REQUEST_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (%IMP_ID_LIST%) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (%IMP_ID_LIST%)", + 0, 0); + + // then + assertThat(result).isEqualTo("SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, reqid, requestData, 'request' as dataType FROM stored_requests2 " + + "WHERE reqid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps " + + "WHERE impid IN (NULL) " + + "UNION ALL " + + "SELECT accountId, impid, impData, 'imp' as dataType FROM stored_imps2 " + + "WHERE impid IN (NULL)"); + } +} diff --git a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java index 8dc39bd0161..79514bf1fec 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java @@ -1,17 +1,17 @@ package org.prebid.server.vertx.jdbc; -import io.vertx.core.AsyncResult; import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonArray; -import io.vertx.ext.jdbc.JDBCClient; -import io.vertx.ext.sql.ResultSet; -import io.vertx.ext.sql.SQLConnection; +import io.vertx.sqlclient.Pool; +import io.vertx.sqlclient.PreparedQuery; +import io.vertx.sqlclient.Row; +import io.vertx.sqlclient.RowIterator; +import io.vertx.sqlclient.RowSet; +import io.vertx.sqlclient.SqlConnection; +import io.vertx.sqlclient.Tuple; +import lombok.Value; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; @@ -22,16 +22,17 @@ import java.time.Clock; import java.time.Instant; import java.time.ZoneId; +import java.util.Arrays; +import java.util.Iterator; import java.util.concurrent.TimeoutException; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static java.util.function.Function.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNullPointerException; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.mock; @@ -44,14 +45,12 @@ public class BasicJdbcClientTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private Vertx vertx; - @Mock - private JDBCClient vertxJdbcClient; + private Pool pool; @Mock private Metrics metrics; private Clock clock; - private BasicJdbcClient jdbcClient; + private BasicJdbcClient target; private Timeout timeout; @@ -60,15 +59,14 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - jdbcClient = new BasicJdbcClient(vertx, vertxJdbcClient, metrics, clock); + target = new BasicJdbcClient(pool, metrics, clock); } @Test public void creationShouldFailOnNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, vertxJdbcClient, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(vertx, vertxJdbcClient, metrics, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, metrics, null)); } @Test @@ -77,7 +75,7 @@ public void initializeShouldReturnEmptySucceededFutureIfConnectionCouldBeEstabli givenGetConnectionReturning(Future.succeededFuture()); // when - final Future future = jdbcClient.initialize(); + final Future future = target.initialize(); // then assertThat(future.succeeded()).isTrue(); @@ -90,7 +88,7 @@ public void initializeShouldReturnFailedFutureIfConnectionCouldNotBeEstablished( givenGetConnectionReturning(Future.failedFuture(new RuntimeException("Failed to open connection"))); // when - final Future future = jdbcClient.initialize(); + final Future future = target.initialize(); // then assertThat(future.failed()).isTrue(); @@ -100,39 +98,26 @@ public void initializeShouldReturnFailedFutureIfConnectionCouldNotBeEstablished( @Test public void executeQueryShouldReturnFailedFutureIfGlobalTimeoutAlreadyExpired() { // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), expiredTimeout()); + final Future> future = target.executeQuery("query", emptyList(), identity(), expiredTimeout()); // then assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(TimeoutException.class) .hasMessage("Timed out while executing SQL query"); - verifyNoMoreInteractions(vertx, vertxJdbcClient); + verifyNoMoreInteractions(pool); } @Test - @SuppressWarnings("unchecked") public void executeQueryShouldReturnFailedFutureIfItTakesLongerThanRemainingTimeout() { // given - given(vertx.setTimer(anyLong(), any())).willAnswer(invocation -> { - ((Handler) invocation.getArgument(1)).handle(123L); - return 123L; - }); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - - givenQueryReturning(connection, Future.succeededFuture(new ResultSet())); + givenQueryReturning(connection, Future.failedFuture(new TimeoutException("Some text"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - final ArgumentCaptor timeoutCaptor = ArgumentCaptor.forClass(Long.class); - verify(vertx).setTimer(timeoutCaptor.capture(), any()); - assertThat(timeoutCaptor.getValue()).isEqualTo(500L); - - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(TimeoutException.class) .hasMessage("Timed out while executing SQL query"); @@ -141,16 +126,12 @@ public void executeQueryShouldReturnFailedFutureIfItTakesLongerThanRemainingTime @Test public void executeQueryShouldReturnFailedFutureIfConnectionAcquisitionFails() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - givenGetConnectionReturning(Future.failedFuture(new RuntimeException("Failed to acquire connection"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(RuntimeException.class).hasMessage("Failed to acquire connection"); } @@ -158,19 +139,15 @@ public void executeQueryShouldReturnFailedFutureIfConnectionAcquisitionFails() { @Test public void executeQueryShouldReturnFailedFutureIfQueryFails() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); givenQueryReturning(connection, Future.failedFuture(new RuntimeException("Failed to execute query"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.failed()).isTrue(); assertThat(future.cause()).isInstanceOf(RuntimeException.class).hasMessage("Failed to execute query"); } @@ -178,21 +155,20 @@ public void executeQueryShouldReturnFailedFutureIfQueryFails() { @Test public void executeQueryShouldReturnSucceededFutureWithMappedQueryResult() { // given - given(vertx.setTimer(anyLong(), any())).willReturn(123L); - - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - givenQueryReturning(connection, Future.succeededFuture( - new ResultSet().setResults(singletonList(new JsonArray().add("value"))))); + final RowSet rowSet = givenRowSet(givenRow("value")); + givenQueryReturning(connection, Future.succeededFuture(rowSet)); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // then - verify(vertx).cancelTimer(eq(123L)); - assertThat(future.succeeded()).isTrue(); assertThat(future.result()).isEqualTo("value"); } @@ -200,13 +176,13 @@ public void executeQueryShouldReturnSucceededFutureWithMappedQueryResult() { @Test public void executeQueryShouldReportMetricsIfQueryFails() { // given - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); givenQueryReturning(connection, Future.failedFuture(new RuntimeException("Failed to execute query"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future> future = target.executeQuery("query", emptyList(), identity(), timeout); // then assertThat(future.failed()).isTrue(); @@ -216,13 +192,13 @@ public void executeQueryShouldReportMetricsIfQueryFails() { @Test public void executeQueryShouldReportMetricsIfQuerySucceeds() { // given - final SQLConnection connection = mock(SQLConnection.class); + final SqlConnection connection = mock(SqlConnection.class); givenGetConnectionReturning(Future.succeededFuture(connection)); - givenQueryReturning(connection, Future.succeededFuture(new ResultSet().setResults(emptyList()))); + givenQueryReturning(connection, Future.succeededFuture(givenRowSet())); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), Object::toString, timeout); + final Future future = target.executeQuery("query", emptyList(), Object::toString, timeout); // then assertThat(future.succeeded()).isTrue(); @@ -230,22 +206,46 @@ public void executeQueryShouldReportMetricsIfQuerySucceeds() { } @SuppressWarnings("unchecked") - private void givenGetConnectionReturning(AsyncResult result) { - given(vertxJdbcClient.getConnection(any())).willAnswer(invocation -> { - ((Handler>) invocation.getArgument(0)).handle(result); - return null; - }); + private static void givenQueryReturning(SqlConnection connection, Future> result) { + final PreparedQuery> preparedQueryMock = mock(PreparedQuery.class); + given(connection.preparedQuery(anyString())).willReturn(preparedQueryMock); + given(preparedQueryMock.execute(any(Tuple.class))).willReturn(result); } - @SuppressWarnings("unchecked") - private static void givenQueryReturning(SQLConnection connection, AsyncResult result) { - given(connection.queryWithParams(anyString(), any(), any())).willAnswer(invocation -> { - ((Handler>) invocation.getArgument(2)).handle(result); - return null; - }); + private void givenGetConnectionReturning(Future result) { + given(pool.getConnection()).willReturn(result); } private Timeout expiredTimeout() { return new TimeoutFactory(clock).create(clock.instant().minusMillis(1500L).toEpochMilli(), 1000L); } + + private RowSet givenRowSet(Row... rows) { + final RowSet rowSet = mock(RowSet.class); + given(rowSet.iterator()).willReturn(CustomRowIterator.of(Arrays.asList(rows).iterator())); + return rowSet; + } + + private Row givenRow(Object... values) { + final Row row = mock(Row.class); + given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + return row; + } + + @Value(staticConstructor = "of") + private static class CustomRowIterator implements RowIterator { + + Iterator delegate; + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public Row next() { + return delegate.next(); + } + } } diff --git a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java index ea0e49fb1ce..a1e86429401 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java @@ -49,7 +49,7 @@ public class CircuitBreakerSecuredJdbcClientTest { @Mock private Metrics metrics; - private CircuitBreakerSecuredJdbcClient jdbcClient; + private CircuitBreakerSecuredJdbcClient target; private Timeout timeout; @@ -59,7 +59,7 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - jdbcClient = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); + target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); } @After @@ -74,12 +74,14 @@ public void executeQueryShouldReturnResultIfCircuitIsClosedAndQuerySucceeded(Tes Future.succeededFuture("value"))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // then - future.onComplete(context.asyncAssertSuccess(result -> - assertThat(result).isEqualTo("value"))); + future.onComplete(context.asyncAssertSuccess(result -> assertThat(result).isEqualTo("value"))); } @Test @@ -89,7 +91,7 @@ public void executeQueryShouldReturnExceptionIfCircuitIsClosedAndQueryFails(Test Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // then future.onComplete(context.asyncAssertFailure(throwable -> @@ -103,8 +105,8 @@ public void executeQueryShouldNotExecuteQueryIfCircuitIsOpened(TestContext conte Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)); // 2 call + final Future future = target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)); // 2 call // then future.onComplete(context.asyncAssertFailure(throwable -> { @@ -123,12 +125,12 @@ public void executeQueryShouldReturnExceptionIfCircuitIsHalfOpenedAndQueryFails( // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 3 call + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // 3 call // then future.onComplete(context.asyncAssertFailure(exception -> { @@ -148,13 +150,16 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); // 3 call + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // 3 call // then future.onComplete(context.asyncAssertSuccess(result -> { @@ -168,7 +173,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded @Test public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds(TestContext context) { // given - jdbcClient = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); + target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); givenExecuteQueryReturning(asList( Future.failedFuture(new RuntimeException("exception1")), @@ -176,11 +181,11 @@ public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds // when final Async async = context.async(); - final Future future1 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call + final Future future1 = target.executeQuery("query", emptyList(), identity(), timeout) // 1 call .onComplete(ignored -> vertx.setTimer(101L, id -> async.complete())); async.await(); - final Future future2 = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); // 2 call + final Future future2 = target.executeQuery("query", emptyList(), identity(), timeout); // 2 call // then future1.onComplete(context.asyncAssertFailure(exception -> @@ -200,7 +205,7 @@ public void circuitBreakerGaugeShouldReportOpenedWhenCircuitOpen(TestContext con Future.failedFuture(new RuntimeException("exception1")))); // when - final Future future = jdbcClient.executeQuery("query", emptyList(), identity(), timeout); + final Future future = target.executeQuery("query", emptyList(), identity(), timeout); // then final ArgumentCaptor gaugeValueProviderCaptor = ArgumentCaptor.forClass(BooleanSupplier.class); @@ -220,13 +225,16 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c // when final Async async = context.async(); - jdbcClient.executeQuery("query", emptyList(), identity(), timeout) // 1 call - .recover(ignored -> jdbcClient.executeQuery("query", emptyList(), identity(), timeout)) // 2 call + target.executeQuery("query", emptyList(), identity(), timeout) // 1 call + .recover(ignored -> target.executeQuery("query", emptyList(), identity(), timeout)) // 2 call .onComplete(ignored -> vertx.setTimer(201L, id -> async.complete())); async.await(); - final Future future = jdbcClient.executeQuery("query", emptyList(), - resultSet -> resultSet.getResults().get(0).getString(0), timeout); // 3 call + final Future future = target.executeQuery( + "query", + emptyList(), + rs -> rs.iterator().next().getString(0), + timeout); // 3 call // then final ArgumentCaptor gaugeValueProviderCaptor = ArgumentCaptor.forClass(BooleanSupplier.class); From 0114262fce920ea8ec9ac19581ac06e6bd3c7e77 Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:36:32 +0300 Subject: [PATCH 11/58] Test: `PostgreSQL` container (#3134) --- docs/developers/functional-tests.md | 11 ++++- pom.xml | 6 +++ .../HibernateRepositoryService.groovy | 20 ++++++-- .../testcontainers/Dependencies.groovy | 10 +++- .../testcontainers/PbsConfig.groovy | 13 +++++ .../tests/postgres/PostgresBaseSpec.groovy | 38 ++++++++++++++ .../tests/postgres/PostgresDBSpec.groovy | 49 +++++++++++++++++++ .../{db_schema.sql => db_mysql_schema.sql} | 0 .../server/functional/db_psql_schema.sql | 47 ++++++++++++++++++ 9 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy rename src/test/resources/org/prebid/server/functional/{db_schema.sql => db_mysql_schema.sql} (100%) create mode 100644 src/test/resources/org/prebid/server/functional/db_psql_schema.sql diff --git a/docs/developers/functional-tests.md b/docs/developers/functional-tests.md index fd216eb89c5..c9e827b370a 100644 --- a/docs/developers/functional-tests.md +++ b/docs/developers/functional-tests.md @@ -131,7 +131,16 @@ Container for mocking different calls from PBS: prebid cache, bidders, currency Container for Mysql database. -- Use `org/prebid/server/functional/db_schema.sql` script for scheme. +- Use `org/prebid/server/functional/db_mysql_schema.sql` script for scheme. +- DataBase: `prebid` +- Username: `prebid` +- Password: `prebid` + +#### PostgreSQLContainer + +Container for PostgreSQL database. + +- Use `org/prebid/server/functional/db_psql_schema.sql` script for scheme. - DataBase: `prebid` - Username: `prebid` - Password: `prebid` diff --git a/pom.xml b/pom.xml index 79ae15fa03f..e9f44e2b1b7 100644 --- a/pom.xml +++ b/pom.xml @@ -589,6 +589,12 @@ ${mockserver.version} test + + org.testcontainers + postgresql + ${testcontainers.version} + test + diff --git a/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy b/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy index 6b39354e62a..d6ee8d65c10 100644 --- a/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy +++ b/src/test/groovy/org/prebid/server/functional/repository/HibernateRepositoryService.groovy @@ -10,22 +10,28 @@ import org.prebid.server.functional.repository.dao.AccountDao import org.prebid.server.functional.repository.dao.StoredImpDao import org.prebid.server.functional.repository.dao.StoredRequestDao import org.prebid.server.functional.repository.dao.StoredResponseDao -import org.testcontainers.containers.MySQLContainer +import org.testcontainers.containers.JdbcDatabaseContainer +import org.testcontainers.containers.PostgreSQLContainer class HibernateRepositoryService { + private static final String MY_SQL_DIALECT = "org.hibernate.dialect.MySQLDialect" + private static final String POSTGRES_SQL_DIALECT = "org.hibernate.dialect.PostgreSQLDialect" + EntityManagerUtil entityManagerUtil AccountDao accountDao StoredImpDao storedImpDao StoredRequestDao storedRequestDao StoredResponseDao storedResponseDao - HibernateRepositoryService(MySQLContainer container) { + HibernateRepositoryService(JdbcDatabaseContainer container) { def jdbcUrl = container.jdbcUrl def user = container.username def pass = container.password def driver = container.driverClassName - SessionFactory sessionFactory = configureHibernate(jdbcUrl, user, pass, driver) + def dialect = container instanceof PostgreSQLContainer ? POSTGRES_SQL_DIALECT : MY_SQL_DIALECT + + SessionFactory sessionFactory = configureHibernate(jdbcUrl, dialect, user, pass, driver) entityManagerUtil = new EntityManagerUtil(sessionFactory) accountDao = new AccountDao(entityManagerUtil) @@ -34,10 +40,14 @@ class HibernateRepositoryService { storedResponseDao = new StoredResponseDao(entityManagerUtil) } - private static SessionFactory configureHibernate(String jdbcUrl, String user, String pass, String driver) { + private static SessionFactory configureHibernate(String jdbcUrl, + String dialect, + String user, + String pass, + String driver) { def properties = new Properties() properties.setProperty("hibernate.connection.url", jdbcUrl) - properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect") + properties.setProperty("hibernate.dialect", dialect) properties.setProperty("hibernate.connection.username", user) properties.setProperty("hibernate.connection.password", pass) properties.setProperty("hibernate.connection.driver_class", driver) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index 0798be45cdf..53cbecf2289 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -4,6 +4,7 @@ import org.prebid.server.functional.testcontainers.container.NetworkServiceConta import org.prebid.server.functional.util.SystemProperties import org.testcontainers.containers.MySQLContainer import org.testcontainers.containers.Network +import org.testcontainers.containers.PostgreSQLContainer import org.testcontainers.lifecycle.Startables import static org.prebid.server.functional.util.SystemProperties.MOCKSERVER_VERSION @@ -20,7 +21,14 @@ class Dependencies { .withDatabaseName("prebid") .withUsername("prebid") .withPassword("prebid") - .withInitScript("org/prebid/server/functional/db_schema.sql") + .withInitScript("org/prebid/server/functional/db_mysql_schema.sql") + .withNetwork(network) + + static final PostgreSQLContainer postgresqlContainer = new PostgreSQLContainer<>("postgres:16.0") + .withDatabaseName("prebid") + .withUsername("prebid") + .withPassword("prebid") + .withInitScript("org/prebid/server/functional/db_psql_schema.sql") .withNetwork(network) static final NetworkServiceContainer networkServiceContainer = new NetworkServiceContainer(MOCKSERVER_VERSION) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index 66cdb55f34b..65a9d8da533 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.testcontainers import org.testcontainers.containers.MySQLContainer +import org.testcontainers.containers.PostgreSQLContainer import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer import static org.prebid.server.functional.testcontainers.container.PrebidServerContainer.ADMIN_ENDPOINT_PASSWORD @@ -99,6 +100,18 @@ LIMIT 1 ].asImmutable() } + static Map getPostgreSqlConfig(PostgreSQLContainer postgres = Dependencies.postgresqlContainer) { + ["settings.database.type" : "postgres", + "settings.database.host" : postgres.getNetworkAliases().get(0), + "settings.database.port" : postgres.exposedPorts.get(0) as String, + "settings.database.dbname" : postgres.databaseName, + "settings.database.user" : postgres.username, + "settings.database.password" : postgres.password, + "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS + "settings.database.provider-class": "hikari" + ].asImmutable() + } + static Map getMetricConfig() { ["admin-endpoints.collected-metrics.enabled": "true"].asImmutable() } diff --git a/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy new file mode 100644 index 00000000000..05b5e054cc0 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresBaseSpec.groovy @@ -0,0 +1,38 @@ +package org.prebid.server.functional.tests.postgres + +import org.prebid.server.functional.repository.HibernateRepositoryService +import org.prebid.server.functional.repository.dao.AccountDao +import org.prebid.server.functional.repository.dao.StoredImpDao +import org.prebid.server.functional.repository.dao.StoredRequestDao +import org.prebid.server.functional.repository.dao.StoredResponseDao +import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.testcontainers.Dependencies +import org.prebid.server.functional.testcontainers.PbsConfig +import org.prebid.server.functional.tests.BaseSpec +import org.testcontainers.lifecycle.Startables + +class PostgresBaseSpec extends BaseSpec { + + protected static HibernateRepositoryService repository + protected static AccountDao accountDao + protected static StoredImpDao storedImpDao + protected static StoredRequestDao storedRequestDao + protected static StoredResponseDao storedResponseDao + + protected PrebidServerService pbsServiceWithPostgres + + void setup() { + Startables.deepStart(Dependencies.postgresqlContainer) + .join() + repository = new HibernateRepositoryService(Dependencies.postgresqlContainer) + accountDao = repository.accountDao + storedImpDao = repository.storedImpDao + storedRequestDao = repository.storedRequestDao + storedResponseDao = repository.storedResponseDao + pbsServiceWithPostgres = pbsServiceFactory.getService(PbsConfig.postgreSqlConfig) + } + + void cleanup() { + Dependencies.postgresqlContainer.stop() + } +} diff --git a/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy new file mode 100644 index 00000000000..fee381bad7c --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/postgres/PostgresDBSpec.groovy @@ -0,0 +1,49 @@ +package org.prebid.server.functional.tests.postgres + +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.db.StoredImp +import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.db.StoredResponse +import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.PrebidStoredRequest +import org.prebid.server.functional.model.request.auction.StoredAuctionResponse +import org.prebid.server.functional.model.response.auction.SeatBid +import org.prebid.server.functional.util.PBSUtils + +class PostgresDBSpec extends PostgresBaseSpec { + + def "PBS with postgresql should proceed with stored requests and responses correctly"() { + given: "Default AMP request" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Default stored request with specified stored response" + def storedResponseId = PBSUtils.randomNumber + def ampStoredRequest = BidRequest.defaultStoredRequest + ampStoredRequest.imp[0].ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomString) + ampStoredRequest.imp[0].ext.prebid.storedAuctionResponse = new StoredAuctionResponse(id: storedResponseId) + + and: "Create and save account in the DB" + def account = new Account(uuid: ampRequest.account) + accountDao.save(account) + + and: "Save storedImp into DB" + def storedImp = StoredImp.getStoredImp(ampStoredRequest) + storedImpDao.save(storedImp) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + and: "Stored response in DB" + def storedAuctionResponse = SeatBid.getStoredResponse(ampStoredRequest) + def storedResponse = new StoredResponse(responseId: storedResponseId, storedAuctionResponse: storedAuctionResponse) + storedResponseDao.save(storedResponse) + + when: "PBS processes amp request" + def response = pbsServiceWithPostgres.sendAmpRequest(ampRequest) + + then: "PBS should not reject request" + assert response.ext?.debug?.httpcalls + } +} diff --git a/src/test/resources/org/prebid/server/functional/db_schema.sql b/src/test/resources/org/prebid/server/functional/db_mysql_schema.sql similarity index 100% rename from src/test/resources/org/prebid/server/functional/db_schema.sql rename to src/test/resources/org/prebid/server/functional/db_mysql_schema.sql diff --git a/src/test/resources/org/prebid/server/functional/db_psql_schema.sql b/src/test/resources/org/prebid/server/functional/db_psql_schema.sql new file mode 100644 index 00000000000..0ac5e5a0c43 --- /dev/null +++ b/src/test/resources/org/prebid/server/functional/db_psql_schema.sql @@ -0,0 +1,47 @@ +CREATE TABLE accounts_account +( + id SERIAL PRIMARY KEY, + uuid varchar(40) NOT NULL, + price_granularity varchar(6), + banner_cache_ttl integer, + video_cache_ttl integer, + events_enabled boolean, + tcf_config text, + truncate_target_attr smallint, + default_integration varchar(64), + analytics_config varchar(512), + bid_validations text, + status text, + config text, + updated_by integer, + updated_by_user varchar(64), + updated timestamp +); + +CREATE TABLE stored_requests +( + id SERIAL PRIMARY KEY, + accountId varchar(40), + reqId varchar(40), + requestData text +); + +CREATE TABLE stored_imps +( + id SERIAL PRIMARY KEY, + accountId varchar(40), + impId varchar(40), + impData text +); + +CREATE TABLE stored_responses +( + id SERIAL PRIMARY KEY, + resId varchar(40) NOT NULL, + storedAuctionResponse varchar(1024), + storedBidResponse varchar(1024) +); + +-- set session wait timeout to 1 minute +set statement_timeout to 60000; +commit; From ca491e5a181c4e1d81828032aeea0abd36871051 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:26:06 -0400 Subject: [PATCH 12/58] Bump IAB TCF decoder version (#3137) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e9f44e2b1b7..32711386616 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 1.2.2 0.16.0 2.0.2 - 2.0.7 + 2.0.10 2.12.0 5.0.1 3.0.10 From fbf2922f569a336cf6974074569c3cb453eeeb89 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:50:43 +0200 Subject: [PATCH 13/58] Core: Fix Async DB clients (#3146) * Fix Async DB clients * Fix Func Tests * Remove property * Renamed everything with `jdbc` prefix to use more generic `database` prefix, since we don't use jdbc anymore. Removed unused provider class field from DatabaseType enum. * Fix import order --------- Co-authored-by: Alex Maltsev Co-authored-by: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> --- docs/config-app.md | 14 +++--- pom.xml | 6 --- .../server/settings/ApplicationSettings.java | 2 +- ....java => DatabaseApplicationSettings.java} | 41 ++++++++-------- ...va => DatabaseStoredDataResultMapper.java} | 13 ++--- ...> DatabaseStoredResponseResultMapper.java} | 9 ++-- ...va => DatabasePeriodicRefreshService.java} | 44 ++++++++--------- .../spring/config/SettingsConfiguration.java | 48 +++++++++---------- .../database/DatabaseConfiguration.java | 37 +++++++------- .../model/ConnectionPoolSettings.java | 2 + .../database/model/DatabasePoolType.java | 6 --- .../config/database/model/DatabaseType.java | 6 +-- .../DatabaseConfigurationProperties.java | 7 +-- .../BasicDatabaseClient.java} | 12 ++--- .../CircuitBreakerSecuredDatabaseClient.java} | 31 ++++++------ .../DatabaseClient.java} | 6 +-- src/main/resources/application.yaml | 2 +- src/main/resources/c3p0.properties | 8 ---- .../testcontainers/PbsConfig.groovy | 4 +- ...a => DatabaseApplicationSettingsTest.java} | 30 ++++++------ ...> DatabaseStoredDataResultMapperTest.java} | 33 +++++++------ ...tabaseStoredResponseResultMapperTest.java} | 14 +++--- ...> DatabasePeriodicRefreshServiceTest.java} | 24 +++++----- .../BasicDatabaseClientTest.java} | 14 +++--- ...cuitBreakerSecuredDatabaseClientTest.java} | 22 ++++----- 25 files changed, 212 insertions(+), 223 deletions(-) rename src/main/java/org/prebid/server/settings/{JdbcApplicationSettings.java => DatabaseApplicationSettings.java} (85%) rename src/main/java/org/prebid/server/settings/helper/{JdbcStoredDataResultMapper.java => DatabaseStoredDataResultMapper.java} (94%) rename src/main/java/org/prebid/server/settings/helper/{JdbcStoredResponseResultMapper.java => DatabaseStoredResponseResultMapper.java} (82%) rename src/main/java/org/prebid/server/settings/service/{JdbcPeriodicRefreshService.java => DatabasePeriodicRefreshService.java} (83%) delete mode 100644 src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java rename src/main/java/org/prebid/server/vertx/{jdbc/BasicJdbcClient.java => database/BasicDatabaseClient.java} (89%) rename src/main/java/org/prebid/server/vertx/{jdbc/CircuitBreakerSecuredJdbcClient.java => database/CircuitBreakerSecuredDatabaseClient.java} (65%) rename src/main/java/org/prebid/server/vertx/{jdbc/JdbcClient.java => database/DatabaseClient.java} (77%) delete mode 100644 src/main/resources/c3p0.properties rename src/test/java/org/prebid/server/settings/{JdbcApplicationSettingsTest.java => DatabaseApplicationSettingsTest.java} (90%) rename src/test/java/org/prebid/server/settings/helper/{JdbcStoredDataResultMapperTest.java => DatabaseStoredDataResultMapperTest.java} (89%) rename src/test/java/org/prebid/server/settings/helper/{JdbcStoredResponseResultMapperTest.java => DatabaseStoredResponseResultMapperTest.java} (83%) rename src/test/java/org/prebid/server/settings/service/{JdbcPeriodicRefreshServiceTest.java => DatabasePeriodicRefreshServiceTest.java} (85%) rename src/test/java/org/prebid/server/vertx/{jdbc/BasicJdbcClientTest.java => database/BasicDatabaseClientTest.java} (96%) rename src/test/java/org/prebid/server/vertx/{jdbc/CircuitBreakerSecuredJdbcClientTest.java => database/CircuitBreakerSecuredDatabaseClientTest.java} (92%) diff --git a/docs/config-app.md b/docs/config-app.md index 0ae973cf9f5..ee6bf32dbe3 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -294,8 +294,8 @@ For database data source available next options: - `settings.database.user` - database user. - `settings.database.password` - database password. - `settings.database.pool-size` - set the initial/min/max pool size of database connections. +- `settings.database.idle-connection-timeout` - Set the idle timeout, time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed and get back to the pool if no data is received nor sent within the timeout. - `settings.database.account-query` - the SQL query to fetch account. -- `settings.database.provider-class` - type of connection pool to be used: `hikari` or `c3p0`. - `settings.database.stored-requests-query` - the SQL query to fetch stored requests. - `settings.database.amp-stored-requests-query` - the SQL query to fetch AMP stored requests. - `settings.database.stored-responses-query` - the SQL query to fetch stored responses. @@ -346,14 +346,14 @@ available: `/cache/invalidate?account={accountId}` which remove account from the - `settings.in-memory-cache.http-update.amp-endpoint` - the url to fetch AMP stored request updates. - `settings.in-memory-cache.http-update.refresh-rate` - refresh period in ms for stored request updates. - `settings.in-memory-cache.http-update.timeout` - timeout for obtaining stored request updates. -- `settings.in-memory-cache.jdbc-update.init-query` - initial query for fetching all stored requests at the startup. -- `settings.in-memory-cache.jdbc-update.update-query` - a query for periodical update of stored requests, that should +- `settings.in-memory-cache.database-update.init-query` - initial query for fetching all stored requests at the startup. +- `settings.in-memory-cache.database-update.update-query` - a query for periodical update of stored requests, that should contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. -- `settings.in-memory-cache.jdbc-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. -- `settings.in-memory-cache.jdbc-update.amp-update-query` - a query for periodical update of AMP stored requests, that should +- `settings.in-memory-cache.database-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. +- `settings.in-memory-cache.database-update.amp-update-query` - a query for periodical update of AMP stored requests, that should contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. -- `settings.in-memory-cache.jdbc-update.refresh-rate` - refresh period in ms for stored request updates. -- `settings.in-memory-cache.jdbc-update.timeout` - timeout for obtaining stored request updates. +- `settings.in-memory-cache.database-update.refresh-rate` - refresh period in ms for stored request updates. +- `settings.in-memory-cache.database-update.timeout` - timeout for obtaining stored request updates. For targeting available next options: - `settings.targeting.truncate-attr-chars` - set the max length for names of targeting keywords (0 means no truncation). diff --git a/pom.xml b/pom.xml index 32711386616..0545e9ad7d9 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,6 @@ 2.0.2 2.0.10 2.12.0 - 5.0.1 3.0.10 3.21.7 3.17.3 @@ -354,11 +353,6 @@ geoip2 ${maxmind-client.version} - - com.zaxxer - HikariCP - ${hikari.version} - com.iabgpp iabgpp-encoder diff --git a/src/main/java/org/prebid/server/settings/ApplicationSettings.java b/src/main/java/org/prebid/server/settings/ApplicationSettings.java index 8a010991b2f..da414bef279 100644 --- a/src/main/java/org/prebid/server/settings/ApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/ApplicationSettings.java @@ -14,7 +14,7 @@ * stored requests and imps) from the source. * * @see FileApplicationSettings - * @see JdbcApplicationSettings + * @see DatabaseApplicationSettings * @see HttpApplicationSettings * @see CachingApplicationSettings * @see CompositeApplicationSettings diff --git a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java b/src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java similarity index 85% rename from src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java rename to src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java index 6dd9f507ffa..9dad7f6a28b 100644 --- a/src/main/java/org/prebid/server/settings/JdbcApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/DatabaseApplicationSettings.java @@ -10,14 +10,15 @@ import org.prebid.server.execution.Timeout; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; -import org.prebid.server.settings.helper.JdbcStoredResponseResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredDataResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredResponseResultMapper; import org.prebid.server.settings.helper.ParametrizedQueryHelper; import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; import org.prebid.server.util.ObjectUtil; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.util.ArrayList; import java.util.Collections; @@ -33,12 +34,12 @@ *

* Reads an application settings from the database source. *

- * In order to enable caching and reduce latency for read operations {@link JdbcApplicationSettings} + * In order to enable caching and reduce latency for read operations {@link DatabaseApplicationSettings} * can be decorated by {@link CachingApplicationSettings}. */ -public class JdbcApplicationSettings implements ApplicationSettings { +public class DatabaseApplicationSettings implements ApplicationSettings { - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final JacksonMapper mapper; private final ParametrizedQueryHelper parametrizedQueryHelper; @@ -81,15 +82,15 @@ public class JdbcApplicationSettings implements ApplicationSettings { */ private final String selectStoredResponsesQuery; - public JdbcApplicationSettings(JdbcClient jdbcClient, - JacksonMapper mapper, - ParametrizedQueryHelper parametrizedQueryHelper, - String selectAccountQuery, - String selectStoredRequestsQuery, - String selectAmpStoredRequestsQuery, - String selectStoredResponsesQuery) { + public DatabaseApplicationSettings(DatabaseClient databaseClient, + JacksonMapper mapper, + ParametrizedQueryHelper parametrizedQueryHelper, + String selectAccountQuery, + String selectStoredRequestsQuery, + String selectAmpStoredRequestsQuery, + String selectStoredResponsesQuery) { - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); this.mapper = Objects.requireNonNull(mapper); this.parametrizedQueryHelper = Objects.requireNonNull(parametrizedQueryHelper); this.selectAccountQuery = parametrizedQueryHelper.replaceAccountIdPlaceholder( @@ -105,7 +106,7 @@ public JdbcApplicationSettings(JdbcClient jdbcClient, */ @Override public Future getAccountById(String accountId, Timeout timeout) { - return jdbcClient.executeQuery( + return databaseClient.executeQuery( selectAccountQuery, Collections.singletonList(accountId), result -> mapToModelOrError(result, this::toAccount), @@ -122,7 +123,7 @@ public Future> getCategories(String primaryAdServer, String * Transforms the first row of {@link RowSet} to required object or returns null. *

* Note: mapper should never throws exception in case of using - * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. + * {@link CircuitBreakerSecuredDatabaseClient}. */ private T mapToModelOrError(RowSet rowSet, Function mapper) { final RowIterator rowIterator = rowSet != null ? rowSet.iterator() : null; @@ -197,8 +198,8 @@ public Future getStoredResponses(Set responseI IntStream.rangeClosed(1, responseIdPlaceholderCount) .forEach(i -> idsQueryParameters.addAll(responseIds)); - return jdbcClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, - result -> JdbcStoredResponseResultMapper.map(result, responseIds), timeout); + return databaseClient.executeQuery(queryResolvedWithParameters, idsQueryParameters, + result -> DatabaseStoredResponseResultMapper.map(result, responseIds), timeout); } /** @@ -223,8 +224,8 @@ private Future fetchStoredData(String query, String accountId, requestIds.size(), impIds.size()); - future = jdbcClient.executeQuery(parametrizedQuery, idsQueryParameters, - result -> JdbcStoredDataResultMapper.map(result, accountId, requestIds, impIds), + future = databaseClient.executeQuery(parametrizedQuery, idsQueryParameters, + result -> DatabaseStoredDataResultMapper.map(result, accountId, requestIds, impIds), timeout); } diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java similarity index 94% rename from src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java rename to src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java index c7e9ec820f8..00853194e65 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapper.java @@ -10,6 +10,7 @@ import org.prebid.server.settings.model.StoredDataType; import org.prebid.server.settings.model.StoredItem; import org.prebid.server.util.ObjectUtil; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; import java.util.ArrayList; import java.util.Collections; @@ -22,11 +23,11 @@ /** * Utility class for mapping {@link RowSet} to {@link StoredDataResult}. */ -public class JdbcStoredDataResultMapper { +public class DatabaseStoredDataResultMapper { - private static final Logger logger = LoggerFactory.getLogger(JdbcStoredDataResultMapper.class); + private static final Logger logger = LoggerFactory.getLogger(DatabaseStoredDataResultMapper.class); - private JdbcStoredDataResultMapper() { + private DatabaseStoredDataResultMapper() { } /** @@ -39,7 +40,7 @@ private JdbcStoredDataResultMapper() { * @return - a {@link StoredDataResult} object *

* Note: mapper should never throws exception in case of using - * {@link org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient}. + * {@link CircuitBreakerSecuredDatabaseClient}. */ public static StoredDataResult map(RowSet rowSet, String accountId, @@ -82,8 +83,8 @@ public static StoredDataResult map(RowSet rowSet, final String data; final String typeAsString; try { - fetchedAccountId = row.getString(0); - id = row.getString(1); + fetchedAccountId = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); + id = ObjectUtil.getIfNotNull(row.getValue(1), Object::toString); data = ObjectUtil.getIfNotNull(row.getValue(2), Object::toString); typeAsString = ObjectUtil.getIfNotNull(row.getValue(3), Object::toString); } catch (ClassCastException e) { diff --git a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java similarity index 82% rename from src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java rename to src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java index 6b6cc4462ae..99896d72911 100644 --- a/src/main/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapper.java +++ b/src/main/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapper.java @@ -4,6 +4,7 @@ import io.vertx.sqlclient.RowIterator; import io.vertx.sqlclient.RowSet; import org.prebid.server.settings.model.StoredResponseDataResult; +import org.prebid.server.util.ObjectUtil; import java.util.ArrayList; import java.util.Collections; @@ -12,9 +13,9 @@ import java.util.Map; import java.util.Set; -public class JdbcStoredResponseResultMapper { +public class DatabaseStoredResponseResultMapper { - private JdbcStoredResponseResultMapper() { + private DatabaseStoredResponseResultMapper() { } public static StoredResponseDataResult map(RowSet rowSet, Set responseIds) { @@ -33,7 +34,9 @@ public static StoredResponseDataResult map(RowSet rowSet, Set respo errors.add("Result set column number is less than expected"); return StoredResponseDataResult.of(Collections.emptyMap(), errors); } - storedIdToResponse.put(row.getString(0), row.getString(1)); + final String key = ObjectUtil.getIfNotNull(row.getValue(0), Object::toString); + final String value = ObjectUtil.getIfNotNull(row.getValue(1), Object::toString); + storedIdToResponse.put(key, value); } errors.addAll(responseIds.stream().filter(id -> !storedIdToResponse.containsKey(id)) diff --git a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java b/src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java similarity index 83% rename from src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java rename to src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java index 13e76bc9c89..cc4b80ad870 100644 --- a/src/main/java/org/prebid/server/settings/service/JdbcPeriodicRefreshService.java +++ b/src/main/java/org/prebid/server/settings/service/DatabasePeriodicRefreshService.java @@ -11,10 +11,10 @@ import org.prebid.server.metric.MetricName; import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; -import org.prebid.server.settings.helper.JdbcStoredDataResultMapper; +import org.prebid.server.settings.helper.DatabaseStoredDataResultMapper; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.vertx.Initializable; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -42,9 +42,9 @@ * If data is not empty, depending on TYPE, it should be put to corresponding map with ID as a key and DATA as value. *

*/ -public class JdbcPeriodicRefreshService implements Initializable { +public class DatabasePeriodicRefreshService implements Initializable { - private static final Logger logger = LoggerFactory.getLogger(JdbcPeriodicRefreshService.class); + private static final Logger logger = LoggerFactory.getLogger(DatabasePeriodicRefreshService.class); /** * Example of initialize query: @@ -71,24 +71,24 @@ public class JdbcPeriodicRefreshService implements Initializable { private final MetricName cacheType; private final CacheNotificationListener cacheNotificationListener; private final Vertx vertx; - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final TimeoutFactory timeoutFactory; private final Metrics metrics; private final Clock clock; private Instant lastUpdate; - public JdbcPeriodicRefreshService(String initQuery, - String updateQuery, - long refreshPeriod, - long timeout, - MetricName cacheType, - CacheNotificationListener cacheNotificationListener, - Vertx vertx, - JdbcClient jdbcClient, - TimeoutFactory timeoutFactory, - Metrics metrics, - Clock clock) { + public DatabasePeriodicRefreshService(String initQuery, + String updateQuery, + long refreshPeriod, + long timeout, + MetricName cacheType, + CacheNotificationListener cacheNotificationListener, + Vertx vertx, + DatabaseClient databaseClient, + TimeoutFactory timeoutFactory, + Metrics metrics, + Clock clock) { this.initQuery = Objects.requireNonNull(StringUtils.stripToNull(initQuery)); this.updateQuery = Objects.requireNonNull(StringUtils.stripToNull(updateQuery)); @@ -97,7 +97,7 @@ public JdbcPeriodicRefreshService(String initQuery, this.cacheType = Objects.requireNonNull(cacheType); this.cacheNotificationListener = Objects.requireNonNull(cacheNotificationListener); this.vertx = Objects.requireNonNull(vertx); - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); this.timeoutFactory = Objects.requireNonNull(timeoutFactory); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); @@ -115,10 +115,10 @@ public void initialize(Promise initializePromise) { private void getAll() { final long startTime = clock.millis(); - jdbcClient.executeQuery( + databaseClient.executeQuery( initQuery, Collections.emptyList(), - JdbcStoredDataResultMapper::map, + DatabaseStoredDataResultMapper::map, createTimeout()) .map(storedDataResult -> handleResult(storedDataResult, Instant.now(clock), startTime, MetricName.initialize)) @@ -139,7 +139,7 @@ private Void handleResult(StoredDataResult storedDataResult, } private Future handleFailure(Throwable exception, long startTime, MetricName refreshType) { - logger.warn("Error occurred while request to jdbc refresh service", exception); + logger.warn("Error occurred while request to database refresh service", exception); metrics.updateSettingsCacheRefreshTime(cacheType, refreshType, clock.millis() - startTime); metrics.updateSettingsCacheRefreshErrorMetric(cacheType, refreshType); @@ -151,10 +151,10 @@ private void refresh() { final Instant updateTime = Instant.now(clock); final long startTime = clock.millis(); - jdbcClient.executeQuery( + databaseClient.executeQuery( updateQuery, Collections.singletonList(Date.from(lastUpdate)), - JdbcStoredDataResultMapper::map, + DatabaseStoredDataResultMapper::map, createTimeout()) .map(storedDataResult -> handleResult(invalidate(storedDataResult), updateTime, startTime, MetricName.update)) diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 4929a67fca4..538eaeb3159 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -16,17 +16,17 @@ import org.prebid.server.settings.ApplicationSettings; import org.prebid.server.settings.CachingApplicationSettings; import org.prebid.server.settings.CompositeApplicationSettings; +import org.prebid.server.settings.DatabaseApplicationSettings; import org.prebid.server.settings.EnrichingApplicationSettings; import org.prebid.server.settings.FileApplicationSettings; import org.prebid.server.settings.HttpApplicationSettings; -import org.prebid.server.settings.JdbcApplicationSettings; import org.prebid.server.settings.SettingsCache; import org.prebid.server.settings.helper.ParametrizedQueryHelper; +import org.prebid.server.settings.service.DatabasePeriodicRefreshService; import org.prebid.server.settings.service.HttpPeriodicRefreshService; -import org.prebid.server.settings.service.JdbcPeriodicRefreshService; import org.prebid.server.spring.config.database.DatabaseConfiguration; +import org.prebid.server.vertx.database.DatabaseClient; import org.prebid.server.vertx.httpclient.HttpClient; -import org.prebid.server.vertx.jdbc.JdbcClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -73,17 +73,17 @@ FileApplicationSettings fileApplicationSettings( static class DatabaseSettingsConfiguration { @Bean - JdbcApplicationSettings jdbcApplicationSettings( + DatabaseApplicationSettings databaseApplicationSettings( @Value("${settings.database.account-query}") String accountQuery, @Value("${settings.database.stored-requests-query}") String storedRequestsQuery, @Value("${settings.database.amp-stored-requests-query}") String ampStoredRequestsQuery, @Value("${settings.database.stored-responses-query}") String storedResponsesQuery, ParametrizedQueryHelper parametrizedQueryHelper, - JdbcClient jdbcClient, + DatabaseClient databaseClient, JacksonMapper jacksonMapper) { - return new JdbcApplicationSettings( - jdbcClient, + return new DatabaseApplicationSettings( + databaseClient, jacksonMapper, parametrizedQueryHelper, accountQuery, @@ -151,21 +151,21 @@ public HttpPeriodicRefreshService ampHttpPeriodicRefreshService( @Configuration @ConditionalOnProperty( - prefix = "settings.in-memory-cache.jdbc-update", + prefix = "settings.in-memory-cache.database-update", name = {"refresh-rate", "timeout", "init-query", "update-query", "amp-init-query", "amp-update-query"}) - static class JdbcPeriodicRefreshServiceConfiguration { + static class DatabasePeriodicRefreshServiceConfiguration { - @Value("${settings.in-memory-cache.jdbc-update.refresh-rate}") + @Value("${settings.in-memory-cache.database-update.refresh-rate}") long refreshPeriod; - @Value("${settings.in-memory-cache.jdbc-update.timeout}") + @Value("${settings.in-memory-cache.database-update.timeout}") long timeout; @Autowired Vertx vertx; @Autowired - JdbcClient jdbcClient; + DatabaseClient databaseClient; @Autowired TimeoutFactory timeoutFactory; @@ -177,12 +177,12 @@ static class JdbcPeriodicRefreshServiceConfiguration { Clock clock; @Bean - public JdbcPeriodicRefreshService jdbcPeriodicRefreshService( + public DatabasePeriodicRefreshService databasePeriodicRefreshService( @Qualifier("settingsCache") SettingsCache settingsCache, - @Value("${settings.in-memory-cache.jdbc-update.init-query}") String initQuery, - @Value("${settings.in-memory-cache.jdbc-update.update-query}") String updateQuery) { + @Value("${settings.in-memory-cache.database-update.init-query}") String initQuery, + @Value("${settings.in-memory-cache.database-update.update-query}") String updateQuery) { - return new JdbcPeriodicRefreshService( + return new DatabasePeriodicRefreshService( initQuery, updateQuery, refreshPeriod, @@ -190,19 +190,19 @@ public JdbcPeriodicRefreshService jdbcPeriodicRefreshService( MetricName.stored_request, settingsCache, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); } @Bean - public JdbcPeriodicRefreshService ampJdbcPeriodicRefreshService( + public DatabasePeriodicRefreshService ampDatabasePeriodicRefreshService( @Qualifier("ampSettingsCache") SettingsCache ampSettingsCache, - @Value("${settings.in-memory-cache.jdbc-update.amp-init-query}") String ampInitQuery, - @Value("${settings.in-memory-cache.jdbc-update.amp-update-query}") String ampUpdateQuery) { + @Value("${settings.in-memory-cache.database-update.amp-init-query}") String ampInitQuery, + @Value("${settings.in-memory-cache.database-update.amp-update-query}") String ampUpdateQuery) { - return new JdbcPeriodicRefreshService( + return new DatabasePeriodicRefreshService( ampInitQuery, ampUpdateQuery, refreshPeriod, @@ -210,7 +210,7 @@ public JdbcPeriodicRefreshService ampJdbcPeriodicRefreshService( MetricName.amp_stored_request, ampSettingsCache, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); @@ -226,12 +226,12 @@ static class CompositeSettingsConfiguration { @Bean CompositeApplicationSettings compositeApplicationSettings( @Autowired(required = false) FileApplicationSettings fileApplicationSettings, - @Autowired(required = false) JdbcApplicationSettings jdbcApplicationSettings, + @Autowired(required = false) DatabaseApplicationSettings databaseApplicationSettings, @Autowired(required = false) HttpApplicationSettings httpApplicationSettings) { final List applicationSettingsList = Stream.of(fileApplicationSettings, - jdbcApplicationSettings, + databaseApplicationSettings, httpApplicationSettings) .filter(Objects::nonNull) .toList(); diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index 56f2f045245..ba322b34707 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -16,8 +16,8 @@ import org.prebid.server.spring.config.database.properties.DatabaseConfigurationProperties; import org.prebid.server.spring.config.model.CircuitBreakerProperties; import org.prebid.server.vertx.ContextRunner; -import org.prebid.server.vertx.jdbc.BasicJdbcClient; -import org.prebid.server.vertx.jdbc.CircuitBreakerSecuredJdbcClient; +import org.prebid.server.vertx.database.BasicDatabaseClient; +import org.prebid.server.vertx.database.CircuitBreakerSecuredDatabaseClient; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -45,6 +45,7 @@ DatabaseAddress databaseAddress(DatabaseConfigurationProperties databaseConfigur ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties databaseConfigurationProperties) { return ConnectionPoolSettings.of( databaseConfigurationProperties.getPoolSize(), + databaseConfigurationProperties.getIdleConnectionTimeout(), databaseConfigurationProperties.getUser(), databaseConfigurationProperties.getPassword(), databaseConfigurationProperties.getType()); @@ -83,7 +84,8 @@ Pool mysqlConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setIdleTimeout(1) + .setCachePreparedStatements(true) + .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); final PoolOptions poolOptions = new PoolOptions() @@ -111,7 +113,8 @@ Pool postgresConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setIdleTimeout(1) + .setCachePreparedStatements(true) + .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); final PoolOptions poolOptions = new PoolOptions() @@ -135,14 +138,14 @@ CircuitBreakerProperties databaseCircuitBreakerProperties() { @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "false", matchIfMissing = true) - BasicJdbcClient basicJdbcClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { + BasicDatabaseClient basicDatabaseClient(Pool pool, Metrics metrics, Clock clock, ContextRunner contextRunner) { - return createBasicJdbcClient(pool, metrics, clock, contextRunner); + return createBasicDatabaseClient(pool, metrics, clock, contextRunner); } @Bean @ConditionalOnProperty(prefix = "settings.database.circuit-breaker", name = "enabled", havingValue = "true") - CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( + CircuitBreakerSecuredDatabaseClient circuitBreakerSecuredAsyncDatabaseClient( Vertx vertx, Pool pool, Metrics metrics, @@ -150,10 +153,10 @@ CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( ContextRunner contextRunner, @Qualifier("databaseCircuitBreakerProperties") CircuitBreakerProperties circuitBreakerProperties) { - final BasicJdbcClient jdbcClient = createBasicJdbcClient(pool, metrics, clock, contextRunner); - return new CircuitBreakerSecuredJdbcClient( + final BasicDatabaseClient databaseClient = createBasicDatabaseClient(pool, metrics, clock, contextRunner); + return new CircuitBreakerSecuredDatabaseClient( vertx, - jdbcClient, + databaseClient, metrics, circuitBreakerProperties.getOpeningThreshold(), circuitBreakerProperties.getOpeningIntervalMs(), @@ -161,15 +164,15 @@ CircuitBreakerSecuredJdbcClient circuitBreakerSecuredAsyncDatabaseClient( clock); } - private static BasicJdbcClient createBasicJdbcClient(Pool pool, - Metrics metrics, - Clock clock, - ContextRunner contextRunner) { + private static BasicDatabaseClient createBasicDatabaseClient(Pool pool, + Metrics metrics, + Clock clock, + ContextRunner contextRunner) { - final BasicJdbcClient basicJdbcClient = new BasicJdbcClient(pool, metrics, clock); + final BasicDatabaseClient basicDatabaseClient = new BasicDatabaseClient(pool, metrics, clock); - contextRunner.runBlocking(promise -> basicJdbcClient.initialize().onComplete(promise)); + contextRunner.runBlocking(promise -> basicDatabaseClient.initialize().onComplete(promise)); - return basicJdbcClient; + return basicDatabaseClient; } } diff --git a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java index a0ffb6fa5b0..10ca0eacf89 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java @@ -7,6 +7,8 @@ public class ConnectionPoolSettings { Integer poolSize; + Integer idleTimeout; + String user; String password; diff --git a/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java b/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java deleted file mode 100644 index d3337549654..00000000000 --- a/src/main/java/org/prebid/server/spring/config/database/model/DatabasePoolType.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.spring.config.database.model; - -public enum DatabasePoolType { - - hikari, c3p0 -} diff --git a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java index 8c94c1c0ced..a521ea0c583 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java @@ -5,8 +5,6 @@ @AllArgsConstructor public enum DatabaseType { - postgres("org.postgresql.Driver"), - mysql("com.mysql.cj.jdbc.Driver"); - - public final String jdbcDriver; + postgres, + mysql; } diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index 174bf82f35c..0f3e6ac8c79 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -2,12 +2,12 @@ import lombok.Data; import lombok.NoArgsConstructor; -import org.prebid.server.spring.config.database.model.DatabasePoolType; import org.prebid.server.spring.config.database.model.DatabaseType; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.PositiveOrZero; @Data @NoArgsConstructor @@ -18,6 +18,9 @@ public class DatabaseConfigurationProperties { @NotNull @Min(1) private Integer poolSize; + @NotNull + @PositiveOrZero + private Integer idleConnectionTimeout; @NotBlank private String host; @NotNull @@ -28,7 +31,5 @@ public class DatabaseConfigurationProperties { private String user; @NotBlank private String password; - @NotNull - private DatabasePoolType providerClass; } diff --git a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java b/src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java similarity index 89% rename from src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java index 6b6effa79a3..e5aa90aabb2 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/BasicJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/BasicDatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Pool; @@ -21,15 +21,15 @@ /** * Wrapper over {@link Pool} that supports setting query timeout in milliseconds. */ -public class BasicJdbcClient implements JdbcClient { +public class BasicDatabaseClient implements DatabaseClient { - private static final Logger logger = LoggerFactory.getLogger(BasicJdbcClient.class); + private static final Logger logger = LoggerFactory.getLogger(BasicDatabaseClient.class); private final Pool pool; private final Metrics metrics; private final Clock clock; - public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { + public BasicDatabaseClient(Pool pool, Metrics metrics, Clock clock) { this.pool = Objects.requireNonNull(pool); this.metrics = Objects.requireNonNull(metrics); this.clock = Objects.requireNonNull(clock); @@ -43,7 +43,7 @@ public BasicJdbcClient(Pool pool, Metrics metrics, Clock clock) { */ public Future initialize() { return pool.getConnection() - .recover(BasicJdbcClient::logConnectionError) + .recover(BasicDatabaseClient::logConnectionError) .mapEmpty(); } @@ -60,7 +60,7 @@ public Future executeQuery(String query, final long startTime = clock.millis(); return pool.getConnection() - .recover(BasicJdbcClient::logConnectionError) + .recover(BasicDatabaseClient::logConnectionError) .compose(connection -> makeQuery(connection, query, params)) .timeout(remainingTimeout, TimeUnit.MILLISECONDS) .recover(this::handleFailure) diff --git a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java b/src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java similarity index 65% rename from src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java index f85fa351941..bb4fa7d09c1 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -18,26 +18,26 @@ import java.util.function.Function; /** - * JDBC Client wrapped by {@link CircuitBreaker} to achieve robust operating. + * Database Client wrapped by {@link CircuitBreaker} to achieve robust operating. */ -public class CircuitBreakerSecuredJdbcClient implements JdbcClient { +public class CircuitBreakerSecuredDatabaseClient implements DatabaseClient { - private static final Logger logger = LoggerFactory.getLogger(CircuitBreakerSecuredJdbcClient.class); + private static final Logger logger = LoggerFactory.getLogger(CircuitBreakerSecuredDatabaseClient.class); private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger); private static final int LOG_PERIOD_SECONDS = 5; - private final JdbcClient jdbcClient; + private final DatabaseClient databaseClient; private final CircuitBreaker breaker; - public CircuitBreakerSecuredJdbcClient(Vertx vertx, - JdbcClient jdbcClient, - Metrics metrics, - int openingThreshold, - long openingIntervalMs, - long closingIntervalMs, - Clock clock) { + public CircuitBreakerSecuredDatabaseClient(Vertx vertx, + DatabaseClient databaseClient, + Metrics metrics, + int openingThreshold, + long openingIntervalMs, + long closingIntervalMs, + Clock clock) { - this.jdbcClient = Objects.requireNonNull(jdbcClient); + this.databaseClient = Objects.requireNonNull(databaseClient); breaker = new CircuitBreaker( "db_cb", @@ -52,7 +52,7 @@ public CircuitBreakerSecuredJdbcClient(Vertx vertx, metrics.createDatabaseCircuitBreakerGauge(breaker::isOpen); - logger.info("Initialized JDBC client with Circuit Breaker"); + logger.info("Initialized database client with Circuit Breaker"); } @Override @@ -61,7 +61,8 @@ public Future executeQuery(String query, Function, T> mapper, Timeout timeout) { - return breaker.execute(promise -> jdbcClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); + return breaker.execute( + promise -> databaseClient.executeQuery(query, params, mapper, timeout).onComplete(promise)); } private void circuitOpened() { diff --git a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java b/src/main/java/org/prebid/server/vertx/database/DatabaseClient.java similarity index 77% rename from src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java rename to src/main/java/org/prebid/server/vertx/database/DatabaseClient.java index 3fc7754b038..87c9ada84c6 100644 --- a/src/main/java/org/prebid/server/vertx/jdbc/JdbcClient.java +++ b/src/main/java/org/prebid/server/vertx/database/DatabaseClient.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Row; @@ -9,10 +9,10 @@ import java.util.function.Function; /** - * Interface for asynchronous interaction with database over JDBC API. + * Interface for asynchronous interaction with database over database API. */ @FunctionalInterface -public interface JdbcClient { +public interface DatabaseClient { /** * Executes query with parameters and returns {@link Future} eventually holding result mapped to a model diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b31305ace9f..ce193e5cbc4 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -165,7 +165,7 @@ settings: enforce-valid-account: false database: pool-size: 20 - provider-class: c3p0 + idle-connection-timeout: 300 targeting: truncate-attr-chars: 20 default-account-config: > diff --git a/src/main/resources/c3p0.properties b/src/main/resources/c3p0.properties deleted file mode 100644 index 5a823a5deab..00000000000 --- a/src/main/resources/c3p0.properties +++ /dev/null @@ -1,8 +0,0 @@ -# can't turn off retries at all, that's why minimum value is 1 -c3p0.acquireRetryAttempts=1 -# don't wait before retrying -c3p0.acquireRetryDelay=0 -# how long to wait until connection becomes available -c3p0.checkoutTimeout=15000 -# how frequently to test idle pooled connections to avoid seeing broken or stale connections -c3p0.idleConnectionTestPeriod=300 diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index 65a9d8da533..f5d934d245f 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -96,7 +96,7 @@ LIMIT 1 "settings.database.user" : mysql.username, "settings.database.password" : mysql.password, "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS - "settings.database.provider-class": "hikari" + "settings.database.idle-connection-timeout": "300" ].asImmutable() } @@ -108,7 +108,7 @@ LIMIT 1 "settings.database.user" : postgres.username, "settings.database.password" : postgres.password, "settings.database.pool-size" : "2", // setting 2 here to leave some slack for the PBS - "settings.database.provider-class": "hikari" + "settings.database.idle-connection-timeout": "300" ].asImmutable() } diff --git a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java similarity index 90% rename from src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java rename to src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java index 1871046b5d6..15ef34417a6 100644 --- a/src/test/java/org/prebid/server/settings/JdbcApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/DatabaseApplicationSettingsTest.java @@ -17,7 +17,7 @@ import org.prebid.server.settings.model.Account; import org.prebid.server.settings.model.StoredDataResult; import org.prebid.server.settings.model.StoredResponseDataResult; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given; @RunWith(VertxUnitRunner.class) -public class JdbcApplicationSettingsTest extends VertxTest { +public class DatabaseApplicationSettingsTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -57,9 +57,9 @@ public class JdbcApplicationSettingsTest extends VertxTest { private ParametrizedQueryHelper parametrizedQueryHelper; @Mock - private JdbcClient jdbcClient; + private DatabaseClient databaseClient; - private JdbcApplicationSettings target; + private DatabaseApplicationSettings target; private Timeout timeout; @@ -67,8 +67,8 @@ public class JdbcApplicationSettingsTest extends VertxTest { public void setUp() { timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(5000L); given(parametrizedQueryHelper.replaceAccountIdPlaceholder(SELECT_ACCOUNT_QUERY)).willReturn("query"); - target = new JdbcApplicationSettings( - jdbcClient, + target = new DatabaseApplicationSettings( + databaseClient, jacksonMapper, parametrizedQueryHelper, SELECT_ACCOUNT_QUERY, @@ -81,7 +81,7 @@ public void setUp() { public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { // given final Account givenAccount = Account.builder().build(); - given(jdbcClient.executeQuery( + given(databaseClient.executeQuery( eq("query"), eq(List.of("1001")), any(), @@ -99,7 +99,7 @@ public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated() { @Test public void getAccountByIdShouldFailIfAccountNotFound() { // given - given(jdbcClient.executeQuery( + given(databaseClient.executeQuery( eq("query"), eq(List.of("non-existing")), any(), @@ -124,7 +124,7 @@ public void getStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of("4", "value4", "5", "value5"), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -146,7 +146,7 @@ public void getAmpStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of(), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -168,7 +168,7 @@ public void getVideoStoredDataShouldReturnExpectedResult() { Map.of("1", "value1", "2", "value2"), Map.of("4", "value4", "5", "value5"), emptyList()); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2", "4", "5")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -190,7 +190,7 @@ public void getStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -212,7 +212,7 @@ public void getAmpStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -234,7 +234,7 @@ public void getVideoStoredDataShouldReturnResultWithError() { Map.of("1", "value1"), Map.of(), List.of("No stored request found for id: 3")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "3")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredDataResult)); // when @@ -255,7 +255,7 @@ public void getStoredResponseShouldReturnExpectedResult() { final StoredResponseDataResult givenStoredResponseResult = StoredResponseDataResult.of( Map.of("1", "response1"), List.of("No stored response found for id: 2")); - given(jdbcClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) + given(databaseClient.executeQuery(eq("query"), eq(List.of("1", "2")), any(), eq(timeout))) .willReturn(Future.succeededFuture(givenStoredResponseResult)); // when diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java similarity index 89% rename from src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java rename to src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java index 305335705d3..88dab8b8267 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredDataResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredDataResultMapperTest.java @@ -24,7 +24,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -public class JdbcStoredDataResultMapperTest { +public class DatabaseStoredDataResultMapperTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -38,7 +38,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet, null, emptySet(), emptySet()); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -53,7 +53,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasEmptyResult givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, null, singleton("reqId"), @@ -72,7 +72,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasLessColumns givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("reqId"), @@ -91,7 +91,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorWhenResultSetHasUnexpectedC givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("reqId"), @@ -112,7 +112,7 @@ public void mapShouldSkipStoredResultWithInvalidType() { givenRow("accountId", "id1", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -131,7 +131,7 @@ public void mapShouldReturnStoredResultWithErrorForMissingId() { givenRowSet(givenRow("accountId", "id1", "data1", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -153,7 +153,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorsForMissingIdsIfAccountDiff givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "otherAccountId", singleton("id1"), @@ -176,7 +176,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB givenRow("accountId2", "id1", "data2", "request")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, null, singleton("id1"), @@ -199,7 +199,7 @@ public void mapShouldReturnEmptyStoredResultWithErrorIfMultipleStoredItemsFoundB givenRow("accountId2", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "otherAccountId", singleton("id1"), @@ -224,7 +224,7 @@ public void mapShouldReturnExpectedStoredResultForGivenAccount() { givenRow("otherAccountId", "id2", "data-otherAccountId", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map( + final StoredDataResult result = DatabaseStoredDataResultMapper.map( rowSet, "accountId", singleton("id1"), @@ -244,7 +244,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH givenRowSet(); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -261,7 +261,7 @@ public void mapWithoutParamsShouldSkipStoredResultWithInvalidType() { givenRow("accountId", "id2", "data2", "invalid")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -276,7 +276,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWithErrorWhenResultSetH givenRowSet(givenRow("accountId", "id1", "data")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -291,7 +291,7 @@ public void mapWithoutParamsShouldReturnEmptyStoredResultWhenResultSetHasInvalid givenRowSet(givenRow("accountId", "id1", "data", 123)); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).isEmpty(); @@ -307,7 +307,7 @@ public void mapWithoutParamsShouldReturnExpectedStoredResult() { givenRow("accountId", "id2", "data2", "imp")); // when - final StoredDataResult result = JdbcStoredDataResultMapper.map(rowSet); + final StoredDataResult result = DatabaseStoredDataResultMapper.map(rowSet); // then assertThat(result.getStoredIdToRequest()).hasSize(1) @@ -323,7 +323,6 @@ private void givenRowSet(Row... rows) { private Row givenRow(Object... values) { final Row row = mock(Row.class); - given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); final JsonObject json = new JsonObject(); IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); diff --git a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java similarity index 83% rename from src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java rename to src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java index 3f6ee8ecd8e..693462b8c50 100644 --- a/src/test/java/org/prebid/server/settings/helper/JdbcStoredResponseResultMapperTest.java +++ b/src/test/java/org/prebid/server/settings/helper/DatabaseStoredResponseResultMapperTest.java @@ -25,7 +25,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -public class JdbcStoredResponseResultMapperTest { +public class DatabaseStoredResponseResultMapperTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -39,7 +39,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetIsEmpty() givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -53,7 +53,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasLessCo givenRowSet(givenRow("id1")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, emptySet()); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, emptySet()); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -67,7 +67,7 @@ public void mapShouldReturnStoredResponseResultWithErrorForMissingID() { givenRowSet(givenRow("id1", "data")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(1) @@ -82,7 +82,7 @@ public void mapShouldReturnEmptyStoredResponseResultWithErrorWhenRowSetHasEmptyR givenRowSet(); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, singleton("id")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, singleton("id")); // then assertThat(result.getIdToStoredResponses()).isEmpty(); @@ -96,7 +96,7 @@ public void mapShouldReturnFilledStoredResponseResultWithoutErrors() { givenRowSet(givenRow("id1", "data1"), givenRow("id2", "data2")); // when - final StoredResponseDataResult result = JdbcStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); + final StoredResponseDataResult result = DatabaseStoredResponseResultMapper.map(rowSet, Set.of("id1", "id2")); // then assertThat(result.getIdToStoredResponses()).hasSize(2) @@ -110,7 +110,7 @@ private void givenRowSet(Row... rows) { private Row givenRow(Object... values) { final Row row = mock(Row.class); - given(row.getString(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); + given(row.getValue(anyInt())).willAnswer(invocation -> values[(Integer) invocation.getArgument(0)]); final JsonObject json = new JsonObject(); IntStream.range(0, values.length).forEach(i -> json.put(String.valueOf(i), values[i])); given(row.toJson()).willReturn(json); diff --git a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java b/src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java similarity index 85% rename from src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java rename to src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java index 9857d048ad9..2913f1e807b 100644 --- a/src/test/java/org/prebid/server/settings/service/JdbcPeriodicRefreshServiceTest.java +++ b/src/test/java/org/prebid/server/settings/service/DatabasePeriodicRefreshServiceTest.java @@ -16,7 +16,7 @@ import org.prebid.server.metric.Metrics; import org.prebid.server.settings.CacheNotificationListener; import org.prebid.server.settings.model.StoredDataResult; -import org.prebid.server.vertx.jdbc.JdbcClient; +import org.prebid.server.vertx.database.DatabaseClient; import java.time.Clock; import java.time.Instant; @@ -37,7 +37,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -public class JdbcPeriodicRefreshServiceTest { +public class DatabasePeriodicRefreshServiceTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -47,7 +47,7 @@ public class JdbcPeriodicRefreshServiceTest { @Mock private Vertx vertx; @Mock - private JdbcClient jdbcClient; + private DatabaseClient databaseClient; private final Clock clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); private final TimeoutFactory timeoutFactory = new TimeoutFactory(clock); @Mock @@ -63,9 +63,9 @@ public void setUp() { final StoredDataResult updateResult = StoredDataResult.of(singletonMap("id1", "null"), singletonMap("id2", "changed_value"), emptyList()); - given(jdbcClient.executeQuery(eq("init_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("init_query"), anyList(), any(), any())) .willReturn(Future.succeededFuture(initialResult)); - given(jdbcClient.executeQuery(eq("update_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("update_query"), anyList(), any(), any())) .willReturn(Future.succeededFuture(updateResult)); } @@ -103,8 +103,8 @@ public void initializeShouldMakeOneInitialRequestAndTwoScheduledRequestsWithPara createAndInitService(1000); // then - verify(jdbcClient).executeQuery(eq("init_query"), eq(emptyList()), any(), any()); - verify(jdbcClient, times(2)).executeQuery(eq("update_query"), anyList(), any(), any()); + verify(databaseClient).executeQuery(eq("init_query"), eq(emptyList()), any(), any()); + verify(databaseClient, times(2)).executeQuery(eq("update_query"), anyList(), any(), any()); } @Test @@ -114,7 +114,7 @@ public void initializeShouldMakeOnlyOneInitialRequestIfRefreshPeriodIsNegative() // then verify(vertx, never()).setPeriodic(anyLong(), any()); - verify(jdbcClient).executeQuery(anyString(), anyList(), any(), any()); + verify(databaseClient).executeQuery(anyString(), anyList(), any(), any()); } @Test @@ -130,7 +130,7 @@ public void shouldUpdateTimerMetric() { @Test public void shouldUpdateTimerAndErrorMetric() { // given - given(jdbcClient.executeQuery(eq("init_query"), anyList(), any(), any())) + given(databaseClient.executeQuery(eq("init_query"), anyList(), any(), any())) .willReturn(Future.failedFuture("Query error")); // when @@ -145,7 +145,7 @@ public void shouldUpdateTimerAndErrorMetric() { private void createAndInitService(long refresh) { - final JdbcPeriodicRefreshService jdbcPeriodicRefreshService = new JdbcPeriodicRefreshService( + final DatabasePeriodicRefreshService databasePeriodicRefreshService = new DatabasePeriodicRefreshService( "init_query", "update_query", refresh, @@ -153,12 +153,12 @@ private void createAndInitService(long refresh) { MetricName.stored_request, cacheNotificationListener, vertx, - jdbcClient, + databaseClient, timeoutFactory, metrics, clock); - jdbcPeriodicRefreshService.initialize(Promise.promise()); + databasePeriodicRefreshService.initialize(Promise.promise()); } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java similarity index 96% rename from src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java rename to src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java index 79514bf1fec..941ac685520 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/BasicJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/database/BasicDatabaseClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.sqlclient.Pool; @@ -39,7 +39,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -public class BasicJdbcClientTest { +public class BasicDatabaseClientTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -50,7 +50,7 @@ public class BasicJdbcClientTest { private Metrics metrics; private Clock clock; - private BasicJdbcClient target; + private BasicDatabaseClient target; private Timeout timeout; @@ -59,14 +59,14 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - target = new BasicJdbcClient(pool, metrics, clock); + target = new BasicDatabaseClient(pool, metrics, clock); } @Test public void creationShouldFailOnNullArguments() { - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(null, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, null, null)); - assertThatNullPointerException().isThrownBy(() -> new BasicJdbcClient(pool, metrics, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(null, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(pool, null, null)); + assertThatNullPointerException().isThrownBy(() -> new BasicDatabaseClient(pool, metrics, null)); } @Test diff --git a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java b/src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java similarity index 92% rename from src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java rename to src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java index a1e86429401..ed415108260 100644 --- a/src/test/java/org/prebid/server/vertx/jdbc/CircuitBreakerSecuredJdbcClientTest.java +++ b/src/test/java/org/prebid/server/vertx/database/CircuitBreakerSecuredDatabaseClientTest.java @@ -1,4 +1,4 @@ -package org.prebid.server.vertx.jdbc; +package org.prebid.server.vertx.database; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify; @RunWith(VertxUnitRunner.class) -public class CircuitBreakerSecuredJdbcClientTest { +public class CircuitBreakerSecuredDatabaseClientTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -45,11 +45,11 @@ public class CircuitBreakerSecuredJdbcClientTest { private Clock clock; @Mock - private JdbcClient wrappedJdbcClient; + private DatabaseClient wrappedDatabaseClient; @Mock private Metrics metrics; - private CircuitBreakerSecuredJdbcClient target; + private CircuitBreakerSecuredDatabaseClient target; private Timeout timeout; @@ -59,7 +59,7 @@ public void setUp() { clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()); timeout = new TimeoutFactory(clock).create(500L); - target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 1, 100L, 200L, clock); + target = new CircuitBreakerSecuredDatabaseClient(vertx, wrappedDatabaseClient, metrics, 1, 100L, 200L, clock); } @After @@ -112,7 +112,7 @@ public void executeQueryShouldNotExecuteQueryIfCircuitIsOpened(TestContext conte future.onComplete(context.asyncAssertFailure(throwable -> { assertThat(throwable).isInstanceOf(RuntimeException.class).hasMessage("open circuit"); - verify(wrappedJdbcClient) + verify(wrappedDatabaseClient) .executeQuery(any(), any(), any(), any()); // invoked only on 1 call })); } @@ -136,7 +136,7 @@ public void executeQueryShouldReturnExceptionIfCircuitIsHalfOpenedAndQueryFails( future.onComplete(context.asyncAssertFailure(exception -> { assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception1"); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); // invoked only on 1 & 3 calls })); } @@ -165,7 +165,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded future.onComplete(context.asyncAssertSuccess(result -> { assertThat(result).isEqualTo("value"); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); // invoked only on 1 & 3 calls })); } @@ -173,7 +173,7 @@ public void executeQueryShouldReturnResultIfCircuitIsHalfOpenedAndQuerySucceeded @Test public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds(TestContext context) { // given - target = new CircuitBreakerSecuredJdbcClient(vertx, wrappedJdbcClient, metrics, 2, 100L, 200L, clock); + target = new CircuitBreakerSecuredDatabaseClient(vertx, wrappedDatabaseClient, metrics, 2, 100L, 200L, clock); givenExecuteQueryReturning(asList( Future.failedFuture(new RuntimeException("exception1")), @@ -194,7 +194,7 @@ public void executeQueryShouldFailsWithOriginalExceptionIfOpeningIntervalExceeds future2.onComplete(context.asyncAssertFailure(exception -> assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("exception2"))); - verify(wrappedJdbcClient, times(2)) + verify(wrappedDatabaseClient, times(2)) .executeQuery(any(), any(), any(), any()); } @@ -248,7 +248,7 @@ public void circuitBreakerGaugeShouldReportClosedWhenCircuitClosed(TestContext c @SuppressWarnings("unchecked") private void givenExecuteQueryReturning(List> results) { BDDMockito.BDDMyOngoingStubbing> given = - given(wrappedJdbcClient.executeQuery(any(), any(), any(), any())); + given(wrappedDatabaseClient.executeQuery(any(), any(), any(), any())); for (Future result : results) { given = given.willReturn((Future) result); } From 42c5b41d5d9d075ecb793936680b2c4f4be305f5 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:58:31 -0400 Subject: [PATCH 14/58] Consolidate Java version properties across all pom.xml files (#3147) --- extra/bundle/pom.xml | 1 - extra/modules/pom.xml | 1 - extra/pom.xml | 5 +++-- pom.xml | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 2c66f1b22f2..7f1adad0d6c 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -17,7 +17,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} 2.5.6 diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 0d442c3d4ef..5091a3e3a65 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -25,7 +25,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} diff --git a/extra/pom.xml b/extra/pom.xml index 7b8a60f2108..90192cc0325 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -15,10 +15,11 @@ + 21 UTF-8 UTF-8 - 21 - 21 + ${java.version} + ${java.version} 4.5.5 1.18.30 3.0.0-M6 diff --git a/pom.xml b/pom.xml index 0545e9ad7d9..17736c0daa2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,6 @@ UTF-8 UTF-8 - 21 ${java.version} ${java.version} Dockerfile From 9cce446827820bf737d16c38736dda927a2dc56f Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Wed, 1 May 2024 07:52:56 -0400 Subject: [PATCH 15/58] Core: Async db client configuration (#3162) * Make prepared statement caching configurable * Bump the default stored request timeout from 50 to 100 ms to account for prepared statement usage --- docs/config-app.md | 2 ++ .../spring/config/database/DatabaseConfiguration.java | 8 ++++++-- .../config/database/model/ConnectionPoolSettings.java | 4 ++++ .../properties/DatabaseConfigurationProperties.java | 6 +++++- src/main/resources/application.yaml | 4 +++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index ee6bf32dbe3..9e9eed3ed2a 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -295,6 +295,8 @@ For database data source available next options: - `settings.database.password` - database password. - `settings.database.pool-size` - set the initial/min/max pool size of database connections. - `settings.database.idle-connection-timeout` - Set the idle timeout, time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed and get back to the pool if no data is received nor sent within the timeout. +- `settings.database.enable-prepared-statement-caching` - Enable caching of the prepared statements so that they can be reused. Defaults to `false`. Please be vary of the DB server limitations as cache instances is per-database-connection. +- `settings.database.max-prepared-statement-cache-size` - Set the maximum size of the prepared statement cache. Defaults to `256`. Has any effect only when `settings.database.enable-prepared-statement-caching` is set to `true`. Please note that the cache size is multiplied by `settings.database.pool-size`. - `settings.database.account-query` - the SQL query to fetch account. - `settings.database.stored-requests-query` - the SQL query to fetch stored requests. - `settings.database.amp-stored-requests-query` - the SQL query to fetch AMP stored requests. diff --git a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java index ba322b34707..6a1a1531f1c 100644 --- a/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/database/DatabaseConfiguration.java @@ -46,6 +46,8 @@ ConnectionPoolSettings connectionPoolSettings(DatabaseConfigurationProperties da return ConnectionPoolSettings.of( databaseConfigurationProperties.getPoolSize(), databaseConfigurationProperties.getIdleConnectionTimeout(), + databaseConfigurationProperties.getEnablePreparedStatementCaching(), + databaseConfigurationProperties.getMaxPreparedStatementCacheSize(), databaseConfigurationProperties.getUser(), databaseConfigurationProperties.getPassword(), databaseConfigurationProperties.getType()); @@ -84,7 +86,8 @@ Pool mysqlConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setCachePreparedStatements(true) + .setCachePreparedStatements(connectionPoolSettings.getEnablePreparedStatementCaching()) + .setPreparedStatementCacheMaxSize(connectionPoolSettings.getMaxPreparedStatementCacheSize()) .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); @@ -113,7 +116,8 @@ Pool postgresConnectionPool(Vertx vertx, .setPassword(connectionPoolSettings.getPassword()) .setSsl(false) .setTcpKeepAlive(true) - .setCachePreparedStatements(true) + .setCachePreparedStatements(connectionPoolSettings.getEnablePreparedStatementCaching()) + .setPreparedStatementCacheMaxSize(connectionPoolSettings.getMaxPreparedStatementCacheSize()) .setIdleTimeout(connectionPoolSettings.getIdleTimeout()) .setIdleTimeoutUnit(TimeUnit.SECONDS); diff --git a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java index 10ca0eacf89..92f929564d6 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/ConnectionPoolSettings.java @@ -9,6 +9,10 @@ public class ConnectionPoolSettings { Integer idleTimeout; + Boolean enablePreparedStatementCaching; + + Integer maxPreparedStatementCacheSize; + String user; String password; diff --git a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java index 0f3e6ac8c79..cd570100df3 100644 --- a/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java +++ b/src/main/java/org/prebid/server/spring/config/database/properties/DatabaseConfigurationProperties.java @@ -21,6 +21,11 @@ public class DatabaseConfigurationProperties { @NotNull @PositiveOrZero private Integer idleConnectionTimeout; + @NotNull + private Boolean enablePreparedStatementCaching; + @NotNull + @Min(1) + private Integer maxPreparedStatementCacheSize; @NotBlank private String host; @NotNull @@ -32,4 +37,3 @@ public class DatabaseConfigurationProperties { @NotBlank private String password; } - diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ce193e5cbc4..94a483a7797 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -114,7 +114,7 @@ auction: max: 5000 percent: 100 tmax-upstream-response-time: 30 - stored-requests-timeout-ms: 50 + stored-requests-timeout-ms: 100 timeout-notification: timeout-ms: 200 log-result: false @@ -166,6 +166,8 @@ settings: database: pool-size: 20 idle-connection-timeout: 300 + enable-prepared-statement-caching: false + max-prepared-statement-cache-size: 256 targeting: truncate-attr-chars: 20 default-account-config: > From c3f6d6dd8ba5e81c74db2f02c67065a1083812f7 Mon Sep 17 00:00:00 2001 From: bretg Date: Thu, 2 May 2024 05:44:08 -0400 Subject: [PATCH 16/58] Mobfoxpb: Update contact email (#3125) --- src/main/resources/bidder-config/mobfoxpb.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/mobfoxpb.yaml b/src/main/resources/bidder-config/mobfoxpb.yaml index f9d05c7e2c3..bed22ef4094 100644 --- a/src/main/resources/bidder-config/mobfoxpb.yaml +++ b/src/main/resources/bidder-config/mobfoxpb.yaml @@ -2,7 +2,7 @@ adapters: mobfoxpb: endpoint: http://bes.mobfox.com/?c=__route__&m=__method__&key=__key__ meta-info: - maintainer-email: platform@mobfox.com + maintainer-email: support@mobfox.com app-media-types: - banner - video From c4f9d6d7f1089aadb71ef9c22dd4965248bd4321 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Thu, 2 May 2024 05:45:19 -0400 Subject: [PATCH 17/58] Sharethrough: Add GDPR and GPP info to usersync url (#3115) --- src/main/resources/bidder-config/sharethrough.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/sharethrough.yaml b/src/main/resources/bidder-config/sharethrough.yaml index d108840dd26..36cc0f0127f 100644 --- a/src/main/resources/bidder-config/sharethrough.yaml +++ b/src/main/resources/bidder-config/sharethrough.yaml @@ -16,6 +16,6 @@ adapters: usersync: cookie-family-name: sharethrough redirect: - url: https://match.sharethrough.com/FGMrCMMc/v1?redirectUri={{redirect_url}} + url: https://match.sharethrough.com/FGMrCMMc/v1?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirectUri={{redirect_url}} support-cors: false uid-macro: '$UID' From 1fee46acea96b5826654cd34058bb5cc9931d4fb Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Thu, 2 May 2024 13:55:08 +0300 Subject: [PATCH 18/58] Core: Add PostgreSQL SASL SCRAM-SHA-256 authentication support (#3141) --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 17736c0daa2..5edefec9fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ 3.21.7 3.17.3 1.0.7 + 2.1 4.13.2 @@ -183,6 +184,11 @@ vertx-auth-common ${vertx.version} + + com.ongres.scram + client + ${scram.version} + io.netty netty-transport-native-epoll From be2b0d6c2b6f915970ff658c3d0695a3e802257a Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 2 May 2024 14:00:16 +0300 Subject: [PATCH 19/58] CleanUp: Remove completed `TODO`s. (#3154) --- .../org/prebid/server/auction/GeoLocationServiceWrapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java index ce1c33a1304..4c1a3b0b8cf 100644 --- a/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java +++ b/src/main/java/org/prebid/server/auction/GeoLocationServiceWrapper.java @@ -38,7 +38,6 @@ public GeoLocationServiceWrapper(GeoLocationService geoLocationService, this.metrics = Objects.requireNonNull(metrics); } - //todo: account settings will work as expected if the default account resolving refactoring is done public Future lookup(AuctionContext auctionContext) { final Account account = auctionContext.getAccount(); final Device device = auctionContext.getBidRequest().getDevice(); From dba8f6dbda91d02e980804898c21f628b9f971b4 Mon Sep 17 00:00:00 2001 From: bretg Date: Thu, 2 May 2024 08:03:27 -0400 Subject: [PATCH 20/58] Emxdigital: add geoscope to YAML (#3132) --- src/main/resources/bidder-config/emxdigital.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/emxdigital.yaml b/src/main/resources/bidder-config/emxdigital.yaml index 5862a06f4ba..34080708c3e 100644 --- a/src/main/resources/bidder-config/emxdigital.yaml +++ b/src/main/resources/bidder-config/emxdigital.yaml @@ -4,6 +4,10 @@ adapters: aliases: cadent_aperture_mx: enabled: false + # CadentAperture only operates in North America + geoscope: + - USA + - CAN meta-info: maintainer-email: contactaperturemx@cadent.tv app-media-types: From 7b5497447c4780da4df491ea778119b18f9b95ef Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:24:49 +0200 Subject: [PATCH 21/58] Kargo: Adding GPP macros to bidder-info (#3108) --- src/main/resources/bidder-config/kargo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/kargo.yaml b/src/main/resources/bidder-config/kargo.yaml index 79532582447..164eb0a7916 100644 --- a/src/main/resources/bidder-config/kargo.yaml +++ b/src/main/resources/bidder-config/kargo.yaml @@ -15,6 +15,6 @@ adapters: usersync: cookie-family-name: kargo redirect: - url: https://crb.kargo.com/api/v1/dsync/PrebidServer?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} + url: https://crb.kargo.com/api/v1/dsync/PrebidServer?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&r={{redirect_url}} support-cors: false uid-macro: '$UID' From 7efacca2b0dc9e156fcc1008ad5af008a859f7ee Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:26:16 +0200 Subject: [PATCH 22/58] Taboola: Fix gpp query param (#3107) --- src/main/resources/bidder-config/taboola.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/bidder-config/taboola.yaml b/src/main/resources/bidder-config/taboola.yaml index f7401931c3b..f5cc2bfeb62 100644 --- a/src/main/resources/bidder-config/taboola.yaml +++ b/src/main/resources/bidder-config/taboola.yaml @@ -15,11 +15,11 @@ adapters: userSync: cookie-family-name: taboola redirect: - url: https://trc.taboola.com/sg/ps/1/cm?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://trc.taboola.com/sg/ps/1/cm?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '' iframe: - url: https://cdn.taboola.com/scripts/ps-sync.html?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://cdn.taboola.com/scripts/ps-sync.html?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '' From 62a266ded277979cd07f0799588250d20c672cde Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:49:25 +0200 Subject: [PATCH 23/58] Criteo: Add GPP macros (#3105) --- src/main/resources/bidder-config/criteo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/bidder-config/criteo.yaml b/src/main/resources/bidder-config/criteo.yaml index cf10a5cf480..2fbbadbb116 100644 --- a/src/main/resources/bidder-config/criteo.yaml +++ b/src/main/resources/bidder-config/criteo.yaml @@ -14,10 +14,10 @@ adapters: usersync: cookie-family-name: criteo redirect: - url: https://ssp-sync.criteo.com/user-sync/redirect?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&redir={{redirect_url}}&profile=230 + url: https://ssp-sync.criteo.com/user-sync/redirect?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redir={{redirect_url}}&profile=230 support-cors: false uid-macro: '${CRITEO_USER_ID}' iframe: - url: https://ssp-sync.criteo.com/user-sync/iframe?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&redir={{redirect_url}}&profile=230 + url: https://ssp-sync.criteo.com/user-sync/iframe?gdprapplies={{gdpr}}&gdpr={{gdpr_consent}}&ccpa={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redir={{redirect_url}}&profile=230 support-cors: false uid-macro: '${CRITEO_USER_ID}' From ec2670f5b85cc28ec2d2cb2c8d115115eff4d1ee Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 2 May 2024 15:53:15 +0200 Subject: [PATCH 24/58] Rise: Add GPP macros (#3106) --- src/main/resources/bidder-config/rise.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/rise.yaml b/src/main/resources/bidder-config/rise.yaml index f85876dd998..12fc11eb92e 100644 --- a/src/main/resources/bidder-config/rise.yaml +++ b/src/main/resources/bidder-config/rise.yaml @@ -15,6 +15,6 @@ adapters: usersync: cookie-family-name: rise iframe: - url: https://pbs-cs.yellowblue.io/pbs-iframe?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + url: https://pbs-cs.yellowblue.io/pbs-iframe?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&redirect={{redirect_url}} support-cors: false uid-macro: '[PBS_UID]' From 630067d71984b14dcf6cc8b2dba666984ebf3a05 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 2 May 2024 16:58:06 +0300 Subject: [PATCH 25/58] Core: Add jitter for cache (#3135) --- docs/config-app.md | 1 + .../USCustomLogicModuleCreator.java | 2 +- .../settings/CachingApplicationSettings.java | 15 ++-- .../prebid/server/settings/SettingsCache.java | 82 +++++++++++++++++-- .../spring/config/SettingsConfiguration.java | 20 ++++- .../CachingApplicationSettingsTest.java | 9 +- .../server/settings/SettingsCacheTest.java | 2 +- 7 files changed, 109 insertions(+), 22 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index 9e9eed3ed2a..a2f3b7a891b 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -340,6 +340,7 @@ See [application settings](application-settings.md) for full reference of availa For caching available next options: - `settings.in-memory-cache.ttl-seconds` - how long (in seconds) data will be available in LRU cache. - `settings.in-memory-cache.cache-size` - the size of LRU cache. +- `settings.in-memory-cache.jitter-seconds` - jitter (in seconds) for `settings.in-memory-cache.ttl-seconds` parameter. - `settings.in-memory-cache.notification-endpoints-enabled` - if equals to `true` two additional endpoints will be available: [/storedrequests/openrtb2](endpoints/storedrequests/openrtb2.md) and [/storedrequests/amp](endpoints/storedrequests/amp.md). - `settings.in-memory-cache.account-invalidation-enabled` - if equals to `true` additional admin protected endpoints will be diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java index 6d8a308fc1a..026e856a585 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/uscustomlogic/USCustomLogicModuleCreator.java @@ -55,7 +55,7 @@ public USCustomLogicModuleCreator(USCustomLogicGppReaderFactory gppReaderFactory this.metrics = Objects.requireNonNull(metrics); jsonLogicNodesCache = cacheTtl != null && cacheSize != null - ? SettingsCache.createCache(cacheTtl, cacheSize) + ? SettingsCache.createCache(cacheTtl, cacheSize, 0) : null; } diff --git a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java index 7fb363a0ff0..f6e8d1f4868 100644 --- a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java @@ -48,16 +48,21 @@ public CachingApplicationSettings(ApplicationSettings delegate, SettingsCache videoCache, Metrics metrics, int ttl, - int size) { + int size, + int jitter) { if (ttl <= 0 || size <= 0) { throw new IllegalArgumentException("ttl and size must be positive"); } + if (jitter < 0 || jitter >= ttl) { + throw new IllegalArgumentException("jitter must match the inequality: 0 <= jitter < ttl"); + } + this.delegate = Objects.requireNonNull(delegate); - this.accountCache = SettingsCache.createCache(ttl, size); - this.accountToErrorCache = SettingsCache.createCache(ttl, size); - this.adServerPublisherToErrorCache = SettingsCache.createCache(ttl, size); - this.categoryConfigCache = SettingsCache.createCache(ttl, size); + this.accountCache = SettingsCache.createCache(ttl, size, jitter); + this.accountToErrorCache = SettingsCache.createCache(ttl, size, jitter); + this.adServerPublisherToErrorCache = SettingsCache.createCache(ttl, size, jitter); + this.categoryConfigCache = SettingsCache.createCache(ttl, size, jitter); this.cache = Objects.requireNonNull(cache); this.ampCache = Objects.requireNonNull(ampCache); this.videoCache = Objects.requireNonNull(videoCache); diff --git a/src/main/java/org/prebid/server/settings/SettingsCache.java b/src/main/java/org/prebid/server/settings/SettingsCache.java index 1bba204db36..3e2446742b1 100644 --- a/src/main/java/org/prebid/server/settings/SettingsCache.java +++ b/src/main/java/org/prebid/server/settings/SettingsCache.java @@ -1,8 +1,10 @@ package org.prebid.server.settings; import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.Expiry; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; +import org.checkerframework.checker.index.qual.NonNegative; import org.prebid.server.settings.model.StoredItem; import java.util.Collections; @@ -10,7 +12,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.ThreadLocalRandom; /** * Just a simple wrapper over in-memory caches for requests and imps. @@ -20,17 +22,26 @@ public class SettingsCache implements CacheNotificationListener { private final Map> requestCache; private final Map> impCache; - public SettingsCache(int ttl, int size) { + public SettingsCache(int ttl, int size, int jitter) { if (ttl <= 0 || size <= 0) { throw new IllegalArgumentException("ttl and size must be positive"); } - requestCache = createCache(ttl, size); - impCache = createCache(ttl, size); + if (jitter < 0 || jitter >= ttl) { + throw new IllegalArgumentException("jitter must match the inequality: 0 <= jitter < ttl"); + } + + requestCache = createCache(ttl, size, jitter); + impCache = createCache(ttl, size, jitter); } - public static Map createCache(int ttl, int size) { + public static Map createCache(int ttlSeconds, int size, int jitterSeconds) { + final long expireAfterNanos = (long) (ttlSeconds * 1e9); + final long jitterNanos = jitterSeconds == 0 ? 0L : (long) (jitterSeconds * 1e9); + return Caffeine.newBuilder() - .expireAfterWrite(ttl, TimeUnit.SECONDS) + .expireAfter(jitterNanos == 0L + ? new StaticExpiry<>(expireAfterNanos) + : new ExpiryWithJitter<>(expireAfterNanos, jitterNanos)) .maximumSize(size) .build() .asMap(); @@ -53,7 +64,10 @@ void saveImpCache(String accountId, String impId, String impValue) { } private static void saveCachedValue(Map> cache, - String accountId, String id, String value) { + String accountId, + String id, + String value) { + final Set values = ObjectUtils.defaultIfNull(cache.get(id), new HashSet<>()); values.add(StoredItem.of(accountId, value)); cache.put(id, values); @@ -79,4 +93,58 @@ public void invalidate(List requests, List imps) { requests.forEach(requestCache.keySet()::remove); imps.forEach(impCache.keySet()::remove); } + + private static class StaticExpiry implements Expiry { + + private final long expireAfterNanos; + + private StaticExpiry(long expireAfterNanos) { + this.expireAfterNanos = expireAfterNanos; + } + + @Override + public long expireAfterCreate(K key, V value, long currentTime) { + return expireAfterNanos; + } + + @Override + public long expireAfterUpdate(K key, V value, long currentTime, @NonNegative long currentDuration) { + return expireAfterNanos; + } + + @Override + public long expireAfterRead(K key, V value, long currentTime, @NonNegative long currentDuration) { + return currentDuration; + } + } + + private static class ExpiryWithJitter implements Expiry { + + private final Expiry baseExpiry; + private final long jitterNanos; + + private ExpiryWithJitter(long baseExpireAfterNanos, long jitterNanos) { + this.baseExpiry = new StaticExpiry<>(baseExpireAfterNanos); + this.jitterNanos = jitterNanos; + } + + @Override + public long expireAfterCreate(K key, V value, long currentTime) { + return baseExpiry.expireAfterCreate(key, value, currentTime) + jitter(); + } + + @Override + public long expireAfterUpdate(K key, V value, long currentTime, @NonNegative long currentDuration) { + return baseExpiry.expireAfterUpdate(key, value, currentTime, currentDuration) + jitter(); + } + + @Override + public long expireAfterRead(K key, V value, long currentTime, @NonNegative long currentDuration) { + return baseExpiry.expireAfterRead(key, value, currentTime, currentDuration); + } + + private long jitter() { + return ThreadLocalRandom.current().nextLong(-jitterNanos, jitterNanos); + } + } } diff --git a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java index 538eaeb3159..1006403c9c4 100644 --- a/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/SettingsConfiguration.java @@ -284,7 +284,8 @@ CachingApplicationSettings cachingApplicationSettings( videoCache, metrics, cacheProperties.getTtlSeconds(), - cacheProperties.getCacheSize()); + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } } @@ -306,19 +307,28 @@ static class CacheConfiguration { @Bean @Qualifier("settingsCache") SettingsCache settingsCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } @Bean @Qualifier("ampSettingsCache") SettingsCache ampSettingsCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } @Bean @Qualifier("videoSettingCache") SettingsCache videoSettingCache(ApplicationSettingsCacheProperties cacheProperties) { - return new SettingsCache(cacheProperties.getTtlSeconds(), cacheProperties.getCacheSize()); + return new SettingsCache( + cacheProperties.getTtlSeconds(), + cacheProperties.getCacheSize(), + cacheProperties.getJitterSeconds()); } } @@ -336,5 +346,7 @@ private static class ApplicationSettingsCacheProperties { @NotNull @Min(1) private Integer cacheSize; + @Min(0) + private int jitterSeconds; } } diff --git a/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java index a51d3fbfef7..9bc9cb27157 100644 --- a/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/CachingApplicationSettingsTest.java @@ -61,12 +61,13 @@ public void setUp() { target = new CachingApplicationSettings( delegateSettings, - new SettingsCache(360, 100), - new SettingsCache(360, 100), - new SettingsCache(360, 100), + new SettingsCache(360, 100, 0), + new SettingsCache(360, 100, 0), + new SettingsCache(360, 100, 0), metrics, 360, - 100); + 100, + 0); } @Test diff --git a/src/test/java/org/prebid/server/settings/SettingsCacheTest.java b/src/test/java/org/prebid/server/settings/SettingsCacheTest.java index cdf602d21fe..f185d40edd7 100644 --- a/src/test/java/org/prebid/server/settings/SettingsCacheTest.java +++ b/src/test/java/org/prebid/server/settings/SettingsCacheTest.java @@ -15,7 +15,7 @@ public class SettingsCacheTest { @Before public void setUp() { - settingsCache = new SettingsCache(10, 10); + settingsCache = new SettingsCache(10, 10, 0); } @Test From dd7e58347bcc818a22c8c606597fefd1c980d0f4 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 2 May 2024 10:23:49 -0400 Subject: [PATCH 26/58] Housekeeping: Remove PG leftovers (#3112) --- docs/config-app.md | 5 -- pom.xml | 31 +++-------- .../prebid/server/health/HealthMonitor.java | 38 ------------- .../spring/config/AopConfiguration.java | 52 ------------------ src/main/resources/application.yaml | 5 -- .../server/health/HealthMonitorTest.java | 54 ------------------- .../org/prebid/server/it/IntegrationTest.java | 3 -- .../server/it/test-application.properties | 1 - 8 files changed, 7 insertions(+), 182 deletions(-) delete mode 100644 src/main/java/org/prebid/server/health/HealthMonitor.java delete mode 100644 src/main/java/org/prebid/server/spring/config/AopConfiguration.java delete mode 100644 src/test/java/org/prebid/server/health/HealthMonitorTest.java diff --git a/docs/config-app.md b/docs/config-app.md index a2f3b7a891b..c27b8980f3e 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -204,11 +204,6 @@ Also, each bidder could have its own bidder-specific options. - `admin-endpoints.tracelog.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. - `admin-endpoints.tracelog.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` -- `admin-endpoints.e2eadmin.enabled` - if equals to `true` the endpoint will be available. -- `admin-endpoints.e2eadmin.path` - the server context path where the endpoint will be accessible. -- `admin-endpoints.e2eadmin.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. -- `admin-endpoints.e2eadmin.protected` - when equals to `true` endpoint will be protected by basic authentication configured in `admin-endpoints.credentials` - - `admin-endpoints.collected-metrics.enabled` - if equals to `true` the endpoint will be available. - `admin-endpoints.collected-metrics.path` - the server context path where the endpoint will be accessible. - `admin-endpoints.collected-metrics.on-application-port` - when equals to `false` endpoint will be bound to `admin.port`. diff --git a/pom.xml b/pom.xml index 5edefec9fc8..2496ff6a6bc 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,6 @@ 4.11.0 3.24.2 2.35.1 - 4.2.0 9.4.53.v20231009 5.4.0 2.2.220 @@ -66,7 +65,6 @@ 4.0.15 1.17.4 5.14.0 - 1.9.9.1 1.12.14 @@ -127,10 +125,6 @@ org.springframework.boot spring-boot-starter - - org.springframework.boot - spring-boot-starter-aop - jakarta.annotation jakarta.annotation-api @@ -409,12 +403,6 @@ ${assertj.version} test - - org.awaitility - awaitility - ${awaitility.version} - test - org.springframework.boot spring-boot-starter-test @@ -619,6 +607,7 @@ false ${skipUnitTests} + ${surefire.jacoco.args} @@ -788,18 +777,22 @@ com/iab/openrtb/** **/proto/** **/model/** + **/functional/** org/prebid/server/spring/config/** - prepare-agent + before-unit-test-execution prepare-agent + + surefire.jacoco.args + - report + after-unit-test-execution report @@ -914,9 +907,6 @@ org.apache.maven.plugins maven-failsafe-plugin - - -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" - ${mockserver.version} ${project.version} @@ -953,13 +943,6 @@ - - - org.aspectj - aspectjweaver - ${aspectj.version} - - org.apache.maven.plugins diff --git a/src/main/java/org/prebid/server/health/HealthMonitor.java b/src/main/java/org/prebid/server/health/HealthMonitor.java deleted file mode 100644 index 3fc8a53ed2a..00000000000 --- a/src/main/java/org/prebid/server/health/HealthMonitor.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.prebid.server.health; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.concurrent.atomic.LongAdder; - -/** - * Used to gather statistics and calculate the health index indicator. - */ -public class HealthMonitor { - - private final LongAdder totalCounter = new LongAdder(); - - private final LongAdder successCounter = new LongAdder(); - - /** - * Increments total number of requests. - */ - public void incTotal() { - totalCounter.increment(); - } - - /** - * Increments succeeded number of requests. - */ - public void incSuccess() { - successCounter.increment(); - } - - /** - * Returns value between 0.0 ... 1.0 where 1.0 is indicated 100% healthy. - */ - public BigDecimal calculateHealthIndex() { - final BigDecimal success = BigDecimal.valueOf(successCounter.sumThenReset()); - final BigDecimal total = BigDecimal.valueOf(totalCounter.sumThenReset()); - return total.longValue() == 0 ? BigDecimal.ONE : success.divide(total, 2, RoundingMode.HALF_EVEN); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java b/src/main/java/org/prebid/server/spring/config/AopConfiguration.java deleted file mode 100644 index 736ca55a494..00000000000 --- a/src/main/java/org/prebid/server/spring/config/AopConfiguration.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.spring.config; - -import io.vertx.core.Future; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.prebid.server.health.HealthMonitor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -@Configuration -public class AopConfiguration { - - @Bean - HealthMonitor healthMonitor() { - return new HealthMonitor(); - } - - @Aspect - @Component - static class HealthMonitorAspect { - - @Autowired - HealthMonitor healthMonitor; - - @Around(value = "execution(* org.prebid.server.vertx.httpclient.HttpClient.*(..)) " - + "|| execution(* org.prebid.server.settings.ApplicationSettings.*(..)) " - + "|| execution(* org.prebid.server.geolocation.GeoLocationService.*(..))") - public Future around(ProceedingJoinPoint joinPoint) { - try { - return ((Future) joinPoint.proceed()) - .map(this::handleSucceedRequest) - .recover(this::handleFailRequest); - } catch (Throwable e) { - throw new IllegalStateException("Error while processing health monitoring", e); - } - } - - private Future handleFailRequest(Throwable throwable) { - healthMonitor.incTotal(); - return Future.failedFuture(throwable); - } - - private T handleSucceedRequest(T result) { - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - return result; - } - } -} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 94a483a7797..b899795f418 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -67,11 +67,6 @@ admin-endpoints: path: /pbs-admin/tracelog on-application-port: false protected: true - e2eadmin: - enabled: false - path: /pbs-admin/e2eAdmin/* - on-application-port: false - protected: true collected-metrics: enabled: false path: /collected-metrics diff --git a/src/test/java/org/prebid/server/health/HealthMonitorTest.java b/src/test/java/org/prebid/server/health/HealthMonitorTest.java deleted file mode 100644 index adf8f6fbe66..00000000000 --- a/src/test/java/org/prebid/server/health/HealthMonitorTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.prebid.server.health; - -import org.junit.Before; -import org.junit.Test; - -import java.math.BigDecimal; - -import static org.assertj.core.api.Assertions.assertThat; - -public class HealthMonitorTest { - - private HealthMonitor healthMonitor; - - @Before - public void setUp() { - healthMonitor = new HealthMonitor(); - } - - @Test - public void calculateHealthIndexShouldReturnFullHealthIfNoRequestsSubmitted() { - // when - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(BigDecimal.ONE); - } - - @Test - public void calculateHealthIndexShouldReturnExpectedResult() { - // when - healthMonitor.incTotal(); - healthMonitor.incTotal(); - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(new BigDecimal("0.33")); - } - - @Test - public void calculateHealthIndexShouldResetResult() { - // when - healthMonitor.incTotal(); - healthMonitor.incSuccess(); - healthMonitor.calculateHealthIndex(); - - final BigDecimal result = healthMonitor.calculateHealthIndex(); - - // then - assertThat(result).isEqualTo(BigDecimal.ONE); - } -} diff --git a/src/test/java/org/prebid/server/it/IntegrationTest.java b/src/test/java/org/prebid/server/it/IntegrationTest.java index 119537ba161..aa519ea5a30 100644 --- a/src/test/java/org/prebid/server/it/IntegrationTest.java +++ b/src/test/java/org/prebid/server/it/IntegrationTest.java @@ -73,8 +73,6 @@ public abstract class IntegrationTest extends VertxTest { private static final String HOST_AND_PORT = "localhost:" + WIREMOCK_PORT; private static final String CACHE_PATH = "/cache"; private static final String CACHE_ENDPOINT = "http://" + HOST_AND_PORT + CACHE_PATH; - private static final String USER_SERVICE_PATH = "/user-data-details"; - private static final String USER_SERVICE_ENDPOINT = "http://" + HOST_AND_PORT + USER_SERVICE_PATH; @BeforeClass public static void setUp() throws IOException { @@ -252,7 +250,6 @@ private static String replaceStaticInfo(String json) { .replaceAll("\\{\\{ cache.resource_url }}", CACHE_ENDPOINT + "?uuid=") .replaceAll("\\{\\{ cache.host }}", HOST_AND_PORT) .replaceAll("\\{\\{ cache.path }}", CACHE_PATH) - .replaceAll("\\{\\{ userservice_uri }}", USER_SERVICE_ENDPOINT) .replaceAll("\\{\\{ event.url }}", "http://localhost:8080/event?"); } diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 29114f9d3fb..28f6c7fc5b3 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -504,7 +504,6 @@ admin-endpoints.logging-changelevel.enabled=true admin-endpoints.logging-changelevel.protected=false admin-endpoints.tracelog.enabled=true admin-endpoints.tracelog.protected=false -admin-endpoints.e2eadmin.enabled=false status-response=ok analytics.log.enabled=true gdpr.host-vendor-id=1 From 7fab67c2a5573bdcc4fa8d5144c540dff8d8cda6 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Mon, 6 May 2024 14:50:59 +0200 Subject: [PATCH 27/58] Docs: Update properties description (#3151) --- docs/config-app.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index c27b8980f3e..ae8c5d937b5 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -346,10 +346,10 @@ available: `/cache/invalidate?account={accountId}` which remove account from the - `settings.in-memory-cache.http-update.timeout` - timeout for obtaining stored request updates. - `settings.in-memory-cache.database-update.init-query` - initial query for fetching all stored requests at the startup. - `settings.in-memory-cache.database-update.update-query` - a query for periodical update of stored requests, that should -contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. +contain 'WHERE last_updated > ?' for MySQL and 'WHERE last_updated > $1' for Postgresql to fetch only the records that were updated since previous check. - `settings.in-memory-cache.database-update.amp-init-query` - initial query for fetching all AMP stored requests at the startup. - `settings.in-memory-cache.database-update.amp-update-query` - a query for periodical update of AMP stored requests, that should -contain 'WHERE last_updated > ?' to fetch only the records that were updated since previous check. +contain 'WHERE last_updated > ?' for MySQL and 'WHERE last_updated > $1' for Postgresql to fetch only the records that were updated since previous check. - `settings.in-memory-cache.database-update.refresh-rate` - refresh period in ms for stored request updates. - `settings.in-memory-cache.database-update.timeout` - timeout for obtaining stored request updates. From 00940b08ba0e3f66fb882472c98b6baeba51ff7b Mon Sep 17 00:00:00 2001 From: Serhii Kolomiiets <46626223+VeryExtraordinaryUsername@users.noreply.github.com> Date: Mon, 6 May 2024 22:00:11 +0300 Subject: [PATCH 28/58] Core: Finished transition period for HTTP properties (#2728) --- docs/config-app.md | 8 ++++---- docs/metrics.md | 2 +- .../ApplicationServerConfiguration.java | 17 ++++++++--------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index ae8c5d937b5..c99bdd63a2f 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -22,10 +22,10 @@ This parameter exists to allow to change the location of the directory Vert.x wi - `server.jks-password` - password for the keystore (if ssl is enabled). ## HTTP Server -- `http.max-headers-size` - set the maximum length of all headers, deprecated(use server.max-headers-size instead). -- `http.ssl` - enable SSL/TLS support, deprecated(use server.ssl instead). -- `http.jks-path` - path to the java keystore (if ssl is enabled), deprecated(use server.jks-path instead). -- `http.jks-password` - password for the keystore (if ssl is enabled), deprecated(use server.jks-password instead). +- `server.max-headers-size` - set the maximum length of all headers, deprecated(use server.max-headers-size instead). +- `server.ssl` - enable SSL/TLS support, deprecated(use server.ssl instead). +- `server.jks-path` - path to the java keystore (if ssl is enabled), deprecated(use server.jks-path instead). +- `server.jks-password` - password for the keystore (if ssl is enabled), deprecated(use server.jks-password instead). - `server.http.server-instances` - how many http server instances should be created. This parameter affects how many CPU cores will be utilized by the application. Rough assumption - one http server instance will keep 1 CPU core busy. - `server.http.enabled` - if set to `true` enables http server diff --git a/docs/metrics.md b/docs/metrics.md index f1af81cbd0a..2f92c1ca71f 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -11,7 +11,7 @@ Other available metrics not mentioned here can found at where: - `[IP]` should be equal to IP address of bound network interface on cluster node for Prebid Server (for example: `0.0.0.0`) -- `[PORT]` should be equal to `http.port` configuration property +- `[PORT]` should be equal to `server.http.port` configuration property ### HTTP client metrics - `vertx.http.clients.connections.{min,max,mean,p95,p99}` - how long connections live diff --git a/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java index 4740f025320..5c7d5b187d0 100644 --- a/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/server/application/ApplicationServerConfiguration.java @@ -86,10 +86,10 @@ public class ApplicationServerConfiguration { @ConditionalOnProperty(name = "server.http.enabled", havingValue = "true") VerticleDefinition httpApplicationServerVerticleDefinition( HttpServerOptions httpServerOptions, - @Value("#{'${http.port:${server.http.port}}'}") Integer port, + @Value("${server.http.port}") int port, Router applicationServerRouter, ExceptionHandler exceptionHandler, - @Value("#{'${vertx.http-server-instances:${server.http.server-instances}}'}") Integer instances) { + @Value("${server.http.server-instances}") int instances) { return VerticleDefinition.ofMultiInstance( () -> new ServerVerticle( @@ -120,15 +120,14 @@ VerticleDefinition unixSocketApplicationServerVerticleDefinition( instances); } - // TODO: remove support for properties with http prefix after transition period @Bean HttpServerOptions httpServerOptions( - @Value("#{'${http.max-headers-size:${server.max-headers-size:}}'}") int maxHeaderSize, - @Value("#{'${http.max-initial-line-length:${server.max-initial-line-length:}}'}") int maxInitialLineLength, - @Value("#{'${http.ssl:${server.ssl:}}'}") boolean ssl, - @Value("#{'${http.jks-path:${server.jks-path:}}'}") String jksPath, - @Value("#{'${http.jks-password:${server.jks-password:}}'}") String jksPassword, - @Value("#{'${http.idle-timeout:${server.idle-timeout}}'}") int idleTimeout, + @Value("${server.max-headers-size}") int maxHeaderSize, + @Value("${server.max-initial-line-length}") int maxInitialLineLength, + @Value("${server.ssl}") boolean ssl, + @Value("${server.jks-path}") String jksPath, + @Value("${server.jks-password}") String jksPassword, + @Value("${server.idle-timeout}") int idleTimeout, @Value("${server.enable-quickack:#{null}}") Optional enableQuickAck, @Value("${server.enable-reuseport:#{null}}") Optional enableReusePort) { From 988fcbe343c1984905f03157e1d321e9c9bddfb6 Mon Sep 17 00:00:00 2001 From: Serhii Kolomiiets <46626223+VeryExtraordinaryUsername@users.noreply.github.com> Date: Mon, 6 May 2024 22:01:38 +0300 Subject: [PATCH 29/58] Core: Finish transition period for alias resolving (#2644) --- .../prebid/server/auction/BidResponseCreator.java | 12 +----------- .../settings/model/AccountAuctionEventConfig.java | 11 +---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index c1ccc7922f9..273f9f7cbfc 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -35,7 +35,6 @@ import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.TargetingInfo; import org.prebid.server.auction.model.debug.DebugContext; -import org.prebid.server.auction.requestfactory.Ortb2ImplicitParametersResolver; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; @@ -1444,16 +1443,7 @@ private static String channelFromRequest(BidRequest bidRequest) { final ExtRequestPrebid prebid = ext != null ? ext.getPrebid() : null; final ExtRequestPrebidChannel channel = prebid != null ? prebid.getChannel() : null; - return channel != null ? recogniseChannelName(channel.getName()) : null; - } - - // TODO: remove alias resolving after transition period - private static String recogniseChannelName(String channelName) { - if (StringUtils.equalsIgnoreCase("pbjs", channelName)) { - return Ortb2ImplicitParametersResolver.WEB_CHANNEL; - } - - return channelName; + return channel != null ? channel.getName() : null; } private static boolean eventsAllowedByRequest(AuctionContext auctionContext) { diff --git a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java index 3df397c63f8..9f9c7b18e54 100644 --- a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java +++ b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import lombok.Builder; import lombok.Value; -import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.HashMap; @@ -23,14 +22,6 @@ public Map getEvents() { @JsonAnySetter public void addEvent(String key, Boolean value) { - events.put(resolveKey(key), value); - } - - private static String resolveKey(String key) { - if (StringUtils.equalsIgnoreCase("pbjs", key)) { - return "web"; - } - - return key; + events.put(key, value); } } From dc42b0bc8ccdaf5df172fd2c69b1cd829416e351 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 7 May 2024 13:32:52 +0200 Subject: [PATCH 30/58] Core: Convert some bidders as Generic aliases (#2828) --- .../prebid/server/bidder/GenericBidder.java | 36 +-- .../server/bidder/adrino/AdrinoBidder.java | 65 ----- .../server/bidder/alkimi/AlkimiBidder.java | 2 - .../prebid/server/bidder/ccx/CcxBidder.java | 83 ------ .../server/bidder/infytv/InfytvBidder.java | 68 ----- .../server/bidder/loopme/LoopmeBidder.java | 83 ------ .../server/bidder/mgidx/MgidxBidder.java | 1 - .../prebid/server/bidder/oms/OmsBidder.java | 19 +- .../zeta_global_ssp/ZetaGlobalSspBidder.java | 90 ------- .../config/bidder/AdrinoConfiguration.java | 41 --- .../config/bidder/CcxConfiguration.java | 42 --- .../config/bidder/InfytvConfiguration.java | 42 --- .../config/bidder/LoopmeConfiguration.java | 41 --- .../bidder/ZetaGlobalSspConfiguration.java | 42 --- src/main/resources/bidder-config/adrino.yaml | 10 - src/main/resources/bidder-config/ccx.yaml | 15 -- src/main/resources/bidder-config/generic.yaml | 73 ++++++ src/main/resources/bidder-config/infytv.yaml | 11 - src/main/resources/bidder-config/loopme.yaml | 15 -- .../bidder-config/zeta_global_ssp.yaml | 20 -- ...a_global_ssp.json => zeta-global-ssp.json} | 0 .../testcontainers/PbsConfig.groovy | 24 +- .../bidder/adrino/AdrinoBidderTest.java | 196 -------------- .../server/bidder/ccx/CcxBidderTest.java | 244 ------------------ .../bidder/infytv/InfytvBidderTest.java | 136 ---------- .../bidder/loopme/LoopmeBidderTest.java | 187 -------------- .../ZetaGlobalSspBidderTest.java | 195 -------------- .../prebid/server/it/ZetaGlobalSspTest.java | 12 +- .../infytv/test-auction-infytv-request.json | 9 +- .../infytv/test-infytv-bid-request-1.json | 9 +- ...test-auction-zeta-global-ssp-request.json} | 2 +- ...est-auction-zeta-global-ssp-response.json} | 4 +- .../test-zeta-global-ssp-bid-request.json} | 0 .../test-zeta-global-ssp-bid-response.json} | 0 .../server/it/test-application.properties | 20 +- 35 files changed, 133 insertions(+), 1704 deletions(-) delete mode 100644 src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java delete mode 100644 src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java delete mode 100644 src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java delete mode 100644 src/main/resources/bidder-config/adrino.yaml delete mode 100644 src/main/resources/bidder-config/ccx.yaml delete mode 100644 src/main/resources/bidder-config/infytv.yaml delete mode 100644 src/main/resources/bidder-config/loopme.yaml delete mode 100644 src/main/resources/bidder-config/zeta_global_ssp.yaml rename src/main/resources/static/bidder-params/{zeta_global_ssp.json => zeta-global-ssp.json} (100%) delete mode 100644 src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java delete mode 100644 src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-auction-zeta_global_ssp-request.json => zetaglobalssp/test-auction-zeta-global-ssp-request.json} (94%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-auction-zeta_global_ssp-response.json => zetaglobalssp/test-auction-zeta-global-ssp-response.json} (86%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-zeta_global_ssp-bid-request.json => zetaglobalssp/test-zeta-global-ssp-bid-request.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zeta_global_ssp/test-zeta_global_ssp-bid-response.json => zetaglobalssp/test-zeta-global-ssp-bid-response.json} (100%) diff --git a/src/main/java/org/prebid/server/bidder/GenericBidder.java b/src/main/java/org/prebid/server/bidder/GenericBidder.java index a929e3673c2..a708de0ca1b 100644 --- a/src/main/java/org/prebid/server/bidder/GenericBidder.java +++ b/src/main/java/org/prebid/server/bidder/GenericBidder.java @@ -2,10 +2,8 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderCall; @@ -14,14 +12,16 @@ import org.prebid.server.bidder.model.Result; import org.prebid.server.json.DecodeException; import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.util.BidderUtil; import org.prebid.server.util.HttpUtil; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; public class GenericBidder implements Bidder { @@ -35,15 +35,7 @@ public GenericBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); } @Override @@ -64,29 +56,15 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + final Map impMap = bidRequest.getImp().stream() + .collect(Collectors.toMap(Imp::getId, Function.identity())); return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) .filter(Objects::nonNull) .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) + .map(bid -> BidderBid.of(bid, BidderUtil.getBidType(bid, impMap), bidResponse.getCur())) .toList(); } - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } else if (imp.getXNative() != null) { - return BidType.xNative; - } else if (imp.getAudio() != null) { - return BidType.audio; - } - } - } - return BidType.banner; - } } diff --git a/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java b/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java deleted file mode 100644 index 2e79b69f0aa..00000000000 --- a/src/main/java/org/prebid/server/bidder/adrino/AdrinoBidder.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.prebid.server.bidder.adrino; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class AdrinoBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public AdrinoBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public final Result>> makeHttpRequests(BidRequest request) { - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidResponse); - } - - private static List bidsFromResponse(BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, BidType.xNative, bidResponse.getCur())) - .toList(); - } -} diff --git a/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java b/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java index 9d729408634..03a05d1b1aa 100644 --- a/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java +++ b/src/main/java/org/prebid/server/bidder/alkimi/AlkimiBidder.java @@ -36,8 +36,6 @@ public class AlkimiBidder implements Bidder { private final String endpointUrl; private final JacksonMapper mapper; - private static final String TYPE_BANNER = "Banner"; - private static final String TYPE_VIDEO = "Video"; private static final String PRICE_MACRO = "${AUCTION_PRICE}"; private static final TypeReference> ALKIMI_EXT_TYPE_REFERENCE = new TypeReference<>() { diff --git a/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java b/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java deleted file mode 100644 index 91fcdc71a1c..00000000000 --- a/src/main/java/org/prebid/server/bidder/ccx/CcxBidder.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.bidder.ccx; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class CcxBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public CcxBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest request) { - - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } - break; - } - } - return BidType.banner; - } - -} diff --git a/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java b/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java deleted file mode 100644 index 237c7b133fc..00000000000 --- a/src/main/java/org/prebid/server/bidder/infytv/InfytvBidder.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.prebid.server.bidder.infytv; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -public class InfytvBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public InfytvBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse("Bad Response, " + e.getMessage())); - } catch (PreBidException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - throw new PreBidException("Empty SeatBid array"); - } - return bidsFromResponse(bidResponse); - } - - private static List bidsFromResponse(BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .map(bid -> BidderBid.of(bid, BidType.video, bidResponse.getCur())) - .toList(); - } -} diff --git a/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java b/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java deleted file mode 100644 index 20161acc420..00000000000 --- a/src/main/java/org/prebid/server/bidder/loopme/LoopmeBidder.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.prebid.server.bidder.loopme; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class LoopmeBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public LoopmeBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest request) { - - return Result.withValue(BidderUtil.defaultRequest(request, endpointUrl, mapper)); - } - - @Override - public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.of(extractBids(httpCall.getRequest().getPayload(), bidResponse), Collections.emptyList()); - } catch (DecodeException | PreBidException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(String impId, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(impId)) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } else if (imp.getXNative() != null) { - return BidType.xNative; - } - } - } - return BidType.banner; - } -} diff --git a/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java b/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java index f8c4ee9a068..bb01db86928 100644 --- a/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java +++ b/src/main/java/org/prebid/server/bidder/mgidx/MgidxBidder.java @@ -42,7 +42,6 @@ public class MgidxBidder implements Bidder { private static final String PUBLISHER_PROPERTY = "publisher"; private static final String NETWORK_PROPERTY = "network"; private static final String BIDDER_PROPERTY = "bidder"; - private static final String PREBID_EXT = "prebid"; private final String endpointUrl; private final JacksonMapper mapper; diff --git a/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java b/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java index 94e9e47af80..9dfc6d158e3 100644 --- a/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java +++ b/src/main/java/org/prebid/server/bidder/oms/OmsBidder.java @@ -3,7 +3,6 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; import org.apache.commons.collections4.CollectionUtils; import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.model.BidderBid; @@ -34,35 +33,27 @@ public OmsBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, endpointUrl, mapper)); } @Override public final Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); + return Result.withValues(extractBids(bidResponse)); } catch (DecodeException e) { return Result.withError(BidderError.badServerResponse(e.getMessage())); } } - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { + private static List extractBids(BidResponse bidResponse) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); } - return bidsFromResponse(bidRequest, bidResponse); + return bidsFromResponse(bidResponse); } - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + private static List bidsFromResponse(BidResponse bidResponse) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) diff --git a/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java b/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java deleted file mode 100644 index 804071d0a2b..00000000000 --- a/src/main/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidder.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.prebid.server.bidder.zeta_global_ssp; - -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.http.HttpMethod; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.BidderUtil; -import org.prebid.server.util.HttpUtil; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class ZetaGlobalSspBidder implements Bidder { - - private final String endpointUrl; - private final JacksonMapper mapper; - - public ZetaGlobalSspBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - } - - @Override - public Result>> makeHttpRequests(BidRequest bidRequest) { - return Result.withValue( - HttpRequest.builder() - .method(HttpMethod.POST) - .uri(endpointUrl) - .headers(HttpUtil.headers()) - .body(mapper.encodeToBytes(bidRequest)) - .impIds(BidderUtil.impIds(bidRequest)) - .payload(bidRequest) - .build()); - } - - @Override - public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { - if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { - return Collections.emptyList(); - } - return bidsFromResponse(bidRequest, bidResponse); - } - - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .map(bid -> BidderBid.of(bid, getBidType(bid, bidRequest.getImp()), bidResponse.getCur())) - .toList(); - } - - private static BidType getBidType(Bid bid, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(bid.getImpid())) { - if (imp.getBanner() != null) { - return BidType.banner; - } else if (imp.getVideo() != null) { - return BidType.video; - } - } - } - return BidType.banner; - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java deleted file mode 100644 index 415835e1b10..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/AdrinoConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.adrino.AdrinoBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/adrino.yaml", factory = YamlPropertySourceFactory.class) -public class AdrinoConfiguration { - - private static final String BIDDER_NAME = "adrino"; - - @Bean("adrinoConfigurationProperties") - @ConfigurationProperties("adapters.adrino") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps adrinoBidderDeps(BidderConfigurationProperties adrinoConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(adrinoConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new AdrinoBidder(config.getEndpoint(), mapper)) - .assemble(); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java deleted file mode 100644 index 91b0c7646ec..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/CcxConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.ccx.CcxBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/ccx.yaml", factory = YamlPropertySourceFactory.class) -public class CcxConfiguration { - - private static final String BIDDER_NAME = "ccx"; - - @Bean("ccxConfigurationProperties") - @ConfigurationProperties("adapters.ccx") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps ccxBidderDeps( - BidderConfigurationProperties ccxConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(ccxConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new CcxBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java deleted file mode 100644 index 7b28f464742..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/InfytvConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.infytv.InfytvBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/infytv.yaml", factory = YamlPropertySourceFactory.class) -public class InfytvConfiguration { - - private static final String BIDDER_NAME = "infytv"; - - @Bean("infytvConfigurationProperties") - @ConfigurationProperties("adapters.infytv") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps infytvBidderDeps(BidderConfigurationProperties infytvConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(infytvConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new InfytvBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java deleted file mode 100644 index a100493fbee..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/LoopmeConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.loopme.LoopmeBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/loopme.yaml", factory = YamlPropertySourceFactory.class) -public class LoopmeConfiguration { - - private static final String BIDDER_NAME = "loopme"; - - @Bean("loopmeConfigurationProperties") - @ConfigurationProperties("adapters.loopme") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps loopmeBidderDeps(BidderConfigurationProperties loopmeConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(loopmeConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new LoopmeBidder(loopmeConfigurationProperties.getEndpoint(), mapper)) - .assemble(); - } -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java deleted file mode 100644 index a886d2bab8e..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/ZetaGlobalSspConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.zeta_global_ssp.ZetaGlobalSspBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import jakarta.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/zeta_global_ssp.yaml", factory = YamlPropertySourceFactory.class) -public class ZetaGlobalSspConfiguration { - - private static final String BIDDER_NAME = "zeta_global_ssp"; - - @Bean - @ConfigurationProperties("adapters.zeta-global-ssp") - BidderConfigurationProperties zetaGlobalSspConfigurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps zetaGlobalSspBidderDeps(BidderConfigurationProperties zetaGlobalSspConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(zetaGlobalSspConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new ZetaGlobalSspBidder(config.getEndpoint(), mapper)) - .assemble(); - } - -} diff --git a/src/main/resources/bidder-config/adrino.yaml b/src/main/resources/bidder-config/adrino.yaml deleted file mode 100644 index 122130ecbbd..00000000000 --- a/src/main/resources/bidder-config/adrino.yaml +++ /dev/null @@ -1,10 +0,0 @@ -adapters: - adrino: - endpoint: https://prd-prebid-bidder.adrino.io/openrtb/bid - meta-info: - maintainer-email: dev@adrino.pl - app-media-types: - site-media-types: - - native - supported-vendors: - vendor-id: 1072 diff --git a/src/main/resources/bidder-config/ccx.yaml b/src/main/resources/bidder-config/ccx.yaml deleted file mode 100644 index 5f4bba80bca..00000000000 --- a/src/main/resources/bidder-config/ccx.yaml +++ /dev/null @@ -1,15 +0,0 @@ -adapters: - ccx: - endpoint: https://delivery.clickonometrics.pl/ortb/prebid/bid - meta-info: - maintainer-email: it@clickonometrics.pl - site-media-types: - - banner - - video - vendor-id: 773 - usersync: - cookie-family-name: ccx - redirect: - url: https://sync.clickonometrics.pl/prebid/set-cookie?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&cb={{redirect_url}} - support-cors: false - uid-macro: '${USER_ID}' diff --git a/src/main/resources/bidder-config/generic.yaml b/src/main/resources/bidder-config/generic.yaml index 01f7c3fa45f..5c4ab6dd510 100644 --- a/src/main/resources/bidder-config/generic.yaml +++ b/src/main/resources/bidder-config/generic.yaml @@ -4,6 +4,79 @@ adapters: aliases: genericAlias: enabled: false + adrino: + enabled: false + endpoint: https://prd-prebid-bidder.adrino.io/openrtb/bid + meta-info: + maintainer-email: dev@adrino.pl + app-media-types: + site-media-types: + - native + supported-vendors: + vendor-id: 1072 + ccx: + enabled: false + endpoint: https://delivery.clickonometrics.pl/ortb/prebid/bid + meta-info: + maintainer-email: it@clickonometrics.pl + site-media-types: + - banner + - video + vendor-id: 773 + usersync: + enabled: true + cookie-family-name: ccx + redirect: + url: https://sync.clickonometrics.pl/prebid/set-cookie?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&cb={{redirect_url}} + support-cors: false + uid-macro: '${USER_ID}' + infytv: + enabled: false + endpoint: https://nxs.infy.tv/pbs/openrtb + meta-info: + maintainer-email: tech+hb@infy.tv + app-media-types: + - video + site-media-types: + - video + supported-vendors: + vendor-id: 0 + loopme: + enabled: false + endpoint: http://prebid-eu.loopmertb.com + meta-info: + maintainer-email: support@loopme.com + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 109 + zeta-global-ssp: + enabled: false + endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA + endpoint-compression: gzip + meta-info: + maintainer-email: DL-Zeta-SSP@zetaglobal.com + app-media-types: + - banner + - video + site-media-types: + - banner + - video + supported-vendors: + vendor-id: 833 + usersync: + enabled: true + cookie-family-name: zeta-global-ssp + redirect: + url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} + uid-macro: 'BUYERUID' + support-cors: false blue: enabled: false endpoint: https://prebid-us-east-1.getblue.io/?src=prebid diff --git a/src/main/resources/bidder-config/infytv.yaml b/src/main/resources/bidder-config/infytv.yaml deleted file mode 100644 index fdf66ff92ac..00000000000 --- a/src/main/resources/bidder-config/infytv.yaml +++ /dev/null @@ -1,11 +0,0 @@ -adapters: - infytv: - endpoint: https://nxs.infy.tv/pbs/openrtb - meta-info: - maintainer-email: tech+hb@infy.tv - app-media-types: - - video - site-media-types: - - video - supported-vendors: - vendor-id: 0 diff --git a/src/main/resources/bidder-config/loopme.yaml b/src/main/resources/bidder-config/loopme.yaml deleted file mode 100644 index 321c6898762..00000000000 --- a/src/main/resources/bidder-config/loopme.yaml +++ /dev/null @@ -1,15 +0,0 @@ -adapters: - loopme: - endpoint: http://prebid-eu.loopmertb.com - meta-info: - maintainer-email: support@loopme.com - app-media-types: - - banner - - video - - native - site-media-types: - - banner - - video - - native - supported-vendors: - vendor-id: 109 diff --git a/src/main/resources/bidder-config/zeta_global_ssp.yaml b/src/main/resources/bidder-config/zeta_global_ssp.yaml deleted file mode 100644 index 36926fb335b..00000000000 --- a/src/main/resources/bidder-config/zeta_global_ssp.yaml +++ /dev/null @@ -1,20 +0,0 @@ -adapters: - zeta-global-ssp: - endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA - endpoint-compression: gzip - meta-info: - maintainer-email: DL-Zeta-SSP@zetaglobal.com - app-media-types: - - banner - - video - site-media-types: - - banner - - video - supported-vendors: - vendor-id: 833 - usersync: - cookie-family-name: zeta_global_ssp - redirect: - url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} - uid-macro: 'BUYERUID' - support-cors: false diff --git a/src/main/resources/static/bidder-params/zeta_global_ssp.json b/src/main/resources/static/bidder-params/zeta-global-ssp.json similarity index 100% rename from src/main/resources/static/bidder-params/zeta_global_ssp.json rename to src/main/resources/static/bidder-params/zeta-global-ssp.json diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy index f5d934d245f..7598fd4cfae 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsConfig.groovy @@ -118,13 +118,23 @@ LIMIT 1 // due to a config validation we'll need to circumvent all future aliases this way static Map getBidderAliasConfig() { - ["adapters.generic.aliases.cwire.meta-info.site-media-types" : "", - "adapters.generic.aliases.blue.meta-info.app-media-types" : "", - "adapters.generic.aliases.blue.meta-info.site-media-types" : "", - "adapters.generic.aliases.adsinteractive.meta-info.app-media-types" : "", - "adapters.generic.aliases.adsinteractive.meta-info.site-media-types": "", - "adapters.generic.aliases.nativo.meta-info.app-media-types" : "", - "adapters.generic.aliases.nativo.meta-info.site-media-types" : ""] + ["adapters.generic.aliases.cwire.meta-info.site-media-types" : "", + "adapters.generic.aliases.blue.meta-info.app-media-types" : "", + "adapters.generic.aliases.blue.meta-info.site-media-types" : "", + "adapters.generic.aliases.adsinteractive.meta-info.app-media-types" : "", + "adapters.generic.aliases.adsinteractive.meta-info.site-media-types" : "", + "adapters.generic.aliases.nativo.meta-info.app-media-types" : "", + "adapters.generic.aliases.nativo.meta-info.site-media-types" : "", + "adapters.generic.aliases.infytv.meta-info.app-media-types" : "", + "adapters.generic.aliases.infytv.meta-info.site-media-types" : "", + "adapters.generic.aliases.loopme.meta-info.app-media-types" : "", + "adapters.generic.aliases.loopme.meta-info.site-media-types" : "", + "adapters.generic.aliases.zeta-global-ssp.meta-info.app-media-types" : "", + "adapters.generic.aliases.zeta-global-ssp.meta-info.site-media-types": "", + "adapters.generic.aliases.ccx.meta-info.app-media-types" : "", + "adapters.generic.aliases.ccx.meta-info.site-media-types" : "", + "adapters.generic.aliases.adrino.meta-info.app-media-types" : "", + "adapters.generic.aliases.adrino.meta-info.site-media-types" : ""] } private PbsConfig() {} diff --git a/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java b/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java deleted file mode 100644 index f1f58954407..00000000000 --- a/src/test/java/org/prebid/server/bidder/adrino/AdrinoBidderTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.prebid.server.bidder.adrino; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.adrino.ExtImpAdrino; -import org.prebid.server.proto.openrtb.ext.response.BidType; - -import java.util.List; -import java.util.Set; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; -import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; -import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; -import static org.prebid.server.util.HttpUtil.headers; -import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; - -public class AdrinoBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://prd-prebid-bidder.adrino.io/openrtb/bid"; - - private final AdrinoBidder target = new AdrinoBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void makeHttpRequestsShouldReturnHttpRequestWithCorrectBodyHeadersAndMethod() { - // given - final BidRequest bidRequest = BidRequest.builder() - .id("test-request-id") - .imp(List.of(Imp.builder().id("imp_id").build())) - .build(); - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - final MultiMap expectedHeaders = headers() - .set(CONTENT_TYPE_HEADER, APPLICATION_JSON_CONTENT_TYPE) - .set(ACCEPT_HEADER, APPLICATION_JSON_VALUE); - final Result>> expectedResult = Result.withValue(HttpRequest.builder() - .method(HttpMethod.POST) - .uri(ENDPOINT_URL) - .headers(expectedHeaders) - .impIds(Set.of("imp_id")) - .body(jacksonMapper.encodeToBytes(bidRequest)) - .payload(bidRequest) - .build()); - assertThat(result.getValue()).usingRecursiveComparison().isEqualTo(expectedResult.getValue()); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeHttpRequestShouldReturnSingleHttpRequestsWhenTwoImpsHasDifferentSourceId() { - // given - final BidRequest bidRequest = BidRequest.builder() - .imp(asList(Imp.builder() - .xNative(Native.builder().build()) - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpAdrino.of("test")))) - .build(), - Imp.builder() - .xNative(Native.builder().build()) - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpAdrino.of("test")))) - .build())) - .build(); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1); - } - - @Test - public void makeBidsShouldReturnExpectedResult() throws JsonProcessingException { - // given - final Bid bid = Bid.builder().id("impId").build(); - final String response = mapper.writeValueAsString(BidResponse.builder() - .cur("PLN") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bid)) - .build())) - .build()); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1).element(0).satisfies(bidderBid -> { - assertThat(bidderBid.getBid()).isEqualTo(bid); - assertThat(bidderBid.getType()).isEqualTo(BidType.xNative); - assertThat(bidderBid.getBidCurrency()).isEqualTo("PLN"); - }); - } - - @Test - public void makeBidsShouldReturnEmptyResponseWhenWhereIsNoBid() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(null); - final BidRequest bidRequest = BidRequest.builder() - .imp(singletonList(Imp.builder().id("impId").build())) - .build(); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBidsFromDifferentSeatBidsInResponse() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder() - .seatbid(asList( - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId1").impid("impId1").build())) - .build(), - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId2").impid("impId2").build())) - .build())) - .build()); - final BidRequest bidRequest = BidRequest.builder() - .imp(asList(Imp.builder().id("impId1").build(), Imp.builder().id("impId2").build())) - .build(); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(BidderBid::getBid) - .extracting(Bid::getId).containsExactly("bidId1", "bidId2"); - } - - @Test - public void makeBidsShouldReturnEmptyBidderBidAndErrorListsIfSeatBidIsNotPresentInResponse() - throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder().build()); - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCanNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall("{"); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).hasSize(1).element(0).satisfies(bidderError -> { - assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(bidderError.getMessage()).startsWith("Failed to decode:"); - }); - } - - private static BidderCall givenHttpCall(String body) { - return BidderCall.succeededHttp(null, HttpResponse.of(204, null, body), null); - } -} diff --git a/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java b/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java deleted file mode 100644 index d88f12400fb..00000000000 --- a/src/test/java/org/prebid/server/bidder/ccx/CcxBidderTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.prebid.server.bidder.ccx; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Audio; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.ccx.ExtImpCcx; - -import java.util.List; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -import static java.util.Collections.singletonList; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; - -public class CcxBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://randomurl.com"; - - private final CcxBidder target = new CcxBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new CcxBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldCreateExpectedUrl() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getUri) - .containsExactly("https://randomurl.com"); - } - - @Test - public void makeHttpRequestsShouldHaveTheSameIncomingAndOutGoingBidRequest() { - // given - final BidRequest bidRequest = givenBidRequest(impCustomizer -> impCustomizer - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789))))); - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .containsExactly(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789)))); - } - - @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall(null, "invalid"); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1) - .allSatisfy(error -> { - assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token"); - }); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBannerBidIfBannerIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(Banner.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfVideoIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.xNative(Native.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfAudioIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.audio(Audio.builder().build())), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfBannerAndVideoAndAudioAndNativeIsAbsentInRequestImp() - throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(identity()), - mapper.writeValueAsString(givenBidResponse(impBuilder -> impBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(givenBid(), banner, "USD")); - } - - private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { - return givenBidRequest(identity(), impCustomizer); - } - - private static BidRequest givenBidRequest( - Function bidRequestCustomizer, - Function impCustomizer) { - return bidRequestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) - .build(); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123") - .ext(mapper.valueToTree(ExtPrebid.of(null, - ExtImpCcx.of(123456789))))) - .build(); - } - - private static BidResponse givenBidResponse(Function bidCustomizer) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder().bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) - .build())) - .build(); - } - - private static Bid givenBid() { - return Bid.builder().impid("123").build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp( - HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), - null); - } - -} diff --git a/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java b/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java deleted file mode 100644 index ce62b2efca0..00000000000 --- a/src/test/java/org/prebid/server/bidder/infytv/InfytvBidderTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.prebid.server.bidder.infytv; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.response.BidType; - -import java.util.List; -import java.util.Set; -import java.util.function.UnaryOperator; - -import static java.util.Collections.singletonList; -import static java.util.function.UnaryOperator.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.util.HttpUtil.ACCEPT_HEADER; -import static org.prebid.server.util.HttpUtil.APPLICATION_JSON_CONTENT_TYPE; -import static org.prebid.server.util.HttpUtil.CONTENT_TYPE_HEADER; -import static org.prebid.server.util.HttpUtil.headers; -import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE; - -public class InfytvBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://nxs.infy.tv/pbs/openrtb"; - - private final InfytvBidder target = new InfytvBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new InfytvBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldReturnExpectedHttpRequest() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - final MultiMap expectedHeaders = headers() - .set(CONTENT_TYPE_HEADER, APPLICATION_JSON_CONTENT_TYPE) - .set(ACCEPT_HEADER, APPLICATION_JSON_VALUE); - final Result>> expectedResult = Result.withValue(HttpRequest.builder() - .method(HttpMethod.POST) - .uri(ENDPOINT_URL) - .headers(expectedHeaders) - .impIds(Set.of("IMP_ID")) - .body(jacksonMapper.encodeToBytes(bidRequest)) - .payload(bidRequest) - .build()); - assertThat(result.getValue()).usingRecursiveComparison().isEqualTo(expectedResult.getValue()); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnExpectedResult() throws JsonProcessingException { - // given - final Bid bid = Bid.builder().id("impId").build(); - final String response = mapper.writeValueAsString(BidResponse.builder() - .cur("PLN") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bid)) - .build())) - .build()); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).allSatisfy(bidderBid -> { - assertThat(bidderBid.getBid()).isEqualTo(bid); - assertThat(bidderBid.getType()).isEqualTo(BidType.video); - assertThat(bidderBid.getBidCurrency()).isEqualTo("PLN"); - }); - } - - @Test - public void makeBidsShouldReturnErrorWhenThereIsNoBid() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(null); - - final BidderCall httpCall = givenHttpCall(response); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getValue()).isEmpty(); - assertThat(result.getErrors()).isNotEmpty(); - assertThat(result.getErrors()) - .containsExactly(BidderError.badServerResponse("Empty SeatBid array")); - } - - @Test - public void makeBidsShouldReturnErrorWhenResponseCanNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall("{"); - - // when - final Result> result = target.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).allSatisfy(bidderError -> { - assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(bidderError.getMessage()).startsWith("Bad Response,"); - }); - } - - private static BidRequest givenBidRequest(UnaryOperator bidRequestCustomizer) { - return bidRequestCustomizer.apply( - BidRequest.builder().imp(List.of(Imp.builder().id("IMP_ID").build()))).build(); - } - - private static BidderCall givenHttpCall(String body) { - return BidderCall.succeededHttp(null, HttpResponse.of(204, null, body), null); - } - -} diff --git a/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java b/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java deleted file mode 100644 index 7fd6fca1073..00000000000 --- a/src/test/java/org/prebid/server/bidder/loopme/LoopmeBidderTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.prebid.server.bidder.loopme; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.loopme.ExtImpLoopme; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; - -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; -import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; - -public class LoopmeBidderTest extends VertxTest { - - public static final String ENDPOINT_URL = "https://test.endpoint.com"; - - private final LoopmeBidder target = new LoopmeBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void makeHttpRequestsShouldMakeOneRequestWithAllImps() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - requestBuilder -> requestBuilder.imp(Arrays.asList( - givenImp(identity()), - givenImp(identity())))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .hasSize(2); - } - - @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder().id("123").build())).build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(Imp.builder().video(Video.builder().build()).id("123").build())) - .build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(givenImp(identity()))) - .build(), - mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnNativeBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(Imp.builder().id("123").xNative(Native.builder().build()).build())) - .build(), - mapper.writeValueAsString( - givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), xNative, "USD")); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - private static BidRequest givenBidRequest( - Function impCustomizer, - Function requestCustomizer) { - return requestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) - .build(); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123")) - .banner(Banner.builder().build()) - .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpLoopme.of("somePubId")))) - .build(); - } - - private static BidResponse givenBidResponse(Function bidCustomizer) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bidCustomizer.apply(Bid.builder()).build())) - .build())) - .build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp(HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), null); - } -} diff --git a/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java b/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java deleted file mode 100644 index 0b94d701d2e..00000000000 --- a/src/test/java/org/prebid/server/bidder/zeta_global_ssp/ZetaGlobalSspBidderTest.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.prebid.server.bidder.zeta_global_ssp; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderCall; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; - -import java.util.List; -import java.util.function.Function; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; -import static org.prebid.server.proto.openrtb.ext.response.BidType.video; - -public class ZetaGlobalSspBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "https://test.endpoint.com"; - - private final ZetaGlobalSspBidder target = new ZetaGlobalSspBidder(ENDPOINT_URL, jacksonMapper); - - @Test - public void creationShouldFailOnInvalidEndpointUrl() { - assertThatIllegalArgumentException().isThrownBy(() -> new ZetaGlobalSspBidder("invalid_url", jacksonMapper)); - } - - @Test - public void makeHttpRequestsShouldReturnExpectedBidRequest() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .containsExactly(bidRequest); - } - - @Test - public void makeHttpRequestsShouldMakeOneRequestForMultipleImps() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - requestBuilder -> requestBuilder.imp(asList( - givenImp(identity()), - givenImp(identity()).toBuilder().id("2").build()))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp).hasSize(2); - } - - @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { - // given - final BidderCall httpCall = givenHttpCall(null, "invalid"); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, mapper.writeValueAsString(null)); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).video(null)), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - @Test - public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(impBuilder -> impBuilder.banner(null).video(Video.builder().build())), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); - } - - @Test - public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall( - givenBidRequest(identity()), - mapper.writeValueAsString(givenBidResponse(Bid.builder().impid("123").build()))); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); - } - - private static BidRequest givenBidRequest( - Function impCustomizer, - Function requestCustomizer) { - - return requestCustomizer.apply(BidRequest.builder().imp(singletonList(givenImp(impCustomizer)))).build(); - } - - private static BidRequest givenBidRequest(Function impCustomizer) { - return givenBidRequest(impCustomizer, identity()); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .id("123") - .banner(Banner.builder().build()) - .video(Video.builder().build())) - .build(); - } - - private static BidderCall givenHttpCall(BidRequest bidRequest, String body) { - return BidderCall.succeededHttp(HttpRequest.builder().payload(bidRequest).build(), - HttpResponse.of(200, null, body), null); - } - - private static BidResponse givenBidResponse(Bid... bids) { - return BidResponse.builder() - .cur("USD") - .seatbid(singletonList(SeatBid.builder() - .bid(List.of(bids)) - .build())) - .build(); - } -} diff --git a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java index 7556d13e67f..074e503b50e 100644 --- a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java +++ b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java @@ -21,18 +21,18 @@ public class ZetaGlobalSspTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromZetaGlobalSsp() throws IOException, JSONException { // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta_global_ssp-exchange")) + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta-global-ssp-exchange")) .withRequestBody(equalToJson( - jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json"))) + jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json"))) .willReturn(aResponse().withBody( - jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json")))); + jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json")))); // when - final Response response = responseFor("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json", + final Response response = responseFor("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json", Endpoint.openrtb2_auction); // then - assertJsonEquals("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json", response, - singletonList("zeta_global_ssp")); + assertJsonEquals("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json", response, + singletonList("zeta-global-ssp")); } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json index 0084cddf231..fd7310654e6 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-auction-infytv-request.json @@ -3,9 +3,12 @@ "imp": [ { "id": "imp_id", - "banner": { - "w": 300, - "h": 250 + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 }, "ext": { "infytv": { diff --git a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json index 26854e41f45..26770d4ac7c 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/infytv/test-infytv-bid-request-1.json @@ -4,9 +4,12 @@ { "id": "imp_id", "secure": 1, - "banner": { - "w": 300, - "h": 250 + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 }, "ext": { "tid": "${json-unit.any-string}", diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json similarity index 94% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json index 0a3824d6e31..3ed84b4e1ee 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json @@ -12,7 +12,7 @@ ] }, "ext": { - "zeta_global_ssp": {} + "zeta-global-ssp": {} } } ], diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json similarity index 86% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json index 802e057bc7a..afb9594d84b 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json @@ -21,14 +21,14 @@ } } ], - "seat": "zeta_global_ssp", + "seat": "zeta-global-ssp", "group": 0 } ], "cur": "USD", "ext": { "responsetimemillis": { - "zeta_global_ssp": "{{ zeta_global_ssp.response_time_ms }}" + "zeta-global-ssp": "{{ zeta-global-ssp.response_time_ms }}" }, "prebid": { "auctiontimestamp": 1000 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 28f6c7fc5b3..8112a071772 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -4,6 +4,16 @@ adapters.generic.aliases.genericAlias.enabled=true adapters.generic.aliases.genericAlias.endpoint=http://localhost:8090/genericAlias-exchange adapters.generic.aliases.nativo.enabled=true adapters.generic.aliases.nativo.endpoint=http://localhost:8090/nativo-exchange +adapters.generic.aliases.adrino.enabled=true +adapters.generic.aliases.adrino.endpoint=http://localhost:8090/adrino-exchange +adapters.generic.aliases.ccx.enabled=true +adapters.generic.aliases.ccx.endpoint=http://localhost:8090/ccx-exchange +adapters.generic.aliases.infytv.enabled=true +adapters.generic.aliases.infytv.endpoint=http://localhost:8090/infytv-exchange +adapters.generic.aliases.loopme.enabled=true +adapters.generic.aliases.loopme.endpoint=http://localhost:8090/loopme-exchange +adapters.generic.aliases.zeta-global-ssp.enabled=true +adapters.generic.aliases.zeta-global-ssp.endpoint=http://localhost:8090/zeta-global-ssp-exchange adapters.aceex.enabled=true adapters.aceex.endpoint=http://localhost:8090/aceex-exchange adapters.acuityads.enabled=true @@ -15,8 +25,6 @@ adapters.adf.endpoint=http://localhost:8090/adf-exchange adapters.adf.aliases.adform.enabled=true adapters.adgeneration.enabled=true adapters.adgeneration.endpoint=http://localhost:8090/adgeneration-exchange -adapters.adrino.enabled=true -adapters.adrino.endpoint=http://localhost:8090/adrino-exchange adapters.adhese.enabled=true adapters.adhese.endpoint=http://localhost:8090/adhese-exchange adapters.adkerneladn.enabled=true @@ -123,8 +131,6 @@ adapters.boldwin.enabled=true adapters.boldwin.endpoint=http://localhost:8090/boldwin-exchange adapters.brave.enabled=true adapters.brave.endpoint=http://localhost:8090/brave-exchange -adapters.ccx.enabled=true -adapters.ccx.endpoint=http://localhost:8090/ccx-exchange adapters.connectad.enabled=true adapters.connectad.endpoint=http://localhost:8090/connectad-exchange adapters.compass.enabled=true @@ -201,8 +207,6 @@ adapters.impactify.enabled=true adapters.impactify.endpoint=http://localhost:8090/impactify-exchange adapters.improvedigital.enabled=true adapters.improvedigital.endpoint=http://localhost:8090/improvedigital-exchange -adapters.infytv.enabled=true -adapters.infytv.endpoint=http://localhost:8090/infytv-exchange adapters.intertech.enabled=true adapters.intertech.endpoint=http://localhost:8090/intertech-exchange adapters.iqx.enabled=true @@ -249,8 +253,6 @@ adapters.lockerdome.enabled=true adapters.lockerdome.endpoint=http://localhost:8090/lockerdome-exchange adapters.logan.enabled=true adapters.logan.endpoint=http://localhost:8090/logan-exchange -adapters.loopme.enabled=true -adapters.loopme.endpoint=http://localhost:8090/loopme-exchange adapters.logicad.enabled=true adapters.logicad.endpoint=http://localhost:8090/logicad-exchange adapters.lunamedia.enabled=true @@ -445,8 +447,6 @@ adapters.zeroclickfraud.enabled=true adapters.zeroclickfraud.endpoint=http://{{Host}}/zeroclickfraud-exchange?sid={{SourceId}} adapters.aax.enabled=true adapters.aax.endpoint=http://localhost:8090/aax-exchange -adapters.zeta_global_ssp.enabled=true -adapters.zeta_global_ssp.endpoint=http://localhost:8090/zeta_global_ssp-exchange adapters.zmaticoo.enabled=true adapters.zmaticoo.endpoint=http://localhost:8090/zmaticoo-exchange adapters.yearxero.enabled=true From fd8ec64794bb78392cc9c083f59f12d6d2652cc6 Mon Sep 17 00:00:00 2001 From: bretg Date: Tue, 7 May 2024 09:07:29 -0400 Subject: [PATCH 31/58] Mgidx: Update mgidx endpoints info (#3174) --- src/main/resources/bidder-config/mgidx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/mgidx.yaml b/src/main/resources/bidder-config/mgidx.yaml index 7c1b74aaae3..4989dc43461 100644 --- a/src/main/resources/bidder-config/mgidx.yaml +++ b/src/main/resources/bidder-config/mgidx.yaml @@ -1,6 +1,6 @@ adapters: mgidX: - # We have the following regional endpoint domains: 'us-east-x' and 'eu' + # We have the following regional endpoint domains: 'us-east-x' and 'eu-x' # Please deploy this config in each of your datacenters with the appropriate regional subdomain endpoint: https://REGION.mgid.com/pserver meta-info: From 0a43967fe593d14b26f5fa71a14ce70450092acd Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Tue, 7 May 2024 16:09:08 +0300 Subject: [PATCH 32/58] Tests: Extend skipUnitTests attributes for module tests (#3173) --- extra/modules/pom.xml | 6 +++--- extra/pom.xml | 3 +++ pom.xml | 3 --- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 5091a3e3a65..865b928cb79 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -32,9 +32,6 @@ 3.23.1 4.13.2 4.7.0 - - 3.11.0 - 2.22.2 @@ -113,6 +110,9 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} + + ${skipUnitTests} + diff --git a/extra/pom.xml b/extra/pom.xml index 90192cc0325..d6b22c6383f 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -23,6 +23,9 @@ 4.5.5 1.18.30 3.0.0-M6 + 3.11.0 + 2.22.2 + false diff --git a/pom.xml b/pom.xml index 2496ff6a6bc..d24b162dfbb 100644 --- a/pom.xml +++ b/pom.xml @@ -73,14 +73,11 @@ 1.2.0 0.8.11 2.2.4 - 3.11.0 - 2.22.2 ${maven-surefire-plugin.version} 0.40.2 3.0.2 false true - false 1.6.2 3.0.0 0.6.1 From e5744d053e7245a5edde0491a08b03c2a499ac2d Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 16:40:13 +0300 Subject: [PATCH 33/58] Core: Change account properties names. (#3152) --- docs/config-app.md | 6 +++--- docs/metrics.md | 2 +- .../auction/VideoStoredRequestProcessor.java | 8 ++++---- .../Ortb2ImplicitParametersResolver.java | 16 +++++++-------- .../requestfactory/Ortb2RequestFactory.java | 20 +++++++++---------- .../BlacklistedAccountException.java | 8 -------- .../exception/BlacklistedAppException.java | 8 -------- .../BlocklistedAccountException.java | 8 ++++++++ .../exception/BlocklistedAppException.java | 8 ++++++++ .../server/handler/openrtb2/AmpHandler.java | 15 +++++++------- .../handler/openrtb2/AuctionHandler.java | 16 +++++++-------- .../org/prebid/server/metric/MetricName.java | 4 ++-- .../spring/config/ServiceConfiguration.java | 14 ++++++------- .../validation/VideoRequestValidator.java | 12 ++++++----- src/main/resources/application.yaml | 4 ++-- .../Ortb2ImplicitParametersResolverTest.java | 6 +++--- .../Ortb2RequestFactoryTest.java | 18 ++++++++--------- .../handler/openrtb2/AmpHandlerTest.java | 16 +++++++-------- .../handler/openrtb2/AuctionHandlerTest.java | 20 +++++++++---------- .../org/prebid/server/metric/MetricsTest.java | 8 ++++---- .../validation/VideoRequestValidatorTest.java | 2 +- 21 files changed, 111 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/org/prebid/server/exception/BlacklistedAccountException.java delete mode 100644 src/main/java/org/prebid/server/exception/BlacklistedAppException.java create mode 100644 src/main/java/org/prebid/server/exception/BlocklistedAccountException.java create mode 100644 src/main/java/org/prebid/server/exception/BlocklistedAppException.java diff --git a/docs/config-app.md b/docs/config-app.md index c99bdd63a2f..5e3ee1192d4 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -75,8 +75,8 @@ Removes and downloads file again if depending service cant process probably corr - `default-request.file.path` - path to a JSON file containing the default request ## Auction (OpenRTB) -- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs. -- `auction.blacklisted-apps` - comma separated list of blacklisted applications IDs, requests from which should not be processed. +- `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. +- `auction.blocklisted-apps` - comma separated list of blocklisted applications IDs, requests from which should not be processed. - `auction.max-timeout-ms` - maximum operation timeout for OpenRTB Auction requests. Deprecated. - `auction.biddertmax.min` - minimum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.max` - maximum operation timeout for OpenRTB Auction requests. @@ -104,7 +104,7 @@ Removes and downloads file again if depending service cant process probably corr ## Video - `auction.video.stored-required` - flag forces to merge with stored request -- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs. +- `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. - `video.stored-requests-timeout-ms` - timeout for stored requests fetching. - `auction.ad-server-currency` - default currency for video auction, if its value was not specified in request. Important note: PBS uses ISO-4217 codes for the representation of currencies. - `auction.video.escape-log-cache-regex` - regex to remove from cache debug log xml. diff --git a/docs/metrics.md b/docs/metrics.md index 2f92c1ca71f..11f2165978c 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -44,7 +44,7 @@ where `[DATASOURCE]` is a data source name, `DEFAULT_DS` by defaul. - `imps_video` - number of video impressions - `imps_native` - number of native impressions - `imps_audio` - number of audio impressions -- `requests.(ok|badinput|err|networkerr|blacklisted_account|blacklisted_app).(openrtb2-web|openrtb-app|amp|legacy)` - number of requests broken down by status and type +- `requests.(ok|badinput|err|networkerr|blocklisted_account|blocklisted_app).(openrtb2-web|openrtb-app|amp|legacy)` - number of requests broken down by status and type - `bidder-cardinality..requests` - number of requests targeting `` of bidders - `connection_accept_errors` - number of errors occurred while establishing HTTP connection - `db_query_time` - timer tracking how long did it take for database client to obtain the result for a query diff --git a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java index 6b6cb533c72..84ebacc7416 100644 --- a/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java +++ b/src/main/java/org/prebid/server/auction/VideoStoredRequestProcessor.java @@ -59,7 +59,7 @@ public class VideoStoredRequestProcessor { private static final String DEFAULT_CURRENCY = "USD"; private final boolean enforceStoredRequest; - private final List blacklistedAccounts; + private final List blocklistedAccounts; private final long defaultTimeout; private final String currency; private final BidRequest defaultBidRequest; @@ -71,7 +71,7 @@ public class VideoStoredRequestProcessor { private final JsonMerger jsonMerger; public VideoStoredRequestProcessor(boolean enforceStoredRequest, - List blacklistedAccounts, + List blocklistedAccounts, long defaultTimeout, String adServerCurrency, String defaultBidRequestPath, @@ -84,7 +84,7 @@ public VideoStoredRequestProcessor(boolean enforceStoredRequest, JsonMerger jsonMerger) { this.enforceStoredRequest = enforceStoredRequest; - this.blacklistedAccounts = Objects.requireNonNull(blacklistedAccounts); + this.blocklistedAccounts = Objects.requireNonNull(blocklistedAccounts); this.defaultTimeout = defaultTimeout; this.currency = StringUtils.isBlank(adServerCurrency) ? DEFAULT_CURRENCY : adServerCurrency; this.defaultBidRequest = readBidRequest( @@ -147,7 +147,7 @@ private WithPodErrors toBidRequestWithPodErrors(StoredDataResult sto String storedBidRequestId) { final BidRequestVideo mergedStoredRequest = mergeBidRequest(videoRequest, storedBidRequestId, storedResult); - validator.validateStoredBidRequest(mergedStoredRequest, enforceStoredRequest, blacklistedAccounts); + validator.validateStoredBidRequest(mergedStoredRequest, enforceStoredRequest, blocklistedAccounts); final Podconfig podconfig = mergedStoredRequest.getPodconfig(); final Video video = mergedStoredRequest.getVideo(); diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java index 0fdf6497141..b11f92592ef 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolver.java @@ -33,7 +33,7 @@ import org.prebid.server.auction.model.Endpoint; import org.prebid.server.auction.model.IpAddress; import org.prebid.server.auction.model.SecBrowsingTopic; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.identity.IdGenerator; @@ -91,7 +91,7 @@ public class Ortb2ImplicitParametersResolver { private final boolean shouldCacheOnlyWinningBids; private final boolean generateBidRequestId; private final String adServerCurrency; - private final List blacklistedApps; + private final List blocklistedApps; private final ExtRequestPrebidServer serverInfo; private final ImplicitParametersExtractor paramsExtractor; private final TimeoutResolver timeoutResolver; @@ -104,7 +104,7 @@ public class Ortb2ImplicitParametersResolver { public Ortb2ImplicitParametersResolver(boolean shouldCacheOnlyWinningBids, boolean generateBidRequestId, String adServerCurrency, - List blacklistedApps, + List blocklistedApps, String externalUrl, Integer hostVendorId, String datacenterRegion, @@ -119,7 +119,7 @@ public Ortb2ImplicitParametersResolver(boolean shouldCacheOnlyWinningBids, this.shouldCacheOnlyWinningBids = shouldCacheOnlyWinningBids; this.generateBidRequestId = generateBidRequestId; this.adServerCurrency = validateCurrency(Objects.requireNonNull(adServerCurrency)); - this.blacklistedApps = Objects.requireNonNull(blacklistedApps); + this.blocklistedApps = Objects.requireNonNull(blocklistedApps); this.serverInfo = ExtRequestPrebidServer.of(externalUrl, hostVendorId, datacenterRegion, null); this.paramsExtractor = Objects.requireNonNull(paramsExtractor); this.timeoutResolver = Objects.requireNonNull(timeoutResolver); @@ -153,7 +153,7 @@ public BidRequest resolve(BidRequest bidRequest, String endpoint, boolean hasStoredBidRequest) { - checkBlacklistedApp(bidRequest); + checkBlocklistedApp(bidRequest); final HttpRequestContext httpRequest = auctionContext.getHttpRequest(); @@ -211,12 +211,12 @@ public static boolean isImpExtBidder(String field) { return !IMP_EXT_NON_BIDDER_FIELDS.contains(field); } - private void checkBlacklistedApp(BidRequest bidRequest) { + private void checkBlocklistedApp(BidRequest bidRequest) { final App app = bidRequest.getApp(); final String appId = app != null ? app.getId() : null; - if (StringUtils.isNotBlank(appId) && blacklistedApps.contains(appId)) { - throw new BlacklistedAppException( + if (StringUtils.isNotBlank(appId) && blocklistedApps.contains(appId)) { + throw new BlocklistedAppException( "Prebid-server does not process requests from App ID: " + appId); } } diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index 761bd1d8434..d738477edbf 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -26,7 +26,7 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.auction.model.debug.DebugContext; import org.prebid.server.cookie.UidsCookieService; -import org.prebid.server.exception.BlacklistedAccountException; +import org.prebid.server.exception.BlocklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -89,7 +89,7 @@ public class Ortb2RequestFactory { private final int timeoutAdjustmentFactor; private final double logSamplingRate; - private final List blacklistedAccounts; + private final List blocklistedAccounts; private final UidsCookieService uidsCookieService; private final ActivityInfrastructureCreator activityInfrastructureCreator; private final RequestValidator requestValidator; @@ -105,7 +105,7 @@ public class Ortb2RequestFactory { public Ortb2RequestFactory(int timeoutAdjustmentFactor, double logSamplingRate, - List blacklistedAccounts, + List blocklistedAccounts, UidsCookieService uidsCookieService, ActivityInfrastructureCreator activityInfrastructureCreator, RequestValidator requestValidator, @@ -125,7 +125,7 @@ public Ortb2RequestFactory(int timeoutAdjustmentFactor, this.timeoutAdjustmentFactor = timeoutAdjustmentFactor; this.logSamplingRate = logSamplingRate; - this.blacklistedAccounts = Objects.requireNonNull(blacklistedAccounts); + this.blocklistedAccounts = Objects.requireNonNull(blocklistedAccounts); this.uidsCookieService = Objects.requireNonNull(uidsCookieService); this.activityInfrastructureCreator = Objects.requireNonNull(activityInfrastructureCreator); this.requestValidator = Objects.requireNonNull(requestValidator); @@ -180,7 +180,7 @@ private Future fetchAccount(AuctionContext auctionContext, boolean isLo final HttpRequestContext httpRequest = auctionContext.getHttpRequest(); return findAccountIdFrom(bidRequest, isLookupStoredRequest) - .map(this::validateIfAccountBlacklisted) + .map(this::validateIfAccountBlocklisted) .compose(accountId -> loadAccount(timeout, httpRequest, accountId)); } @@ -423,13 +423,13 @@ private Future findAccountIdFrom(BidRequest bidRequest, boolean isLookup .map(storedAuctionResult -> accountIdFrom(storedAuctionResult.bidRequest())); } - private String validateIfAccountBlacklisted(String accountId) { - if (CollectionUtils.isNotEmpty(blacklistedAccounts) + private String validateIfAccountBlocklisted(String accountId) { + if (CollectionUtils.isNotEmpty(blocklistedAccounts) && StringUtils.isNotBlank(accountId) - && blacklistedAccounts.contains(accountId)) { + && blocklistedAccounts.contains(accountId)) { - throw new BlacklistedAccountException( - "Prebid-server has blacklisted Account ID: %s, please reach out to the prebid server host." + throw new BlocklistedAccountException( + "Prebid-server has blocklisted Account ID: %s, please reach out to the prebid server host." .formatted(accountId)); } return accountId; diff --git a/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java b/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java deleted file mode 100644 index afe1fdc4d2a..00000000000 --- a/src/main/java/org/prebid/server/exception/BlacklistedAccountException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.exception; - -public class BlacklistedAccountException extends RuntimeException { - - public BlacklistedAccountException(String message) { - super(message); - } -} diff --git a/src/main/java/org/prebid/server/exception/BlacklistedAppException.java b/src/main/java/org/prebid/server/exception/BlacklistedAppException.java deleted file mode 100644 index 53707383798..00000000000 --- a/src/main/java/org/prebid/server/exception/BlacklistedAppException.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.prebid.server.exception; - -public class BlacklistedAppException extends RuntimeException { - - public BlacklistedAppException(String message) { - super(message); - } -} diff --git a/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java b/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java new file mode 100644 index 00000000000..6f88b7b0a04 --- /dev/null +++ b/src/main/java/org/prebid/server/exception/BlocklistedAccountException.java @@ -0,0 +1,8 @@ +package org.prebid.server.exception; + +public class BlocklistedAccountException extends RuntimeException { + + public BlocklistedAccountException(String message) { + super(message); + } +} diff --git a/src/main/java/org/prebid/server/exception/BlocklistedAppException.java b/src/main/java/org/prebid/server/exception/BlocklistedAppException.java new file mode 100644 index 00000000000..7774a02334b --- /dev/null +++ b/src/main/java/org/prebid/server/exception/BlocklistedAppException.java @@ -0,0 +1,8 @@ +package org.prebid.server.exception; + +public class BlocklistedAppException extends RuntimeException { + + public BlocklistedAppException(String message) { + super(message); + } +} diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index b6fb1ea046c..f238694a593 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -28,8 +28,8 @@ import org.prebid.server.auction.requestfactory.AmpRequestFactory; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; @@ -322,11 +322,12 @@ private void handleResult(AsyncResult> respo status = HttpResponseStatus.UNAUTHORIZED; body = message; - } else if (exception instanceof BlacklistedAppException - || exception instanceof BlacklistedAccountException) { - metricRequestStatus = exception instanceof BlacklistedAccountException - ? MetricName.blacklisted_account : MetricName.blacklisted_app; - final String message = "Blacklisted: " + exception.getMessage(); + } else if (exception instanceof BlocklistedAppException + || exception instanceof BlocklistedAccountException) { + metricRequestStatus = exception instanceof BlocklistedAccountException + ? MetricName.blocklisted_account + : MetricName.blocklisted_app; + final String message = "Blocklisted: " + exception.getMessage(); logger.debug(message); errorMessages = Collections.singletonList(message); diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java index 4bbc18c53c3..e6523345399 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AuctionHandler.java @@ -15,8 +15,8 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.auction.requestfactory.AuctionRequestFactory; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -180,12 +180,12 @@ private void handleResult(AsyncResult responseResult, status = HttpResponseStatus.UNAUTHORIZED; body = message; - } else if (exception instanceof BlacklistedAppException - || exception instanceof BlacklistedAccountException) { - metricRequestStatus = exception instanceof BlacklistedAccountException - ? MetricName.blacklisted_account - : MetricName.blacklisted_app; - final String message = "Blacklisted: " + exception.getMessage(); + } else if (exception instanceof BlocklistedAppException + || exception instanceof BlocklistedAccountException) { + metricRequestStatus = exception instanceof BlocklistedAccountException + ? MetricName.blocklisted_account + : MetricName.blocklisted_app; + final String message = "Blocklisted: " + exception.getMessage(); logger.debug(message); errorMessages = Collections.singletonList(message); diff --git a/src/main/java/org/prebid/server/metric/MetricName.java b/src/main/java/org/prebid/server/metric/MetricName.java index dec0f38534a..fc9d3c251c3 100644 --- a/src/main/java/org/prebid/server/metric/MetricName.java +++ b/src/main/java/org/prebid/server/metric/MetricName.java @@ -62,8 +62,8 @@ public enum MetricName { nobid, gotbids, badinput, - blacklisted_account, - blacklisted_app, + blocklisted_account, + blocklisted_app, badserverresponse, failedtorequestbids, timeout, diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index edf2f45b665..c3cfbdd2747 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -277,7 +277,7 @@ Ortb2ImplicitParametersResolver ortb2ImplicitParametersResolver( @Value("${auction.cache.only-winning-bids}") boolean cacheOnlyWinningBids, @Value("${settings.generate-storedrequest-bidrequest-id}") boolean generateBidRequestId, @Value("${auction.ad-server-currency}") String adServerCurrency, - @Value("${auction.blacklisted-apps}") String blacklistedAppsString, + @Value("${auction.blocklisted-apps}") String blocklistedAppsString, @Value("${external-url}") String externalUrl, @Value("${gdpr.host-vendor-id:#{null}}") Integer hostVendorId, @Value("${datacenter-region}") String datacenterRegion, @@ -293,7 +293,7 @@ Ortb2ImplicitParametersResolver ortb2ImplicitParametersResolver( cacheOnlyWinningBids, generateBidRequestId, adServerCurrency, - splitToList(blacklistedAppsString), + splitToList(blocklistedAppsString), externalUrl, hostVendorId, datacenterRegion, @@ -356,7 +356,7 @@ SetuidGppService setuidGppService(GppService gppService) { @Bean Ortb2RequestFactory openRtb2RequestFactory( @Value("${auction.biddertmax.percent}") int timeoutAdjustmentFactor, - @Value("${auction.blacklisted-accounts}") String blacklistedAccountsString, + @Value("${auction.blocklisted-accounts}") String blocklistedAccountsString, UidsCookieService uidsCookieService, ActivityInfrastructureCreator activityInfrastructureCreator, RequestValidator requestValidator, @@ -370,12 +370,12 @@ Ortb2RequestFactory openRtb2RequestFactory( PriceFloorProcessor priceFloorProcessor, Metrics metrics) { - final List blacklistedAccounts = splitToList(blacklistedAccountsString); + final List blocklistedAccounts = splitToList(blocklistedAccountsString); return new Ortb2RequestFactory( timeoutAdjustmentFactor, logSamplingRate, - blacklistedAccounts, + blocklistedAccounts, uidsCookieService, activityInfrastructureCreator, requestValidator, @@ -505,7 +505,7 @@ VideoResponseFactory videoResponseFactory(JacksonMapper mapper) { @Bean VideoStoredRequestProcessor videoStoredRequestProcessor( @Value("${video.stored-request-required}") boolean enforceStoredRequest, - @Value("${auction.blacklisted-accounts}") String blacklistedAccountsString, + @Value("${auction.blocklisted-accounts}") String blocklistedAccountsString, @Value("${video.stored-requests-timeout-ms}") long defaultTimeoutMs, @Value("${auction.ad-server-currency:#{null}}") String adServerCurrency, @Value("${default-request.file.path:#{null}}") String defaultBidRequestPath, @@ -519,7 +519,7 @@ VideoStoredRequestProcessor videoStoredRequestProcessor( return new VideoStoredRequestProcessor( enforceStoredRequest, - splitToList(blacklistedAccountsString), + splitToList(blocklistedAccountsString), defaultTimeoutMs, adServerCurrency, defaultBidRequestPath, diff --git a/src/main/java/org/prebid/server/validation/VideoRequestValidator.java b/src/main/java/org/prebid/server/validation/VideoRequestValidator.java index 354db143e0a..be8c553d735 100644 --- a/src/main/java/org/prebid/server/validation/VideoRequestValidator.java +++ b/src/main/java/org/prebid/server/validation/VideoRequestValidator.java @@ -25,8 +25,10 @@ public class VideoRequestValidator { /** * Throws {@link InvalidRequestException} in case of invalid {@link BidRequestVideo}. */ - public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, boolean enforceStoredRequest, - List blacklistedAccounts) { + public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, + boolean enforceStoredRequest, + List blocklistedAccounts) { + if (enforceStoredRequest && StringUtils.isBlank(bidRequestVideo.getStoredrequestid())) { throw new InvalidRequestException("request missing required field: storedrequestid"); } @@ -44,7 +46,7 @@ public void validateStoredBidRequest(BidRequestVideo bidRequestVideo, boolean en } } - validateSiteAndApp(bidRequestVideo.getSite(), bidRequestVideo.getApp(), blacklistedAccounts); + validateSiteAndApp(bidRequestVideo.getSite(), bidRequestVideo.getApp(), blocklistedAccounts); validateVideo(bidRequestVideo.getVideo()); } @@ -53,7 +55,7 @@ private static boolean isZeroOrNegativeDuration(List durationRangeSec) .anyMatch(duration -> duration <= 0); } - private void validateSiteAndApp(Site site, App app, List blacklistedAccounts) { + private void validateSiteAndApp(Site site, App app, List blocklistedAccounts) { if (app == null && site == null) { throw new InvalidRequestException("request missing required field: site or app"); } else if (app != null && site != null) { @@ -64,7 +66,7 @@ private void validateSiteAndApp(Site site, App app, List blacklistedAcco final String appId = app.getId(); if (StringUtils.isNotBlank(appId)) { - if (blacklistedAccounts.contains(appId)) { + if (blocklistedAccounts.contains(appId)) { throw new InvalidRequestException("Prebid-server does not process requests from App ID: " + appId); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b899795f418..ea6fd14e6dc 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -102,8 +102,8 @@ adapter-defaults: allow: true auction: ad-server-currency: USD - blacklisted-accounts: - blacklisted-apps: + blocklisted-accounts: + blocklisted-apps: biddertmax: min: 50 max: 5000 diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java index 022cb2f33e3..bee92aea095 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2ImplicitParametersResolverTest.java @@ -34,7 +34,7 @@ import org.prebid.server.auction.model.IpAddress; import org.prebid.server.auction.model.SecBrowsingTopic; import org.prebid.server.auction.model.debug.DebugContext; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.identity.IdGenerator; @@ -2469,14 +2469,14 @@ public void shouldPassExtPrebidServer() { } @Test - public void shouldReturnFailedFutureWhenAppIdIsBlacklisted() { + public void shouldReturnFailedFutureWhenAppIdIsBlocklisted() { // given final BidRequest bidRequest = BidRequest.builder() .app(App.builder().id("bad_app").build()) .build(); // when and then - assertThatExceptionOfType(BlacklistedAppException.class) + assertThatExceptionOfType(BlocklistedAppException.class) .isThrownBy(() -> target.resolve(bidRequest, auctionContext, ENDPOINT, false)) .withMessage("Prebid-server does not process requests from App ID: bad_app"); } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java index 8791ac5eabf..98f172faee3 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java @@ -33,7 +33,7 @@ import org.prebid.server.cookie.UidsCookie; import org.prebid.server.cookie.UidsCookieService; import org.prebid.server.cookie.proto.Uids; -import org.prebid.server.exception.BlacklistedAccountException; +import org.prebid.server.exception.BlocklistedAccountException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.PreBidException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -100,7 +100,7 @@ public class Ortb2RequestFactoryTest extends VertxTest { - private static final List BLACKLISTED_ACCOUNTS = singletonList("bad_acc"); + private static final List BLOCKLISTED_ACCOUNTS = singletonList("bad_acc"); @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -262,7 +262,7 @@ public void fetchAccountShouldReturnFailedFutureIfAccountIsInactive() { } @Test - public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlacklisted() { + public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlocklisted() { // given final BidRequest bidRequest = givenBidRequest(builder -> builder .site(Site.builder() @@ -279,8 +279,8 @@ public void fetchAccountShouldReturnFailedFutureWhenAccountIdIsBlacklisted() { // then assertThat(result.failed()).isTrue(); assertThat(result.cause()) - .isInstanceOf(BlacklistedAccountException.class) - .hasMessage("Prebid-server has blacklisted Account ID: bad_acc, please reach out to the prebid " + .isInstanceOf(BlocklistedAccountException.class) + .hasMessage("Prebid-server has blocklisted Account ID: bad_acc, please reach out to the prebid " + "server host."); } @@ -482,7 +482,7 @@ public void shouldFetchAccountFromStoredIfStoredLookupIsTrueAndAccountIsNotFound } @Test - public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlacklisted() { + public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlocklisted() { // given final BidRequest receivedBidRequest = givenBidRequest(identity()); @@ -507,8 +507,8 @@ public void shouldFetchAccountFromStoredAndReturnFailedFutureWhenAccountIdIsBlac assertThat(result.failed()).isTrue(); assertThat(result.cause()) - .isInstanceOf(BlacklistedAccountException.class) - .hasMessage("Prebid-server has blacklisted Account ID: bad_acc, please reach out to the prebid " + .isInstanceOf(BlocklistedAccountException.class) + .hasMessage("Prebid-server has blocklisted Account ID: bad_acc, please reach out to the prebid " + "server host."); } @@ -1613,7 +1613,7 @@ private void givenTarget(int timeoutAdjustmentFactor) { target = new Ortb2RequestFactory( timeoutAdjustmentFactor, 0.01, - BLACKLISTED_ACCOUNTS, + BLOCKLISTED_ACCOUNTS, uidsCookieService, activityInfrastructureCreator, requestValidator, diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java index 502f13fccc6..a64ea4b05dc 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AmpHandlerTest.java @@ -35,8 +35,8 @@ import org.prebid.server.bidder.Bidder; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -281,10 +281,10 @@ public void shouldRespondWithBadRequestIfRequestIsInvalid() { } @Test - public void shouldRespondWithBadRequestIfRequestHasBlacklistedAccount() { + public void shouldRespondWithBadRequestIfRequestHasBlocklistedAccount() { // given given(ampRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAccountException("Blacklisted account"))); + .willReturn(Future.failedFuture(new BlocklistedAccountException("Blocklisted account"))); // when ampHandler.handle(routingContext); @@ -298,14 +298,14 @@ public void shouldRespondWithBadRequestIfRequestHasBlacklistedAccount() { tuple("AMP-Access-Control-Allow-Source-Origin", "http://example.com"), tuple("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin"), tuple("x-prebid", "pbs-java/1.00")); - verify(httpResponse).end(eq("Blacklisted: Blacklisted account")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted account")); } @Test - public void shouldRespondWithBadRequestIfRequestHasBlacklistedApp() { + public void shouldRespondWithBadRequestIfRequestHasBlocklistedApp() { // given given(ampRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAppException("Blacklisted app"))); + .willReturn(Future.failedFuture(new BlocklistedAppException("Blocklisted app"))); // when ampHandler.handle(routingContext); @@ -319,7 +319,7 @@ public void shouldRespondWithBadRequestIfRequestHasBlacklistedApp() { tuple("AMP-Access-Control-Allow-Source-Origin", "http://example.com"), tuple("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin"), tuple("x-prebid", "pbs-java/1.00")); - verify(httpResponse).end(eq("Blacklisted: Blacklisted app")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted app")); } @Test diff --git a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java index 14f83a310f9..da34965c6ef 100644 --- a/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java +++ b/src/test/java/org/prebid/server/handler/openrtb2/AuctionHandlerTest.java @@ -26,8 +26,8 @@ import org.prebid.server.auction.model.TimeoutContext; import org.prebid.server.auction.requestfactory.AuctionRequestFactory; import org.prebid.server.cookie.UidsCookie; -import org.prebid.server.exception.BlacklistedAccountException; -import org.prebid.server.exception.BlacklistedAppException; +import org.prebid.server.exception.BlocklistedAccountException; +import org.prebid.server.exception.BlocklistedAppException; import org.prebid.server.exception.InvalidAccountConfigException; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.exception.UnauthorizedAccountException; @@ -238,19 +238,19 @@ public void shouldComputeTimeoutBasedOnRequestProcessingStartTime() { } @Test - public void shouldRespondWithServiceUnavailableIfBidRequestHasAccountBlacklisted() { + public void shouldRespondWithServiceUnavailableIfBidRequestHasAccountBlocklisted() { // given given(auctionRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAccountException("Blacklisted account"))); + .willReturn(Future.failedFuture(new BlocklistedAccountException("Blocklisted account"))); // when auctionHandler.handle(routingContext); // then verify(httpResponse).setStatusCode(eq(403)); - verify(httpResponse).end(eq("Blacklisted: Blacklisted account")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted account")); - verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blacklisted_account)); + verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blocklisted_account)); } @Test @@ -270,19 +270,19 @@ public void shouldRespondWithBadRequestIfBidRequestHasAccountWithInvalidConfig() } @Test - public void shouldRespondWithServiceUnavailableIfBidRequestHasAppBlacklisted() { + public void shouldRespondWithServiceUnavailableIfBidRequestHasAppBlocklisted() { // given given(auctionRequestFactory.fromRequest(any(), anyLong())) - .willReturn(Future.failedFuture(new BlacklistedAppException("Blacklisted app"))); + .willReturn(Future.failedFuture(new BlocklistedAppException("Blocklisted app"))); // when auctionHandler.handle(routingContext); // then verify(httpResponse).setStatusCode(eq(403)); - verify(httpResponse).end(eq("Blacklisted: Blacklisted app")); + verify(httpResponse).end(eq("Blocklisted: Blocklisted app")); - verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blacklisted_app)); + verify(metrics).updateRequestTypeMetric(eq(MetricName.openrtb2web), eq(MetricName.blocklisted_app)); } @Test diff --git a/src/test/java/org/prebid/server/metric/MetricsTest.java b/src/test/java/org/prebid/server/metric/MetricsTest.java index e06847c7386..b320e2e8d53 100644 --- a/src/test/java/org/prebid/server/metric/MetricsTest.java +++ b/src/test/java/org/prebid/server/metric/MetricsTest.java @@ -388,16 +388,16 @@ public void updateRequestTimeMetricShouldUpdateMetric() { public void updateRequestTypeMetricShouldIncrementMetric() { // when metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.ok); - metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.blacklisted_account); - metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.blacklisted_app); + metrics.updateRequestTypeMetric(MetricName.openrtb2web, MetricName.blocklisted_account); + metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.blocklisted_app); metrics.updateRequestTypeMetric(MetricName.openrtb2app, MetricName.err); metrics.updateRequestTypeMetric(MetricName.amp, MetricName.badinput); metrics.updateRequestTypeMetric(MetricName.amp, MetricName.networkerr); // then assertThat(metricRegistry.counter("requests.ok.openrtb2-web").getCount()).isOne(); - assertThat(metricRegistry.counter("requests.blacklisted_account.openrtb2-web").getCount()).isOne(); - assertThat(metricRegistry.counter("requests.blacklisted_app.openrtb2-app").getCount()).isOne(); + assertThat(metricRegistry.counter("requests.blocklisted_account.openrtb2-web").getCount()).isOne(); + assertThat(metricRegistry.counter("requests.blocklisted_app.openrtb2-app").getCount()).isOne(); assertThat(metricRegistry.counter("requests.err.openrtb2-app").getCount()).isOne(); assertThat(metricRegistry.counter("requests.badinput.amp").getCount()).isOne(); assertThat(metricRegistry.counter("requests.networkerr.amp").getCount()).isOne(); diff --git a/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java b/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java index 615b117a3ab..51985f786b3 100644 --- a/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/VideoRequestValidatorTest.java @@ -123,7 +123,7 @@ public void validateStoredBidRequestShouldThrowExceptionWhenSiteHaveNoId() { } @Test - public void validateStoredBidRequestShouldThrowExceptionWhenAppHaveBlacklistedAccount() { + public void validateStoredBidRequestShouldThrowExceptionWhenAppHaveBlocklistedAccount() { // given final BidRequestVideo requestVideo = givenBidRequestVideo( requestBuilder -> requestBuilder.site(null).app(App.builder().id("BAD").build()), From e4b97d0148c6acc5e5edbc8c8122072656b5e5d2 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 17:43:36 +0300 Subject: [PATCH 34/58] Core: Set `strict-app-site-dooh` to `true` (#3153) --- src/main/resources/application.yaml | 2 +- .../server/functional/tests/MetricsSpec.groovy | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ea6fd14e6dc..e85b4a9de5c 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -125,7 +125,7 @@ auction: secure-markup: skip host-schain-node: category-mapping-enabled: false - strict-app-site-dooh: false + strict-app-site-dooh: true video: stored-request-required: false stored-requests-timeout-ms: 90 diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index ae3795ca1f8..c1740646811 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Dooh import org.prebid.server.functional.model.request.auction.Site import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.service.PrebidServerService import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.BASIC import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.DETAILED @@ -16,8 +17,11 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class MetricsSpec extends BaseSpec { + private final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) + def setup() { flushMetrics(defaultPbsService) + flushMetrics(softPrebidService) } def "PBS should not populate account metric when verbosity level is none"() { @@ -113,7 +117,7 @@ class MetricsSpec extends BaseSpec { assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] } - def "PBS should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { + def "PBS with soft setup should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { given: "Default bid request with dooh and site" def bidRequest = BidRequest.defaultBidRequest.tap { dooh = Dooh.defaultDooh @@ -126,7 +130,7 @@ class MetricsSpec extends BaseSpec { accountDao.save(account) when: "Requesting PBS auction" - defaultPbsService.sendAuctionRequest(bidRequest) + softPrebidService.sendAuctionRequest(bidRequest) then: "Bidder request should have only dooh data" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -134,7 +138,7 @@ class MetricsSpec extends BaseSpec { assert !bidderRequest.site and: "Metrics processed across site should be updated" - def metrics = defaultPbsService.sendCollectedMetricsRequest() + def metrics = softPrebidService.sendCollectedMetricsRequest() assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 @@ -146,7 +150,7 @@ class MetricsSpec extends BaseSpec { assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] } - def "PBS should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { + def "PBS with soft setup should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { given: "Account in the DB" def accountId = bidRequest.app.publisher.id def accountMetricsConfig = new AccountConfig(metrics: new AccountMetricsConfig(verbosityLevel: DETAILED)) @@ -154,7 +158,7 @@ class MetricsSpec extends BaseSpec { accountDao.save(account) when: "Requesting PBS auction" - defaultPbsService.sendAuctionRequest(bidRequest) + softPrebidService.sendAuctionRequest(bidRequest) then: "Bidder request should have only site data" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -163,7 +167,7 @@ class MetricsSpec extends BaseSpec { assert !bidderRequest.dooh and: "Metrics processed across site should be updated" - def metrics = defaultPbsService.sendCollectedMetricsRequest() + def metrics = softPrebidService.sendCollectedMetricsRequest() assert metrics["account.${accountId}.requests.type.openrtb2-app" as String] == 1 assert metrics["adapter.generic.requests.type.openrtb2-app" as String] == 1 From e895d458ec0d973145b44805d13d09e77a65f173 Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Tue, 7 May 2024 17:46:33 +0300 Subject: [PATCH 35/58] Core: Fix source text in jackson error output (#3121) --- .../java/org/prebid/server/json/ObjectMapperProvider.java | 5 ++++- .../org/prebid/server/auction/BidResponseCreatorTest.java | 5 ++--- .../server/bidder/adtelligent/AdtelligentBidderTest.java | 7 ++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/prebid/server/json/ObjectMapperProvider.java b/src/main/java/org/prebid/server/json/ObjectMapperProvider.java index 96189d6706f..fc1bcea0611 100644 --- a/src/main/java/org/prebid/server/json/ObjectMapperProvider.java +++ b/src/main/java/org/prebid/server/json/ObjectMapperProvider.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.StreamReadFeature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -17,7 +18,9 @@ public final class ObjectMapperProvider { MAPPER = JsonMapper.builder().configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) - .enable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN).build() + .enable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN) + .enable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION) + .build() .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .registerModule(new BlackbirdModule()) diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index f96251f16be..58a9386de55 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -2652,8 +2652,7 @@ public void shouldPopulateBidResponseExtension() { ExtBidderError.of(3, "Failed to decode: Cannot deserialize value" + " of type `com.iab.openrtb.response.Response` from Array value " + "(token `JsonToken.START_ARRAY`)\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION`" - + " disabled); line: 1, column: 1]"))), + + " at [Source: (String)\"[]\"; line: 1, column: 1]"))), entry("cache", singletonList(ExtBidderError.of(999, "cacheError")))); assertThat(responseExt.getResponsetimemillis()).hasSize(2) @@ -3151,7 +3150,7 @@ public void shouldThrowExceptionWhenNativeRequestIsInvalid() throws JsonProcessi .extracting(error -> error.get(bidder1)) .extracting(extBidderErrors -> extBidderErrors.get(0)) .isEqualTo(ExtBidderError.of(3, "No content to map due to end-of-input\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1]")); + + " at [Source: (String)\"\"; line: 1, column: 0]")); } @Test diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index 2628aabb755..73622242460 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -402,11 +402,8 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( "Failed to decode: Unexpected end-of-input: expected close marker" - + " for Object (start marker at [Source: REDACTED " - + "(`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); " - + "line: 1, column: 1])\n" - + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled);" - + " line: 1, column: 2]")); + + " for Object (start marker at [Source: (String)\"{\"; line: 1, column: 1])\n" + + " at [Source: (String)\"{\"; line: 1, column: 2]")); } private static BidderCall givenHttpCall(String body) { From bc76b28ac2ebed83954dd9089b8cd005336d730c Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Tue, 7 May 2024 17:56:52 +0300 Subject: [PATCH 36/58] Core: Always merge account config for purpose1 (#3155) --- .../java/org/prebid/server/privacy/gdpr/Tcf2Service.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java b/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java index f2369e6247f..3134f33e91d 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/Tcf2Service.java @@ -100,21 +100,23 @@ private Future> permissionsForInternal(Collection vendorPermissionsByType = toVendorPermissionsByType(vendorPermissions, accountGdprConfig); - // TODO: always merge account config for purpose1 with next major release return versionedVendorListService.forConsent(tcfConsent) .compose(vendorGvlPermissions -> processSupportedPurposeStrategies( tcfConsent, wrapWithGVL(vendorPermissionsByType, vendorGvlPermissions), mergedPurposes, - purposeOneTreatmentInterpretation), + mergedPurposeOneTreatmentInterpretation), ignored -> processDowngradedSupportedPurposeStrategies( tcfConsent, wrapWithGVL(vendorPermissionsByType, Collections.emptyMap()), mergedPurposes, - mergePurposeOneTreatmentInterpretation(accountGdprConfig))) + mergedPurposeOneTreatmentInterpretation)) .map(ignored -> enforcePurpose4IfRequired(mergedPurposes, vendorPermissionsByType)) .map(ignored -> processSupportedSpecialFeatureStrategies( tcfConsent, From d5af622b2bdab526e1752a3afe62be24c7c6e45b Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Wed, 8 May 2024 13:26:17 +0300 Subject: [PATCH 37/58] Core: Remove deprecated `auction.max-timeout-ms` property (#3158) --- docs/config-app.md | 1 - .../spring/config/ServiceConfiguration.java | 16 +--------------- .../server/functional/tests/AuctionSpec.groovy | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/docs/config-app.md b/docs/config-app.md index 5e3ee1192d4..f162efff719 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -77,7 +77,6 @@ Removes and downloads file again if depending service cant process probably corr ## Auction (OpenRTB) - `auction.blocklisted-accounts` - comma separated list of blocklisted account IDs. - `auction.blocklisted-apps` - comma separated list of blocklisted applications IDs, requests from which should not be processed. -- `auction.max-timeout-ms` - maximum operation timeout for OpenRTB Auction requests. Deprecated. - `auction.biddertmax.min` - minimum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.max` - maximum operation timeout for OpenRTB Auction requests. - `auction.biddertmax.percent` - adjustment factor for `request.tmax` for bidders. diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index c3cfbdd2747..719f9aee0df 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -239,24 +239,10 @@ SupplyChainResolver schainResolver( @Bean TimeoutResolver auctionTimeoutResolver( @Value("${auction.biddertmax.min}") long minTimeout, - @Value("${auction.max-timeout-ms:#{0}}") long maxTimeoutDeprecated, @Value("${auction.biddertmax.max:#{0}}") long maxTimeout, @Value("${auction.tmax-upstream-response-time}") long upstreamResponseTime) { - return new TimeoutResolver( - minTimeout, - resolveMaxTimeout(maxTimeoutDeprecated, maxTimeout), - upstreamResponseTime); - } - - // TODO: Remove after transition period - private static long resolveMaxTimeout(long maxTimeoutDeprecated, long maxTimeout) { - if (maxTimeout != 0) { - return maxTimeout; - } - - logger.warn("Usage of deprecated property: auction.max-timeout-ms. Use auction.biddertmax.max instead."); - return maxTimeoutDeprecated; + return new TimeoutResolver(minTimeout, maxTimeout, upstreamResponseTime); } @Bean diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index cfab2bafde1..268c66e182e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -45,7 +45,7 @@ class AuctionSpec extends BaseSpec { private static final boolean CORS_SUPPORT = false private static final UserSyncInfo.Type USER_SYNC_TYPE = REDIRECT private static final int DEFAULT_TIMEOUT = getRandomTimeout() - private static final Map PBS_CONFIG = ["auction.max-timeout-ms" : MAX_TIMEOUT as String, + private static final Map PBS_CONFIG = ["auction.biddertmax.max" : MAX_TIMEOUT as String, "auction.default-timeout-ms": DEFAULT_TIMEOUT as String] private static final Map GENERIC_CONFIG = [ "adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL, From 6aabd8b65a87006b2516e0ce4918b14d82b11ccf Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Wed, 8 May 2024 07:37:45 -0400 Subject: [PATCH 38/58] Dependencies: Bump IAB GPP library (#3127) --- pom.xml | 2 +- .../privacy/PrivacySection.java | 24 +- .../reader/USCaliforniaGppReader.java | 34 +- .../reader/USColoradoGppReader.java | 32 +- .../reader/USConnecticutGppReader.java | 32 +- .../uscustomlogic/reader/USUtahGppReader.java | 30 +- .../reader/USVirginiaGppReader.java | 28 +- .../reader/USMappedCaliforniaGppReader.java | 30 +- .../reader/USMappedColoradoGppReader.java | 30 +- .../reader/USMappedConnecticutGppReader.java | 32 +- .../usnat/reader/USMappedUtahGppReader.java | 28 +- .../reader/USMappedVirginiaGppReader.java | 26 +- .../usnat/reader/USNationalGppReader.java | 42 +- .../model/config/GppModuleConfig.groovy | 2 +- .../config/UsNationalPrivacySection.groovy | 61 +- .../model/request/GppSectionId.groovy | 24 +- .../tests/privacy/ActivityTraceLogSpec.groovy | 15 +- .../tests/privacy/GppAmpSpec.groovy | 6 +- .../tests/privacy/GppAuctionSpec.groovy | 8 +- .../tests/privacy/GppCookieSyncSpec.groovy | 4 +- .../privacy/GppFetchBidActivitiesSpec.groovy | 321 ++++----- .../tests/privacy/GppSetUidSpec.groovy | 8 +- .../privacy/GppSyncUserActivitiesSpec.groovy | 512 ++++++++------ .../GppTransmitEidsActivitiesSpec.groovy | 598 +++++++++++------ ...GppTransmitPreciseGeoActivitiesSpec.groovy | 373 ++++++----- .../GppTransmitUfpdActivitiesSpec.groovy | 628 ++++++++++++------ .../tests/privacy/PrivacyBaseSpec.groovy | 4 +- .../util/privacy/gpp/GppConsent.groovy | 28 +- ...aV1Consent.groovy => UsCaV1Consent.groovy} | 40 +- ...oV1Consent.groovy => UsCoV1Consent.groovy} | 40 +- ...tV1Consent.groovy => UsCtV1Consent.groovy} | 38 +- ...V1Consent.groovy => UsNatV1Consent.groovy} | 50 +- ...tV1Consent.groovy => UsUtV1Consent.groovy} | 36 +- ...UspV1Consent.groovy => UsV1Consent.groovy} | 8 +- ...aV1Consent.groovy => UsVaV1Consent.groovy} | 32 +- .../reader/USCaliforniaGppReaderTest.java | 44 +- .../reader/USColoradoGppReaderTest.java | 44 +- .../reader/USConnecticutGppReaderTest.java | 44 +- .../reader/USUtahGppReaderTest.java | 44 +- .../reader/USVirginiaGppReaderTest.java | 44 +- .../USMappedCaliforniaGppReaderTest.java | 46 +- .../reader/USMappedColoradoGppReaderTest.java | 48 +- .../USMappedConnecticutGppReaderTest.java | 48 +- .../reader/USMappedUtahGppReaderTest.java | 48 +- .../reader/USMappedVirginiaGppReaderTest.java | 48 +- .../usnat/reader/USNationalGppReaderTest.java | 44 +- .../gpp/model/GppContextCreatorTest.java | 2 +- 47 files changed, 2124 insertions(+), 1586 deletions(-) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCaV1Consent.groovy => UsCaV1Consent.groovy} (56%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCoV1Consent.groovy => UsCoV1Consent.groovy} (55%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspCtV1Consent.groovy => UsCtV1Consent.groovy} (56%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspNatV1Consent.groovy => UsNatV1Consent.groovy} (54%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspUtV1Consent.groovy => UsUtV1Consent.groovy} (54%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspV1Consent.groovy => UsV1Consent.groovy} (80%) rename src/test/groovy/org/prebid/server/functional/util/privacy/gpp/{UspVaV1Consent.groovy => UsVaV1Consent.groovy} (56%) diff --git a/pom.xml b/pom.xml index d24b162dfbb..aee1ffd7d5e 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ 2.0.2 2.0.10 2.12.0 - 3.0.10 + 3.2.0 3.21.7 3.17.3 1.0.7 diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java index a35982c532d..3e081a6310e 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/PrivacySection.java @@ -1,22 +1,22 @@ package org.prebid.server.activity.infrastructure.privacy; -import com.iab.gpp.encoder.section.UspCaV1; -import com.iab.gpp.encoder.section.UspCoV1; -import com.iab.gpp.encoder.section.UspCtV1; -import com.iab.gpp.encoder.section.UspNatV1; -import com.iab.gpp.encoder.section.UspUtV1; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsCaV1; +import com.iab.gpp.encoder.section.UsCoV1; +import com.iab.gpp.encoder.section.UsCtV1; +import com.iab.gpp.encoder.section.UsNatV1; +import com.iab.gpp.encoder.section.UsUtV1; +import com.iab.gpp.encoder.section.UsVaV1; import java.util.Set; public enum PrivacySection { - NATIONAL(UspNatV1.ID), - CALIFORNIA(UspCaV1.ID), - VIRGINIA(UspVaV1.ID), - COLORADO(UspCoV1.ID), - UTAH(UspUtV1.ID), - CONNECTICUT(UspCtV1.ID); + NATIONAL(UsNatV1.ID), + CALIFORNIA(UsCaV1.ID), + VIRGINIA(UsVaV1.ID), + COLORADO(UsCoV1.ID), + UTAH(UsUtV1.ID), + CONNECTICUT(UsCtV1.ID); public static final Set US_PRIVACY_SECTIONS = Set.of( NATIONAL, diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java index 5ac3e9601a5..963f50ab2b1 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,20 +9,20 @@ public class USCaliforniaGppReader implements USCustomLogicGppReader { - private final UspCaV1 consent; + private final UsCaV1 consent; public USCaliforniaGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCaV1Section() : null; + consent = gppModel != null ? gppModel.getUsCaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpc); } @Override @@ -32,17 +32,17 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOutNotice); } @Override @@ -52,12 +52,12 @@ public Integer getSharingNotice() { @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOutNotice); } @Override @@ -72,12 +72,12 @@ public Integer getTargetedAdvertisingOptOutNotice() { @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataLimitUseNotice); } @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataProcessing); } @Override @@ -87,26 +87,26 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getKnownChildSensitiveDataConsents); } @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java index 8a6d1c457e4..bdc3889f6e0 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReader.java @@ -2,7 +2,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -10,20 +10,20 @@ public class USColoradoGppReader implements USCustomLogicGppReader { - private final UspCoV1 consent; + private final UsCoV1 consent; public USColoradoGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCoV1Section() : null; + consent = gppModel != null ? gppModel.getUsCoV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpc); } @Override @@ -33,22 +33,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSharingNotice); } @Override @@ -63,12 +63,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -78,7 +78,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSensitiveDataProcessing); } @Override @@ -88,7 +88,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getKnownChildSensitiveDataConsents); } @Override @@ -98,16 +98,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java index 9c617577099..d7d588926f8 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,20 +9,20 @@ public class USConnecticutGppReader implements USCustomLogicGppReader { - private final UspCtV1 consent; + private final UsCtV1 consent; public USConnecticutGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCtV1Section() : null; + consent = gppModel != null ? gppModel.getUsCtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpc); } @Override @@ -32,22 +32,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,7 +77,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSensitiveDataProcessing); } @Override @@ -87,7 +87,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java index d9c768c7dc3..3f34d024b35 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,15 +9,15 @@ public class USUtahGppReader implements USCustomLogicGppReader { - private final UspUtV1 consent; + private final UsUtV1 consent; public USUtahGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspUtV1Section() : null; + consent = gppModel != null ? gppModel.getUsUtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getVersion); } @Override @@ -37,17 +37,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,17 +77,17 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessing); } @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessingOptOutNotice); } @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java index a07986e4160..cccb0186946 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.util.ObjectUtil; @@ -9,15 +9,15 @@ public class USVirginiaGppReader implements USCustomLogicGppReader { - private final UspVaV1 consent; + private final UsVaV1 consent; public USVirginiaGppReader(GppModel gppModel) { - this.consent = gppModel != null ? gppModel.getUspVaV1Section() : null; + this.consent = gppModel != null ? gppModel.getUsVaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getVersion); } @Override @@ -37,17 +37,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSharingNotice); } @Override @@ -62,12 +62,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -77,7 +77,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSensitiveDataProcessing); } @Override @@ -87,7 +87,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public Integer getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getKnownChildSensitiveDataConsents); } @Override @@ -97,16 +97,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java index 637685b774e..81878e5d908 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -15,20 +15,20 @@ public class USMappedCaliforniaGppReader implements USNatGppReader, USCustomLogi private static final List DEFAULT_SENSITIVE_DATA = Collections.nCopies(12, null); private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); - private final UspCaV1 consent; + private final UsCaV1 consent; public USMappedCaliforniaGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCaV1Section() : null; + consent = gppModel != null ? gppModel.getUsCaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpc); } @Override @@ -38,17 +38,17 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSaleOptOutNotice); } @Override @@ -58,12 +58,12 @@ public Integer getSharingNotice() { @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSharingOptOutNotice); } @Override @@ -78,7 +78,7 @@ public Integer getTargetedAdvertisingOptOutNotice() { @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getSensitiveDataLimitUseNotice); } @Override @@ -117,21 +117,21 @@ public List getKnownChildSensitiveDataConsents() { @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java index 6ea4eefce91..b9505a7c458 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -13,20 +13,20 @@ public class USMappedColoradoGppReader implements USNatGppReader, USCustomLogicG private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspCoV1 consent; + private final UsCoV1 consent; public USMappedColoradoGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCoV1Section() : null; + consent = gppModel != null ? gppModel.getUsCoV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpc); } @Override @@ -36,22 +36,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSharingNotice); } @Override @@ -66,12 +66,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -81,7 +81,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getSensitiveDataProcessing); } @Override @@ -108,16 +108,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCoV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCoV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java index 10a24f3f26f..8309e75ebc1 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -15,20 +15,20 @@ public class USMappedConnecticutGppReader implements USNatGppReader, USCustomLog private static final List MIXED_CHILD_SENSITIVE_DATA = List.of(2, 1); private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); - private final UspCtV1 consent; + private final UsCtV1 consent; public USMappedConnecticutGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspCtV1Section() : null; + consent = gppModel != null ? gppModel.getUsCtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpc); } @Override @@ -38,22 +38,22 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSharingNotice); } @Override @@ -68,12 +68,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -83,7 +83,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getSensitiveDataProcessing); } @Override @@ -94,7 +94,7 @@ public Integer getSensitiveDataProcessingOptOutNotice() { @Override public List getKnownChildSensitiveDataConsents() { final List originalData = ObjectUtil.getIfNotNull( - consent, UspCtV1::getKnownChildSensitiveDataConsents); + consent, UsCtV1::getKnownChildSensitiveDataConsents); final Integer first = originalData != null ? originalData.get(0) : null; final Integer second = originalData != null ? originalData.get(1) : null; @@ -116,16 +116,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspCtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsCtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java index d808c96784f..527a87288f7 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -17,15 +17,15 @@ public class USMappedUtahGppReader implements USNatGppReader, USCustomLogicGppRe private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspUtV1 consent; + private final UsUtV1 consent; public USMappedUtahGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspUtV1Section() : null; + consent = gppModel != null ? gppModel.getUsUtV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getVersion); } @Override @@ -45,17 +45,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSharingNotice); } @Override @@ -70,12 +70,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -86,7 +86,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { final List originalData = Optional.ofNullable(consent) - .map(UspUtV1::getSensitiveDataProcessing) + .map(UsUtV1::getSensitiveDataProcessing) .orElse(DEFAULT_SENSITIVE_DATA_PROCESSING); final List data = new ArrayList<>(DEFAULT_SENSITIVE_DATA_PROCESSING); @@ -104,7 +104,7 @@ public List getSensitiveDataProcessing() { @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getSensitiveDataProcessingOptOutNotice); } @Override @@ -126,16 +126,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspUtV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsUtV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java index 97abfef6331..739762666ea 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -13,15 +13,15 @@ public class USMappedVirginiaGppReader implements USNatGppReader, USCustomLogicG private static final List CHILD_SENSITIVE_DATA = List.of(1, 1); private static final List NON_CHILD_SENSITIVE_DATA = List.of(0, 0); - private final UspVaV1 consent; + private final UsVaV1 consent; public USMappedVirginiaGppReader(GppModel gppModel) { - this.consent = gppModel != null ? gppModel.getUspVaV1Section() : null; + this.consent = gppModel != null ? gppModel.getUsVaV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getVersion); } @Override @@ -41,17 +41,17 @@ public Boolean getGpcSegmentIncluded() { @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSharingNotice); } @Override @@ -66,12 +66,12 @@ public Integer getSharingOptOutNotice() { @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getTargetedAdvertisingOptOutNotice); } @Override @@ -81,7 +81,7 @@ public Integer getSensitiveDataLimitUseNotice() { @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getSensitiveDataProcessing); } @Override @@ -108,16 +108,16 @@ public Integer getPersonalDataConsents() { @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspVaV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsVaV1::getMspaOptOutOptionMode); } } diff --git a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java index 8e5332fd979..11dec8ebbc2 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReader.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspNatV1; +import com.iab.gpp.encoder.section.UsNatV1; import org.prebid.server.activity.infrastructure.privacy.uscustomlogic.USCustomLogicGppReader; import org.prebid.server.activity.infrastructure.privacy.usnat.USNatGppReader; import org.prebid.server.util.ObjectUtil; @@ -10,20 +10,20 @@ public class USNationalGppReader implements USNatGppReader, USCustomLogicGppReader { - private final UspNatV1 consent; + private final UsNatV1 consent; public USNationalGppReader(GppModel gppModel) { - consent = gppModel != null ? gppModel.getUspNatV1Section() : null; + consent = gppModel != null ? gppModel.getUsNatV1Section() : null; } @Override public Integer getVersion() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getVersion); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getVersion); } @Override public Boolean getGpc() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getGpc); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getGpc); } @Override @@ -37,81 +37,81 @@ public Boolean getGpcSegmentType() { @Override public Boolean getGpcSegmentIncluded() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getGpcSegmentIncluded); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getGpcSegmentIncluded); } @Override public Integer getSaleOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSaleOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSaleOptOut); } @Override public Integer getSaleOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSaleOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSaleOptOutNotice); } @Override public Integer getSharingNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingNotice); } @Override public Integer getSharingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingOptOut); } @Override public Integer getSharingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSharingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSharingOptOutNotice); } @Override public Integer getTargetedAdvertisingOptOut() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getTargetedAdvertisingOptOut); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getTargetedAdvertisingOptOut); } @Override public Integer getTargetedAdvertisingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getTargetedAdvertisingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getTargetedAdvertisingOptOutNotice); } @Override public Integer getSensitiveDataLimitUseNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataLimitUseNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataLimitUseNotice); } @Override public List getSensitiveDataProcessing() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataProcessing); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataProcessing); } @Override public Integer getSensitiveDataProcessingOptOutNotice() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getSensitiveDataProcessingOptOutNotice); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getSensitiveDataProcessingOptOutNotice); } @Override public List getKnownChildSensitiveDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getKnownChildSensitiveDataConsents); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getKnownChildSensitiveDataConsents); } @Override public Integer getPersonalDataConsents() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getPersonalDataConsents); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getPersonalDataConsents); } @Override public Integer getMspaCoveredTransaction() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaCoveredTransaction); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaCoveredTransaction); } @Override public Integer getMspaServiceProviderMode() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaServiceProviderMode); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaServiceProviderMode); } @Override public Integer getMspaOptOutOptionMode() { - return ObjectUtil.getIfNotNull(consent, UspNatV1::getMspaOptOutOptionMode); + return ObjectUtil.getIfNotNull(consent, UsNatV1::getMspaOptOutOptionMode); } } diff --git a/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy b/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy index 3ac38525dc7..be7a710ce44 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy @@ -12,7 +12,7 @@ class GppModuleConfig { List skipSids static GppModuleConfig getDefaultModuleConfig(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules, - List sids = [GppSectionId.USP_NAT_V1], + List sids = [GppSectionId.US_NAT_V1], Boolean normalizeFlags = true) { new GppModuleConfig().tap { it.activityConfig = [activityConfig] diff --git a/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy b/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy index caab68873e0..d5733707955 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/UsNationalPrivacySection.groovy @@ -1,40 +1,39 @@ package org.prebid.server.functional.model.config import com.fasterxml.jackson.annotation.JsonValue -import com.iab.gpp.encoder.field.UspNatV1Field -import org.prebid.server.functional.util.PBSUtils +import com.iab.gpp.encoder.field.UsNatV1Field enum UsNationalPrivacySection { - SHARING_NOTICE(UspNatV1Field.SHARING_NOTICE), - SALE_OPT_OUT_NOTICE(UspNatV1Field.SALE_OPT_OUT_NOTICE), - SHARING_OPT_OUT_NOTICE(UspNatV1Field.SHARING_OPT_OUT_NOTICE), - TARGETED_ADVERTISING_OPT_OUT_NOTICE(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE), - SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE(UspNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE), - SENSITIVE_DATA_LIMIT_USE_NOTICE(UspNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE), - SALE_OPT_OUT(UspNatV1Field.SALE_OPT_OUT), - SHARING_OPT_OUT(UspNatV1Field.SHARING_OPT_OUT), - TARGETED_ADVERTISING_OPT_OUT(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT), - SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 1), - SENSITIVE_DATA_RELIGIOUS_BELIEFS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 2), - SENSITIVE_DATA_HEALTH_INFO(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 3), - SENSITIVE_DATA_ORIENTATION(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 4), - SENSITIVE_DATA_CITIZENSHIP_STATUS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 5), - SENSITIVE_DATA_GENETIC_ID(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 6), - SENSITIVE_DATA_BIOMETRIC_ID(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 7), - SENSITIVE_DATA_GEOLOCATION(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 8), - SENSITIVE_DATA_ID_NUMBERS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 9), - SENSITIVE_DATA_ACCOUNT_INFO(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 10), - SENSITIVE_DATA_UNION_MEMBERSHIP(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 11), - SENSITIVE_DATA_COMMUNICATION_CONTENTS(UspNatV1Field.SENSITIVE_DATA_PROCESSING + 12), - SENSITIVE_DATA_PROCESSING_ALL(UspNatV1Field.SENSITIVE_DATA_PROCESSING + "*"), - CHILD_CONSENTS_FROM_13_TO_16(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 1), - CHILD_CONSENTS_BELOW_13(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 2), - PERSONAL_DATA_CONSENTS(UspNatV1Field.PERSONAL_DATA_CONSENTS), - MSPA_COVERED_TRANSACTION(UspNatV1Field.MSPA_COVERED_TRANSACTION), - MSPA_OPT_OUT_OPTION_MODE(UspNatV1Field.MSPA_OPT_OUT_OPTION_MODE), - MSPA_SERVICE_PROVIDER_MODE(UspNatV1Field.MSPA_SERVICE_PROVIDER_MODE), - GPC(UspNatV1Field.GPC); + SHARING_NOTICE(UsNatV1Field.SHARING_NOTICE), + SALE_OPT_OUT_NOTICE(UsNatV1Field.SALE_OPT_OUT_NOTICE), + SHARING_OPT_OUT_NOTICE(UsNatV1Field.SHARING_OPT_OUT_NOTICE), + TARGETED_ADVERTISING_OPT_OUT_NOTICE(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE), + SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE(UsNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE), + SENSITIVE_DATA_LIMIT_USE_NOTICE(UsNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE), + SALE_OPT_OUT(UsNatV1Field.SALE_OPT_OUT), + SHARING_OPT_OUT(UsNatV1Field.SHARING_OPT_OUT), + TARGETED_ADVERTISING_OPT_OUT(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT), + SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 1), + SENSITIVE_DATA_RELIGIOUS_BELIEFS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 2), + SENSITIVE_DATA_HEALTH_INFO(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 3), + SENSITIVE_DATA_ORIENTATION(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 4), + SENSITIVE_DATA_CITIZENSHIP_STATUS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 5), + SENSITIVE_DATA_GENETIC_ID(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 6), + SENSITIVE_DATA_BIOMETRIC_ID(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 7), + SENSITIVE_DATA_GEOLOCATION(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 8), + SENSITIVE_DATA_ID_NUMBERS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 9), + SENSITIVE_DATA_ACCOUNT_INFO(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 10), + SENSITIVE_DATA_UNION_MEMBERSHIP(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 11), + SENSITIVE_DATA_COMMUNICATION_CONTENTS(UsNatV1Field.SENSITIVE_DATA_PROCESSING + 12), + SENSITIVE_DATA_PROCESSING_ALL(UsNatV1Field.SENSITIVE_DATA_PROCESSING + "*"), + CHILD_CONSENTS_FROM_13_TO_16(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 1), + CHILD_CONSENTS_BELOW_13(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS + 2), + PERSONAL_DATA_CONSENTS(UsNatV1Field.PERSONAL_DATA_CONSENTS), + MSPA_COVERED_TRANSACTION(UsNatV1Field.MSPA_COVERED_TRANSACTION), + MSPA_OPT_OUT_OPTION_MODE(UsNatV1Field.MSPA_OPT_OUT_OPTION_MODE), + MSPA_SERVICE_PROVIDER_MODE(UsNatV1Field.MSPA_SERVICE_PROVIDER_MODE), + GPC(UsNatV1Field.GPC); @JsonValue final String value diff --git a/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy b/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy index d71d60d8aa5..f3866eb24cd 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/GppSectionId.groovy @@ -4,13 +4,13 @@ import com.fasterxml.jackson.annotation.JsonValue import com.iab.gpp.encoder.section.HeaderV1 import com.iab.gpp.encoder.section.TcfCaV1 import com.iab.gpp.encoder.section.TcfEuV2 -import com.iab.gpp.encoder.section.UspCaV1 -import com.iab.gpp.encoder.section.UspCoV1 -import com.iab.gpp.encoder.section.UspCtV1 -import com.iab.gpp.encoder.section.UspNatV1 -import com.iab.gpp.encoder.section.UspUtV1 +import com.iab.gpp.encoder.section.UsCaV1 +import com.iab.gpp.encoder.section.UsCoV1 +import com.iab.gpp.encoder.section.UsCtV1 +import com.iab.gpp.encoder.section.UsNatV1 +import com.iab.gpp.encoder.section.UsUtV1 +import com.iab.gpp.encoder.section.UsVaV1 import com.iab.gpp.encoder.section.UspV1 -import com.iab.gpp.encoder.section.UspVaV1 enum GppSectionId { @@ -18,12 +18,12 @@ enum GppSectionId { HEADER_V1(HeaderV1.ID), TCF_CA_V1(TcfCaV1.ID), USP_V1(UspV1.ID), - USP_NAT_V1(UspNatV1.ID), - USP_CA_V1(UspCaV1.ID), - USP_VA_V1(UspVaV1.ID), - USP_CO_V1(UspCoV1.ID), - USP_UT_V1(UspUtV1.ID), - USP_CT_V1(UspCtV1.ID) + US_NAT_V1(UsNatV1.ID), + US_CA_V1(UsCaV1.ID), + US_VA_V1(UsVaV1.ID), + US_CO_V1(UsCoV1.ID), + US_UT_V1(UsUtV1.ID), + US_CT_V1(UsCtV1.ID) @JsonValue final Integer value diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy index 041738cc5ab..87c7689b4ab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy @@ -15,13 +15,13 @@ import org.prebid.server.functional.model.response.auction.And import org.prebid.server.functional.model.response.auction.GeoCode import org.prebid.server.functional.model.response.auction.RuleConfiguration import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 import static org.prebid.server.functional.model.request.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_TID @@ -193,14 +193,14 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { ext.prebid.trace = VERBOSE device = new Device(geo: new Geo(country: USA, region: ALABAMA.abbreviation)) regs.ext.gpc = PBSUtils.randomString - regs.gppSid = [USP_CA_V1.intValue] + regs.gppSid = [US_CA_V1.intValue] setAccountId(accountId) } and: "Set up activities" def gpc = PBSUtils.randomString def condition = Condition.baseCondition.tap { - it.gppSid = [USP_CO_V1.intValue] + it.gppSid = [US_CO_V1.intValue] it.gpc = gpc it.geo = [CAN.withState(ARIZONA)] } @@ -299,8 +299,8 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { ext.prebid.trace = VERBOSE device = new Device(geo: new Geo(country: USA, region: ALABAMA.abbreviation)) regs.ext.gpc = PBSUtils.randomString - regs.gppSid = [USP_CA_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().setGpc(true).build() + regs.gppSid = [US_CA_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().setGpc(true).build() setAccountId(accountId) } @@ -404,4 +404,3 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { activityInfrastructures[new IntRange(true, firstIndex, lastIndex)] } } - diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy index 9d7657f452c..3b69b139bc3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAmpSpec.groovy @@ -7,7 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 @@ -125,7 +125,7 @@ class GppAmpSpec extends PrivacyBaseSpec { where: gppConsent << [new TcfEuV2Consent.Builder().build(), - new UspV1Consent.Builder().build()] + new UsV1Consent.Builder().build()] } def "PBS should copy consent_string to user.consent and set gdpr=1 when consent_string is valid and gppSid contains 2"() { @@ -157,7 +157,7 @@ class GppAmpSpec extends PrivacyBaseSpec { def "PBS should copy consent_string to user.us_privacy when consent_string contains us_privacy and gppSid contains 6"() { given: "Default amp request with valid consent_string and gpp consent_type" - def gppConsent = new UspV1Consent.Builder().build() + def gppConsent = new UsV1Consent.Builder().build() def gppSidIds = USP_V1.value def ampRequest = getGppAmpRequest(gppConsent.consentString, gppSidIds) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy index 0283bc1887f..cef812e4cf5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 @@ -173,7 +173,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should copy regs.gpp to regs.usPrivacy when gppSid contains 6, gpp is USP_V1 and regs.us_privacy isn't specified"() { given: "Default bid request with gpp and gppSid, without us_privacy" - def gppConsent = new UspV1Consent.Builder().build() + def gppConsent = new UsV1Consent.Builder().build() def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gpp: gppConsent, gppSid: [USP_V1.intValue], usPrivacy: null) } @@ -190,7 +190,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS shouldn't copy regs.gpp to regs.usPrivacy when gppSid doesn't contain 6, gpp is USP_V1 and regs.us_privacy isn't specified"() { given: "Default bid request with gpp and gppSid, without us_privacy" def gppSidIds = [PBSUtils.getRandomNumberWithExclusion(USP_V1.intValue)] - def gpp = new UspV1Consent.Builder().build() + def gpp = new UsV1Consent.Builder().build() def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gppSid: gppSidIds, gpp: gpp, usPrivacy: null) } @@ -211,7 +211,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should emit warning when gppSid contains 6, gpp is USP_V1 and regs.gpp and regs.usPrivacy are different"() { given: "Default bid request with gpp, gppSid and usPrivacy" def gppSidIds = [USP_V1.intValue] - def gpp = new UspV1Consent.Builder().build() + def gpp = new UsV1Consent.Builder().build() def ccpaConsent = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: NOT_ENFORCED) def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gppSid: gppSidIds, gpp: gpp, usPrivacy: ccpaConsent) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy index 9f44c987360..c200c154bab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy @@ -11,7 +11,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2 @@ -186,7 +186,7 @@ class GppCookieSyncSpec extends BaseSpec { given: "Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { it.gppSid = USP_V1.value - it.gpp = new UspV1Consent.Builder().build() + it.gpp = new UsV1Consent.Builder().build() it.gdpr = null it.usPrivacy = new CcpaConsent(explicitNotice: ENFORCED, optOutSale: ENFORCED) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy index a2683a8b7ff..0d090758e08 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy @@ -3,27 +3,27 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule import org.prebid.server.functional.model.request.auction.AllowActivities import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Condition -import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -31,6 +31,7 @@ import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.DataActivity.CONSENT import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED import static org.prebid.server.functional.model.config.DataActivity.NOTICE_PROVIDED @@ -41,6 +42,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -53,16 +55,15 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RELIGIOUS_BELIEFS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.pricefloors.Country.CAN -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 +import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -71,8 +72,8 @@ import static org.prebid.server.functional.model.request.auction.PrivacyModule.I import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE -import static org.prebid.server.functional.util.privacy.model.State.ONTARIO import static org.prebid.server.functional.util.privacy.model.State.ALABAMA +import static org.prebid.server.functional.util.privacy.model.State.ONTARIO class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { @@ -584,8 +585,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = BidRequest.defaultBidRequest.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().build() + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().build() } and: "Activities set for fetchBid with rejecting privacy regulation" @@ -642,13 +643,13 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequest(bidRequest.id) where: - gppConsent | gppSid - new UspNatV1Consent.Builder().build() | USP_NAT_V1 - new UspCaV1Consent.Builder().build() | USP_CA_V1 - new UspVaV1Consent.Builder().build() | USP_VA_V1 - new UspCoV1Consent.Builder().build() | USP_CO_V1 - new UspUtV1Consent.Builder().build() | USP_UT_V1 - new UspCtV1Consent.Builder().build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().build() | US_NAT_V1 + new UsCaV1Consent.Builder().build() | US_CA_V1 + new UsVaV1Consent.Builder().build() | US_VA_V1 + new UsCoV1Consent.Builder().build() | US_CO_V1 + new UsUtV1Consent.Builder().build() | US_UT_V1 + new UsCtV1Consent.Builder().build() | US_CT_V1 } def "PBS auction call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -657,7 +658,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def genericBidRequest = BidRequest.defaultBidRequest.tap { it.setAccountId(accountId) ext.prebid.trace = VERBOSE - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for fetchBid with privacy regulation" @@ -671,7 +672,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -692,8 +693,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] - regs.gpp = new UspNatV1Consent.Builder().build() + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = new UsNatV1Consent.Builder().build() it.setAccountId(accountId) } @@ -721,10 +722,10 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should call to bidder"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -739,7 +740,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [US_NAT_V1], false) } and: "Existed account with privacy regulation setup" @@ -764,7 +765,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -780,7 +781,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], accountLogic), [US_NAT_V1], false) } and: "Existed account with privacy regulation setup" @@ -794,23 +795,23 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequests(generalBidRequest.id).size() == 0 where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -826,7 +827,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -885,74 +886,74 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(generalBidRequest.id) where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1281,8 +1282,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value - it.consentString = new UspNatV1Consent.Builder().build() + it.gppSid = US_NAT_V1.value + it.consentString = new UsNatV1Consent.Builder().build() it.consentType = GPP } @@ -1354,13 +1355,13 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert bidder.getBidderRequest(ampStoredRequest.id) where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -1373,7 +1374,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "Activities set for fetchBid with privacy regulation" @@ -1387,7 +1388,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1416,8 +1417,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value - it.consentString = new UspNatV1Consent.Builder().build() + it.gppSid = US_NAT_V1.value + it.consentString = new UsNatV1Consent.Builder().build() it.consentType = GPP } @@ -1455,10 +1456,10 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { } and: "amp request with link to account and gppSid" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1508,7 +1509,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1542,22 +1543,22 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(ampStoredRequest.id).size() where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampStoredRequest = BidRequest.defaultBidRequest.tap { - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1565,7 +1566,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue } and: "Activities set with privacy regulation" @@ -1579,7 +1580,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([FETCH_BIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -1656,74 +1657,74 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { assert !bidder.getBidderRequests(ampStoredRequest.id) where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy index 877676332fa..47a04509805 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSetUidSpec.groovy @@ -6,10 +6,10 @@ import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent -import org.prebid.server.functional.util.privacy.gpp.UspV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsV1Consent import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID class GppSetUidSpec extends PrivacyBaseSpec { @@ -18,7 +18,7 @@ class GppSetUidSpec extends PrivacyBaseSpec { given: "Set uid request with invalid GPP" def setUidRequest = SetuidRequest.defaultSetuidRequest.tap { it.gpp = "Invalid_GPP_Consent_String" - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.uid = UUID.randomUUID().toString() it.gdpr = null it.gdprConsent = null @@ -68,7 +68,7 @@ class GppSetUidSpec extends PrivacyBaseSpec { assert response.uidsCookie.tempUIDs[GENERIC] where: - gpp << [new UspV1Consent.Builder().build().encodeSection(), + gpp << [new UsV1Consent.Builder().build().encodeSection(), new TcfEuV2Consent.Builder().build().encodeSection()] } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy index 42a096d2c55..fefb27cfd1b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy @@ -8,9 +8,9 @@ import org.prebid.server.functional.model.config.AccountPrivacyConfig import org.prebid.server.functional.model.config.AccountSetting import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule @@ -20,12 +20,12 @@ import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -43,6 +43,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -57,23 +58,23 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.auction.ActivityType.SYNC_USER import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.PublicCountryIp.USA_IP -import static org.prebid.server.functional.util.privacy.model.State.MANITOBA import static org.prebid.server.functional.util.privacy.model.State.ALABAMA import static org.prebid.server.functional.util.privacy.model.State.ALASKA -import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU -import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL +import static org.prebid.server.functional.util.privacy.model.State.MANITOBA class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { @@ -340,7 +341,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -373,7 +374,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = disallowGppLogic } @@ -401,22 +402,81 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSaleOptOut(1).setSaleOptOutNotice(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setSaleOptOutNotice(2).setSaleOptOut(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build() + ] + } + + def "PBS cookie sync call when privacy module contain some part of disallow logic which violates GPP validation should exclude bidders URLs"() { + given: "Cookie sync request with link to account" + def accountId = PBSUtils.randomString + def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { + it.gppSid = US_NAT_V1.value + it.account = accountId + it.gpp = disallowGppLogic + } + + and: "Activities set for cookie sync with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with cookie sync and privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes cookie sync request" + def response = activityPbsService.sendCookieSyncRequest(cookieSyncRequest) + + then: "Response should not contain any URLs for bidders" + assert !response.bidderStatus.userSync.url + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAACAAAAAAA.QA' ] } @@ -450,20 +510,20 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS cookie sync call when privacy modules contain allowing settings should include proper responded with bidders URLs"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -489,7 +549,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -497,7 +557,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId it.gpp = regsGpp } @@ -524,14 +584,14 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert response.getBidderUserSync(GENERIC).userSync.url where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS cookie sync call when privacy regulation have duplicate should include proper responded with bidders URLs"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.account = accountId } @@ -543,7 +603,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ruleUsGeneric])) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) and: "Flush metrics" @@ -568,7 +628,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC it.account = accountId } @@ -596,10 +656,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS cookie sync call when privacy regulation don't match custom requirement should include proper responded with bidders URLs"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -639,7 +699,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -669,22 +729,22 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS cookie sync call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.gpp = gppConsent setAccount(accountId) } @@ -700,7 +760,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -760,74 +820,74 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert !response.bidderStatus.userSync.url where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1112,7 +1172,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1150,7 +1210,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = disallowGppLogic } @@ -1182,22 +1242,86 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSaleOptOut(1).setSaleOptOutNotice(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setSaleOptOutNotice(2).setSaleOptOut(1).setMspaServiceProviderMode(2).setMspaOptOutOptionMode(1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build() + ] + } + + def "PBS setuid request when privacy module contain some part of disallow logic which violates GPP validation should reject bidders with status code invalidStatusCode"() { + given: "Cookie sync SetuidRequest with accountId" + def accountId = PBSUtils.randomString + def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.gpp = disallowGppLogic + } + + and: "UIDS Cookie" + def uidsCookie = UidsCookie.defaultUidsCookie + + and: "Activities set for cookie sync with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with cookie sync and allow activities setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes cookie sync request" + activityPbsService.sendSetUidRequest(setuidRequest, uidsCookie) + + then: "Request should fail with error" + def exception = thrown(PrebidServerException) + assert exception.statusCode == INVALID_STATUS_CODE + assert exception.responseBody == INVALID_STATUS_MESSAGE + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAACAAAAAAA.QA' ] } @@ -1236,13 +1360,13 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS setuid request when privacy modules contain allowing settings should respond with valid bidders UIDs cookies"() { @@ -1250,7 +1374,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1278,7 +1402,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true), + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true), ] } @@ -1288,7 +1412,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = regsGpp } @@ -1317,7 +1441,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert response.responseBody where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS setuid request when privacy regulation have duplicate should respond with valid bidders UIDs cookies"() { @@ -1325,7 +1449,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "UIDS Cookie" @@ -1339,7 +1463,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def activities = AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ruleUsGeneric])) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) and: "Flush metrics" @@ -1365,7 +1489,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomString def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1396,10 +1520,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS setuid call when privacy regulation don't match custom requirement should respond with required UIDs cookies"() { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -1442,7 +1566,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomNumber as String def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.account = accountId it.gpp = gppConsent } @@ -1477,24 +1601,24 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS setuid call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Cookie sync SetuidRequest with accountId" def accountId = PBSUtils.randomString - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def setuidRequest = SetuidRequest.defaultSetuidRequest.tap { it.account = accountId it.gpp = gppConsent - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "UIDS Cookie" @@ -1511,7 +1635,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([SYNC_USER], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -1576,74 +1700,74 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { assert exception.responseBody == INVALID_STATUS_MESSAGE where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy index a05f0e64b39..464197e7985 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy @@ -3,9 +3,9 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -20,12 +20,12 @@ import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -45,6 +45,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -59,13 +60,13 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -613,7 +614,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -650,7 +651,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -681,25 +682,73 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -707,7 +756,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -722,7 +771,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -737,14 +786,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -754,6 +803,47 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove EIDS fields in request"() { + given: "Default Generic BidRequests with EIDS fields and account id" + def accountId = PBSUtils.randomNumber as String + def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = disallowGppLogic + } + + and: "Activities set for transmitEIDS with rejecting privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes auction requests" + activityPbsService.sendAuctionRequest(genericBidRequest) + + then: "Generic bidder request should have empty EIDS fields" + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + verifyAll { + !genericBidderRequest.user.eids + !genericBidderRequest.user?.ext?.eids + } + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS auction call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String @@ -787,20 +877,20 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should leave EIDS fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -825,7 +915,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -833,7 +923,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -859,14 +949,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { assert genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should leave EIDS fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitEIDS with privacy regulation" @@ -880,7 +970,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -902,7 +992,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -930,10 +1020,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should leave EIDS fields in request"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -973,7 +1063,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1006,23 +1096,23 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndEidsData(accountId).tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent } @@ -1037,7 +1127,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [USP_CT_V1], false) + config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1100,74 +1190,74 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1492,7 +1582,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1537,7 +1627,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1573,25 +1663,73 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -1599,7 +1737,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -1614,7 +1752,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -1629,14 +1767,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -1646,6 +1784,56 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS amp call when privacy module contain some part of disallow logic which violates GPP validation should remove EIDS fields in request"() { + given: "Default Generic BidRequest with EIDS fields field and account id" + def accountId = PBSUtils.randomNumber as String + def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) + + and: "amp request with link to account" + def ampRequest = AmpRequest.defaultAmpRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.consentString = disallowGppLogic + it.consentType = GPP + } + + and: "Activities set for transmitEIDS with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes amp request" + activityPbsService.sendAmpRequest(ampRequest) + + then: "Generic bidder request should have empty EIDS fields" + def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll { + !genericBidderRequest.user.eids + !genericBidderRequest.user?.ext?.eids + } + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS amp call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { given: "Default Generic BidRequest with EIDS fields field and account id" def accountId = PBSUtils.randomNumber as String @@ -1688,13 +1876,13 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should leave EIDS fields in request"() { @@ -1705,7 +1893,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1735,7 +1923,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1747,7 +1935,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -1778,7 +1966,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { assert genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should leave EIDS fields in request and update alerts metrics"() { @@ -1789,7 +1977,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = "" it.consentType = GPP } @@ -1805,7 +1993,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1835,7 +2023,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1872,10 +2060,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) and: "amp request with link to account and gpp" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1924,7 +2112,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -1962,14 +2150,14 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { @@ -1978,10 +2166,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndEidsData(accountId) and: "amp request with link to account and gpp string" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -1997,7 +2185,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_EIDS], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2076,74 +2264,74 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy index 3372d8d0c15..7115f3fc561 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -3,9 +3,9 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -15,12 +15,12 @@ import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -40,6 +40,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -54,16 +55,20 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO -import static org.prebid.server.functional.model.request.auction.PrivacyModule.* +import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_ALL +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_TFC_EU +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC +import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE import static org.prebid.server.functional.util.privacy.model.State.ALABAMA import static org.prebid.server.functional.util.privacy.model.State.ONTARIO @@ -767,7 +772,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -809,7 +814,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -845,24 +850,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 1 @@ -909,13 +918,13 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should not round lat/lon data"() { @@ -923,7 +932,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -956,7 +965,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -965,7 +974,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -999,7 +1008,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -1007,7 +1016,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitPreciseGeo with privacy regulation" @@ -1021,7 +1030,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1052,7 +1061,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountId = PBSUtils.randomNumber as String def bidRequest = bidRequestWithGeo.tap { it.setAccountId(accountId) - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1080,10 +1089,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should not round lat/lon data"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = bidRequestWithGeo.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1133,7 +1142,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = bidRequestWithGeo.tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1173,23 +1182,23 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def generalBidRequest = bidRequestWithGeo.tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) } @@ -1207,7 +1216,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [USP_CT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1279,74 +1288,74 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1730,7 +1739,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1780,7 +1789,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1821,24 +1830,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), + new UsNatV1Consent.Builder().setKnownChildSensitiveDataConsents(1, 0).build(), + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( geolocation: 1 @@ -1893,13 +1906,13 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should not round lat/lon data"() { @@ -1910,7 +1923,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1948,7 +1961,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1960,7 +1973,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -1999,7 +2012,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should process request and update alerts metrics"() { @@ -2010,7 +2023,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value } and: "Activities set for transmitPreciseGeo with privacy regulation" @@ -2024,7 +2037,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -2062,7 +2075,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2097,7 +2110,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS amp call when privacy regulation don't match custom requirement should not round lat/lon data in request"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampStoredRequest = bidRequestWithGeo.tap { setAccountId(accountId) } @@ -2105,7 +2118,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2165,7 +2178,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2209,20 +2222,20 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Store bid request with gpp string and link for account" def accountId = PBSUtils.randomNumber as String - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampStoredRequest = bidRequestWithGeo.tap { setAccountId(accountId) } @@ -2230,7 +2243,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -2246,7 +2259,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_PRECISE_GEO], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2332,74 +2345,74 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index d056412e225..a1d8a1d6104 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -4,13 +4,14 @@ import org.prebid.server.functional.model.config.AccountGdprConfig import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule +import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.InequalityValueRule import org.prebid.server.functional.model.config.LogicalRestrictedRule -import org.prebid.server.functional.model.config.GppModuleConfig import org.prebid.server.functional.model.config.Purpose import org.prebid.server.functional.model.config.PurposeConfig import org.prebid.server.functional.model.config.PurposeEid import org.prebid.server.functional.model.db.StoredRequest +import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity import org.prebid.server.functional.model.request.auction.ActivityRule import org.prebid.server.functional.model.request.auction.AllowActivities @@ -23,15 +24,14 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtData -import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.util.PBSUtils -import org.prebid.server.functional.util.privacy.gpp.UspCaV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCoV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspCtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspUtV1Consent -import org.prebid.server.functional.util.privacy.gpp.UspVaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCoV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsCtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsUtV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsVaV1Consent import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData @@ -40,6 +40,7 @@ import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.DataActivity.CONSENT import static org.prebid.server.functional.model.config.DataActivity.NOTICE_NOT_PROVIDED import static org.prebid.server.functional.model.config.DataActivity.NOTICE_PROVIDED @@ -50,6 +51,7 @@ import static org.prebid.server.functional.model.config.LogicalRestrictedRule.Lo import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_FROM_13_TO_16 import static org.prebid.server.functional.model.config.UsNationalPrivacySection.GPC +import static org.prebid.server.functional.model.config.UsNationalPrivacySection.PERSONAL_DATA_CONSENTS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_ACCOUNT_INFO import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_BIOMETRIC_ID import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_CITIZENSHIP_STATUS @@ -62,16 +64,15 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SENSITIVE_DATA_RELIGIOUS_BELIEFS import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE -import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.GppSectionId.USP_CA_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CO_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_CT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_UT_V1 import static org.prebid.server.functional.model.request.GppSectionId.USP_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_NAT_V1 -import static org.prebid.server.functional.model.request.GppSectionId.USP_VA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CA_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CO_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_CT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_NAT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_UT_V1 +import static org.prebid.server.functional.model.request.GppSectionId.US_VA_V1 import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD import static org.prebid.server.functional.model.request.auction.PrivacyModule.ALL @@ -793,7 +794,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -841,7 +842,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -884,25 +885,73 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -910,7 +959,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -925,7 +974,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -940,14 +989,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -957,6 +1006,60 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { + given: "Default Generic BidRequests with UFPD fields and account id" + def accountId = PBSUtils.randomNumber as String + def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + regs.gppSid = [US_NAT_V1.intValue] + regs.gpp = disallowGppLogic + } + + and: "Activities set for transmitUfpd with rejecting privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + when: "PBS processes auction requests" + activityPbsService.sendAuctionRequest(genericBidRequest) + + then: "Generic bidder request should have empty UFPD fields" + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + verifyAll { + !genericBidderRequest.device.didsha1 + !genericBidderRequest.device.didmd5 + !genericBidderRequest.device.dpidsha1 + !genericBidderRequest.device.ifa + !genericBidderRequest.device.macsha1 + !genericBidderRequest.device.macmd5 + !genericBidderRequest.device.dpidmd5 + !genericBidderRequest.user.id + !genericBidderRequest.user.buyeruid + !genericBidderRequest.user.yob + !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.data + !genericBidderRequest.user.ext + } + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String @@ -1002,20 +1105,20 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS auction call when privacy modules contain allowing settings should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1057,7 +1160,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -1065,7 +1168,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -1108,14 +1211,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS auction call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] } and: "Activities set for transmitUfpd with privacy regulation" @@ -1129,7 +1232,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -1168,7 +1271,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1196,10 +1299,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation don't match custom requirement should leave UFPD fields in request"() { given: "Default basic generic BidRequest" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1254,7 +1357,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { - regs.gppSid = [USP_NAT_V1.intValue] + regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1299,23 +1402,23 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS auction call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { given: "Generic BidRequest with gpp and account setup" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE - regs.gppSid = [USP_CT_V1.intValue] + regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent } @@ -1330,7 +1433,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [USP_CT_V1], false) + config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [US_CT_V1], false) } and: "Flush metrics" @@ -1405,74 +1508,74 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } @@ -1893,7 +1996,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -1950,7 +2053,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = disallowGppLogic it.consentType = GPP } @@ -1998,25 +2101,73 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build(), - new UspNatV1Consent.Builder().setSaleOptOut(1).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(2).build(), - new UspNatV1Consent.Builder().setSaleOptOutNotice(0).setSaleOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSharingOptOut(1).build(), - new UspNatV1Consent.Builder().setSharingOptOutNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setSharingNotice(0).setSharingOptOut(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOut(1).build(), - new UspNatV1Consent.Builder().setTargetedAdvertisingOptOutNotice(0).setTargetedAdvertisingOptOut(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessingOptOutNotice(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataLimitUseNotice(2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2).build(), - new UspNatV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 1).build(), - new UspNatV1Consent.Builder().setPersonalDataConsents(2).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder() + .setMspaServiceProviderMode(1) + .setMspaOptOutOptionMode(2) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSaleOptOutNotice(2) + .setSaleOptOut(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingNotice(2) + .setSharingOptOutNotice(1) + .setSharingOptOut(1) + .setMspaServiceProviderMode(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSharingOptOutNotice(2) + .setSharingOptOut(1) + .setSharingNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOutNotice(2) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setTargetedAdvertisingOptOut(1) + .setTargetedAdvertisingOptOutNotice(1) + .setSaleOptOut(1) + .setSaleOptOutNotice(1) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataProcessingOptOutNotice(2) + .build(), + new UsNatV1Consent.Builder() + .setSensitiveDataLimitUseNotice(2) + .setMspaServiceProviderMode(2) + .setMspaOptOutOptionMode(1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 1) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(0, 2) + .build(), + new UsNatV1Consent.Builder() + .setKnownChildSensitiveDataConsents(1, 0) + .build(), + new UsNatV1Consent.Builder() + .setPersonalDataConsents(2) + .build(), + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 1, religiousBeliefs: 1, healthInfo: 1, @@ -2024,7 +2175,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { citizenshipStatus: 1, unionMembership: 1, )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataLimitUseNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -2039,7 +2190,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder() + new UsNatV1Consent.Builder() .setSensitiveDataProcessingOptOutNotice(0) .setSensitiveDataProcessing(new UsNationalSensitiveData( racialEthnicOrigin: 2, @@ -2054,14 +2205,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { unionMembership: 2, communicationContents: 2 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 1, biometricId: 1, idNumbers: 1, accountInfo: 1, communicationContents: 1 )).build(), - new UspNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( + new UsNatV1Consent.Builder().setSensitiveDataProcessing(new UsNationalSensitiveData( geneticId: 2, biometricId: 2, idNumbers: 2, @@ -2071,6 +2222,69 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { ] } + def "PBS amp call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { + given: "Default Generic BidRequest with UFPD fields field and account id" + def accountId = PBSUtils.randomNumber as String + def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) + + and: "amp request with link to account" + def ampRequest = AmpRequest.defaultAmpRequest.tap { + it.account = accountId + it.gppSid = US_NAT_V1.value + it.consentString = disallowGppLogic + it.consentType = GPP + } + + and: "Activities set for transmitUfpd with allowing privacy regulation" + def rule = new ActivityRule().tap { + it.privacyRegulation = [IAB_US_GENERAL] + } + + def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([rule])) + + and: "Account gpp configuration" + def accountGppConfig = new AccountGppConfig(code: IAB_US_GENERAL, enabled: true) + + and: "Existed account with privacy regulation setup" + def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppConfig]) + accountDao.save(account) + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes amp request" + activityPbsService.sendAmpRequest(ampRequest) + + then: "Generic bidder request should have empty UFPD fields" + def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll { + !genericBidderRequest.device.didsha1 + !genericBidderRequest.device.didmd5 + !genericBidderRequest.device.dpidsha1 + !genericBidderRequest.device.ifa + !genericBidderRequest.device.macsha1 + !genericBidderRequest.device.macmd5 + !genericBidderRequest.device.dpidmd5 + !genericBidderRequest.user.id + !genericBidderRequest.user.buyeruid + !genericBidderRequest.user.yob + !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.data + !genericBidderRequest.user.ext + } + + where: + disallowGppLogic << [ + 'DBABLA~BAAgAAAAAAA.QA', + 'DBABLA~BCAAAAAAAAA.QA', + 'DBABLA~BAAEAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA', + 'DBABLA~BAAIAAAAAAA.QA' + ] + } + def "PBS amp call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequest with UFPD fields field and account id" def accountId = PBSUtils.randomNumber as String @@ -2125,13 +2339,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | gppSid - new UspNatV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_NAT_V1 - new UspCaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CA_V1 - new UspVaV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_VA_V1 - new UspCoV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CO_V1 - new UspUtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_UT_V1 - new UspCtV1Consent.Builder().setMspaServiceProviderMode(1).build() | USP_CT_V1 + gppConsent | gppSid + new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 + new UsCaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CA_V1 + new UsVaV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_VA_V1 + new UsCoV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CO_V1 + new UsUtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_UT_V1 + new UsCtV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_CT_V1 } def "PBS amp call when privacy modules contain allowing settings should leave UFPD fields in request"() { @@ -2142,7 +2356,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2188,7 +2402,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), - new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: true) + new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: true) ] } @@ -2200,7 +2414,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = regsGpp it.consentType = GPP } @@ -2247,7 +2461,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - regsGpp << ["", new UspNatV1Consent.Builder().build(), new UspNatV1Consent.Builder().setGpc(false).build()] + regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } def "PBS amp call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { @@ -2258,7 +2472,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = "" it.consentType = GPP } @@ -2274,7 +2488,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { flushMetrics(activityPbsService) and: "Account gpp privacy regulation configs with conflict" - def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [USP_NAT_V1]), enabled: false) + def accountGppUsNatAllowConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false) def accountGppUsNatRejectConfig = new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: []), enabled: true) def account = getAccountWithAllowActivitiesAndPrivacyModule(accountId, activities, [accountGppUsNatAllowConfig, accountGppUsNatRejectConfig]) @@ -2320,7 +2534,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = SIMPLE_GPC_DISALLOW_LOGIC it.consentType = GPP } @@ -2357,10 +2571,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "amp request with link to account and gpp" - def gppConsent = new UspNatV1Consent.Builder().setGpc(gpcValue).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2424,7 +2638,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "amp request with link to account and gppSid" def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.value + it.gppSid = US_NAT_V1.value it.consentString = gppConsent it.consentType = GPP } @@ -2474,14 +2688,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppConsent | valueRules - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] - new UspNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] - new UspNatV1Consent.Builder().setSharingNotice(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), - new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + gppConsent | valueRules + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(false).build() | [new InequalityValueRule(GPC, NOTICE_PROVIDED)] + new UsNatV1Consent.Builder().setGpc(true).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(SHARING_NOTICE, NOTICE_NOT_PROVIDED)] + new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(GPC, NOTICE_PROVIDED), + new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] } def "PBS amp call when custom privacy regulation empty and normalize is disabled should respond with an error and update metric"() { @@ -2490,10 +2704,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "amp request with link to account and gpp string" - def gppConsent = new UspNatV1Consent.Builder().setGpc(true).build() + def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId - it.gppSid = USP_NAT_V1.intValue + it.gppSid = US_NAT_V1.intValue it.consentString = gppConsent it.consentType = GPP } @@ -2509,7 +2723,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def accountGppConfig = new AccountGppConfig().tap { it.code = IAB_US_CUSTOM_LOGIC it.enabled = true - it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [USP_NAT_V1], false) + it.config = GppModuleConfig.getDefaultModuleConfig(new ActivityConfig([TRANSMIT_UFPD], restrictedRule), [US_NAT_V1], false) } and: "Flush metrics" @@ -2600,74 +2814,74 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { } where: - gppSid | equalityValueRules | gppStateConsent - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UspCaV1Consent.Builder() + gppSid | equalityValueRules | gppStateConsent + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(idNumbers: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ACCOUNT_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(accountInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geolocation: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(racialEthnicOrigin: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_COMMUNICATION_CONTENTS, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(communicationContents: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(geneticId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(biometricId: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(healthInfo: 2)) - USP_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsCaV1Consent.Builder() .setSensitiveDataProcessing(new UsCaliforniaSensitiveData(orientation: 2)) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(0, 0) - USP_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCaV1Consent.Builder() + US_CA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2), PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspVaV1Consent.Builder() + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsVaV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_VA_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsVaV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCoV1Consent.Builder() + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCoV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + US_CO_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCoV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RACIAL_ETHNIC_ORIGIN, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(racialEthnicOrigin: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_RELIGIOUS_BELIEFS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(religiousBeliefs: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_ORIENTATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(orientation: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_CITIZENSHIP_STATUS, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(citizenshipStatus: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_HEALTH_INFO, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(healthInfo: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GENETIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geneticId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_BIOMETRIC_ID, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(biometricId: 2)) - USP_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UspUtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(SENSITIVE_DATA_GEOLOCATION, CONSENT)] | new UsUtV1Consent.Builder() .setSensitiveDataProcessing(new UsUtahSensitiveData(geolocation: 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) - USP_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) - - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UspCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(1, 2)) + US_UT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsUtV1Consent.Builder().setKnownChildSensitiveDataConsents(0) + + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NOT_APPLICABLE), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NOT_APPLICABLE)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 0, 0) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, CONSENT)] | new UsCtV1Consent.Builder().setKnownChildSensitiveDataConsents(0, 2, 2) + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), PBSUtils.getRandomNumber(0, 2), 1) - USP_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), - new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UspCtV1Consent.Builder() + US_CT_V1 | [new EqualityValueRule(CHILD_CONSENTS_BELOW_13, NO_CONSENT), + new EqualityValueRule(CHILD_CONSENTS_FROM_13_TO_16, NO_CONSENT)] | new UsCtV1Consent.Builder() .setKnownChildSensitiveDataConsents(PBSUtils.getRandomNumber(0, 2), 1, PBSUtils.getRandomNumber(0, 2)) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index 4a8a1d5e68e..c2115d06f4a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -29,7 +29,7 @@ import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.ConsentString import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.GppConsent -import org.prebid.server.functional.util.privacy.gpp.UspNatV1Consent +import org.prebid.server.functional.util.privacy.gpp.UsNatV1Consent import spock.lang.Shared import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -89,7 +89,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { protected static final String VENDOR_LIST_PATH = "/app/prebid-server/data/vendorlist-v{VendorVersion}/{VendorVersion}.json" protected static final String VALID_VALUE_FOR_GPC_HEADER = "1" - protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UspNatV1Consent.Builder().setGpc(true).build() + protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UsNatV1Consent.Builder().setGpc(true).build() protected static final VendorList vendorListResponse = new VendorList(networkServiceContainer) @Shared diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy index 09ce5fdb277..dd30e8c20ba 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/GppConsent.groovy @@ -2,13 +2,13 @@ package org.prebid.server.functional.util.privacy.gpp import com.iab.gpp.encoder.GppModel import com.iab.gpp.encoder.section.TcfEuV2 -import com.iab.gpp.encoder.section.UspCaV1 -import com.iab.gpp.encoder.section.UspCoV1 -import com.iab.gpp.encoder.section.UspCtV1 -import com.iab.gpp.encoder.section.UspNatV1 -import com.iab.gpp.encoder.section.UspUtV1 +import com.iab.gpp.encoder.section.UsCaV1 +import com.iab.gpp.encoder.section.UsCoV1 +import com.iab.gpp.encoder.section.UsCtV1 +import com.iab.gpp.encoder.section.UsNatV1 +import com.iab.gpp.encoder.section.UsUtV1 +import com.iab.gpp.encoder.section.UsVaV1 import com.iab.gpp.encoder.section.UspV1 -import com.iab.gpp.encoder.section.UspVaV1 import org.prebid.server.functional.util.privacy.ConsentString abstract class GppConsent implements ConsentString { @@ -62,14 +62,14 @@ abstract class GppConsent implements ConsentString { enum Section { - TCF_EU_V2(TcfEuV2.NAME, TcfEuV2.VERSION), //2 - USP_V1(UspV1.NAME, UspV1.VERSION), //6 - USP_NAT_V1(UspNatV1.NAME, UspNatV1.VERSION), //7 - USP_CA_V1(UspCaV1.NAME, UspCaV1.VERSION), //8 - USP_VA_V1(UspVaV1.NAME, UspVaV1.VERSION), //9 - USP_CO_V1(UspCoV1.NAME, UspCoV1.VERSION), //10 - USP_UT_V1(UspUtV1.NAME, UspUtV1.VERSION), //11 - USP_CT_V1(UspCtV1.NAME, UspCtV1.VERSION), // 12 + TCF_EU_V2(TcfEuV2.NAME, TcfEuV2.VERSION), //2 + USP_V1(UspV1.NAME, UspV1.VERSION), //6 + US_NAT_V1(UsNatV1.NAME, UsNatV1.VERSION), //7 + US_CA_V1(UsCaV1.NAME, UsCaV1.VERSION), //8 + US_VA_V1(UsVaV1.NAME, UsVaV1.VERSION), //9 + US_CO_V1(UsCoV1.NAME, UsCoV1.VERSION), //10 + US_UT_V1(UsUtV1.NAME, UsUtV1.VERSION), //11 + US_CT_V1(UsCtV1.NAME, UsCtV1.VERSION), //12 final String name final int version diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy index d5ab56be602..dec740c4395 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCaV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCaV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCaV1Field +import com.iab.gpp.encoder.field.UsCaV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsCaliforniaSensitiveData -class UspCaV1Consent extends GppConsent { +class UsCaV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CA_V1 + private static final Section SECTION = Section.US_CA_V1 - protected UspCaV1Consent(Section section, Map fieldValues) { + protected UsCaV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,83 +23,83 @@ class UspCaV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCaV1Field.VERSION, version) + fieldValue(UsCaV1Field.VERSION, version) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setSharingOptOutNotice(Integer sharingOptOutNotice) { - fieldValue(UspCaV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) + fieldValue(UsCaV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) this } Builder setSensitiveDataLimitUseNotice(Integer sensitiveDataLimitUseNotice) { - fieldValue(UspCaV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) + fieldValue(UsCaV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCaV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCaV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setSharingOptOut(Integer sharingOptOut) { - fieldValue(UspCaV1Field.SHARING_OPT_OUT, sharingOptOut) + fieldValue(UsCaV1Field.SHARING_OPT_OUT, sharingOptOut) this } Builder setSensitiveDataProcessing(UsCaliforniaSensitiveData sensitiveDataProcessing) { - fieldValue(UspCaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13) { - fieldValue(UspCaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) + fieldValue(UsCaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) this } Builder setPersonalDataConsents(Integer personalDataConsents) { - fieldValue(UspCaV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) + fieldValue(UsCaV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCaV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCaV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Boolean gpcSegmentIncluded) { - fieldValue(UspCaV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCaV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCaV1Field.GPC, gpc) + fieldValue(UsCaV1Field.GPC, gpc) this } @Override GppConsent build() { - return new UspCaV1Consent(section, fieldValues) + return new UsCaV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy similarity index 55% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy index 4469eac024c..25bbc9dfb81 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCoV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCoV1Consent.groovy @@ -1,19 +1,19 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCoV1Field +import com.iab.gpp.encoder.field.UsCoV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsColoradoSensitiveData -class UspCoV1Consent extends GppConsent { +class UsCoV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CO_V1 + private static final Section SECTION = Section.US_CO_V1 - protected UspCoV1Consent(Section section, Map fieldValues) { + protected UsCoV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @Override protected String encodeSection() { - gppModel.encodeSection(Section.USP_CO_V1.name) + gppModel.encodeSection(SECTION.name) } static class Builder extends GppConsent.Builder { @@ -23,78 +23,78 @@ class UspCoV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCoV1Field.VERSION, version) + fieldValue(UsCoV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspCoV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsCoV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCoV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCoV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspCoV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCoV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCoV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspCoV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsCoV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsColoradoSensitiveData sensitiveDataProcessing) { - fieldValue(UspCoV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCoV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer knownChildSensitiveDataConsents) { - fieldValue(UspCoV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) + fieldValue(UsCoV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCoV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCoV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCoV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCoV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCoV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCoV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCoV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCoV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Integer gpcSegmentIncluded) { - fieldValue(UspCoV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCoV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCoV1Field.GPC, gpc) + fieldValue(UsCoV1Field.GPC, gpc) this } @Override GppConsent build() { - new UspCoV1Consent(section, fieldValues) + new UsCoV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy index a7fe10c4443..9c95345939a 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspCtV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsCtV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspCtV1Field +import com.iab.gpp.encoder.field.UsCtV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsConnecticutSensitiveData -class UspCtV1Consent extends GppConsent { +class UsCtV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_CT_V1 + private static final Section SECTION = Section.US_CT_V1 - protected UspCtV1Consent(Section section, Map fieldValues) { + protected UsCtV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,78 +23,78 @@ class UspCtV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspCtV1Field.VERSION, version) + fieldValue(UsCtV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspCtV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsCtV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspCtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsCtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspCtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspCtV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsCtV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspCtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsCtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsConnecticutSensitiveData sensitiveDataProcessing) { - fieldValue(UspCtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsCtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13, Integer childFrom16to18) { - fieldValue(UspCtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13, childFrom16to18]) + fieldValue(UsCtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13, childFrom16to18]) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspCtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsCtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspCtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsCtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspCtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsCtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspCtV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsCtV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Integer gpcSegmentIncluded) { - fieldValue(UspCtV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsCtV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspCtV1Field.GPC, gpc) + fieldValue(UsCtV1Field.GPC, gpc) this } @Override GppConsent build() { - return new UspCtV1Consent(section, fieldValues) + return new UsCtV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy similarity index 54% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy index a5c38e9de72..1805cdcf9bd 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspNatV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsNatV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspNatV1Field +import com.iab.gpp.encoder.field.UsNatV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsNationalSensitiveData -class UspNatV1Consent extends GppConsent { +class UsNatV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_NAT_V1 + private static final Section SECTION = Section.US_NAT_V1 - protected UspNatV1Consent(Section section, Map fieldValues) { + protected UsNatV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -19,107 +19,107 @@ class UspNatV1Consent extends GppConsent { static class Builder extends GppConsent.Builder { Builder() { - super(GppConsent.Section.USP_NAT_V1) + super(SECTION) } Builder setVersion(Integer version) { - fieldValue(UspNatV1Field.VERSION, version) + fieldValue(UsNatV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspNatV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsNatV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspNatV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsNatV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setSharingOptOutNotice(Integer sharingOptOutNotice) { - fieldValue(UspNatV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) + fieldValue(UsNatV1Field.SHARING_OPT_OUT_NOTICE, sharingOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSensitiveDataProcessingOptOutNotice(Integer sensitiveDataProcessingOptOutNotice) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) + fieldValue(UsNatV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) this } Builder setSensitiveDataLimitUseNotice(Integer sensitiveDataLimitUseNotice) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) + fieldValue(UsNatV1Field.SENSITIVE_DATA_LIMIT_USE_NOTICE, sensitiveDataLimitUseNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspNatV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsNatV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setSharingOptOut(Integer sharingOptOut) { - fieldValue(UspNatV1Field.SHARING_OPT_OUT, sharingOptOut) + fieldValue(UsNatV1Field.SHARING_OPT_OUT, sharingOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspNatV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsNatV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsNationalSensitiveData sensitiveDataProcessing) { - fieldValue(UspNatV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsNatV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setPersonalDataConsents(Integer personalDataConsents) { - fieldValue(UspNatV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) + fieldValue(UsNatV1Field.PERSONAL_DATA_CONSENTS, personalDataConsents) this } Builder setKnownChildSensitiveDataConsents(Integer childFrom13to16, Integer childBlow13) { - fieldValue(UspNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) + fieldValue(UsNatV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, [childFrom13to16, childBlow13]) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspNatV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsNatV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspNatV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsNatV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspNatV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsNatV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } Builder setGpcSegmentType(Integer gpcSegmentType) { - fieldValue(UspNatV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) + fieldValue(UsNatV1Field.GPC_SEGMENT_TYPE, gpcSegmentType) this } Builder setGpcSegmentIncluded(Boolean gpcSegmentIncluded) { - fieldValue(UspNatV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) + fieldValue(UsNatV1Field.GPC_SEGMENT_INCLUDED, gpcSegmentIncluded) this } Builder setGpc(Boolean gpc) { - fieldValue(UspNatV1Field.GPC, gpc) + fieldValue(UsNatV1Field.GPC, gpc) this } @Override GppConsent build() { - new UspNatV1Consent(section, fieldValues) + new UsNatV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy similarity index 54% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy index cb9101db214..fd37a095026 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspUtV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsUtV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspUtV1Field +import com.iab.gpp.encoder.field.UsUtV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsUtahSensitiveData -class UspUtV1Consent extends GppConsent { +class UsUtV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_UT_V1 + private static final Section SECTION = Section.US_UT_V1 - protected UspUtV1Consent(Section section, Map fieldValues) { + protected UsUtV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -19,72 +19,72 @@ class UspUtV1Consent extends GppConsent { static class Builder extends GppConsent.Builder { Builder() { - super(GppConsent.Section.USP_UT_V1) + super(SECTION) } Builder setVersion(Integer version) { - fieldValue(UspUtV1Field.VERSION, version) + fieldValue(UsUtV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspUtV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsUtV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspUtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsUtV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspUtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsUtV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSensitiveDataProcessingOptOutNotice(Integer sensitiveDataProcessingOptOutNotice) { - fieldValue(UspUtV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) + fieldValue(UsUtV1Field.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE, sensitiveDataProcessingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspUtV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsUtV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspUtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsUtV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsUtahSensitiveData sensitiveDataProcessing) { - fieldValue(UspUtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsUtV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer knownChildSensitiveDataConsents) { - fieldValue(UspUtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) + fieldValue(UsUtV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, knownChildSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspUtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsUtV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspUtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsUtV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspUtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsUtV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } @Override GppConsent build() { - return new UspUtV1Consent(section, fieldValues) + return new UsUtV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy similarity index 80% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy index 371611e0851..e3a0682ca73 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsV1Consent.groovy @@ -2,9 +2,9 @@ package org.prebid.server.functional.util.privacy.gpp import com.iab.gpp.encoder.field.UspV1Field -class UspV1Consent extends GppConsent { +class UsV1Consent extends GppConsent { - protected UspV1Consent(Section section, Map fieldValues) { + protected UsV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -35,8 +35,8 @@ class UspV1Consent extends GppConsent { } @Override - UspV1Consent build() { - new UspV1Consent(section, fieldValues) + UsV1Consent build() { + new UsV1Consent(section, fieldValues) } } } diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy similarity index 56% rename from src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy rename to src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy index b33cf2d9603..97463c079fc 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UspVaV1Consent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/gpp/UsVaV1Consent.groovy @@ -1,13 +1,13 @@ package org.prebid.server.functional.util.privacy.gpp -import com.iab.gpp.encoder.field.UspVaV1Field +import com.iab.gpp.encoder.field.UsVaV1Field import org.prebid.server.functional.util.privacy.gpp.data.UsVirginiaSensitiveData -class UspVaV1Consent extends GppConsent { +class UsVaV1Consent extends GppConsent { - private static final Section SECTION = Section.USP_VA_V1 + private static final Section SECTION = Section.US_VA_V1 - protected UspVaV1Consent(Section section, Map fieldValues) { + protected UsVaV1Consent(Section section, Map fieldValues) { super(section, fieldValues) } @@ -23,63 +23,63 @@ class UspVaV1Consent extends GppConsent { } Builder setVersion(Integer version) { - fieldValue(UspVaV1Field.VERSION, version) + fieldValue(UsVaV1Field.VERSION, version) this } Builder setSharingNotice(Integer sharingNotice) { - fieldValue(UspVaV1Field.SHARING_NOTICE, sharingNotice) + fieldValue(UsVaV1Field.SHARING_NOTICE, sharingNotice) this } Builder setSaleOptOutNotice(Integer saleOptOutNotice) { - fieldValue(UspVaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) + fieldValue(UsVaV1Field.SALE_OPT_OUT_NOTICE, saleOptOutNotice) this } Builder setTargetedAdvertisingOptOutNotice(Integer targetedAdvertisingOptOutNotice) { - fieldValue(UspVaV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) + fieldValue(UsVaV1Field.TARGETED_ADVERTISING_OPT_OUT_NOTICE, targetedAdvertisingOptOutNotice) this } Builder setSaleOptOut(Integer saleOptOut) { - fieldValue(UspVaV1Field.SALE_OPT_OUT, saleOptOut) + fieldValue(UsVaV1Field.SALE_OPT_OUT, saleOptOut) this } Builder setTargetedAdvertisingOptOut(Integer targetedAdvertisingOptOut) { - fieldValue(UspVaV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) + fieldValue(UsVaV1Field.TARGETED_ADVERTISING_OPT_OUT, targetedAdvertisingOptOut) this } Builder setSensitiveDataProcessing(UsVirginiaSensitiveData sensitiveDataProcessing) { - fieldValue(UspVaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) + fieldValue(UsVaV1Field.SENSITIVE_DATA_PROCESSING, sensitiveDataProcessing.contentList) this } Builder setKnownChildSensitiveDataConsents(Integer childSensitiveDataConsents) { - fieldValue(UspVaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, childSensitiveDataConsents) + fieldValue(UsVaV1Field.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS, childSensitiveDataConsents) this } Builder setMspaCoveredTransaction(Integer mspaCoveredTransaction) { - fieldValue(UspVaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) + fieldValue(UsVaV1Field.MSPA_COVERED_TRANSACTION, mspaCoveredTransaction) this } Builder setMspaOptOutOptionMode(Integer mspaOptOutOptionMode) { - fieldValue(UspVaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) + fieldValue(UsVaV1Field.MSPA_OPT_OUT_OPTION_MODE, mspaOptOutOptionMode) this } Builder setMspaServiceProviderMode(Integer mspaServiceProviderMode) { - fieldValue(UspVaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) + fieldValue(UsVaV1Field.MSPA_SERVICE_PROVIDER_MODE, mspaServiceProviderMode) this } @Override GppConsent build() { - return new UspVaV1Consent(section, fieldValues) + return new UsVaV1Consent(section, fieldValues) } } } diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java index 2a2bde3824d..1582b453ce9 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USCaliforniaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USCaliforniaGppReaderTest { private GppModel gppModel; @Mock - private UspCaV1 uspCaV1; + private UsCaV1 usCaV1; private USCaliforniaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCaV1Section()).willReturn(uspCaV1); + given(gppModel.getUsCaV1Section()).willReturn(usCaV1); gppReader = new USCaliforniaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCaV1.getVersion()).willReturn(1); + given(usCaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCaV1.getGpc()).willReturn(true); + given(usCaV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCaV1.getGpcSegmentIncluded()).willReturn(true); + given(usCaV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOut()).willReturn(1); + given(usCaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOutNotice()).willReturn(1); + given(usCaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,13 +92,13 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { public void getSharingNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOut()).willReturn(1); + given(usCaV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -107,7 +107,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOutNotice()).willReturn(1); + given(usCaV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -117,20 +117,20 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -140,7 +140,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCaV1.getSensitiveDataProcessing()).willReturn(data); + given(usCaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,14 +150,14 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -166,7 +166,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspCaV1.getPersonalDataConsents()).willReturn(1); + given(usCaV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -175,7 +175,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaCoveredTransaction()).willReturn(1); + given(usCaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -184,7 +184,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaServiceProviderMode()).willReturn(1); + given(usCaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -193,7 +193,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java index bbe77552039..c0304049075 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USColoradoGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USColoradoGppReaderTest { private GppModel gppModel; @Mock - private UspCoV1 uspCoV1; + private UsCoV1 usCoV1; private USColoradoGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCoV1Section()).willReturn(uspCoV1); + given(gppModel.getUsCoV1Section()).willReturn(usCoV1); gppReader = new USColoradoGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCoV1.getVersion()).willReturn(1); + given(usCoV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCoV1.getGpc()).willReturn(true); + given(usCoV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCoV1.getGpcSegmentIncluded()).willReturn(true); + given(usCoV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOut()).willReturn(1); + given(usCoV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOutNotice()).willReturn(1); + given(usCoV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSharingNotice()).willReturn(1); + given(usCoV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCoV1.getSensitiveDataProcessing()).willReturn(data); + given(usCoV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -166,13 +166,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaCoveredTransaction()).willReturn(1); + given(usCoV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -181,7 +181,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaServiceProviderMode()).willReturn(1); + given(usCoV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -190,7 +190,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCoV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java index 0ee56cfcd1a..a3ffa92c763 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USConnecticutGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USConnecticutGppReaderTest { private GppModel gppModel; @Mock - private UspCtV1 uspCtV1; + private UsCtV1 usCtV1; private USConnecticutGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCtV1Section()).willReturn(uspCtV1); + given(gppModel.getUsCtV1Section()).willReturn(usCtV1); gppReader = new USConnecticutGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCtV1.getVersion()).willReturn(1); + given(usCtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCtV1.getGpc()).willReturn(true); + given(usCtV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCtV1.getGpcSegmentIncluded()).willReturn(true); + given(usCtV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOut()).willReturn(1); + given(usCtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOutNotice()).willReturn(1); + given(usCtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSharingNotice()).willReturn(1); + given(usCtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getSensitiveDataProcessing()).willReturn(data); + given(usCtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,14 +150,14 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -167,13 +167,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaCoveredTransaction()).willReturn(1); + given(usCtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -182,7 +182,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaServiceProviderMode()).willReturn(1); + given(usCtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -191,7 +191,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java index ace4324c7b3..70ba21416da 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USUtahGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USUtahGppReaderTest { private GppModel gppModel; @Mock - private UspUtV1 uspUtV1; + private UsUtV1 usUtV1; private USUtahGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspUtV1Section()).willReturn(uspUtV1); + given(gppModel.getUsUtV1Section()).willReturn(usUtV1); gppReader = new USUtahGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspUtV1.getVersion()).willReturn(1); + given(usUtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOut()).willReturn(1); + given(usUtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOutNotice()).willReturn(1); + given(usUtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSharingNotice()).willReturn(1); + given(usUtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspUtV1.getSensitiveDataProcessing()).willReturn(data); + given(usUtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -145,7 +145,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -154,7 +154,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -164,13 +164,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaCoveredTransaction()).willReturn(1); + given(usUtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -179,7 +179,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaServiceProviderMode()).willReturn(1); + given(usUtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -188,7 +188,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usUtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java index 7d326e4b0ae..04a685037e2 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/uscustomlogic/reader/USVirginiaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.uscustomlogic.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USVirginiaGppReaderTest { private GppModel gppModel; @Mock - private UspVaV1 uspVaV1; + private UsVaV1 usVaV1; private USVirginiaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspVaV1Section()).willReturn(uspVaV1); + given(gppModel.getUsVaV1Section()).willReturn(usVaV1); gppReader = new USVirginiaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspVaV1.getVersion()).willReturn(1); + given(usVaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOut()).willReturn(1); + given(usVaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOutNotice()).willReturn(1); + given(usVaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSharingNotice()).willReturn(1); + given(usVaV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspVaV1.getSensitiveDataProcessing()).willReturn(data); + given(usVaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -146,13 +146,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isEqualTo(1); @@ -162,13 +162,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaCoveredTransaction()).willReturn(1); + given(usVaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -177,7 +177,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaServiceProviderMode()).willReturn(1); + given(usVaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -186,7 +186,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usVaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java index 6b4133f2ba9..9e5ab6ba540 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedCaliforniaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCaV1; +import com.iab.gpp.encoder.section.UsCaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedCaliforniaGppReaderTest { private GppModel gppModel; @Mock - private UspCaV1 uspCaV1; + private UsCaV1 usCaV1; private USMappedCaliforniaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCaV1Section()).willReturn(uspCaV1); + given(gppModel.getUsCaV1Section()).willReturn(usCaV1); gppReader = new USMappedCaliforniaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCaV1.getVersion()).willReturn(1); + given(usCaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCaV1.getGpc()).willReturn(true); + given(usCaV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCaV1.getGpcSegmentIncluded()).willReturn(true); + given(usCaV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOut()).willReturn(1); + given(usCaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSaleOptOutNotice()).willReturn(1); + given(usCaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,13 +92,13 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { public void getSharingNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOut()).willReturn(1); + given(usCaV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -107,7 +107,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSharingOptOutNotice()).willReturn(1); + given(usCaV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -117,20 +117,20 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usCaV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -139,7 +139,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given - given(uspCaV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); + given(usCaV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); // when and then assertThat(gppReader.getSensitiveDataProcessing()) @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCaV1); + verifyNoInteractions(usCaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { // given - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0)); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -165,7 +165,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { // given - given(uspCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 2)); + given(usCaV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 2)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspCaV1.getPersonalDataConsents()).willReturn(1); + given(usCaV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -183,7 +183,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaCoveredTransaction()).willReturn(1); + given(usCaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -192,7 +192,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaServiceProviderMode()).willReturn(1); + given(usCaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -201,7 +201,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java index 4f7d83f0be8..0e45614e6da 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedColoradoGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCoV1; +import com.iab.gpp.encoder.section.UsCoV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedColoradoGppReaderTest { private GppModel gppModel; @Mock - private UspCoV1 uspCoV1; + private UsCoV1 usCoV1; private USMappedColoradoGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCoV1Section()).willReturn(uspCoV1); + given(gppModel.getUsCoV1Section()).willReturn(usCoV1); gppReader = new USMappedColoradoGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCoV1.getVersion()).willReturn(1); + given(usCoV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCoV1.getGpc()).willReturn(true); + given(usCoV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCoV1.getGpcSegmentIncluded()).willReturn(true); + given(usCoV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOut()).willReturn(1); + given(usCoV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSaleOptOutNotice()).willReturn(1); + given(usCoV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getSharingNotice()).willReturn(1); + given(usCoV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -101,20 +101,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -123,7 +123,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCoV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -133,14 +133,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCoV1.getSensitiveDataProcessing()).willReturn(data); + given(usCoV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -150,13 +150,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -165,7 +165,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspCoV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usCoV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -184,13 +184,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCoV1); + verifyNoInteractions(usCoV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaCoveredTransaction()).willReturn(1); + given(usCoV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -199,7 +199,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaServiceProviderMode()).willReturn(1); + given(usCoV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -208,7 +208,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCoV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCoV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java index 75e4caf48e9..ed15d382944 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedConnecticutGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspCtV1; +import com.iab.gpp.encoder.section.UsCtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -26,13 +26,13 @@ public class USMappedConnecticutGppReaderTest { private GppModel gppModel; @Mock - private UspCtV1 uspCtV1; + private UsCtV1 usCtV1; private USMappedConnecticutGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspCtV1Section()).willReturn(uspCtV1); + given(gppModel.getUsCtV1Section()).willReturn(usCtV1); gppReader = new USMappedConnecticutGppReader(gppModel); } @@ -40,7 +40,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspCtV1.getVersion()).willReturn(1); + given(usCtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,7 +49,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspCtV1.getGpc()).willReturn(true); + given(usCtV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -59,13 +59,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspCtV1.getGpcSegmentIncluded()).willReturn(true); + given(usCtV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -74,7 +74,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOut()).willReturn(1); + given(usCtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -83,7 +83,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSaleOptOutNotice()).willReturn(1); + given(usCtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -92,7 +92,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getSharingNotice()).willReturn(1); + given(usCtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -102,20 +102,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -124,7 +124,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usCtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -134,14 +134,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspCtV1.getSensitiveDataProcessing()).willReturn(data); + given(usCtV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -151,13 +151,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0, 0)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(0, 0, 0)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -166,7 +166,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnMixedChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, 2, 2)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, 2, 2)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(2, 1); @@ -175,7 +175,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnMixedChildResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { // given - given(uspCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, null, null)); + given(usCtV1.getKnownChildSensitiveDataConsents()).willReturn(asList(null, null, null)); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -185,13 +185,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResult() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspCtV1); + verifyNoInteractions(usCtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaCoveredTransaction()).willReturn(1); + given(usCtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -200,7 +200,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaServiceProviderMode()).willReturn(1); + given(usCtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -209,7 +209,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspCtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usCtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java index 92b87cdd8e9..799a2cd914b 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedUtahGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspUtV1; +import com.iab.gpp.encoder.section.UsUtV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedUtahGppReaderTest { private GppModel gppModel; @Mock - private UspUtV1 uspUtV1; + private UsUtV1 usUtV1; private USMappedUtahGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspUtV1Section()).willReturn(uspUtV1); + given(gppModel.getUsUtV1Section()).willReturn(usUtV1); gppReader = new USMappedUtahGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspUtV1.getVersion()).willReturn(1); + given(usUtV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOut()).willReturn(1); + given(usUtV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSaleOptOutNotice()).willReturn(1); + given(usUtV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSharingNotice()).willReturn(1); + given(usUtV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usUtV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,13 +129,13 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7)); + given(usUtV1.getSensitiveDataProcessing()).willReturn(asList(0, 1, 2, 3, 4, 5, 6, 7)); // when and then assertThat(gppReader.getSensitiveDataProcessing()) @@ -145,7 +145,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usUtV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -154,7 +154,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -163,7 +163,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -172,7 +172,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspUtV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usUtV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -182,13 +182,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspUtV1); + verifyNoInteractions(usUtV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaCoveredTransaction()).willReturn(1); + given(usUtV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -197,7 +197,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaServiceProviderMode()).willReturn(1); + given(usUtV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -206,7 +206,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspUtV1.getMspaOptOutOptionMode()).willReturn(1); + given(usUtV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java index 0d420793460..1aaae9a9592 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USMappedVirginiaGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspVaV1; +import com.iab.gpp.encoder.section.UsVaV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USMappedVirginiaGppReaderTest { private GppModel gppModel; @Mock - private UspVaV1 uspVaV1; + private UsVaV1 usVaV1; private USMappedVirginiaGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspVaV1Section()).willReturn(uspVaV1); + given(gppModel.getUsVaV1Section()).willReturn(usVaV1); gppReader = new USMappedVirginiaGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspVaV1.getVersion()).willReturn(1); + given(usVaV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -49,27 +49,27 @@ public void getVersionShouldReturnExpectedResult() { public void getGpcShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpc()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentIncluded()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOut()).willReturn(1); + given(usVaV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -78,7 +78,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSaleOptOutNotice()).willReturn(1); + given(usVaV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -87,7 +87,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getSharingNotice()).willReturn(1); + given(usVaV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -97,20 +97,20 @@ public void getSharingNoticeShouldReturnExpectedResult() { public void getSharingOptOutShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOut()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSharingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -119,7 +119,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usVaV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -129,14 +129,14 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspVaV1.getSensitiveDataProcessing()).willReturn(data); + given(usVaV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -146,13 +146,13 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(1); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -161,7 +161,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn1() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(2); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(2); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(1, 1); @@ -170,7 +170,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnChildResultOn2() { @Test public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { // given - given(uspVaV1.getKnownChildSensitiveDataConsents()).willReturn(0); + given(usVaV1.getKnownChildSensitiveDataConsents()).willReturn(0); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).containsExactly(0, 0); @@ -180,13 +180,13 @@ public void getKnownChildSensitiveDataConsentsShouldReturnNonChildResultOn0() { public void getPersonalDataConsentsShouldReturnExpectedResult() { // when and then assertThat(gppReader.getPersonalDataConsents()).isNull(); - verifyNoInteractions(uspVaV1); + verifyNoInteractions(usVaV1); } @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaCoveredTransaction()).willReturn(1); + given(usVaV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -195,7 +195,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaServiceProviderMode()).willReturn(1); + given(usVaV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -204,7 +204,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspVaV1.getMspaOptOutOptionMode()).willReturn(1); + given(usVaV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java index 80beebf8770..79279c280bf 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/privacy/usnat/reader/USNationalGppReaderTest.java @@ -1,7 +1,7 @@ package org.prebid.server.activity.infrastructure.privacy.usnat.reader; import com.iab.gpp.encoder.GppModel; -import com.iab.gpp.encoder.section.UspNatV1; +import com.iab.gpp.encoder.section.UsNatV1; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -25,13 +25,13 @@ public class USNationalGppReaderTest { private GppModel gppModel; @Mock - private UspNatV1 uspNatV1; + private UsNatV1 usNatV1; private USNationalGppReader gppReader; @Before public void setUp() { - given(gppModel.getUspNatV1Section()).willReturn(uspNatV1); + given(gppModel.getUsNatV1Section()).willReturn(usNatV1); gppReader = new USNationalGppReader(gppModel); } @@ -39,7 +39,7 @@ public void setUp() { @Test public void getVersionShouldReturnExpectedResult() { // given - given(uspNatV1.getVersion()).willReturn(1); + given(usNatV1.getVersion()).willReturn(1); // when and then assertThat(gppReader.getVersion()).isEqualTo(1); @@ -48,7 +48,7 @@ public void getVersionShouldReturnExpectedResult() { @Test public void getGpcShouldReturnExpectedResult() { // given - given(uspNatV1.getGpc()).willReturn(true); + given(usNatV1.getGpc()).willReturn(true); // when and then assertThat(gppReader.getGpc()).isTrue(); @@ -58,13 +58,13 @@ public void getGpcShouldReturnExpectedResult() { public void getGpcSegmentTypeShouldReturnExpectedResult() { // when and then assertThat(gppReader.getGpcSegmentType()).isNull(); - verifyNoInteractions(uspNatV1); + verifyNoInteractions(usNatV1); } @Test public void getGpcSegmentIncludedShouldReturnExpectedResult() { // given - given(uspNatV1.getGpcSegmentIncluded()).willReturn(true); + given(usNatV1.getGpcSegmentIncluded()).willReturn(true); // when and then assertThat(gppReader.getGpcSegmentIncluded()).isTrue(); @@ -73,7 +73,7 @@ public void getGpcSegmentIncludedShouldReturnExpectedResult() { @Test public void getSaleOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getSaleOptOut()).willReturn(1); + given(usNatV1.getSaleOptOut()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOut()).isEqualTo(1); @@ -82,7 +82,7 @@ public void getSaleOptOutShouldReturnExpectedResult() { @Test public void getSaleOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSaleOptOutNotice()).willReturn(1); + given(usNatV1.getSaleOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSaleOptOutNotice()).isEqualTo(1); @@ -91,7 +91,7 @@ public void getSaleOptOutNoticeShouldReturnExpectedResult() { @Test public void getSharingNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingNotice()).willReturn(1); + given(usNatV1.getSharingNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingNotice()).isEqualTo(1); @@ -100,7 +100,7 @@ public void getSharingNoticeShouldReturnExpectedResult() { @Test public void getSharingOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingOptOut()).willReturn(1); + given(usNatV1.getSharingOptOut()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOut()).isEqualTo(1); @@ -109,7 +109,7 @@ public void getSharingOptOutShouldReturnExpectedResult() { @Test public void getSharingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSharingOptOutNotice()).willReturn(1); + given(usNatV1.getSharingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSharingOptOutNotice()).isEqualTo(1); @@ -118,7 +118,7 @@ public void getSharingOptOutNoticeShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { // given - given(uspNatV1.getTargetedAdvertisingOptOut()).willReturn(1); + given(usNatV1.getTargetedAdvertisingOptOut()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOut()).isEqualTo(1); @@ -127,7 +127,7 @@ public void getTargetedAdvertisingOptOutShouldReturnExpectedResult() { @Test public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); + given(usNatV1.getTargetedAdvertisingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getTargetedAdvertisingOptOutNotice()).isEqualTo(1); @@ -136,7 +136,7 @@ public void getTargetedAdvertisingOptOutNoticeShouldReturnExpectedResult() { @Test public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSensitiveDataLimitUseNotice()).willReturn(1); + given(usNatV1.getSensitiveDataLimitUseNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataLimitUseNotice()).isEqualTo(1); @@ -146,7 +146,7 @@ public void getSensitiveDataLimitUseNoticeShouldReturnExpectedResult() { public void getSensitiveDataProcessingShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspNatV1.getSensitiveDataProcessing()).willReturn(data); + given(usNatV1.getSensitiveDataProcessing()).willReturn(data); // when and then assertThat(gppReader.getSensitiveDataProcessing()).isSameAs(data); @@ -155,7 +155,7 @@ public void getSensitiveDataProcessingShouldReturnExpectedResult() { @Test public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { // given - given(uspNatV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); + given(usNatV1.getSensitiveDataProcessingOptOutNotice()).willReturn(1); // when and then assertThat(gppReader.getSensitiveDataProcessingOptOutNotice()).isEqualTo(1); @@ -165,7 +165,7 @@ public void getSensitiveDataProcessingOptOutNoticeShouldReturnExpectedResult() { public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { // given final List data = Collections.emptyList(); - given(uspNatV1.getKnownChildSensitiveDataConsents()).willReturn(data); + given(usNatV1.getKnownChildSensitiveDataConsents()).willReturn(data); // when and then assertThat(gppReader.getKnownChildSensitiveDataConsents()).isSameAs(data); @@ -174,7 +174,7 @@ public void getKnownChildSensitiveDataConsentsShouldReturnExpectedResult() { @Test public void getPersonalDataConsentsShouldReturnExpectedResult() { // given - given(uspNatV1.getPersonalDataConsents()).willReturn(1); + given(usNatV1.getPersonalDataConsents()).willReturn(1); // when and then assertThat(gppReader.getPersonalDataConsents()).isEqualTo(1); @@ -183,7 +183,7 @@ public void getPersonalDataConsentsShouldReturnExpectedResult() { @Test public void getMspaCoveredTransactionShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaCoveredTransaction()).willReturn(1); + given(usNatV1.getMspaCoveredTransaction()).willReturn(1); // when and then assertThat(gppReader.getMspaCoveredTransaction()).isEqualTo(1); @@ -192,7 +192,7 @@ public void getMspaCoveredTransactionShouldReturnExpectedResult() { @Test public void getMspaServiceProviderModeShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaServiceProviderMode()).willReturn(1); + given(usNatV1.getMspaServiceProviderMode()).willReturn(1); // when and then assertThat(gppReader.getMspaServiceProviderMode()).isEqualTo(1); @@ -201,7 +201,7 @@ public void getMspaServiceProviderModeShouldReturnExpectedResult() { @Test public void getMspaOptOutOptionModeShouldReturnExpectedResult() { // given - given(uspNatV1.getMspaOptOutOptionMode()).willReturn(1); + given(usNatV1.getMspaOptOutOptionMode()).willReturn(1); // when and then assertThat(gppReader.getMspaOptOutOptionMode()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java b/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java index 2a998ec0421..3ffd0b1a40a 100644 --- a/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java @@ -37,7 +37,7 @@ public void fromShouldReturnGppContextWrapperWithErrorOnInvalidGpp() { assertThat(gppContext.regions()).isEqualTo(GppContext.Regions.builder().build()); }); assertThat(gppContextWrapper.getErrors()) - .containsExactly("GPP string invalid: Undecodable FibonacciIntegerRange '101111011'"); + .containsExactly("GPP string invalid: Unable to decode 'invalid'"); } @Test From 970f38426f0dd0599be3c01a19d61a367dd2d397 Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Wed, 8 May 2024 16:13:44 +0300 Subject: [PATCH 39/58] Core: Change default value for `p4.eid.activity_transition` (#3159) --- .../ActivityInfrastructureCreator.java | 2 +- .../GppTransmitUfpdActivitiesSpec.groovy | 131 +++++++++++------- .../ActivityInfrastructureCreatorTest.java | 10 +- 3 files changed, 84 insertions(+), 59 deletions(-) diff --git a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java index f3a0b515a3c..49e24a06183 100644 --- a/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java +++ b/src/main/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreator.java @@ -124,7 +124,7 @@ private Function fallbackActivity( .or(() -> Optional.ofNullable(defaultPurpose4)) .map(Purpose::getEid) .map(PurposeEid::getActivityTransition) - .orElse(true); + .orElse(false); return originalActivity -> originalActivity == Activity.TRANSMIT_EIDS && imitateTransmitEids ? activityControllerCreator.apply(Activity.TRANSMIT_UFPD) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index a1d8a1d6104..c6c68f81714 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -126,15 +126,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction call when transmit UFPD activities is rejecting requests should remove UFPD fields in request and update disallowed metrics"() { @@ -171,10 +170,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -213,10 +214,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids } def "PBS auction call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -286,7 +289,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -326,10 +328,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids } def "PBS auction shouldn't allow rule when gppSid not intersect"() { @@ -375,15 +379,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -434,10 +437,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -490,15 +495,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 where: deviceGeo | conditionGeo @@ -553,10 +557,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -613,15 +619,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -669,10 +674,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -724,15 +731,14 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.buyeruid == bidRequest.user.buyeruid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender - bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source bidderRequest.user.data == bidRequest.user.data bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 - assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 + assert metrics[ACTIVITY_PROCESSED_RULES_FOR_ACCOUNT.formatted(accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -779,10 +785,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.data } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -829,11 +837,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] } @@ -877,11 +887,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, @@ -1099,11 +1111,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: gppConsent | gppSid new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 @@ -1152,7 +1166,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1205,7 +1218,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1257,7 +1269,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1340,7 +1351,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.eids[0].source == genericBidRequest.user.eids[0].source genericBidderRequest.user.data == genericBidRequest.user.data genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1396,11 +1406,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == generalBidRequest.user.eids + where: gppConsent | valueRules new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] @@ -1459,7 +1471,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing that match custom config should have empty UFPD fields"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1486,10 +1498,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(genericBidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(generalBidRequest.id) + def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) verifyAll { !genericBidderRequest.device.didsha1 !genericBidderRequest.device.didmd5 @@ -1502,11 +1514,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == genericBidRequest.user.eids + where: gppSid | equalityValueRules | gppStateConsent US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() @@ -1621,14 +1635,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 } def "PBS amp call when transmit UFPD activities is rejecting request should remove UFPD fields field in active request and update disallowed metrics"() { @@ -1673,11 +1686,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -1724,10 +1739,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -1815,7 +1832,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -1864,10 +1880,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp should disallowed rule when header.gpc intersection with condition.gpc"() { @@ -1919,11 +1937,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[DISALLOWED_COUNT_FOR_ACTIVITY_RULE] == 1 @@ -1978,14 +1998,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 2 + assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -2036,11 +2055,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] } @@ -2093,11 +2114,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: disallowGppLogic << [ SIMPLE_GPC_DISALLOW_LOGIC, @@ -2333,11 +2356,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppConsent | gppSid new UsNatV1Consent.Builder().setMspaServiceProviderMode(1).setMspaOptOutOptionMode(2).build() | US_NAT_V1 @@ -2394,7 +2419,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2455,7 +2479,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2516,7 +2539,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2617,7 +2639,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source genericBidderRequest.user.data == ampStoredRequest.user.data genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2682,11 +2703,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppConsent | valueRules new UsNatV1Consent.Builder().setPersonalDataConsents(2).build() | [new EqualityValueRule(PERSONAL_DATA_CONSENTS, NOTICE_NOT_PROVIDED)] @@ -2808,11 +2831,13 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender - !genericBidderRequest.user.eids !genericBidderRequest.user.data !genericBidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + where: gppSid | equalityValueRules | gppStateConsent US_CA_V1 | [new EqualityValueRule(SENSITIVE_DATA_ID_NUMBERS, CONSENT)] | new UsCaV1Consent.Builder() diff --git a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java index 0927f596a41..d938ec69aa0 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java @@ -141,7 +141,7 @@ public void parseShouldReturnExpectedResult() { } @Test - public void parseShouldReturnImitatedTransmitEidsActivity() { + public void parseShouldReturnOriginalTransmitEidsActivity() { // given final Account account = Account.builder() .privacy(AccountPrivacyConfig.builder() @@ -158,17 +158,17 @@ public void parseShouldReturnImitatedTransmitEidsActivity() { assertThat(controllers.get(Activity.CALL_BIDDER).isAllowed(null)).isEqualTo(true); assertThat(controllers.get(Activity.TRANSMIT_UFPD).isAllowed(null)).isEqualTo(false); - assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(false); + assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(true); } @Test - public void parseShouldReturnOriginalTransmitEidsActivity() { + public void parseShouldReturnImitatedTransmitEidsActivity() { // given final Account account = Account.builder() .privacy(AccountPrivacyConfig.builder() .gdpr(AccountGdprConfig.builder() .purposes(Purposes.builder() - .p4(Purpose.of(null, null, null, PurposeEid.of(false, false, null))) + .p4(Purpose.of(null, null, null, PurposeEid.of(true, false, null))) .build()) .build()) .activities(Map.of(Activity.TRANSMIT_UFPD, AccountActivityConfiguration.of(false, null))) @@ -184,6 +184,6 @@ public void parseShouldReturnOriginalTransmitEidsActivity() { assertThat(controllers.get(Activity.CALL_BIDDER).isAllowed(null)).isEqualTo(true); assertThat(controllers.get(Activity.TRANSMIT_UFPD).isAllowed(null)).isEqualTo(false); - assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(true); + assertThat(controllers.get(Activity.TRANSMIT_EIDS).isAllowed(null)).isEqualTo(false); } } From 8652ffffb533dd956d3b69d92dd1805821b8566a Mon Sep 17 00:00:00 2001 From: Dubyk Danylo <45672370+CTMBNara@users.noreply.github.com> Date: Thu, 9 May 2024 13:22:13 +0300 Subject: [PATCH 40/58] Core: Update transmitPreciseGeo and transmitUfpd activities (#3128) --- ...ConfiantAdQualityBidResponsesScanHook.java | 2 +- ...iantAdQualityBidResponsesScanHookTest.java | 6 +- .../reporter/AnalyticsReporterDelegator.java | 2 +- .../enforcement/ActivityEnforcement.java | 11 +- .../privacy/enforcement/TcfEnforcement.java | 2 +- .../enforcement/mask/UserFpdActivityMask.java | 7 +- .../enforcement/mask/UserFpdCcpaMask.java | 35 +- .../enforcement/mask/UserFpdCoppaMask.java | 27 +- .../enforcement/mask/UserFpdPrivacyMask.java | 39 +- .../enforcement/mask/UserFpdTcfMask.java | 23 +- .../config/PrivacyServiceConfiguration.java | 8 +- .../request/auction/GeoExtGeoProvider.groovy | 5 + .../functional/tests/privacy/CoppaSpec.groovy | 242 ++++ ...GppTransmitPreciseGeoActivitiesSpec.groovy | 1022 +++++++++++++---- .../GppTransmitUfpdActivitiesSpec.groovy | 50 + .../tests/privacy/PrivacyBaseSpec.groovy | 32 +- .../AnalyticsReporterDelegatorTest.java | 2 +- .../enforcement/ActivityEnforcementTest.java | 2 +- .../enforcement/TcfEnforcementTest.java | 6 +- .../mask/UserFpdActivityMaskTest.java | 20 +- .../enforcement/mask/UserFpdCcpaMaskTest.java | 75 +- .../mask/UserFpdCoppaMaskTest.java | 71 +- .../enforcement/mask/UserFpdTcfMaskTest.java | 76 +- 23 files changed, 1261 insertions(+), 504 deletions(-) diff --git a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java index 4cf66880bef..7db1446bcce 100644 --- a/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java +++ b/extra/modules/confiant-ad-quality/src/main/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHook.java @@ -81,7 +81,7 @@ private BidRequest getBidRequest(AuctionInvocationContext auctionInvocationConte final boolean disallowTransmitGeo = !auctionContext.getActivityInfrastructure() .isAllowed(Activity.TRANSMIT_GEO, activityInvocationPayload); - final User maskedUser = userFpdActivityMask.maskUser(bidRequest.getUser(), true, true, disallowTransmitGeo); + final User maskedUser = userFpdActivityMask.maskUser(bidRequest.getUser(), true, true); final Device maskedDevice = userFpdActivityMask.maskDevice(bidRequest.getDevice(), true, disallowTransmitGeo); return bidRequest.toBuilder() diff --git a/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java b/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java index 8746a3e10b2..4d2e61ee1cb 100644 --- a/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java +++ b/extra/modules/confiant-ad-quality/src/test/java/org/prebid/server/hooks/modules/com/confiant/adquality/v1/ConfiantAdQualityBidResponsesScanHookTest.java @@ -277,8 +277,7 @@ public void callShouldSubmitBidsWithoutMaskedGeoInfoWhenTransmitGeoIsAllowed() { final Boolean transmitGeoIsAllowed = true; final BidsScanResult bidsScanResult = redisParser.parseBidsScanResult( "[[[{\"tag_key\": \"tag\", \"issues\":[{\"spec_name\":\"malicious_domain\",\"value\":\"ads.deceivenetworks.net\",\"first_adinstance\":\"e91e8da982bb8b7f80100426\"}]}]]]"); - final User user = userFpdActivityMask.maskUser( - getUser(), true, true, !transmitGeoIsAllowed); + final User user = userFpdActivityMask.maskUser(getUser(), true, true); final Device device = userFpdActivityMask.maskDevice( getDevice(), true, !transmitGeoIsAllowed); @@ -306,8 +305,7 @@ public void callShouldSubmitBidsWithMaskedGeoInfoWhenTransmitGeoIsNotAllowed() { final Boolean transmitGeoIsAllowed = false; final BidsScanResult bidsScanResult = redisParser.parseBidsScanResult( "[[[{\"tag_key\": \"tag\", \"issues\":[{\"spec_name\":\"malicious_domain\",\"value\":\"ads.deceivenetworks.net\",\"first_adinstance\":\"e91e8da982bb8b7f80100426\"}]}]]]"); - final User user = userFpdActivityMask.maskUser( - getUser(), true, true, !transmitGeoIsAllowed); + final User user = userFpdActivityMask.maskUser(getUser(), true, true); final Device device = userFpdActivityMask.maskDevice( getDevice(), true, !transmitGeoIsAllowed); diff --git a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java index a65b2293a8d..adaf4aaf888 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java @@ -238,7 +238,7 @@ private BidRequest updateBidRequest(BidRequest bidRequest, final boolean disallowTransmitGeo = !isAllowedActivity(infrastructure, Activity.TRANSMIT_GEO, payload); final User user = bidRequest != null ? bidRequest.getUser() : null; - final User resolvedUser = mask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids, disallowTransmitGeo); + final User resolvedUser = mask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids); final Device device = bidRequest != null ? bidRequest.getDevice() : null; final Device resolvedDevice = mask.maskDevice(device, disallowTransmitUfpd, disallowTransmitGeo); diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java index 29e07658eb6..df7603048ee 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcement.java @@ -57,15 +57,8 @@ private BidderPrivacyResult applyActivityRestrictions(BidderPrivacyResult bidder final boolean disallowTransmitEids = !infrastructure.isAllowed(Activity.TRANSMIT_EIDS, payload); final boolean disallowTransmitGeo = !infrastructure.isAllowed(Activity.TRANSMIT_GEO, payload); - final User resolvedUser = userFpdActivityMask.maskUser( - user, - disallowTransmitUfpd, - disallowTransmitEids, - disallowTransmitGeo); - final Device resolvedDevice = userFpdActivityMask.maskDevice( - device, - disallowTransmitUfpd, - disallowTransmitGeo); + final User resolvedUser = userFpdActivityMask.maskUser(user, disallowTransmitUfpd, disallowTransmitEids); + final Device resolvedDevice = userFpdActivityMask.maskDevice(device, disallowTransmitUfpd, disallowTransmitGeo); return bidderPrivacyResult.toBuilder() .user(resolvedUser) diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java index 042e130132b..fc5e2dab1fb 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcement.java @@ -194,7 +194,7 @@ private BidderPrivacyResult createBidderPrivacyResult(String bidder, final boolean maskUserIds = privacyEnforcementAction.isRemoveUserIds() || isLmtEnabled; final boolean maskGeo = privacyEnforcementAction.isMaskGeo() || isLmtEnabled; final Set eidExceptions = privacyEnforcementAction.getEidExceptions(); - final User maskedUser = userFpdTcfMask.maskUser(user, maskUserFpd, maskUserIds, maskGeo, eidExceptions); + final User maskedUser = userFpdTcfMask.maskUser(user, maskUserFpd, maskUserIds, eidExceptions); final boolean maskIp = privacyEnforcementAction.isMaskDeviceIp() || isLmtEnabled; final boolean maskDeviceInfo = privacyEnforcementAction.isMaskDeviceInfo() || isLmtEnabled; diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java index 559d35b02fc..6e8a5558ba2 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMask.java @@ -14,16 +14,11 @@ public UserFpdActivityMask(UserFpdTcfMask userFpdTcfMask) { this.userFpdTcfMask = Objects.requireNonNull(userFpdTcfMask); } - public User maskUser(User user, - boolean disallowTransmitUfpd, - boolean disallowTransmitEids, - boolean disallowTransmitGeo) { - + public User maskUser(User user, boolean disallowTransmitUfpd, boolean disallowTransmitEids) { return userFpdTcfMask.maskUser( user, disallowTransmitUfpd, disallowTransmitEids, - disallowTransmitGeo, Collections.emptySet()); } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java index 4ed50a5cb58..fbb20d55a9b 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMask.java @@ -1,42 +1,23 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; -import org.prebid.server.auction.IpAddressHelper; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Collections; +import java.util.Objects; -public class UserFpdCcpaMask extends UserFpdPrivacyMask { +public class UserFpdCcpaMask { - public UserFpdCcpaMask(IpAddressHelper ipAddressHelper) { - super(ipAddressHelper); + private final UserFpdActivityMask userFpdActivityMask; + + public UserFpdCcpaMask(UserFpdActivityMask userFpdActivityMask) { + this.userFpdActivityMask = Objects.requireNonNull(userFpdActivityMask); } public User maskUser(User user) { - return maskUser(user, true, true, true, Collections.emptySet()); + return userFpdActivityMask.maskUser(user, true, true); } public Device maskDevice(Device device) { - return maskDevice(device, true, true, true); - } - - @Override - protected Geo maskGeo(Geo geo) { - return geo.toBuilder() - .lat(maskGeoCoordinate(geo.getLat())) - .lon(maskGeoCoordinate(geo.getLon())) - .metro(null) - .city(null) - .zip(null) - .build(); - } - - private static Float maskGeoCoordinate(Float coordinate) { - return coordinate != null - ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() - : null; + return userFpdActivityMask.maskDevice(device, true, true); } } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java index 0fc8a6ad6fc..ded930bff83 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMask.java @@ -1,34 +1,23 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; -import org.prebid.server.auction.IpAddressHelper; -import java.util.Collections; +import java.util.Objects; -public class UserFpdCoppaMask extends UserFpdPrivacyMask { +public class UserFpdCoppaMask { - public UserFpdCoppaMask(IpAddressHelper ipAddressHelper) { - super(ipAddressHelper); + private final UserFpdActivityMask userFpdActivityMask; + + public UserFpdCoppaMask(UserFpdActivityMask userFpdActivityMask) { + this.userFpdActivityMask = Objects.requireNonNull(userFpdActivityMask); } public User maskUser(User user) { - return maskUser(user, true, true, true, Collections.emptySet()); + return userFpdActivityMask.maskUser(user, true, true); } public Device maskDevice(Device device) { - return maskDevice(device, true, true, true); - } - - @Override - protected Geo maskGeo(Geo geo) { - return geo.toBuilder() - .lat(null) - .lon(null) - .metro(null) - .city(null) - .zip(null) - .build(); + return userFpdActivityMask.maskDevice(device, true, true); } } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java index 4d2a04ee203..6ce4e99c44f 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdPrivacyMask.java @@ -8,6 +8,8 @@ import org.prebid.server.auction.IpAddressHelper; import org.prebid.server.proto.openrtb.ext.request.ExtUser; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import java.util.Objects; import java.util.Set; @@ -23,10 +25,9 @@ protected UserFpdPrivacyMask(IpAddressHelper ipAddressHelper) { protected User maskUser(User user, boolean maskUserFpd, boolean maskEids, - boolean maskGeo, Set eidExceptions) { - if (user == null || !(maskUserFpd || maskEids || maskGeo)) { + if (user == null || !(maskUserFpd || maskEids)) { return user; } @@ -40,6 +41,7 @@ protected User maskUser(User user, .keywords(null) .kwarray(null) .data(null) + .geo(null) .ext(maskExtUser(user.getExt())); } @@ -47,10 +49,6 @@ protected User maskUser(User user, userBuilder.eids(removeEids(user.getEids(), eidExceptions)); } - if (maskGeo) { - userBuilder.geo(maskNullableGeo(user.getGeo())); - } - return nullIfEmpty(userBuilder.build()); } @@ -73,12 +71,6 @@ private static List removeEids(List eids, Set exceptions) { return clearedEids.isEmpty() ? null : clearedEids; } - private Geo maskNullableGeo(Geo geo) { - return geo != null ? nullIfEmpty(maskGeo(geo)) : null; - } - - protected abstract Geo maskGeo(Geo geo); - protected Device maskDevice(Device device, boolean maskIp, boolean maskGeo, boolean maskDeviceInfo) { if (device == null || !(maskIp || maskGeo || maskDeviceInfo)) { return device; @@ -105,6 +97,29 @@ protected Device maskDevice(Device device, boolean maskIp, boolean maskGeo, bool return deviceBuilder.build(); } + private static Geo maskNullableGeo(Geo geo) { + return geo != null ? nullIfEmpty(maskGeo(geo)) : null; + } + + private static Geo maskGeo(Geo geo) { + return geo.toBuilder() + .lat(maskGeoCoordinate(geo.getLat())) + .lon(maskGeoCoordinate(geo.getLon())) + .metro(null) + .city(null) + .zip(null) + .accuracy(null) + .ipservice(null) + .ext(null) + .build(); + } + + private static Float maskGeoCoordinate(Float coordinate) { + return coordinate != null + ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() + : null; + } + private static User nullIfEmpty(User user) { return user.equals(User.EMPTY) ? null : user; } diff --git a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java index 744b492807d..c0dfed0c175 100644 --- a/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java +++ b/src/main/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMask.java @@ -1,12 +1,9 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.prebid.server.auction.IpAddressHelper; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.Set; public class UserFpdTcfMask extends UserFpdPrivacyMask { @@ -15,27 +12,11 @@ public UserFpdTcfMask(IpAddressHelper ipAddressHelper) { super(ipAddressHelper); } - public User maskUser(User user, boolean maskUserFpd, boolean maskEids, boolean maskGeo, Set eidExceptions) { - return super.maskUser(user, maskUserFpd, maskEids, maskGeo, eidExceptions); + public User maskUser(User user, boolean maskUserFpd, boolean maskEids, Set eidExceptions) { + return super.maskUser(user, maskUserFpd, maskEids, eidExceptions); } public Device maskDevice(Device device, boolean maskIp, boolean maskGeo, boolean maskDeviceInfo) { return super.maskDevice(device, maskIp, maskGeo, maskDeviceInfo); } - - @Override - protected Geo maskGeo(Geo geo) { - return geo != null - ? geo.toBuilder() - .lat(maskGeoCoordinate(geo.getLat())) - .lon(maskGeoCoordinate(geo.getLon())) - .build() - : null; - } - - private static Float maskGeoCoordinate(Float coordinate) { - return coordinate != null - ? BigDecimal.valueOf(coordinate).setScale(2, RoundingMode.HALF_UP).floatValue() - : null; - } } diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index 2fa66398e28..d9ac686d861 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -355,13 +355,13 @@ UserFpdActivityMask userFpdActivityMask(UserFpdTcfMask userFpdTcfMask) { } @Bean - UserFpdCcpaMask userFpdCcpaMask(IpAddressHelper ipAddressHelper) { - return new UserFpdCcpaMask(ipAddressHelper); + UserFpdCcpaMask userFpdCcpaMask(UserFpdActivityMask userFpdActivityMask) { + return new UserFpdCcpaMask(userFpdActivityMask); } @Bean - UserFpdCoppaMask userFpdCoppaMask(IpAddressHelper ipAddressHelper) { - return new UserFpdCoppaMask(ipAddressHelper); + UserFpdCoppaMask userFpdCoppaMask(UserFpdActivityMask userFpdActivityMask) { + return new UserFpdCoppaMask(userFpdActivityMask); } @Bean diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy index c2c15f595da..1aa51084f20 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/GeoExtGeoProvider.groovy @@ -1,5 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode +import groovy.transform.ToString + +@EqualsAndHashCode +@ToString(includeNames = true, ignoreNulls = true) class GeoExtGeoProvider { String country diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy index dac9fafca18..6ad61e46cd3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -2,9 +2,17 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.Data +import org.prebid.server.functional.model.request.auction.Eid +import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.model.request.auction.UserExt +import org.prebid.server.functional.model.request.auction.UserExtData +import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE class CoppaSpec extends PrivacyBaseSpec { @@ -139,4 +147,238 @@ class CoppaSpec extends PrivacyBaseSpec { privacy.errors?.isEmpty() } } + + def "PBS shouldn't mask device and user fields for auction request when coppa = 0 was passed"() { + given: "BidRequest with personal data" + def bidRequest = bidRequestWithPersonalData.tap { + regs.coppa = 0 + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request shouldn't mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.device.ip == bidRequest.device.ip + bidderRequest.device.ipv6 == "af47:892b:3e98:b49a::" + bidderRequest.device.geo.lat == bidRequest.device.geo.lat + bidderRequest.device.geo.lon == bidRequest.device.geo.lon + bidderRequest.device.geo.country == bidRequest.device.geo.country + bidderRequest.device.geo.region == bidRequest.device.geo.region + bidderRequest.device.geo.utcoffset == bidRequest.device.geo.utcoffset + bidderRequest.device.geo.metro == bidRequest.device.geo.metro + bidderRequest.device.geo.city == bidRequest.device.geo.city + bidderRequest.device.geo.zip == bidRequest.device.geo.zip + bidderRequest.device.geo.accuracy == bidRequest.device.geo.accuracy + bidderRequest.device.geo.ipservice == bidRequest.device.geo.ipservice + bidderRequest.device.geo.ext == bidRequest.device.geo.ext + + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo.lat == bidRequest.user.geo.lat + bidderRequest.user.geo.lon == bidRequest.user.geo.lon + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + } + } + + def "PBS should mask device and user fields for auction request when coppa = 1 was passed"() { + given: "BidRequest with personal data" + def bidRequest = bidRequestWithPersonalData.tap { + regs.coppa = 1 + } + + when: "PBS processes auction request" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Bidder request should mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.ip == "43.77.114.0" + bidderRequest.device.ipv6 == "af47:892b:3e98:b400::" + bidderRequest.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequest.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequest.device.geo.country == bidRequest.device.geo.country + bidderRequest.device.geo.region == bidRequest.device.geo.region + bidderRequest.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask device personal data" + verifyAll (bidderRequest.device) { + !didsha1 + !didmd5 + !dpidsha1 + !ifa + !macsha1 + !macmd5 + !dpidmd5 + !geo.metro + !geo.city + !geo.zip + !geo.accuracy + !geo.ipservice + !geo.ext + } + + and: "Bidder request should mask user personal data" + verifyAll (bidderRequest.user) { + !id + !buyeruid + !yob + !gender + !eids + !data + !geo + !ext + !eids + !ext?.eids + } + } + + def "PBS shouldn't mask device and user fields for amp request when coppa = 0 was passed"() { + given: "Default AmpRequest" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Save storedRequest into DB" + def ampStoredRequest = bidRequestWithPersonalData.tap { + regs.coppa = 0 + } + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + defaultPbsService.sendAmpRequest(ampRequest) + + then: "Bidder request shouldn't mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.device.ip == ampStoredRequest.device.ip + bidderRequest.device.ipv6 == "af47:892b:3e98:b49a::" + bidderRequest.device.geo.lat == ampStoredRequest.device.geo.lat + bidderRequest.device.geo.lon == ampStoredRequest.device.geo.lon + bidderRequest.device.geo.country == ampStoredRequest.device.geo.country + bidderRequest.device.geo.region == ampStoredRequest.device.geo.region + bidderRequest.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + bidderRequest.device.geo.metro == ampStoredRequest.device.geo.metro + bidderRequest.device.geo.city == ampStoredRequest.device.geo.city + bidderRequest.device.geo.zip == ampStoredRequest.device.geo.zip + bidderRequest.device.geo.accuracy == ampStoredRequest.device.geo.accuracy + bidderRequest.device.geo.ipservice == ampStoredRequest.device.geo.ipservice + bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext + + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequest.user.geo.lon == ampStoredRequest.user.geo.lon + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + } + } + + def "PBS should mask device and user fields for amp request when coppa = 1 was passed"() { + given: "Default AmpRequest" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Save storedRequest into DB" + def ampStoredRequest = bidRequestWithPersonalData.tap { + regs.coppa = 1 + } + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes auction request" + defaultPbsService.sendAmpRequest(ampRequest) + + then: "Bidder request should mask device and user personal data" + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + verifyAll (bidderRequest) { + bidderRequest.device.ip == "43.77.114.0" + bidderRequest.device.ipv6 == "af47:892b:3e98:b400::" + bidderRequest.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequest.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequest.device.geo.country == ampStoredRequest.device.geo.country + bidderRequest.device.geo.region == ampStoredRequest.device.geo.region + bidderRequest.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask device personal data" + verifyAll (bidderRequest.device) { + !didsha1 + !didmd5 + !dpidsha1 + !ifa + !macsha1 + !macmd5 + !dpidmd5 + !geo.metro + !geo.city + !geo.zip + !geo.accuracy + !geo.ipservice + !geo.ext + } + + and: "Bidder request should mask user personal data" + verifyAll (bidderRequest.user) { + !id + !buyeruid + !yob + !gender + !eids + !data + !geo + !ext + !eids + !ext?.eids + } + } + + private static BidRequest getBidRequestWithPersonalData() { + getBidRequestWithGeo().tap { + setAccountId(accountId) + ext.prebid.trace = VERBOSE + device.tap { + didsha1 = PBSUtils.randomString + didmd5 = PBSUtils.randomString + dpidsha1 = PBSUtils.randomString + ifa = PBSUtils.randomString + macsha1 = PBSUtils.randomString + macmd5 = PBSUtils.randomString + dpidmd5 = PBSUtils.randomString + } + user.tap { + customdata = PBSUtils.randomString + eids = [Eid.defaultEid] + data = [new Data(name: PBSUtils.randomString)] + buyeruid = PBSUtils.randomString + yob = PBSUtils.randomNumber + gender = PBSUtils.randomString + geo = Geo.FPDGeo + ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) + } + } + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy index 7115f3fc561..c1e90d78a06 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -105,12 +105,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -145,14 +159,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -189,10 +220,24 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } } @@ -254,12 +299,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -289,14 +347,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } } @@ -332,12 +407,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -385,14 +473,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -439,12 +544,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -468,7 +586,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.setAccountId(accountId) it.regs.gppSid = [USP_V1.intValue] it.ext.prebid.trace = VERBOSE - it.device.geo = null + it.device.geo.tap { + country = null + region = null + } } and: "Setup condition" @@ -476,7 +597,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.componentType = null it.componentName = [PBSUtils.randomString] it.gppSid = [USP_V1.intValue] - it.geo = ["$USA.ISOAlpha3".toString()] + it.geo = [USA.ISOAlpha3] } and: "Set activity" @@ -495,14 +616,27 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon - !bidderRequests.device.geo - !bidderRequests.device.geo } and: "Metrics processed across activities should be updated" @@ -518,9 +652,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { it.setAccountId(accountId) it.regs.gppSid = null it.ext.prebid.trace = VERBOSE - it.device.geo = deviceGeo.tap { - lat = PBSUtils.getRandomDecimal(0, 90) - lon = PBSUtils.getRandomDecimal(0, 90) + it.device.geo.tap { + country = geoCountry + region = geoRegion } } @@ -548,14 +682,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -565,10 +716,10 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { assert metrics[DISALLOWED_COUNT_FOR_GENERIC_ADAPTER] == 1 where: - deviceGeo | conditionGeo - new Geo(country: USA) | [USA.ISOAlpha3] - new Geo(country: USA, region: ALABAMA.abbreviation) | [USA.withState(ALABAMA)] - new Geo(country: USA, region: ALABAMA.abbreviation) | [CAN.withState(ONTARIO), USA.withState(ALABAMA)] + geoCountry | geoRegion | conditionGeo + USA | null | [USA.ISOAlpha3] + USA | ALABAMA.abbreviation | [USA.withState(ALABAMA)] + USA | ALABAMA.abbreviation | [CAN.withState(ONTARIO), USA.withState(ALABAMA)] } def "PBS auction should process rule when regs.ext.gpc doesn't intersection with condition.gpc"() { @@ -603,12 +754,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -657,10 +821,28 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -702,12 +884,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -750,14 +945,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -795,14 +1007,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -837,14 +1066,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -907,14 +1153,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - bidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - bidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - bidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - bidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -952,12 +1215,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -997,12 +1273,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -1041,12 +1331,26 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(bidRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == bidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == bidRequest.device.geo.lat - bidderRequests.device.geo.lon == bidRequest.device.geo.lon bidderRequests.user.geo.lat == bidRequest.user.geo.lat bidderRequests.user.geo.lon == bidRequest.user.geo.lon } @@ -1091,7 +1395,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) @@ -1116,18 +1420,32 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain not rounded geo data for device and user" - def bidderRequests = bidder.getBidderRequest(genericBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) + def deviceBidderRequest = bidderRequests.device verifyAll { - bidderRequests.device.ip == genericBidRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == genericBidRequest.device.geo.lat - bidderRequests.device.geo.lon == genericBidRequest.device.geo.lon - bidderRequests.user.geo.lat == genericBidRequest.user.geo.lat - bidderRequests.user.geo.lon == genericBidRequest.user.geo.lon + deviceBidderRequest.ip == bidRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + + deviceBidderRequest.geo.lat == bidRequest.device.geo.lat + deviceBidderRequest.geo.lon == bidRequest.device.geo.lon + deviceBidderRequest.geo.country == bidRequest.device.geo.country + deviceBidderRequest.geo.region == bidRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == bidRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == bidRequest.device.geo.metro + deviceBidderRequest.geo.city == bidRequest.device.geo.city + deviceBidderRequest.geo.zip == bidRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == bidRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == bidRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == bidRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1141,7 +1459,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match custom requirement should round lat/lon data to 2 digits"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent setAccountId(accountId) @@ -1167,18 +1485,35 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain rounded geo data for device and user to 2 digits" - def bidderRequests = bidder.getBidderRequest(generalBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - generalBidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - generalBidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - generalBidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - generalBidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1242,7 +1577,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing should change request consent and call to bidder"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = bidRequestWithGeo.tap { + def bidRequest = bidRequestWithGeo.tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1273,18 +1608,35 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain rounded geo data for device and user to 2 digits" - def bidderRequests = bidder.getBidderRequest(generalBidRequest.id) - + def bidderRequests = bidder.getBidderRequest(bidRequest.id) verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - generalBidRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - generalBidRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - generalBidRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - generalBidRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == bidRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == bidRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == bidRequest.device.geo.country + bidderRequests.device.geo.region == bidRequest.device.geo.region + bidderRequests.device.geo.utcoffset == bidRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == bidRequest.user.geo.lat + bidderRequests.user.geo.lon == bidRequest.user.geo.lon } where: @@ -1391,12 +1743,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1438,14 +1803,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -1483,14 +1865,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } } @@ -1570,12 +1969,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1614,14 +2026,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } } @@ -1662,12 +2091,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -1715,14 +2157,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } and: "Metrics for disallowed activities should be updated" @@ -1767,14 +2226,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1817,14 +2293,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1895,14 +2388,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -1948,12 +2458,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2001,12 +2524,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2052,12 +2588,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2150,12 +2699,25 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain not rounded geo data for device and user" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - + def deviceBidderRequest = bidderRequests.device + verifyAll { + deviceBidderRequest.ip == ampStoredRequest.device.ip + deviceBidderRequest.ipv6 == "af47:892b:3e98:b49a::" + deviceBidderRequest.geo.lat == ampStoredRequest.device.geo.lat + deviceBidderRequest.geo.lon == ampStoredRequest.device.geo.lon + deviceBidderRequest.geo.country == ampStoredRequest.device.geo.country + deviceBidderRequest.geo.region == ampStoredRequest.device.geo.region + deviceBidderRequest.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + deviceBidderRequest.geo.metro == ampStoredRequest.device.geo.metro + deviceBidderRequest.geo.city == ampStoredRequest.device.geo.city + deviceBidderRequest.geo.zip == ampStoredRequest.device.geo.zip + deviceBidderRequest.geo.accuracy == ampStoredRequest.device.geo.accuracy + deviceBidderRequest.geo.ipservice == ampStoredRequest.device.geo.ipservice + deviceBidderRequest.geo.ext == ampStoredRequest.device.geo.ext + } + + and: "Bidder request user.geo.{lat,lon} shouldn't mask" verifyAll { - bidderRequests.device.ip == ampStoredRequest.device.ip - bidderRequests.device.ipv6 == "af47:892b:3e98:b49a::" - bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat - bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } @@ -2211,14 +2773,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: @@ -2334,14 +2913,31 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { then: "Bidder request should contain rounded geo data for device and user to 2 digits" def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) - verifyAll { bidderRequests.device.ip == "43.77.114.0" bidderRequests.device.ipv6 == "af47:892b:3e98:b400::" - ampStoredRequest.device.geo.lat.round(2) == bidderRequests.device.geo.lat - ampStoredRequest.device.geo.lon.round(2) == bidderRequests.device.geo.lon - ampStoredRequest.user.geo.lat.round(2) == bidderRequests.user.geo.lat - ampStoredRequest.user.geo.lon.round(2) == bidderRequests.user.geo.lon + bidderRequests.device.geo.lat == ampStoredRequest.device.geo.lat.round(2) + bidderRequests.device.geo.lon == ampStoredRequest.device.geo.lon.round(2) + + bidderRequests.device.geo.country == ampStoredRequest.device.geo.country + bidderRequests.device.geo.region == ampStoredRequest.device.geo.region + bidderRequests.device.geo.utcoffset == ampStoredRequest.device.geo.utcoffset + } + + and: "Bidder request should mask several geo fields" + verifyAll { + !bidderRequests.device.geo.metro + !bidderRequests.device.geo.city + !bidderRequests.device.geo.zip + !bidderRequests.device.geo.accuracy + !bidderRequests.device.geo.ipservice + !bidderRequests.device.geo.ext + } + + and: "Bidder request shouldn't mask geo.{lat,lon} fields" + verifyAll { + bidderRequests.user.geo.lat == ampStoredRequest.user.geo.lat + bidderRequests.user.geo.lon == ampStoredRequest.user.geo.lon } where: diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index c6c68f81714..e842521e853 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -127,6 +127,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -171,6 +172,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo + !genericBidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -215,6 +218,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -290,6 +294,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } } @@ -329,6 +334,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -380,6 +386,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -437,7 +444,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.buyeruid !genericBidderRequest.user.yob !genericBidderRequest.user.gender + !genericBidderRequest.user.eids + !genericBidderRequest.user.geo !genericBidderRequest.user.data + !genericBidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -496,6 +506,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -557,7 +568,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -620,6 +634,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -674,7 +689,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -732,6 +750,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo.zip == bidRequest.user.geo.zip bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } @@ -785,7 +804,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender + !bidderRequest.user.eids + !bidderRequest.user.geo !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" @@ -838,6 +860,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -888,6 +911,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1112,6 +1136,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1167,6 +1192,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1219,6 +1245,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1270,6 +1297,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1352,6 +1380,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == genericBidRequest.user.yob genericBidderRequest.user.gender == genericBidRequest.user.gender genericBidderRequest.user.data == genericBidRequest.user.data + genericBidderRequest.user.geo == genericBidRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid } @@ -1407,6 +1436,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1515,6 +1545,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1636,6 +1667,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -1687,6 +1719,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1740,6 +1773,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1833,6 +1867,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } } @@ -1881,6 +1916,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1938,6 +1974,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -1999,6 +2036,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2056,6 +2094,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2115,6 +2154,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2357,6 +2397,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2420,6 +2461,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2480,6 +2522,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2540,6 +2583,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2640,6 +2684,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { genericBidderRequest.user.yob == ampStoredRequest.user.yob genericBidderRequest.user.gender == ampStoredRequest.user.gender genericBidderRequest.user.data == ampStoredRequest.user.data + genericBidderRequest.user.geo == ampStoredRequest.user.geo genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } @@ -2704,6 +2749,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2832,6 +2878,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo !genericBidderRequest.user.ext } @@ -2947,6 +2994,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !genericBidderRequest.user.yob !genericBidderRequest.user.gender !genericBidderRequest.user.data + !genericBidderRequest.user.geo + !genericBidderRequest.user.ext } and: "Eids fields should have original data" @@ -2979,6 +3028,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { it.user.buyeruid = PBSUtils.randomString it.user.yob = PBSUtils.randomNumber it.user.gender = PBSUtils.randomString + it.user.geo = Geo.FPDGeo it.user.ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index c2115d06f4a..d709c5ba5b4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -19,6 +19,8 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.model.request.auction.GeoExt +import org.prebid.server.functional.model.request.auction.GeoExtGeoProvider import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt @@ -38,6 +40,7 @@ import static org.prebid.server.functional.model.config.PurposeEnforcement.BASIC import static org.prebid.server.functional.model.config.PurposeEnforcement.FULL import static org.prebid.server.functional.model.config.PurposeEnforcement.NO import static org.prebid.server.functional.model.mock.services.vendorlist.VendorListResponse.getDefaultVendorListResponse +import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.request.amp.ConsentType.GPP import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_2 import static org.prebid.server.functional.model.request.amp.ConsentType.US_PRIVACY @@ -50,6 +53,7 @@ import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionTy import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionType.REQUIRE_LEGITIMATE_INTEREST import static org.prebid.server.functional.util.privacy.TcfConsent.RestrictionType.UNDEFINED import static org.prebid.server.functional.util.privacy.TcfConsent.TcfPolicyVersion.TCF_POLICY_V2 +import static org.prebid.server.functional.util.privacy.model.State.ALABAMA abstract class PrivacyBaseSpec extends BaseSpec { @@ -112,10 +116,26 @@ abstract class PrivacyBaseSpec extends BaseSpec { protected static BidRequest getBidRequestWithGeo(DistributionChannel channel = SITE) { BidRequest.getDefaultBidRequest(channel).tap { - device = new Device(ip: "43.77.114.227", ipv6: "af47:892b:3e98:b49a:a747:bda4:a6c8:aee2", - geo: new Geo(lat: PBSUtils.getRandomDecimal(0, 90), lon: PBSUtils.getRandomDecimal(0, 90))) + device = new Device( + ip: "43.77.114.227", + ipv6: "af47:892b:3e98:b49a:a747:bda4:a6c8:aee2", + geo: new Geo( + lat: PBSUtils.getRandomDecimal(0, 90), + lon: PBSUtils.getRandomDecimal(0, 90), + country: USA, + region: ALABAMA, + utcoffset: PBSUtils.randomNumber, + metro: PBSUtils.randomString, + city: PBSUtils.randomString, + zip: PBSUtils.randomString, + accuracy: PBSUtils.randomNumber, + ipservice: PBSUtils.randomNumber, + ext: new GeoExt(geoProvider: new GeoExtGeoProvider()), + )) user = User.defaultUser.tap { - geo = new Geo(lat: PBSUtils.getRandomDecimal(0, 90), lon: PBSUtils.getRandomDecimal(0, 90)) + geo = new Geo( + lat: PBSUtils.getRandomDecimal(0, 90), + lon: PBSUtils.getRandomDecimal(0, 90)) } } } @@ -169,6 +189,12 @@ abstract class PrivacyBaseSpec extends BaseSpec { def geo = bidRequest.device.geo.clone() geo.lat = PBSUtils.roundDecimal(bidRequest.device.geo.lat as BigDecimal, precision) geo.lon = PBSUtils.roundDecimal(bidRequest.device.geo.lon as BigDecimal, precision) + geo.accuracy = null + geo.zip = null + geo.metro = null + geo.city = null + geo.ext = null + geo.ipservice = null geo } diff --git a/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java b/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java index 10c53f7ba06..d76d0d68dbd 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegatorTest.java @@ -355,7 +355,7 @@ public void shouldUpdateAuctionEventToConsideringActivitiesRestrictions() { given(activityInfrastructure.isAllowed(eq(Activity.TRANSMIT_EIDS), any())).willReturn(false); given(activityInfrastructure.isAllowed(eq(Activity.TRANSMIT_GEO), any())).willReturn(false); - given(userFpdActivityMask.maskUser(any(), eq(true), eq(true), eq(true))) + given(userFpdActivityMask.maskUser(any(), eq(true), eq(true))) .willReturn(User.builder().id("masked").build()); given(userFpdActivityMask.maskDevice(any(), eq(true), eq(true))) .willReturn(Device.builder().model("masked").build()); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java index 78512a06f41..a46d068f221 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/ActivityEnforcementTest.java @@ -47,7 +47,7 @@ public void enforceShouldReturnExpectedResult() { final Device maskedDevice = Device.builder().ip("maskedDevice").build(); given(activityInfrastructure.isAllowed(any(), any())).willReturn(false); - given(userFpdActivityMask.maskUser(any(), anyBoolean(), anyBoolean(), anyBoolean())) + given(userFpdActivityMask.maskUser(any(), anyBoolean(), anyBoolean())) .willReturn(maskedUser); given(userFpdActivityMask.maskDevice(any(), anyBoolean(), anyBoolean())) .willReturn(maskedDevice); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java index e0b2c288673..6d138486f72 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/TcfEnforcementTest.java @@ -67,7 +67,7 @@ public class TcfEnforcementTest { @Before public void setUp() { - given(userFpdTcfMask.maskUser(any(), anyBoolean(), anyBoolean(), anyBoolean(), anySet())) + given(userFpdTcfMask.maskUser(any(), anyBoolean(), anyBoolean(), anySet())) .willAnswer(invocation -> invocation.getArgument(0)); given(userFpdTcfMask.maskDevice(any(), anyBoolean(), anyBoolean(), anyBoolean())) .willAnswer(invocation -> invocation.getArgument(0)); @@ -276,7 +276,7 @@ public void enforceShouldMaskUserAndDeviceWhenRestrictionsEnforcedAndLmtNotEnabl final User maskedUser = User.builder().id("maskedUser").build(); final Device maskedDevice = Device.builder().ip("maskedDevice").build(); - given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(true), eq(singleton("eidException")))) + given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(singleton("eidException")))) .willReturn(maskedUser); given(userFpdTcfMask.maskDevice(any(), eq(true), eq(true), eq(true))) .willReturn(maskedDevice); @@ -333,7 +333,7 @@ public void enforceShouldMaskUserAndDeviceWhenRestrictionsNotEnforcedAndLmtEnabl final User maskedUser = User.builder().id("maskedUser").build(); final Device maskedDevice = Device.builder().ip("maskedDevice").build(); - given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(true), eq(singleton("eidException")))) + given(userFpdTcfMask.maskUser(any(), eq(true), eq(true), eq(singleton("eidException")))) .willReturn(maskedUser); given(userFpdTcfMask.maskDevice(any(), eq(true), eq(true), eq(true))) .willReturn(maskedDevice); diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java index bcf2ee5f7d7..811c1b30a0e 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdActivityMaskTest.java @@ -35,10 +35,10 @@ public void maskUserShouldProperlyDelegateUfpdParameter() { final User user = User.builder().build(); // when - target.maskUser(user, true, false, false); + target.maskUser(user, true, false); // then - verify(userFpdTcfMask).maskUser(same(user), eq(true), eq(false), eq(false), eq(emptySet())); + verify(userFpdTcfMask).maskUser(same(user), eq(true), eq(false), eq(emptySet())); } @Test @@ -47,22 +47,10 @@ public void maskUserShouldProperlyDelegateEidsParameter() { final User user = User.builder().build(); // when - target.maskUser(user, false, true, false); + target.maskUser(user, false, true); // then - verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(true), eq(false), eq(emptySet())); - } - - @Test - public void maskUserShouldProperlyDelegateGeoParameter() { - // given - final User user = User.builder().build(); - - // when - target.maskUser(user, false, false, true); - - // then - verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(false), eq(true), eq(emptySet())); + verify(userFpdTcfMask).maskUser(same(user), eq(false), eq(true), eq(emptySet())); } @Test diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java index 53d4a1571df..7247e8e0118 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCcpaMaskTest.java @@ -1,7 +1,6 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.junit.Before; import org.junit.Rule; @@ -10,13 +9,10 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.auction.IpAddressHelper; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.verify; public class UserFpdCcpaMaskTest extends VertxTest { @@ -24,81 +20,36 @@ public class UserFpdCcpaMaskTest extends VertxTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private IpAddressHelper ipAddressHelper; + private UserFpdActivityMask userFpdActivityMask; private UserFpdCcpaMask target; @Before public void setUp() { - target = new UserFpdCcpaMask(ipAddressHelper); + target = new UserFpdCcpaMask(userFpdActivityMask); } @Test - public void maskUserShouldReturnExpectedResult() { + public void maskUserShouldProperlyDelegateUser() { // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); + final User user = User.builder().build(); // when - final User result = target.maskUser(user); + target.maskUser(user); // then - assertThat(result).isEqualTo( - User.builder() - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .build()); + verify(userFpdActivityMask).maskUser(same(user), eq(true), eq(true)); } @Test - public void maskDeviceShouldReturnExpectedResult() { + public void maskDeviceShouldProperlyDelegateDevice() { // given - given(ipAddressHelper.maskIpv4(any())).willReturn("ip4"); - given(ipAddressHelper.anonymizeIpv6(any())).willReturn("ip6"); - - final Device device = Device.builder() - .ip("192.168.0.10") - .ipv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334") - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ifa("ifa") - .macsha1("macsha1") - .macmd5("macmd5") - .didsha1("didsha1") - .didmd5("didmd5") - .dpidsha1("dpidsha1") - .dpidmd5("dpidmd5") - .build(); + final Device device = Device.builder().build(); // when - final Device result = target.maskDevice(device); + target.maskDevice(device); // then - assertThat(result).isEqualTo( - Device.builder() - .ip("ip4") - .ipv6("ip6") - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .build()); + verify(userFpdActivityMask).maskDevice(same(device), eq(true), eq(true)); } } diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java index 056b36f3a84..46bbd3cb1ea 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdCoppaMaskTest.java @@ -1,7 +1,6 @@ package org.prebid.server.auction.privacy.enforcement.mask; import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Geo; import com.iab.openrtb.request.User; import org.junit.Before; import org.junit.Rule; @@ -10,13 +9,10 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; -import org.prebid.server.auction.IpAddressHelper; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.verify; public class UserFpdCoppaMaskTest extends VertxTest { @@ -24,77 +20,36 @@ public class UserFpdCoppaMaskTest extends VertxTest { public final MockitoRule mockitoRule = MockitoJUnit.rule(); @Mock - private IpAddressHelper ipAddressHelper; + private UserFpdActivityMask userFpdActivityMask; private UserFpdCoppaMask target; @Before public void setUp() { - target = new UserFpdCoppaMask(ipAddressHelper); + target = new UserFpdCoppaMask(userFpdActivityMask); } @Test - public void maskUserShouldReturnExpectedResult() { + public void maskUserShouldProperlyDelegateUser() { // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); + final User user = User.builder().build(); // when - final User result = target.maskUser(user); + target.maskUser(user); // then - assertThat(result).isNull(); + verify(userFpdActivityMask).maskUser(same(user), eq(true), eq(true)); } @Test - public void maskDeviceShouldReturnExpectedResult() { + public void maskDeviceShouldProperlyDelegateDevice() { // given - given(ipAddressHelper.maskIpv4(any())).willReturn("ip4"); - given(ipAddressHelper.anonymizeIpv6(any())).willReturn("ip6"); - - final Device device = Device.builder() - .ip("192.168.0.10") - .ipv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334") - .geo(Geo.builder() - .lon(-85.34321F) - .lat(189.342323F) - .metro("metro") - .city("city") - .zip("zip") - .build()) - .ifa("ifa") - .macsha1("macsha1") - .macmd5("macmd5") - .didsha1("didsha1") - .didmd5("didmd5") - .dpidsha1("dpidsha1") - .dpidmd5("dpidmd5") - .build(); + final Device device = Device.builder().build(); // when - final Device result = target.maskDevice(device); + target.maskDevice(device); // then - assertThat(result).isEqualTo( - Device.builder() - .ip("ip4") - .ipv6("ip6") - .build()); + verify(userFpdActivityMask).maskDevice(same(device), eq(true), eq(true)); } } diff --git a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java index 444fd839aa7..33ccbf94803 100644 --- a/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java +++ b/src/test/java/org/prebid/server/auction/privacy/enforcement/mask/UserFpdTcfMaskTest.java @@ -12,6 +12,7 @@ import org.mockito.junit.MockitoRule; import org.prebid.server.VertxTest; import org.prebid.server.auction.IpAddressHelper; +import org.prebid.server.proto.openrtb.ext.request.ExtGeo; import org.prebid.server.proto.openrtb.ext.request.ExtUser; import static java.util.Arrays.asList; @@ -55,14 +56,10 @@ public void maskUserShouldReturnExpectedResultWhenFpdMasked() { .build(); // when - final User result = target.maskUser(user, true, false, false, emptySet()); + final User result = target.maskUser(user, true, false, emptySet()); // then - assertThat(result).isEqualTo( - User.builder() - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34321F).lat(189.342323F).build()) - .build()); + assertThat(result).isEqualTo(User.builder().eids(emptyList()).build()); } @Test @@ -85,7 +82,7 @@ public void maskUserShouldReturnExpectedResultWhenEidsMasked() { .build(); // when - final User result = target.maskUser(user, false, true, false, singleton("2")); + final User result = target.maskUser(user, false, true, singleton("2")); // then assertThat(result).isEqualTo( @@ -103,41 +100,6 @@ public void maskUserShouldReturnExpectedResultWhenEidsMasked() { .build()); } - @Test - public void maskUserShouldReturnExpectedResultWhenGeoMasked() { - // given - final User user = User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34321F).lat(189.342323F).build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build(); - - // when - final User result = target.maskUser(user, false, false, true, emptySet()); - - // then - assertThat(result).isEqualTo( - User.builder() - .id("id") - .buyeruid("buyeruid") - .yob(1) - .gender("gender") - .keywords("keywords") - .kwarray(emptyList()) - .data(emptyList()) - .eids(emptyList()) - .geo(Geo.builder().lon(-85.34F).lat(189.34F).build()) - .ext(ExtUser.builder().data(mapper.createObjectNode()).build()) - .build()); - } - @Test public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { // given @@ -150,6 +112,12 @@ public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -171,6 +139,12 @@ public void maskDeviceShouldReturnExpectedResultWhenIpMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -194,6 +168,12 @@ public void maskDeviceShouldReturnExpectedResultWhenGeoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -238,6 +218,12 @@ public void maskDeviceShouldReturnExpectedResultWhenDeviceInfoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .ifa("ifa") .macsha1("macsha1") @@ -259,6 +245,12 @@ public void maskDeviceShouldReturnExpectedResultWhenDeviceInfoMasked() { .geo(Geo.builder() .lon(-85.34321F) .lat(189.342323F) + .metro("metro") + .city("city") + .zip("zip") + .accuracy(1) + .ipservice(1) + .ext(ExtGeo.of()) .build()) .build()); } From 43cba2892ebf580324f2e9b4a994b021106e6788 Mon Sep 17 00:00:00 2001 From: Oleksandr Zhevedenko <720803+Net-burst@users.noreply.github.com> Date: Thu, 9 May 2024 09:29:04 -0400 Subject: [PATCH 41/58] Core: Reorganize Maven dependencies (#3180) --- extra/bundle/pom.xml | 8 - extra/modules/confiant-ad-quality/pom.xml | 1 - extra/modules/pom.xml | 51 +- extra/pom.xml | 219 ++- pom.xml | 205 +-- .../container/NetworkServiceContainer.groovy | 1 - .../GppTransmitUfpdActivitiesSpec.groovy | 1237 +++++++++-------- .../tests/prometheus/PrometheusSpec.groovy | 2 +- .../adtelligent/AdtelligentBidderTest.java | 6 +- 9 files changed, 888 insertions(+), 842 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 7f1adad0d6c..454a9b0de5b 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -14,14 +14,6 @@ prebid-server-bundle Creates bundle (fat jar) with PBS-Core and other submodules listed as dependency - - UTF-8 - UTF-8 - ${java.version} - ${java.version} - 2.5.6 - - org.prebid diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 51a81049e5e..7e1bfc91bd9 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -17,7 +17,6 @@ io.vertx vertx-redis-client - ${vertx.version} diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 865b928cb79..36014ede43a 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -22,51 +22,12 @@ pb-richmedia-filter - - UTF-8 - UTF-8 - ${java.version} - ${java.version} - - 5.9.0 - 3.23.1 - 4.13.2 - 4.7.0 - - org.prebid prebid-server - 3.0.0-SNAPSHOT - - - org.projectlombok - lombok - ${lombok.version} - - - org.junit - junit-bom - ${junit-bom.version} - pom - import - - - org.assertj - assertj-core - ${assertj.version} - - - junit - junit - ${junit.version} - - - org.mockito - mockito-core - ${mockito.version} + ${project.version} @@ -76,6 +37,11 @@ org.prebid prebid-server + + org.junit.jupiter + junit-jupiter-engine + test + org.junit.vintage junit-vintage-engine @@ -86,11 +52,6 @@ assertj-core test - - junit - junit - test - org.mockito mockito-core diff --git a/extra/pom.xml b/extra/pom.xml index d6b22c6383f..dc0d1be2c02 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.prebid @@ -15,17 +16,48 @@ + 21 UTF-8 - UTF-8 + UTF-8 ${java.version} ${java.version} - 4.5.5 - 1.18.30 + + 3.0.0-M6 3.11.0 2.22.2 - false + ${maven-surefire-plugin.version} + 0.40.2 + + + 3.2.3 + 4.5.5 + 2.0.1.Final + 4.4 + 1.26.0 + 3.6.1 + 2.1 + 4.5.14 + 5.3.1 + 6.4.5 + 1.0.76 + 1.13 + 2.2.0 + 1.2.2 + 0.16.0 + 2.0.10 + 3.2.0 + 2.12.0 + 3.21.7 + 3.17.3 + 1.0.7 + + + 2.35.1 + 2.4-M4-groovy-4.0 + + 5.15.0 @@ -34,11 +66,186 @@ bundle + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + io.vertx + vertx-dependencies + ${vertx.version} + pom + import + + + org.spockframework + spock-bom + ${spock.version} + pom + import + + + com.github.tomakehurst + wiremock-jre8 + ${wiremock.version} + + + javax.validation + validation-api + ${validation-api.version} + + + com.ongres.scram + client + ${scram.version} + + + org.apache.commons + commons-collections4 + ${commons.collections.version} + + + org.apache.commons + commons-compress + ${commons.compress.version} + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + com.github.seancfoley + ipaddress + ${ipaddress.version} + + + com.github.oshi + oshi-core + ${oshi.version} + + + com.networknt + json-schema-validator + ${json-schema-validator.version} + + + com.github.java-json-tools + json-patch + ${jsonpatch.version} + + + com.google.code.findbugs + jsr305 + + + + + de.malkusch.whois-server-list + public-suffix-list + ${psl.version} + + + com.google.code.findbugs + jsr305 + + + + + com.izettle + dropwizard-metrics-influxdb + ${metrics-influxdb.version} + + + io.dropwizard + dropwizard-metrics + + + org.apache.kafka + kafka-clients + + + + + io.prometheus + simpleclient_vertx4 + ${vertx.prometheus.version} + + + io.prometheus + simpleclient_dropwizard + ${vertx.prometheus.version} + + + com.iabtcf + iabtcf-decoder + ${iabtcf.version} + + + com.iabtcf + iabtcf-encoder + ${iabtcf.version} + + + com.iabgpp + iabgpp-encoder + ${gpp-encoder.version} + + + com.maxmind.geoip2 + geoip2 + ${maxmind-client.version} + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + com.google.protobuf + protobuf-java-util + ${protobuf.version} + + + com.google.code.findbugs + jsr305 + + + + + io.github.jamsesso + json-logic-java + ${json-logic.version} + + + org.mock-server + mockserver-client-java + ${mockserver.version} + + + com.google.code.findbugs + jsr305 + + + + + + org.projectlombok lombok - ${lombok.version} provided diff --git a/pom.xml b/pom.xml index aee1ffd7d5e..d01e20873bd 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -19,53 +20,10 @@ - UTF-8 - UTF-8 - ${java.version} - ${java.version} Dockerfile - - 3.2.3 - 2.0.1.Final - 3.14.0 - 4.4 - 1.26.0 - 3.6.1 - 4.5.14 - 5.3.1 - 6.4.5 - 2.16.2 - 1.0.76 - 1.13 - 8.0.28 - 42.7.2 - 2.2.0 - 1.2.2 - 0.16.0 - 2.0.2 - 2.0.10 - 2.12.0 - 3.2.0 - 3.21.7 - 3.17.3 - 1.0.7 - 2.1 - - - 4.13.2 - 5.10.2 - 4.11.0 - 3.24.2 - 2.35.1 + 9.4.53.v20231009 - 5.4.0 - 2.2.220 - 2.4-M2-groovy-4.0 - 4.0.15 - 1.17.4 - 5.14.0 - 1.12.14 3.1.2 @@ -73,8 +31,7 @@ 1.2.0 0.8.11 2.2.4 - ${maven-surefire-plugin.version} - 0.40.2 + 3.0.2 false true @@ -83,40 +40,6 @@ 0.6.1 - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - com.google.code.gson - gson - - - commons-codec - commons-codec - compile - - - org.apache.httpcomponents - httpcore - compile - - - com.rabbitmq - amqp-client - - - org.jboss.logging - jboss-logging - - - - org.springframework.boot @@ -129,7 +52,6 @@ javax.validation validation-api - ${validation-api.version} org.hibernate.validator @@ -138,47 +60,38 @@ io.vertx vertx-core - ${vertx.version} io.vertx vertx-web - ${vertx.version} io.vertx vertx-config - ${vertx.version} io.vertx vertx-mysql-client - ${vertx.version} io.vertx vertx-pg-client - ${vertx.version} io.vertx vertx-circuit-breaker - ${vertx.version} io.vertx vertx-dropwizard-metrics - ${vertx.version} io.vertx vertx-auth-common - ${vertx.version} com.ongres.scram client - ${scram.version} io.netty @@ -193,94 +106,76 @@ org.apache.commons commons-lang3 - ${commons.version} org.apache.commons commons-collections4 - ${commons.collections.version} org.apache.commons commons-compress - ${commons.compress.version} org.apache.commons commons-math3 - ${commons-math3.version} org.apache.httpcomponents httpclient - ${httpclient.version} com.github.seancfoley ipaddress - ${ipaddress.version} com.github.oshi oshi-core - ${oshi.version} com.fasterxml.jackson.core jackson-core - ${jackson.version} com.fasterxml.jackson.core jackson-databind - ${jackson.version} com.fasterxml.jackson.core jackson-annotations - ${jackson.version} com.fasterxml.jackson.dataformat jackson-dataformat-yaml - ${jackson.version} com.fasterxml.jackson.module jackson-module-blackbird - ${jackson.version} com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson.version} test com.fasterxml.jackson.dataformat jackson-dataformat-xml - ${jackson.version} test com.networknt json-schema-validator - ${json-schema-validator.version} com.github.java-json-tools json-patch - ${jsonpatch.version} - mysql - mysql-connector-java - ${mysql.version} + com.mysql + mysql-connector-j org.postgresql postgresql - ${postgresql.version} com.github.ben-manes.caffeine @@ -289,13 +184,6 @@ de.malkusch.whois-server-list public-suffix-list - ${psl.version} - - - com.google.code.findbugs - jsr305 - - io.dropwizard.metrics @@ -312,92 +200,63 @@ com.izettle dropwizard-metrics-influxdb - ${metrics-influxdb.version} - - - io.dropwizard - dropwizard-metrics - - - org.apache.kafka - kafka-clients - - - - - com.conversantmedia.gdpr - consent-string-sdk-java - ${consent-string-sdk.version} com.iabtcf iabtcf-decoder - ${iabtcf.version} io.prometheus simpleclient_vertx4 - ${vertx.prometheus.version} io.prometheus simpleclient_dropwizard - ${vertx.prometheus.version} com.maxmind.geoip2 geoip2 - ${maxmind-client.version} com.iabgpp iabgpp-encoder - ${gpp-encoder.version} com.google.protobuf protobuf-java-util - ${protobuf.version} com.google.protobuf protobuf-java - ${protobuf.version} io.github.jamsesso json-logic-java - ${json-logic.version} - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter-engine test org.junit.vintage junit-vintage-engine - ${junit-jupiter.version} test org.mockito mockito-core - ${mockito.version} test org.mockito mockito-junit-jupiter - ${mockito.version} test org.assertj assertj-core - ${assertj.version} test @@ -408,19 +267,16 @@ io.vertx vertx-unit - ${vertx.version} test com.github.tomakehurst wiremock-jre8 - ${wiremock.version} test com.iabtcf iabtcf-encoder - ${iabtcf.version} test @@ -486,49 +342,31 @@ io.rest-assured rest-assured - ${restassured.version} test io.rest-assured json-path - ${restassured.version} test io.rest-assured xml-path - ${restassured.version} - test - - - net.bytebuddy - byte-buddy - ${bytebuddy.version} test org.spockframework spock-core - ${spock.version} test - - - org.apache.groovy - groovy - - org.apache.groovy groovy - ${groovy.version} test org.apache.groovy groovy-yaml - ${groovy.version} test @@ -540,43 +378,36 @@ io.vertx vertx-codegen - ${vertx.version} test com.h2database h2 - ${h2.version} test org.testcontainers testcontainers - ${testcontainers.version} test org.testcontainers mockserver - ${testcontainers.version} test org.testcontainers mysql - ${testcontainers.version} test - org.mock-server - mockserver-client-java - ${mockserver.version} + org.testcontainers + postgresql test - org.testcontainers - postgresql - ${testcontainers.version} + org.mock-server + mockserver-client-java test @@ -719,7 +550,9 @@ ${project.basedir}/src/main/proto ${project.basedir}/src/test/proto - com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + @@ -734,7 +567,9 @@ wget - https://raw.githubusercontent.com/IABTechLab/openrtb-proto-v2/master/openrtb-core/src/main/protobuf/openrtb.proto + + https://raw.githubusercontent.com/IABTechLab/openrtb-proto-v2/master/openrtb-core/src/main/protobuf/openrtb.proto + ${project.basedir}/src/main/proto openrtb.proto @@ -746,7 +581,9 @@ wget - https://raw.githubusercontent.com/MagniteEngineering/xapi-proto/main/src/proto/com/magnite/openrtb/v2/openrtb-xapi.proto + + https://raw.githubusercontent.com/MagniteEngineering/xapi-proto/main/src/proto/com/magnite/openrtb/v2/openrtb-xapi.proto + ${project.basedir}/src/main/proto openrtb-xapi.proto diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy index 2d3cbe8abf0..53faa7165fa 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/container/NetworkServiceContainer.groovy @@ -8,7 +8,6 @@ class NetworkServiceContainer extends MockServerContainer { NetworkServiceContainer(String version) { super(DockerImageName.parse("mockserver/mockserver:mockserver-$version")) - withCommand("-serverPort $PORT -logLevel WARN") } String getHostAndPort() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index e842521e853..935903e8581 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -96,7 +96,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is allowing requests should leave UFPD fields in request and update proper metrics"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set with generic bidder allowed" def activities = AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.defaultActivity) @@ -109,28 +109,31 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -140,7 +143,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is rejecting requests should remove UFPD fields in request and update disallowed metrics"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)]) @@ -154,30 +157,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext - } + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext - and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + } and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -189,7 +192,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when default activity setting set to false should remove UFPD fields from request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = new Activity(defaultAction: false) @@ -200,30 +203,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -232,7 +235,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set for transmit ufpd with bidder allowed without type" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(conditions, isAllowed)]) @@ -243,7 +246,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -261,7 +264,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when first rule allowing in activities should leave UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields field and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activity rules with same priority" def allowActivity = new ActivityRule(condition: Condition.baseCondition, allow: true) @@ -276,33 +279,36 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction call when first rule disallowing in activities should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Activities set for actions with Generic bidder rejected by hierarchy setup" def disallowActivity = new ActivityRule(condition: Condition.baseCondition, allow: false) @@ -317,35 +323,35 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids } def "PBS auction shouldn't allow rule when gppSid not intersect"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = regsGppSid } @@ -368,28 +374,31 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -404,7 +413,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction should allow rule when gppSid intersect"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [USP_V1.intValue] } @@ -427,31 +436,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.geo - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.geo + !bidderRequest.user.data + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -510,6 +518,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -568,7 +579,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -638,6 +648,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -689,7 +702,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -754,6 +766,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -804,7 +819,6 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.user.buyeruid !bidderRequest.user.yob !bidderRequest.user.gender - !bidderRequest.user.eids !bidderRequest.user.geo !bidderRequest.user.data !bidderRequest.user.ext @@ -823,7 +837,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -843,29 +857,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] @@ -874,7 +888,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain some part of disallow logic should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -894,29 +908,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: disallowGppLogic << [ @@ -1045,7 +1059,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain some part of disallow logic which violates GPP validation should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = disallowGppLogic } @@ -1065,27 +1079,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: disallowGppLogic << [ 'DBABLA~BAAgAAAAAAA.QA', @@ -1099,7 +1115,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [gppSid.intValue] regs.gpp = gppConsent } @@ -1119,29 +1135,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppConsent | gppSid @@ -1156,7 +1172,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy modules contain allowing settings should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1173,29 +1189,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), @@ -1206,7 +1225,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when regs.gpp in request is allowing should leave UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = regsGpp } @@ -1226,29 +1245,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } @@ -1256,7 +1278,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation have duplicate should leave UFPD fields in request and update alerts metrics"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] } @@ -1278,29 +1300,32 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) and: "Generic bidder should be called due to positive allow in activities" verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ALERT_GENERAL] == 1 @@ -1309,7 +1334,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid property should respond with an error"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = SIMPLE_GPC_DISALLOW_LOGIC } @@ -1328,7 +1353,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def error = thrown(PrebidServerException) @@ -1340,7 +1365,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Default basic generic BidRequest" def gppConsent = new UsNatV1Consent.Builder().setGpc(gpcValue).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1363,27 +1388,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == genericBidRequest.device.didsha1 - genericBidderRequest.device.didmd5 == genericBidRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == genericBidRequest.device.dpidsha1 - genericBidderRequest.device.ifa == genericBidRequest.device.ifa - genericBidderRequest.device.macsha1 == genericBidRequest.device.macsha1 - genericBidderRequest.device.macmd5 == genericBidRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == genericBidRequest.device.dpidmd5 - genericBidderRequest.user.id == genericBidRequest.user.id - genericBidderRequest.user.buyeruid == genericBidRequest.user.buyeruid - genericBidderRequest.user.yob == genericBidRequest.user.yob - genericBidderRequest.user.gender == genericBidRequest.user.gender - genericBidderRequest.user.data == genericBidRequest.user.data - genericBidderRequest.user.geo == genericBidRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == genericBidRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == bidRequest.device.didsha1 + bidderRequest.device.didmd5 == bidRequest.device.didmd5 + bidderRequest.device.dpidsha1 == bidRequest.device.dpidsha1 + bidderRequest.device.ifa == bidRequest.device.ifa + bidderRequest.device.macsha1 == bidRequest.device.macsha1 + bidderRequest.device.macmd5 == bidRequest.device.macmd5 + bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 + bidderRequest.user.id == bidRequest.user.id + bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.yob == bidRequest.user.yob + bidderRequest.user.gender == bidRequest.user.gender + bidderRequest.user.data == bidRequest.user.data + bidderRequest.user.geo == bidRequest.user.geo + bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == bidRequest.user.eids + where: gpcValue | accountLogic false | LogicalRestrictedRule.generateSingleRestrictedRule(OR, [new EqualityValueRule(GPC, NOTICE_PROVIDED)]) @@ -1395,7 +1423,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy regulation match custom requirement should remove UFPD fields in request"() { given: "Default basic generic BidRequest" def accountId = PBSUtils.randomNumber as String - def generalBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = gppConsent } @@ -1419,29 +1447,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(generalBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(generalBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == generalBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppConsent | valueRules @@ -1458,7 +1486,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { given: "Generic BidRequest with gpp and account setup" def gppConsent = new UsNatV1Consent.Builder().setGpc(true).build() def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [US_CT_V1.intValue] regs.gpp = gppConsent @@ -1486,7 +1514,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Response should contain error" def error = thrown(PrebidServerException) @@ -1501,7 +1529,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when custom privacy regulation with normalizing that match custom config should have empty UFPD fields"() { given: "Generic BidRequest with gpp and account setup" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId).tap { ext.prebid.trace = VERBOSE regs.gppSid = [gppSid.intValue] regs.gpp = gppStateConsent.build() @@ -1528,29 +1556,29 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids where: gppSid | equalityValueRules | gppStateConsent @@ -1652,25 +1680,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -1705,26 +1736,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -1758,27 +1789,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when bidder allowed activities have empty condition type should skip this rule and emit an error"() { @@ -1852,24 +1883,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp call when first rule disallowing in activities should remove UFPD fields in request"() { @@ -1902,26 +1936,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids } def "PBS amp should disallowed rule when header.gpc intersection with condition.gpc"() { @@ -1960,26 +1994,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest, ["Sec-GPC": VALID_VALUE_FOR_GPC_HEADER]) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() @@ -2021,25 +2055,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest, ["Sec-GPC": VALID_VALUE_FOR_GPC_HEADER]) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ACTIVITY_RULES_PROCESSED_COUNT] == 1 @@ -2080,26 +2117,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: privacyAllowRegulations << [IAB_US_GENERAL, IAB_ALL, ALL] @@ -2140,26 +2177,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: disallowGppLogic << [ @@ -2320,24 +2357,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.eids - !genericBidderRequest.user.data - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.ext } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: disallowGppLogic << [ 'DBABLA~BAAgAAAAAAA.QA', @@ -2345,7 +2384,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { 'DBABLA~BAAEAAAAAAA.QA', 'DBABLA~BAAIAAAAAAA.QA', 'DBABLA~BAAIAAAAAAA.QA' - ] + ] } def "PBS amp call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { @@ -2383,26 +2422,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppConsent | gppSid @@ -2446,25 +2485,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: accountGppConfig << [ new AccountGppConfig(code: IAB_US_GENERAL, enabled: false), @@ -2507,25 +2549,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: regsGpp << ["", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] } @@ -2568,25 +2613,28 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() assert metrics[ALERT_GENERAL] == 1 @@ -2670,24 +2718,27 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have data in UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - genericBidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 - genericBidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 - genericBidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 - genericBidderRequest.device.ifa == ampStoredRequest.device.ifa - genericBidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 - genericBidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 - genericBidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 - genericBidderRequest.user.id == ampStoredRequest.user.id - genericBidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid - genericBidderRequest.user.yob == ampStoredRequest.user.yob - genericBidderRequest.user.gender == ampStoredRequest.user.gender - genericBidderRequest.user.data == ampStoredRequest.user.data - genericBidderRequest.user.geo == ampStoredRequest.user.geo - genericBidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.device.didsha1 == ampStoredRequest.device.didsha1 + bidderRequest.device.didmd5 == ampStoredRequest.device.didmd5 + bidderRequest.device.dpidsha1 == ampStoredRequest.device.dpidsha1 + bidderRequest.device.ifa == ampStoredRequest.device.ifa + bidderRequest.device.macsha1 == ampStoredRequest.device.macsha1 + bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 + bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 + bidderRequest.user.id == ampStoredRequest.user.id + bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.yob == ampStoredRequest.user.yob + bidderRequest.user.gender == ampStoredRequest.user.gender + bidderRequest.user.data == ampStoredRequest.user.data + bidderRequest.user.geo == ampStoredRequest.user.geo + bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid } + and: "Generic bidder request should have data in EIDS fields" + assert bidderRequest.user.eids == ampStoredRequest.user.eids + where: gpcValue | accountLogic false | LogicalRestrictedRule.generateSingleRestrictedRule(OR, [new EqualityValueRule(GPC, NOTICE_PROVIDED)]) @@ -2735,26 +2786,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppConsent | valueRules @@ -2864,26 +2915,26 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { activityPbsService.sendAmpRequest(ampRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) + def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Generic bidder request should have data in EIDS fields" - assert genericBidderRequest.user.eids == ampStoredRequest.user.eids + assert bidderRequest.user.eids == ampStoredRequest.user.eids where: gppSid | equalityValueRules | gppStateConsent @@ -2960,7 +3011,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when transmit UFPD activities is rejecting requests with activityTransition false should remove only UFPD fields in request"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def genericBidRequest = givenBidRequestWithAccountAndUfpdData(accountId) + def bidRequest = givenBidRequestWithAccountAndUfpdData(accountId) and: "Allow activities setup" def activity = Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)]) @@ -2976,30 +3027,30 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { accountDao.save(account) when: "PBS processes auction requests" - activityPbsService.sendAuctionRequest(genericBidRequest) + activityPbsService.sendAuctionRequest(bidRequest) then: "Generic bidder request should have empty UFPD fields" - def genericBidderRequest = bidder.getBidderRequest(genericBidRequest.id) + def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll { - !genericBidderRequest.device.didsha1 - !genericBidderRequest.device.didmd5 - !genericBidderRequest.device.dpidsha1 - !genericBidderRequest.device.ifa - !genericBidderRequest.device.macsha1 - !genericBidderRequest.device.macmd5 - !genericBidderRequest.device.dpidmd5 - !genericBidderRequest.user.id - !genericBidderRequest.user.buyeruid - !genericBidderRequest.user.yob - !genericBidderRequest.user.gender - !genericBidderRequest.user.data - !genericBidderRequest.user.geo - !genericBidderRequest.user.ext + !bidderRequest.device.didsha1 + !bidderRequest.device.didmd5 + !bidderRequest.device.dpidsha1 + !bidderRequest.device.ifa + !bidderRequest.device.macsha1 + !bidderRequest.device.macmd5 + !bidderRequest.device.dpidmd5 + !bidderRequest.user.id + !bidderRequest.user.buyeruid + !bidderRequest.user.yob + !bidderRequest.user.gender + !bidderRequest.user.data + !bidderRequest.user.geo + !bidderRequest.user.ext } and: "Eids fields should have original data" - assert genericBidderRequest.user.eids == genericBidRequest.user.eids + assert bidderRequest.user.eids == bidRequest.user.eids and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() diff --git a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy index 826e110299a..538705e3b68 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy @@ -111,7 +111,7 @@ class PrometheusSpec extends BaseSpec { and: "PBS container is prepared" def pbsContainer = new PrebidServerContainer(config) - pbsContainer.setWaitStrategy(Wait.defaultWaitStrategy()) + pbsContainer.waitingFor(Wait.defaultWaitStrategy()) when: "PBS is started" pbsContainer.start() diff --git a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java index 73622242460..c279492e5ed 100644 --- a/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtelligent/AdtelligentBidderTest.java @@ -401,9 +401,9 @@ public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { // then assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badServerResponse( - "Failed to decode: Unexpected end-of-input: expected close marker" - + " for Object (start marker at [Source: (String)\"{\"; line: 1, column: 1])\n" - + " at [Source: (String)\"{\"; line: 1, column: 2]")); + "Failed to decode: Unexpected end-of-input: expected close marker for Object (start marker at" + + " [Source: (String)\"{\"; line: 1, column: 1])\n at [Source: (String)\"{\"; line: 1, " + + "column: 2]")); } private static BidderCall givenHttpCall(String body) { From 36bd261b6d19db702e50785dbbb8302748220542 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Fri, 10 May 2024 14:33:07 +0200 Subject: [PATCH 42/58] ZetaGlobalSsp: Revert renaming (#3187) --- src/main/resources/bidder-config/generic.yaml | 4 ++-- .../{zeta-global-ssp.json => zeta_global_ssp.json} | 0 .../java/org/prebid/server/it/ZetaGlobalSspTest.java | 12 ++++++------ .../test-auction-zeta_global_ssp-request.json} | 2 +- .../test-auction-zeta_global_ssp-response.json} | 4 ++-- .../test-zeta_global_ssp-bid-request.json} | 0 .../test-zeta_global_ssp-bid-response.json} | 0 .../org/prebid/server/it/test-application.properties | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename src/main/resources/static/bidder-params/{zeta-global-ssp.json => zeta_global_ssp.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-auction-zeta-global-ssp-request.json => zeta_global_ssp/test-auction-zeta_global_ssp-request.json} (94%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-auction-zeta-global-ssp-response.json => zeta_global_ssp/test-auction-zeta_global_ssp-response.json} (86%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-zeta-global-ssp-bid-request.json => zeta_global_ssp/test-zeta_global_ssp-bid-request.json} (100%) rename src/test/resources/org/prebid/server/it/openrtb2/{zetaglobalssp/test-zeta-global-ssp-bid-response.json => zeta_global_ssp/test-zeta_global_ssp-bid-response.json} (100%) diff --git a/src/main/resources/bidder-config/generic.yaml b/src/main/resources/bidder-config/generic.yaml index 5c4ab6dd510..172069d1a2e 100644 --- a/src/main/resources/bidder-config/generic.yaml +++ b/src/main/resources/bidder-config/generic.yaml @@ -56,7 +56,7 @@ adapters: - native supported-vendors: vendor-id: 109 - zeta-global-ssp: + zeta_global_ssp: enabled: false endpoint: https://ssp.disqus.com/bid/prebid-server?sid=GET_SID_FROM_ZETA endpoint-compression: gzip @@ -72,7 +72,7 @@ adapters: vendor-id: 833 usersync: enabled: true - cookie-family-name: zeta-global-ssp + cookie-family-name: zeta_global_ssp redirect: url: https://ssp.disqus.com/redirectuser?sid=GET_SID_FROM_ZETA&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&r={{redirect_url}} uid-macro: 'BUYERUID' diff --git a/src/main/resources/static/bidder-params/zeta-global-ssp.json b/src/main/resources/static/bidder-params/zeta_global_ssp.json similarity index 100% rename from src/main/resources/static/bidder-params/zeta-global-ssp.json rename to src/main/resources/static/bidder-params/zeta_global_ssp.json diff --git a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java index 074e503b50e..7556d13e67f 100644 --- a/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java +++ b/src/test/java/org/prebid/server/it/ZetaGlobalSspTest.java @@ -21,18 +21,18 @@ public class ZetaGlobalSspTest extends IntegrationTest { @Test public void openrtb2AuctionShouldRespondWithBidsFromZetaGlobalSsp() throws IOException, JSONException { // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta-global-ssp-exchange")) + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/zeta_global_ssp-exchange")) .withRequestBody(equalToJson( - jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json"))) + jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json"))) .willReturn(aResponse().withBody( - jsonFrom("openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json")))); + jsonFrom("openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json")))); // when - final Response response = responseFor("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json", + final Response response = responseFor("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json", Endpoint.openrtb2_auction); // then - assertJsonEquals("openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json", response, - singletonList("zeta-global-ssp")); + assertJsonEquals("openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json", response, + singletonList("zeta_global_ssp")); } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json similarity index 94% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json index 3ed84b4e1ee..0a3824d6e31 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-request.json @@ -12,7 +12,7 @@ ] }, "ext": { - "zeta-global-ssp": {} + "zeta_global_ssp": {} } } ], diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json similarity index 86% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json index afb9594d84b..802e057bc7a 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-auction-zeta-global-ssp-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-auction-zeta_global_ssp-response.json @@ -21,14 +21,14 @@ } } ], - "seat": "zeta-global-ssp", + "seat": "zeta_global_ssp", "group": 0 } ], "cur": "USD", "ext": { "responsetimemillis": { - "zeta-global-ssp": "{{ zeta-global-ssp.response_time_ms }}" + "zeta_global_ssp": "{{ zeta_global_ssp.response_time_ms }}" }, "prebid": { "auctiontimestamp": 1000 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-request.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-request.json diff --git a/src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json similarity index 100% rename from src/test/resources/org/prebid/server/it/openrtb2/zetaglobalssp/test-zeta-global-ssp-bid-response.json rename to src/test/resources/org/prebid/server/it/openrtb2/zeta_global_ssp/test-zeta_global_ssp-bid-response.json diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index 8112a071772..e4f8a793e55 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -12,8 +12,8 @@ adapters.generic.aliases.infytv.enabled=true adapters.generic.aliases.infytv.endpoint=http://localhost:8090/infytv-exchange adapters.generic.aliases.loopme.enabled=true adapters.generic.aliases.loopme.endpoint=http://localhost:8090/loopme-exchange -adapters.generic.aliases.zeta-global-ssp.enabled=true -adapters.generic.aliases.zeta-global-ssp.endpoint=http://localhost:8090/zeta-global-ssp-exchange +adapters.generic.aliases.zeta_global_ssp.enabled=true +adapters.generic.aliases.zeta_global_ssp.endpoint=http://localhost:8090/zeta_global_ssp-exchange adapters.aceex.enabled=true adapters.aceex.endpoint=http://localhost:8090/aceex-exchange adapters.acuityads.enabled=true From afe72e3d31c8d19af5356e89573a12b763a3ebd1 Mon Sep 17 00:00:00 2001 From: bretg Date: Fri, 10 May 2024 08:34:05 -0400 Subject: [PATCH 43/58] Core: Add switzerland to the default eea-countries (#3186) --- src/main/resources/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index e85b4a9de5c..2e7f328a81e 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -194,7 +194,7 @@ host-cookie: max-cookie-size-bytes: 4096 gdpr: enabled: true - eea-countries: at,bg,be,cy,cz,dk,ee,fi,fr,de,gr,hu,ie,it,lv,lt,lu,mt,nl,pl,pt,ro,sk,si,es,se,gb,is,no,li,ai,aw,pt,bm,aq,io,vg,ic,ky,fk,re,mw,gp,gf,yt,pf,tf,gl,pt,ms,an,bq,cw,sx,nc,pn,sh,pm,gs,tc,uk,wf + eea-countries: at,bg,be,cy,cz,dk,ee,fi,fr,de,gr,hu,ie,it,lv,lt,lu,mt,nl,pl,pt,ro,sk,si,es,se,gb,is,no,li,ai,aw,pt,bm,aq,io,vg,ic,ky,fk,re,mw,gp,gf,yt,pf,tf,gl,pt,ms,an,bq,cw,sx,nc,pn,sh,pm,gs,tc,uk,wf,ch vendorlist: default-timeout-ms: 2000 v2: From 00b749ab3dbee8aaed4c13131ab8939af6077a88 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Mon, 13 May 2024 12:37:11 +0200 Subject: [PATCH 44/58] Revert "Core: Finish transition period for alias resolving (#2644)" (#3188) --- .../prebid/server/auction/BidResponseCreator.java | 12 +++++++++++- .../settings/model/AccountAuctionEventConfig.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index 273f9f7cbfc..c1ccc7922f9 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -35,6 +35,7 @@ import org.prebid.server.auction.model.MultiBidConfig; import org.prebid.server.auction.model.TargetingInfo; import org.prebid.server.auction.model.debug.DebugContext; +import org.prebid.server.auction.requestfactory.Ortb2ImplicitParametersResolver; import org.prebid.server.bidder.BidderCatalog; import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; @@ -1443,7 +1444,16 @@ private static String channelFromRequest(BidRequest bidRequest) { final ExtRequestPrebid prebid = ext != null ? ext.getPrebid() : null; final ExtRequestPrebidChannel channel = prebid != null ? prebid.getChannel() : null; - return channel != null ? channel.getName() : null; + return channel != null ? recogniseChannelName(channel.getName()) : null; + } + + // TODO: remove alias resolving after transition period + private static String recogniseChannelName(String channelName) { + if (StringUtils.equalsIgnoreCase("pbjs", channelName)) { + return Ortb2ImplicitParametersResolver.WEB_CHANNEL; + } + + return channelName; } private static boolean eventsAllowedByRequest(AuctionContext auctionContext) { diff --git a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java index 9f9c7b18e54..3df397c63f8 100644 --- a/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java +++ b/src/main/java/org/prebid/server/settings/model/AccountAuctionEventConfig.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import lombok.Builder; import lombok.Value; +import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.HashMap; @@ -22,6 +23,14 @@ public Map getEvents() { @JsonAnySetter public void addEvent(String key, Boolean value) { - events.put(key, value); + events.put(resolveKey(key), value); + } + + private static String resolveKey(String key) { + if (StringUtils.equalsIgnoreCase("pbjs", key)) { + return "web"; + } + + return key; } } From 3d42462332f33d00fd61e89ff356995c185d7aca Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Thu, 16 May 2024 15:34:46 +0200 Subject: [PATCH 45/58] Adkernel: Unsecured endpoint url (#3109) --- src/main/resources/bidder-config/adkernel.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/adkernel.yaml b/src/main/resources/bidder-config/adkernel.yaml index 210900b4466..8fe685f93e2 100644 --- a/src/main/resources/bidder-config/adkernel.yaml +++ b/src/main/resources/bidder-config/adkernel.yaml @@ -1,6 +1,6 @@ adapters: adkernel: - endpoint: https://pbs.adksrv.com/hb?zone=%s + endpoint: http://pbs.adksrv.com/hb?zone=%s endpoint-compression: gzip meta-info: maintainer-email: prebid-dev@adkernel.com From 51f3f82403e45dc0968836362a50c9d3c3ff0c12 Mon Sep 17 00:00:00 2001 From: CPMStar Date: Thu, 16 May 2024 06:41:30 -0700 Subject: [PATCH 46/58] CPMStar: updated to use iframe based usersync (#3175) --- src/main/resources/bidder-config/cpmstar.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/cpmstar.yaml b/src/main/resources/bidder-config/cpmstar.yaml index d85bf27a51c..a61a8503a81 100644 --- a/src/main/resources/bidder-config/cpmstar.yaml +++ b/src/main/resources/bidder-config/cpmstar.yaml @@ -13,6 +13,10 @@ adapters: vendor-id: 0 usersync: cookie-family-name: cpmstar + iframe: + url: https://server.cpmstar.com/usersync.aspx?ifr=1&gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} + support-cors: false + uid-macro: '$UID' redirect: url: https://server.cpmstar.com/usersync.aspx?gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} support-cors: false From 7ce1ecbb46d1489664617e8fe41b8989cb3bdb33 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Mon, 20 May 2024 13:08:26 +0200 Subject: [PATCH 47/58] Core: Ortb26 downgrader update (#3196) --- .../down/BidRequestOrtb26To25Converter.java | 276 +------ .../model/request/auction/Audio.groovy | 2 + .../model/request/auction/Content.groovy | 2 + .../model/request/auction/Dooh.groovy | 4 +- .../model/request/auction/DoohExt.groovy | 2 + .../model/request/auction/Publisher.groovy | 2 + .../model/request/auction/Qty.groovy | 2 + .../model/request/auction/RefSettings.groovy | 2 + .../model/request/auction/Refresh.groovy | 2 + .../model/request/auction/Video.groovy | 2 + .../model/response/auction/Bid.groovy | 2 + .../functional/tests/OrtbConverterSpec.groovy | 778 +++++++++--------- .../BidRequestOrtb26To25ConverterTest.java | 151 +--- .../algorix/test-algorix-bid-request.json | 1 + .../test-bidmachine-bid-request.json | 1 + .../test-generic-bid-request.json | 1 + 16 files changed, 443 insertions(+), 787 deletions(-) diff --git a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java index 3a968fc8192..43de9dff9a0 100644 --- a/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java +++ b/src/main/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25Converter.java @@ -2,23 +2,16 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Content; -import com.iab.openrtb.request.Device; import com.iab.openrtb.request.Eid; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Producer; -import com.iab.openrtb.request.Publisher; import com.iab.openrtb.request.Regs; -import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import com.iab.openrtb.request.Video; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.prebid.server.auction.versionconverter.BidRequestOrtbVersionConverter; import org.prebid.server.json.JacksonMapper; import org.prebid.server.proto.openrtb.ext.FlexibleExtension; @@ -37,9 +30,6 @@ public class BidRequestOrtb26To25Converter implements BidRequestOrtbVersionConve private static final String PREBID_FIELD = "prebid"; private static final String IS_REWARDED_INVENTORY_FIELD = "is_rewarded_inventory"; - private static final Producer EMPTY_PRODUCER = Producer.builder().build(); - private static final Publisher EMPTY_PUBLISHER = Publisher.builder().build(); - private final JacksonMapper mapper; public BidRequestOrtb26To25Converter(JacksonMapper mapper) { @@ -51,15 +41,6 @@ public BidRequest convert(BidRequest bidRequest) { final List imps = bidRequest.getImp(); final List modifiedImps = modifyImps(imps); - final Site site = bidRequest.getSite(); - final Site modifiedSite = modifySite(site); - - final App app = bidRequest.getApp(); - final App modifiedApp = modifyApp(app); - - final Device device = bidRequest.getDevice(); - final Device modifiedDevice = modifyDevice(device); - final User user = bidRequest.getUser(); final User modifiedUser = modifyUser(user); @@ -71,25 +52,13 @@ public BidRequest convert(BidRequest bidRequest) { return ObjectUtils.anyNotNull( modifiedImps, - modifiedSite, - modifiedApp, - modifiedDevice, modifiedUser, - bidRequest.getWlangb(), - bidRequest.getCattax(), - bidRequest.getDooh(), modifiedSource, modifiedRegs) ? bidRequest.toBuilder() .imp(modifiedImps != null ? modifiedImps : imps) - .site(modifiedSite != null ? modifiedSite : site) - .app(modifiedApp != null ? modifiedApp : app) - .device(modifiedDevice != null ? modifiedDevice : device) .user(modifiedUser != null ? modifiedUser : user) - .wlangb(null) - .cattax(null) - .dooh(null) .source(modifiedSource != null ? modifiedSource : source) .regs(modifiedRegs != null ? modifiedRegs : regs) .build() @@ -112,88 +81,10 @@ private List modifyImps(List imps) { } private Imp modifyImp(Imp imp) { - final Video video = imp.getVideo(); - final Video modifiedVideo = modifyVideo(video); - - final Audio audio = imp.getAudio(); - final Audio modifiedAudio = modifyAudio(audio); - - final ObjectNode impExt = imp.getExt(); - final ObjectNode modifiedImpExt = modifyImpExt(impExt, imp.getRwdd()); - - return ObjectUtils.anyNotNull(modifiedVideo, - modifiedAudio, - imp.getSsai(), - imp.getQty(), - imp.getDt(), - imp.getRefresh(), - modifiedImpExt) - - ? imp.toBuilder() - .video(modifiedVideo != null ? modifiedVideo : video) - .audio(modifiedAudio != null ? modifiedAudio : audio) - .rwdd(null) - .ssai(null) - .qty(null) - .dt(null) - .refresh(null) - .ext(modifiedImpExt != null ? modifiedImpExt : impExt) - .build() - - : null; - } - - private static Video modifyVideo(Video video) { - if (video == null) { - return null; - } - - return ObjectUtils.anyNotNull( - video.getMaxseq(), - video.getPoddur(), - video.getPodid(), - video.getPodseq(), - video.getRqddurs(), - video.getSlotinpod(), - video.getMincpmpersec()) - - ? video.toBuilder() - .maxseq(null) - .poddur(null) - .podid(null) - .podseq(null) - .rqddurs(null) - .slotinpod(null) - .mincpmpersec(null) - .build() - - : null; - } - - private static Audio modifyAudio(Audio audio) { - if (audio == null) { - return null; - } - - return ObjectUtils.anyNotNull( - audio.getPoddur(), - audio.getRqddurs(), - audio.getPodid(), - audio.getPodseq(), - audio.getSlotinpod(), - audio.getMincpmpersec(), - audio.getMaxseq()) - - ? audio.toBuilder() - .poddur(null) - .rqddurs(null) - .podid(null) - .podseq(null) - .slotinpod(null) - .mincpmpersec(null) - .maxseq(null) - .build() + final ObjectNode modifiedImpExt = modifyImpExt(imp.getExt(), imp.getRwdd()); + return modifiedImpExt != null + ? imp.toBuilder().ext(modifiedImpExt).build() : null; } @@ -216,160 +107,25 @@ private ObjectNode modifyImpExt(ObjectNode impExt, Integer rewarded) { return copy; } - private static Site modifySite(Site site) { - if (site == null) { - return null; - } - - final Publisher publisher = site.getPublisher(); - final Publisher modifiedPublisher = modifyPublisher(publisher); - - final Content content = site.getContent(); - final Content modifiedContent = modifyContent(content); - - return ObjectUtils.anyNotNull( - site.getCattax(), - site.getInventorypartnerdomain(), - modifiedPublisher, - modifiedContent, - site.getKwarray()) - - ? site.toBuilder() - .cattax(null) - .inventorypartnerdomain(null) - .publisher(modifiedPublisher != null ? nullIfEmpty(modifiedPublisher) : publisher) - .content(modifiedContent != null ? nullIfEmpty(modifiedContent) : content) - .kwarray(null) - .build() - - : null; - } - - private static Publisher modifyPublisher(Publisher publisher) { - return publisher != null && publisher.getCattax() != null - ? publisher.toBuilder() - .cattax(null) - .build() - : null; - } - - private static Content modifyContent(Content content) { - if (content == null) { - return null; - } - - final Producer producer = content.getProducer(); - final Producer modifiedProducer = modifyProducer(producer); - - return ObjectUtils.anyNotNull( - modifiedProducer, - content.getCattax(), - content.getKwarray(), - content.getLangb(), - content.getNetwork(), - content.getChannel()) - - ? content.toBuilder() - .producer(modifiedProducer != null ? nullIfEmpty(modifiedProducer) : producer) - .cattax(null) - .kwarray(null) - .langb(null) - .network(null) - .channel(null) - .build() - - : null; - } - - private static Producer modifyProducer(Producer producer) { - return producer != null && producer.getCattax() != null - ? producer.toBuilder() - .cattax(null) - .build() - : null; - } - - private static Producer nullIfEmpty(Producer producer) { - return nullIfEmpty(producer, EMPTY_PRODUCER.equals(producer)); - } - - private static Publisher nullIfEmpty(Publisher publisher) { - return nullIfEmpty(publisher, EMPTY_PUBLISHER.equals(publisher)); - } - - private static Content nullIfEmpty(Content content) { - return nullIfEmpty(content, content.isEmpty()); - } - - private static T nullIfEmpty(T object, boolean isEmpty) { - return isEmpty ? null : object; - } - - private static App modifyApp(App app) { - if (app == null) { - return null; - } - - final Publisher publisher = app.getPublisher(); - final Publisher modifiedPublisher = modifyPublisher(publisher); - - final Content content = app.getContent(); - final Content modifiedContent = modifyContent(content); - - return ObjectUtils.anyNotNull( - app.getCattax(), - app.getInventorypartnerdomain(), - modifiedPublisher, - modifiedContent, - app.getKwarray()) - - ? app.toBuilder() - .cattax(null) - .inventorypartnerdomain(null) - .publisher(modifiedPublisher != null ? nullIfEmpty(modifiedPublisher) : publisher) - .content(modifiedContent != null ? nullIfEmpty(modifiedContent) : content) - .kwarray(null) - .build() - - : null; - } - - private static Device modifyDevice(Device device) { - if (device == null) { - return null; - } - - return ObjectUtils.anyNotNull(device.getSua(), device.getLangb()) - ? device.toBuilder() - .sua(null) - .langb(null) - .build() - : null; - } - private static User modifyUser(User user) { if (user == null) { return null; } - final ExtUser extUser = user.getExt(); - final ExtUser modifiedExtUser = modifyUserExt(extUser, user.getConsent(), user.getEids()); + final List eids = user.getEids(); + final String consent = user.getConsent(); + if (StringUtils.isEmpty(consent) && CollectionUtils.isEmpty(eids)) { + return null; + } - return ObjectUtils.anyNotNull(user.getKwarray(), modifiedExtUser) - ? user.toBuilder() - .kwarray(null) - .consent(null) + return user.toBuilder() .eids(null) - .ext(modifiedExtUser != null ? modifiedExtUser : extUser) - .build() - : null; + .consent(null) + .ext(modifyUserExt(user.getExt(), consent, eids)) + .build(); } private static ExtUser modifyUserExt(ExtUser extUser, String consent, List eids) { - if (consent == null && CollectionUtils.isEmpty(eids)) { - return null; - } - final ExtUser modifiedExtUser = Optional.ofNullable(extUser) .map(ExtUser::toBuilder) .orElseGet(ExtUser::builder) @@ -413,9 +169,7 @@ private static Regs modifyRegs(Regs regs) { final Integer gdpr = regs.getGdpr(); final String usPrivacy = regs.getUsPrivacy(); - final String gpp = regs.getGpp(); - final List gppSid = regs.getGppSid(); - if (gdpr == null && usPrivacy == null && gpp == null && gppSid == null) { + if (gdpr == null && usPrivacy == null) { return null; } @@ -428,8 +182,6 @@ private static Regs modifyRegs(Regs regs) { return regs.toBuilder() .gdpr(null) .usPrivacy(null) - .gpp(null) - .gppSid(null) .ext(extRegs) .build(); } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy index 9fd950aaf21..57d9bbd40ee 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Audio.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Audio { List mimes diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy index 9634910fb02..7b49458a5fc 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Content.groovy @@ -1,9 +1,11 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Content { String id diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy index b5cefe73339..321d7e53585 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dooh.groovy @@ -2,13 +2,15 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Dooh { - + String id String name List venueType diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy index d7a2bcee7b8..1654b806d5c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/DoohExt.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class DoohExt { DoohExtData data diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy index b0778a10cd5..ef0c64fe881 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Publisher.groovy @@ -1,9 +1,11 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Publisher { String id diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy index 938b044fd7a..590e232cfb5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Qty.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Qty { BigDecimal multiplier diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy index e00ee5ecdf5..c90adf142ae 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/RefSettings.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class RefSettings { RefType refType diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy index aee58a890d0..397c9053eaa 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Refresh.groovy @@ -2,10 +2,12 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) +@EqualsAndHashCode class Refresh { List refSettings diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy index 064a5e01b9d..40b32028217 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Video { List mimes diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy index ff4a1933d0d..9346c228932 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.model.response.auction +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.Asset import org.prebid.server.functional.model.request.auction.Imp @@ -7,6 +8,7 @@ import org.prebid.server.functional.util.ObjectMapperWrapper import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@EqualsAndHashCode class Bid implements ObjectMapperWrapper { String id diff --git a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy index b22ef5438c6..856315e17d2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Content @@ -8,6 +9,7 @@ import org.prebid.server.functional.model.request.auction.Dooh import org.prebid.server.functional.model.request.auction.DoohExt import org.prebid.server.functional.model.request.auction.Eid import org.prebid.server.functional.model.request.auction.Network +import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Producer import org.prebid.server.functional.model.request.auction.Publisher import org.prebid.server.functional.model.request.auction.Qty @@ -39,22 +41,24 @@ class OrtbConverterSpec extends BaseSpec { @Shared PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.5"]) - def "PBS shouldn't move regs to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move regs.{gdpr,usPrivacy} to regs.ext.{gdpr,usPrivacy} when adapter support ortb 2.6"() { given: "Default bid request with regs object" def usPrivacyRandomString = PBSUtils.randomString + def gdpr = 0 def bidRequest = BidRequest.defaultBidRequest.tap { regs = Regs.defaultRegs.tap { - usPrivacy = usPrivacyRandomString + it.usPrivacy = usPrivacyRandomString + it.gdpr = gdpr } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" + then: "Bidder request should contain the same regs.{gdpr,usPrivacy} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.usPrivacy == usPrivacyRandomString - regs.gdpr == 0 + regs.gdpr == gdpr !regs.ext } } @@ -71,14 +75,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same imp.rwdd as on request" + then: "Bidder request should contain the same imp.rwdd as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { imp.first().rwdd == rwdRandomNumber !imp.first().ext.prebid } } - def "PBS shouldn't move eids to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move user.eids to user.ext.eids when adapter support ortb 2.6"() { given: "Default bid request with user.eids" def defaultEids = [Eid.defaultEid] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -90,16 +94,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.eids as on request" + then: "Bidder request should contain user.eids as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - user.eids.first().source == defaultEids.first().source - user.eids.first().uids.first().id == defaultEids.first().uids.first().id - user.eids.first().uids.first().atype == defaultEids.first().uids.first().atype + user.eids == defaultEids !user.ext } } - def "PBS shouldn't move consent to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move consent to user.ext.consent when adapter support ortb 2.6"() { given: "Default bid request with user.consent" def consentRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -111,14 +113,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.consent as on request" + then: "Bidder request should contain the same user.consent as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.consent == consentRandomString !user.ext } } - def "PBS shouldn't move schain to past location when adapter support ortb 2.6"() { + def "PBS shouldn't move source.schain to source.ext.schain when adapter support ortb 2.6"() { given: "Default bid request with source.schain" def defaultSource = Source.defaultSource def defaultSupplyChain = defaultSource.schain @@ -129,16 +131,9 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same source.schain as on request" + then: "Bidder request should contain the same source.schain as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - source.schain.ver == defaultSupplyChain.ver - source.schain.complete == defaultSupplyChain.complete - source.schain.nodes.first().asi == defaultSupplyChain.nodes.first().asi - source.schain.nodes.first().sid == defaultSupplyChain.nodes.first().sid - source.schain.nodes.first().rid == defaultSupplyChain.nodes.first().rid - source.schain.nodes.first().name == defaultSupplyChain.nodes.first().name - source.schain.nodes.first().domain == defaultSupplyChain.nodes.first().domain - source.schain.nodes.first().hp == defaultSupplyChain.nodes.first().hp + source.schain == defaultSupplyChain !source.ext } } @@ -154,7 +149,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same source.schain as on request but should be in source.ext.schain" + then: "Bidder request should contain the same source.schain as on request but should be in source.ext.schain" verifyAll(bidder.getBidderRequest(bidRequest.id)) { source.ext.schain.ver == defaultSupplyChain.ver source.ext.schain.complete == defaultSupplyChain.complete @@ -168,7 +163,7 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move consent to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move consent to user.ext.consent when adapter doesn't support ortb 2.6"() { given: "Default bid request with user.consent" def consentRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -180,14 +175,14 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.consent as on request but should be in user.ext" + then: "Bidder request should contain the same user.consent as on request but should be in user.ext" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.ext.consent == consentRandomString !user.consent } } - def "PBS should move eids to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move eids to o user.ext.eids when adapter doesn't support ortb 2.6"() { given: "Default bid request with user.eids" def defaultEids = [Eid.defaultEid] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -199,7 +194,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same user.eids as on request but should be in user.ext.eids" + then: "Bidder request should contain the same user.eids as on request but should be in user.ext.eids" verifyAll(bidder.getBidderRequest(bidRequest.id)) { user.ext.eids.first().source == defaultEids.first().source user.ext.eids.first().uids.first().id == defaultEids.first().uids.first().id @@ -208,7 +203,7 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move regs to past location when adapter doesn't support ortb 2.6"() { + def "PBS should move regs to regs.ext.{gdpr,upPrivacy} when adapter doesn't support ortb 2.6"() { given: "Default bid request with regs object" def usPrivacyRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -220,7 +215,7 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs object as on request but should be in regs.ext" + then: "Bidder request should contain the same regs object as on request but should be in regs.ext" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.ext.usPrivacy == usPrivacyRandomString regs.ext.gdpr == 0 @@ -229,26 +224,24 @@ class OrtbConverterSpec extends BaseSpec { } } - def "PBS should move rewarded video to past location when adapter doesn't support ortb 2.6"() { + def "PBS should copy rewarded video to imp.ext.prebid.isRewardedInventory when adapter support ortb 2.6"() { given: "Default bid request with rwdd" def rwdRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].tap { - rwdd = rwdRandomNumber - } + imp[0].rwdd = rwdRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same imp.rwdd as on request but should be in ext.prebid" + then: "Bidder request should contain the same imp.rwdd as on request but should be also in ext.prebid" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp.first().ext.prebid.isRewardedInventory == rwdRandomNumber - !imp.first().rwdd + imp[0].ext.prebid.isRewardedInventory == rwdRandomNumber + imp[0].rwdd == rwdRandomNumber } } - def "PBS shouldn't remove wlangb when we we support ortb 2.6"() { + def "PBS shouldn't remove wlangb when bidder supports ortb 2.6"() { given: "Default bid request with wlangb" def wlangbRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -258,45 +251,43 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn contain the wlangb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - wlangb == wlangbRandomStrings - } + then: "Bidder request shouldn contain the wlangb as on request" + assert bidder.getBidderRequest(bidRequest.id).wlangb == wlangbRandomStrings } - def "PBS should remove wlangb when we don't support ortb 2.6"() { + def "PBS shouldn't remove wlangb when bidder doesn't support ortb 2.6"() { given: "Default bid request with wlangb" + def wlangbRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { - wlangb = [PBSUtils.randomString] + wlangb = wlangbRandomStrings } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the wlangb as on request" + then: "Bidder request should contain the wlangb as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !wlangb + wlangb == wlangbRandomStrings } } - def "PBS should remove device.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove device.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with device.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the device.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !device.langb - } + then: "Bidder request should contain the device.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).device.langb == langbRandomString } - def "PBS shouldn't remove device.langb when we support ortb 2.6"() { + def "PBS shouldn't remove device.langb when bidder supports ortb 2.6"() { given: "Default bid request with device.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -308,30 +299,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the device.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - device.langb == langbRandomString - } + then: "Bidder request should contain the device.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).device.langb == langbRandomString } - def "PBS should remove site.content.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.langb - } + then: "Bidder request should contain the site.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.langb == langbRandomString } - def "PBS shouldn't remove site.content.langb when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.langb when bidder supports ortb 2.6"() { given: "Default bid request with site.content.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { @@ -343,30 +331,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.langb == langbRandomString - } + then: "Bidder request should contain the site.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.langb == langbRandomString } - def "PBS should remove app.content.langb when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.content.langb when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.content.langb" + def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { app.content = Content.defaultContent.tap { - langb = PBSUtils.randomString + langb = langbRandomString } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.content.langb - } + then: "Bidder request should contain the app.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).app.content.langb == langbRandomString } - def "PBS shouldn't remove app.content.langb when we support ortb 2.6"() { + def "PBS shouldn't remove app.content.langb when bidder supports ortb 2.6"() { given: "Default bid request with app.content.langb" def langbRandomString = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -378,30 +363,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.content.langb as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.content.langb == langbRandomString - } + then: "Bidder request should contain the app.content.langb as on request" + assert bidder.getBidderRequest(bidRequest.id).app.content.langb == langbRandomString } - def "PBS should remove site.publisher.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.publisher.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.publisher.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.publisher = Publisher.defaultPublisher.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.publisher.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.publisher.cattax - } + then: "Bidder request should contain the site.publisher.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.publisher.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.publisher.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.publisher.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.publisher.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -413,18 +395,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.publisher.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.publisher.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.publisher.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.publisher.cattax == cattaxRandomNumber } - def "PBS should remove site.content.producer.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.producer.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.producer.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { producer = Producer.defaultProducer.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } } @@ -432,13 +413,11 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.producer.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.producer.cattax - } + then: "Bidder request should contain the site.content.producer.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.producer.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.content.producer.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.producer.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.content.producer.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -452,28 +431,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.producer.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.producer.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.content.producer.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.producer.cattax == cattaxRandomNumber } - def "PBS should remove app.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.catTax = PBSUtils.randomNumber + app.catTax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.catTax - } + then: "Bidder request should contain the app.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).app.catTax == cattaxRandomNumber } - def "PBS shouldn't remove app.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove app.cattax when bidder supports ortb 2.6"() { given: "Default bid request with app.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -483,28 +459,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.catTax == cattaxRandomNumber - } + then: "Bidder request should contain the app.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).app.catTax == cattaxRandomNumber } - def "PBS should remove cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !cattax - } + then: "Bidder request should contain the cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).cattax == cattaxRandomNumber } - def "PBS shouldn't remove cattax when we support ortb 2.6"() { + def "PBS shouldn't remove cattax when bidder supports ortb 2.6"() { given: "Default bid request with cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -514,28 +487,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - cattax == cattaxRandomNumber - } + then: "Bidder request should contain the cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).cattax == cattaxRandomNumber } - def "PBS should remove site.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - site.catTax = PBSUtils.randomNumber + site.catTax = cattaxRandomNumber } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.catTax - } + then: "Bidder request should contain the site.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.catTax == cattaxRandomNumber } - def "PBS shouldn't remove site.cattax when we support ortb 2.6"() { + def "PBS shouldn't remove site.cattax when bidder supports ortb 2.6"() { given: "Default bid request with site.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -545,30 +515,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.catTax == cattaxRandomNumber - } + then: "Bidder request should contain the site.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.catTax == cattaxRandomNumber } - def "PBS should remove site.content.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.cattax when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.cattax" + def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - cattax = PBSUtils.randomNumber + cattax = cattaxRandomNumber } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.cattax - } + then: "Bidder request should contain the site.content.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.cattax == cattaxRandomNumber } - def "PBS shouldn't remove site.content.cattax when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.cattax when bidder supports ortb 2.5"() { given: "Default bid request with site.content.cattax" def cattaxRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -580,15 +547,12 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.cattax as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.cattax == cattaxRandomNumber - } + then: "Bidder request should contain the site.content.cattax as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.cattax == cattaxRandomNumber } - def "PBS should remove imp[0].video.* and keep imp[0].video.plcmt when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].video.* and keep imp[0].video.plcmt when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].video.*" - def placement = PBSUtils.getRandomEnum(VideoPlcmtSubtype) def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].video = Video.defaultVideo.tap { rqddurs = [PBSUtils.randomNumber] @@ -598,69 +562,42 @@ class OrtbConverterSpec extends BaseSpec { podseq = PBSUtils.randomNumber mincpmpersec = PBSUtils.randomDecimal slotinpod = PBSUtils.randomNumber - plcmt = placement + plcmt = PBSUtils.getRandomEnum(VideoPlcmtSubtype) } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "Bidder request shouldn't contain the imp[0].video.* as on request" + then: "Bidder request should contain the imp[0].video.* as on request" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - verifyAll(bidderRequest) { - !imp[0].video.rqddurs - !imp[0].video.maxseq - !imp[0].video.poddur - !imp[0].video.podid - !imp[0].video.podseq - !imp[0].video.mincpmpersec - !imp[0].video.slotinpod - } - - and: "Bidder request should contain the imp[0].video.* as on request" - bidderRequest.imp[0].video.plcmt == placement + assert bidderRequest.imp[0].video == bidRequest.imp[0].video } - def "PBS shouldn't remove imp[0].video.* when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].video.* when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].video.*" - def rqddursListOfRandomNumber = [PBSUtils.randomNumber] - def maxseqRandomNumber = PBSUtils.randomNumber - def poddurRandomNumber = PBSUtils.randomNumber - def podidRandomNumber = PBSUtils.randomNumber - def podseqRandomNumber = PBSUtils.randomNumber - def mincpmpersecRandomNumber = PBSUtils.randomDecimal - def slotinpodRandomNumber = PBSUtils.randomNumber - def plcmtRandomEnum = PBSUtils.getRandomEnum(VideoPlcmtSubtype) def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].video = Video.defaultVideo.tap { - rqddurs = rqddursListOfRandomNumber - maxseq = maxseqRandomNumber - poddur = poddurRandomNumber - podid = podidRandomNumber - podseq = podseqRandomNumber - mincpmpersec = mincpmpersecRandomNumber - slotinpod = slotinpodRandomNumber - plcmt = plcmtRandomEnum + rqddurs = [PBSUtils.randomNumber] + maxseq = PBSUtils.randomNumber + poddur = PBSUtils.randomNumber + podid = PBSUtils.randomNumber + podseq = PBSUtils.randomNumber + mincpmpersec = PBSUtils.randomDecimal + slotinpod = PBSUtils.randomNumber + plcmt = PBSUtils.getRandomEnum(VideoPlcmtSubtype) } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].video.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].video.rqddurs == rqddursListOfRandomNumber - imp[0].video.maxseq == maxseqRandomNumber - imp[0].video.poddur == poddurRandomNumber - imp[0].video.podid == podidRandomNumber - imp[0].video.podseq == podseqRandomNumber - imp[0].video.mincpmpersec == mincpmpersecRandomNumber - imp[0].video.slotinpod == slotinpodRandomNumber - imp[0].video.plcmt == plcmtRandomEnum - } + then: "Bidder request should contain the imp[0].video.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].video == bidRequest.imp[0].video } - def "PBS should remove imp[0].audio.* when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].audio.* when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].audio.*" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].audio = Audio.defaultAudio.tap { @@ -677,70 +614,49 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].audio.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].audio.rqddurs - !imp[0].audio.maxseq - !imp[0].audio.poddur - !imp[0].audio.podid - !imp[0].audio.podseq - !imp[0].audio.mincpmpersec - !imp[0].audio.slotinpod - } + then: "Bidder request should contain the imp[0].audio.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].audio == bidRequest.imp[0].audio } - def "PBS shouldn't remove imp[0].audio.* when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].audio.* when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].audio.*" - def rqddursListOfRandomNumber = [PBSUtils.randomNumber] - def maxseqRandomNumber = PBSUtils.randomNumber - def poddurRandomNumber = PBSUtils.randomNumber - def podidRandomNumber = PBSUtils.randomNumber - def podseqRandomNumber = PBSUtils.randomNumber - def mincpmpersecRandomNumber = PBSUtils.randomDecimal - def slotinpodRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].audio = Audio.defaultAudio.tap { - rqddurs = rqddursListOfRandomNumber - maxseq = maxseqRandomNumber - poddur = poddurRandomNumber - podid = podidRandomNumber - podseq = podseqRandomNumber - mincpmpersec = mincpmpersecRandomNumber - slotinpod = slotinpodRandomNumber + rqddurs = [PBSUtils.randomNumber] + maxseq = PBSUtils.randomNumber + poddur = PBSUtils.randomNumber + podid = PBSUtils.randomNumber + podseq = PBSUtils.randomNumber + mincpmpersec = BigDecimal.valueOf(1) + slotinpod = PBSUtils.randomNumber } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].audio.* as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].audio.rqddurs == rqddursListOfRandomNumber - imp[0].audio.maxseq == maxseqRandomNumber - imp[0].audio.poddur == poddurRandomNumber - imp[0].audio.podid == podidRandomNumber - imp[0].audio.podseq == podseqRandomNumber - imp[0].audio.mincpmpersec == mincpmpersecRandomNumber - imp[0].audio.slotinpod == slotinpodRandomNumber - } + then: "Bidder request should contain the imp[0].audio.* as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].audio == bidRequest.imp[0].audio } - def "PBS should remove imp[0].ssai when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].ssai when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].ssai" + def randomSsai = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].ssai = PBSUtils.randomNumber + imp[0].ssai = randomSsai } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].ssai as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].ssai - } + then: "Bidder request should contain the imp[0].ssai as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].ssai == randomSsai } - def "PBS shouldn't remove imp[0].ssai when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].ssai when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].ssai" def ssaiRandomNumber = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -750,32 +666,33 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].ssai as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].ssai == ssaiRandomNumber - } + then: "Bidder request should contain the imp[0].ssai as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest.imp[0].ssai == ssaiRandomNumber } - def "PBS should remove site.content.{channel, network} when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.{channel, network} when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.{network, channel}" + def defaultChannel = Channel.defaultChannel + def defaultNetwork = Network.defaultNetwork def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - channel = Channel.defaultChannel - network = Network.defaultNetwork + it.channel = defaultChannel + it.network = defaultNetwork } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.{network, channel} as on request" + then: "Bidder request should contain the site.content.{network, channel} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.channel - !site.content.network + site.content.channel.id == defaultChannel.id + site.content.network.id == defaultNetwork.id } } - def "PBS shouldn't remove site.content.{channel, network} when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.{channel, network} when bidder supports ortb 2.6"() { given: "Default bid request with site.content.{network, channel}" def defaultChannel = Channel.defaultChannel def defaultNetwork = Network.defaultNetwork @@ -789,33 +706,35 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.{channel, network} as on request" + then: "Bidder request should contain the site.content.{channel, network} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { site.content.channel.id == defaultChannel.id site.content.network.id == defaultNetwork.id } } - def "PBS should remove app.content.{channel, network} when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.content.{channel, network} when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.content.{network, channel}" + def defaultChannel = Channel.defaultChannel + def defaultNetwork = Network.defaultNetwork def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { app.content = Content.defaultContent.tap { - channel = Channel.defaultChannel - network = Network.defaultNetwork + channel = defaultChannel + network = defaultNetwork } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.content.{network, channel} as on request" + then: "Bidder request should contain the app.content.{network, channel} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.content.channel - !app.content.network + app.content.channel.id == defaultChannel.id + app.content.network.id == defaultNetwork.id } } - def "PBS shouldn't remove app.content.{channel, network} when we support ortb 2.6"() { + def "PBS shouldn't remove app.content.{channel, network} when bidder supports ortb 2.6"() { given: "Default bid request with content.{network, channel}" def defaultChannel = Channel.defaultChannel def defaultNetwork = Network.defaultNetwork @@ -829,29 +748,28 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.content.{channel, network} as on request" + then: "Bidder response should contain the app.content.{channel, network} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { app.content.channel.id == defaultChannel.id app.content.network.id == defaultNetwork.id } } - def "PBS should remove site.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.kwarray" + def randomKwArray = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { - site.kwArray = [PBSUtils.randomString] + site.kwArray = randomKwArray } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.kwArray - } + then: "Bidder request should contain the site.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.kwArray == randomKwArray } - def "PBS shouldn't remove site.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove site.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with site.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -861,30 +779,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.kwArray == kwarrayRandomStrings - } + then: "Bidder request should contain the site.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.kwArray == kwarrayRandomStrings } - def "PBS should remove site.content.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove site.content.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with site.content.kwarray" + def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { site.content = Content.defaultContent.tap { - kwarray = [PBSUtils.randomString] + kwarray = kwarrayRandomStrings } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the site.content.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.content.kwarray - } + then: "Bidder request should contain the site.content.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.kwarray == kwarrayRandomStrings } - def "PBS shouldn't remove site.content.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove site.content.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with site.content.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -896,28 +811,25 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the site.content.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.content.kwarray == kwarrayRandomStrings - } + then: "Bidder request should contain the site.content.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).site.content.kwarray == kwarrayRandomStrings } - def "PBS should remove app.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove app.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with app.kwarray" + def randomKwArray = [PBSUtils.randomString] def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.kwArray = [PBSUtils.randomString] + app.kwArray = randomKwArray } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the app.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.kwArray - } + then: "Bidder request should contain the app.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).app.kwArray == randomKwArray } - def "PBS shouldn't remove app.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove app.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with app.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -927,30 +839,27 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the app.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.kwArray == kwarrayRandomStrings - } + then: "Bidder request should contain the app.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).app.kwArray == kwarrayRandomStrings } - def "PBS should remove user.kwarray when we don't support ortb 2.6"() { + def "PBS shouldn't remove user.kwarray when bidder doesn't support ortb 2.6"() { given: "Default bid request with user.kwarray" + def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { user = User.defaultUser.tap { - kwarray = [PBSUtils.randomString] + kwarray = kwarrayRandomStrings } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the user.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !user.kwarray - } + then: "Bidder request shouldn't contain the user.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).user.kwarray == kwarrayRandomStrings } - def "PBS shouldn't remove user.kwarray when we support ortb 2.6"() { + def "PBS shouldn't remove user.kwarray when bidder supports ortb 2.6"() { given: "Default bid request with user.kwarray" def kwarrayRandomStrings = [PBSUtils.randomString] def bidRequest = BidRequest.defaultBidRequest.tap { @@ -962,18 +871,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the user.kwarray as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - user.kwarray == kwarrayRandomStrings - } + then: "Bidder request should contain the user.kwarray as on request" + assert bidder.getBidderRequest(bidRequest.id).user.kwarray == kwarrayRandomStrings } - def "PBS should remove device.sua when we don't support ortb 2.6"() { + def "PBS shouldn't remove device.sua when bidder doesn't support ortb 2.6"() { given: "Default bid request with device.sua" + def model = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { sua = new UserAgent().tap { - model = PBSUtils.randomString + it.model = model } } } @@ -981,19 +889,17 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the device.sua as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !device.sua - } + then: "Bidder request should contain the device.sua as on request" + assert bidder.getBidderRequest(bidRequest.id).device.sua.model == model } - def "PBS shouldn't remove device.sua when we support ortb 2.6"() { + def "PBS shouldn't remove device.sua when bidder supports ortb 2.6"() { given: "Default bid request with device.sua" - def modelRandomString = PBSUtils.randomString + def model = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { device = new Device().tap { sua = new UserAgent().tap { - model = modelRandomString + it.model = model } } } @@ -1001,10 +907,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the device.sua as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - device.sua.model == modelRandomString - } + then: "Bidder request should contain the device.sua as on request" + assert bidder.getBidderRequest(bidRequest.id).device.sua.model == model } def "PBS should pass bid[].{langb, dur, slotinpor, apis, cattax} through to response"() { @@ -1017,12 +921,14 @@ class OrtbConverterSpec extends BaseSpec { def apisRandomNumbers = [PBSUtils.randomNumber] def slotinpodRandomNumber = PBSUtils.randomNumber def cattaxRandomNumber = PBSUtils.randomNumber + def catRandomNumber = [PBSUtils.randomString] def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { seatbid.first().bid.first().langb = langbRandomString seatbid.first().bid.first().dur = durRandomNumber seatbid.first().bid.first().apis = apisRandomNumbers seatbid.first().bid.first().slotinpod = slotinpodRandomNumber seatbid.first().bid.first().cattax = cattaxRandomNumber + seatbid.first().bid.first().cat = catRandomNumber } and: "Set bidder response" @@ -1031,30 +937,32 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" def response = prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the lang, dur, apis, slotinpod, cattax as on request" + then: "Bidder request should contain the lang, dur, apis, slotinpod, cattax,cat as on request" verifyAll(response) { seatbid.first().bid.first().langb == langbRandomString seatbid.first().bid.first().dur == durRandomNumber seatbid.first().bid.first().apis == apisRandomNumbers seatbid.first().bid.first().slotinpod == slotinpodRandomNumber seatbid.first().bid.first().cattax == cattaxRandomNumber + seatbid.first().bid.first().cat == catRandomNumber } } - def "PBS should remove gpp and gppSid when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove gpp and gppSid when PBS don't support ortb 2.6"() { given: "Default bid request with device.sua" + def randomGpp = PBSUtils.randomString + def randomGppSid = [PBSUtils.getRandomNumber(), PBSUtils.getRandomNumber()] def bidRequest = BidRequest.defaultBidRequest.tap { - regs = new Regs(gpp: PBSUtils.randomString, gppSid: [PBSUtils.getRandomNumber(), - PBSUtils.getRandomNumber()]) + regs = new Regs(gpp: randomGpp, gppSid: randomGppSid) } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the regs.gpp and regs.gppSid as on request" + then: "BidderRequest should contain the regs.gpp and regs.gppSid as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !regs.gpp - !regs.gppSid + regs.gpp == bidRequest.regs.gpp + regs.gppSid.eachWithIndex { value, i -> bidRequest.regs.gppSid[i] == value } } } @@ -1071,122 +979,114 @@ class OrtbConverterSpec extends BaseSpec { then: "BidderRequest should contain the regs.gpp and regs.gppSid as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { regs.gpp == bidRequest.regs.gpp - regs.gppSid.eachWithIndex { Integer value, int i -> bidRequest.regs.gppSid[i] == value } + regs.gppSid.eachWithIndex { value, i -> bidRequest.regs.gppSid[i] == value } } } - def "PBS should remove imp[0].{refresh/qty/dt} when we don't support ortb 2.6"() { + def "PBS shouldn't remove imp[0].{refresh/qty/dt} when bidder doesn't support ortb 2.6"() { given: "Default bid request with imp[0].{refresh/qty/dt}" + def refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: + [new RefSettings(refType: PBSUtils.getRandomEnum(RefType), minInt: PBSUtils.randomNumber)]) + def qty = new Qty(multiplier: PBSUtils.randomDecimal, sourceType: PBSUtils.getRandomEnum(SourceType), + vendor: PBSUtils.randomString) + def dt = PBSUtils.randomDecimal def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { - refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: [new RefSettings( - refType: PBSUtils.getRandomEnum(RefType), - minInt: PBSUtils.randomNumber)]) - qty = new Qty(multiplier: PBSUtils.randomDecimal, - sourceType: PBSUtils.getRandomEnum(SourceType), - vendor: PBSUtils.randomString) - dt = PBSUtils.randomDecimal + it.refresh = refresh + it.qty = qty + it.dt = dt } } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse shouldn't contain the imp[0].{refresh/qty/dt} as on request" + then: "Bidder request should contain the imp[0].{refresh/qty/dt} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !imp[0].refresh - !imp[0].qty - !imp[0].dt + imp[0].refresh == refresh + imp[0].qty == qty + imp[0].dt == dt } } - def "PBS shouldn't remove imp[0].{refresh/qty/dt} when we support ortb 2.6"() { + def "PBS shouldn't remove imp[0].{refresh/qty/dt} when bidder supports ortb 2.6"() { given: "Default bid request with imp[0].{refresh/qty/dt}" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { - refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: [new RefSettings( - refType: PBSUtils.getRandomEnum(RefType), - minInt: PBSUtils.randomNumber)]) - qty = new Qty(multiplier: PBSUtils.randomDecimal, + it.refresh = new Refresh(count: PBSUtils.randomNumber, refSettings: + [new RefSettings(refType: PBSUtils.getRandomEnum(RefType), minInt: PBSUtils.randomNumber)]) + it.qty = new Qty(multiplier: PBSUtils.randomDecimal, sourceType: PBSUtils.getRandomEnum(SourceType), vendor: PBSUtils.randomString) - dt = PBSUtils.randomDecimal + it.dt = PBSUtils.randomDecimal } } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the imp[0].{refresh/qty/dt} as on request" + then: "Bidder request should contain the imp[0].{refresh/qty/dt} as on request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { - imp[0].refresh.count == bidRequest.imp[0].refresh.count - imp[0].refresh.refSettings[0].refType == bidRequest.imp[0].refresh.refSettings[0].refType - imp[0].refresh.refSettings[0].minInt == bidRequest.imp[0].refresh.refSettings[0].minInt - imp[0].qty.multiplier == bidRequest.imp[0].qty.multiplier - imp[0].qty.sourceType == bidRequest.imp[0].qty.sourceType - imp[0].qty.vendor == bidRequest.imp[0].qty.vendor + imp[0].refresh == bidRequest.imp[0].refresh + imp[0].qty == bidRequest.imp[0].qty imp[0].dt == bidRequest.imp[0].dt } } - def "PBS should remove site.inventoryPartnerDomain when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove site.inventoryPartnerDomain when PBS don't support ortb 2.6"() { given: "Default bid request with site.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { - site.inventoryPartnerDomain = PBSUtils.randomString + site.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !site.inventoryPartnerDomain - } + then: "BidderRequest should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).site.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS shouldn't remove site.inventoryPartnerDomain when PBS support ortb 2.6"() { given: "Default bid request with site.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { - site.inventoryPartnerDomain = PBSUtils.randomString + site.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) then: "BidderRequest should contain the site.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - site.inventoryPartnerDomain == bidRequest.site.inventoryPartnerDomain - } + assert bidder.getBidderRequest(bidRequest.id).site.inventoryPartnerDomain == inventoryPartnerDomain } - def "PBS should remove app.inventoryPartnerDomain when PBS don't support ortb 2.6"() { + def "PBS shouldn't remove app.inventoryPartnerDomain when PBS don't support ortb 2.6"() { given: "Default bid request with app.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.inventoryPartnerDomain = PBSUtils.randomString + app.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !app.inventoryPartnerDomain - } + then: "Bidder request should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).app.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS shouldn't remove app.inventoryPartnerDomain when PBS support ortb 2.6"() { given: "Default bid request with app.inventoryPartnerDomain" + def inventoryPartnerDomain = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - app.inventoryPartnerDomain = PBSUtils.randomString + app.inventoryPartnerDomain = inventoryPartnerDomain } when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest should contain the app.inventoryPartnerDomain as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - app.inventoryPartnerDomain == bidRequest.app.inventoryPartnerDomain - } + then: "Bidder request should contain the app.inventoryPartnerDomain as on request" + assert bidder.getBidderRequest(bidRequest.id).app.inventoryPartnerDomain == inventoryPartnerDomain } def "PBS should remove bidRequest.dooh when PBS don't support ortb 2.6"() { @@ -1208,10 +1108,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest shouldn't contain the bidRequest.dooh as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - !dooh - } + then: "Bidder request should contain the bidRequest.dooh as on request" + assert bidder.getBidderRequest(bidRequest.id).dooh == bidRequest.dooh } def "PBS shouldn't remove bidRequest.dooh when PBS support ortb 2.6"() { @@ -1233,18 +1131,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidderRequest should contain the bidRequest.dooh as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - dooh.id == bidRequest.dooh.id - dooh.name == bidRequest.dooh.name - dooh.venueType == bidRequest.dooh.venueType - dooh.venueTypeTax == bidRequest.dooh.venueTypeTax - dooh.publisher.id == bidRequest.dooh.publisher.id - dooh.domain == bidRequest.dooh.domain - dooh.keywords == bidRequest.dooh.keywords - dooh.content.id == bidRequest.dooh.content.id - dooh.ext.data == bidRequest.dooh.ext.data - } + then: "Bidder request should contain the bidRequest.dooh as on request" + assert bidder.getBidderRequest(bidRequest.id).dooh == bidRequest.dooh } def "PBS shouldn't remove regs.ext.gpc when ortb request support ortb 2.6"() { @@ -1259,10 +1147,8 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.6" prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - regs.ext.gpc == randomGpc - } + then: "Bidder request should contain the same regs as on request" + assert bidder.getBidderRequest(bidRequest.id).regs.ext.gpc == randomGpc } def "PBS shouldn't remove regs.ext.gpc when ortb request doesn't support ortb 2.6"() { @@ -1277,9 +1163,131 @@ class OrtbConverterSpec extends BaseSpec { when: "Requesting PBS auction with ortb 2.5" prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) - then: "BidResponse should contain the same regs as on request" - verifyAll(bidder.getBidderRequest(bidRequest.id)) { - regs.ext.gpc == randomGpc + then: "Bidder request should contain the same regs as on request" + assert bidder.getBidderRequest(bidRequest.id).regs.ext.gpc == randomGpc + } + + def "PBS shouldn't remove video.protocols when ortb request support 2.6"() { + given: "Default bid request with Banner object" + def protocols = [PBSUtils.randomNumber] + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].video = Video.getDefaultVideo().tap { + it.protocols = protocols + } + } + + when: "Requesting PBS auction with ortb 2.6" + prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain video.protocols on request" + assert bidder.getBidderRequest(bidRequest.id).imp[0].video.protocols == protocols + } + + def "PBS shouldn't remove video.protocols when ortb request support 2.5"() { + given: "Default bid request with Banner object" + def protocols = [PBSUtils.randomNumber] + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].video = Video.getDefaultVideo().tap { + it.protocols = protocols + } + } + + when: "Requesting PBS auction with ortb 2.5" + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain video.protocols on request" + assert bidder.getBidderRequest(bidRequest.id).imp[0].video.protocols == protocols + } + + def "PBS shouldn't remove saetbid[0].bid[].{lang,dur.slotinpod,apis,cat,cattax} when ortb request support 2.5"() { + given: "Default bid request with stored request object" + def storedRequestId = PBSUtils.randomString + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getStoredRequest(bidRequest) + storedRequestDao.save(storedRequest) + + and: "Default bidder response" + def langb = PBSUtils.randomString + def dur = PBSUtils.randomNumber + def slotinpod = PBSUtils.randomNumber + def apis = [PBSUtils.randomNumber] + def cat = [PBSUtils.randomString] + def cattax = PBSUtils.randomNumber + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].tap { + it.langb = langb + it.dur = dur + it.slotinpod = slotinpod + it.apis = apis + it.cat = cat + it.cattax = cattax + } + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "Requesting PBS auction with ortb 2.5" + def response = prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain seat[0].bid[0].{langb,dur,slotinpod,apis,cattax,cat} on request" + verifyAll(response.seatbid[0].bid[0]) { + it.langb == langb + it.dur == dur + it.slotinpod == slotinpod + it.apis == apis + it.cattax == cattax + it.cat == cat + } + } + + def "PBS shouldn't remove saetbid[0].bid[].{lang,dur.slotinpod,apis,cat,cattax} when ortb request support 2.6"() { + given: "Default bid request with stored request object" + def storedRequestId = PBSUtils.randomString + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) + } + + and: "Save storedRequest into DB" + def storedRequest = StoredRequest.getStoredRequest(bidRequest) + storedRequestDao.save(storedRequest) + + and: "Default bidder response " + def langb = PBSUtils.randomString + def dur = PBSUtils.randomNumber + def slotinpod = PBSUtils.randomNumber + def apis = [PBSUtils.randomNumber] + def cat = [PBSUtils.randomString] + def cattax = PBSUtils.randomNumber + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].tap { + it.langb = langb + it.dur = dur + it.slotinpod = slotinpod + it.apis = apis + it.cattax = cattax + it.cat = cat + } + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "Requesting PBS auction with ortb 2.6" + def response = prebidServerServiceWithNewOrtb.sendAuctionRequest(bidRequest) + + then: "Bidder request should contain seat[0].bid[0].{langb,dur,slotinpod,apis,cattax,cat} on request" + verifyAll(response.seatbid[0].bid[0]) { + it.langb == langb + it.dur == dur + it.slotinpod == slotinpod + it.apis == apis + it.cattax == cattax + it.cat == cat } } } diff --git a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java index 5dd9ef12906..f485fad913d 100644 --- a/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java +++ b/src/test/java/org/prebid/server/auction/versionconverter/down/BidRequestOrtb26To25ConverterTest.java @@ -1,28 +1,13 @@ package org.prebid.server.auction.versionconverter.down; import com.fasterxml.jackson.databind.node.TextNode; -import com.iab.openrtb.request.App; -import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Channel; -import com.iab.openrtb.request.Content; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Dooh; import com.iab.openrtb.request.Eid; import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Network; -import com.iab.openrtb.request.Producer; -import com.iab.openrtb.request.Publisher; -import com.iab.openrtb.request.Qty; -import com.iab.openrtb.request.RefSettings; -import com.iab.openrtb.request.Refresh; import com.iab.openrtb.request.Regs; -import com.iab.openrtb.request.Site; import com.iab.openrtb.request.Source; import com.iab.openrtb.request.SupplyChain; import com.iab.openrtb.request.User; -import com.iab.openrtb.request.UserAgent; -import com.iab.openrtb.request.Video; import org.junit.Test; import org.prebid.server.VertxTest; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; @@ -30,16 +15,14 @@ import org.prebid.server.proto.openrtb.ext.request.ExtSource; import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import java.math.BigDecimal; -import java.util.List; import java.util.Map; import java.util.function.UnaryOperator; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; +import static java.util.function.UnaryOperator.identity; import static org.assertj.core.api.Assertions.assertThat; -import static org.prebid.server.hooks.v1.PayloadUpdate.identity; public class BidRequestOrtb26To25ConverterTest extends VertxTest { @@ -60,20 +43,17 @@ public void convertShouldMoveImpsRwdd() { // then assertThat(result) .extracting(BidRequest::getImp) - .satisfies(imps -> { - assertThat(imps) - .extracting(Imp::getRwdd) - .containsOnlyNulls(); - assertThat(imps) - .extracting(Imp::getExt) - .containsExactly( - null, - mapper.valueToTree(Map.of("prebid", Map.of("is_rewarded_inventory", 1))), - mapper.valueToTree(Map.of( - "prebid", Map.of( - "is_rewarded_inventory", 0, - "someField", "someValue")))); - }); + .satisfies(imps -> + assertThat(imps) + .extracting(Imp::getExt) + .containsExactly( + null, + mapper.valueToTree(Map.of("prebid", Map.of("is_rewarded_inventory", 1))), + mapper.valueToTree(Map.of( + "prebid", Map.of( + "is_rewarded_inventory", 0, + "someField", "someValue")))) + ); } @Test @@ -145,25 +125,6 @@ public void convertShouldMoveRegsData() { }); } - @Test - public void convertShouldRemoveRegsGppData() { - // given - final BidRequest bidRequest = givenBidRequest(request -> request.regs( - Regs.builder() - .gpp("gppValue") - .gppSid(List.of(1, 2, 3)) - .build())); - - // when - final BidRequest result = target.convert(bidRequest); - - // then - assertThat(result) - .extracting(BidRequest::getRegs) - .extracting(Regs::getGpp, Regs::getGppSid) - .containsOnlyNulls(); - } - @Test public void convertShouldMoveUserData() { // given @@ -196,94 +157,6 @@ public void convertShouldMoveUserData() { }); } - @Test - public void convertShouldRemoveFieldsThatAreNotInOrtb25() { - // given - final BidRequest bidRequest = givenBidRequest(request -> request - .imp(singletonList(givenImp(imp -> imp - .video(Video.builder() - .maxseq(1) - .poddur(1) - .podid(1) - .podseq(1) - .rqddurs(singletonList(1)) - .slotinpod(1) - .mincpmpersec(BigDecimal.ONE) - .build()) - .audio(Audio.builder() - .poddur(1) - .rqddurs(singletonList(1)) - .podid(1) - .podseq(1) - .slotinpod(1) - .mincpmpersec(BigDecimal.ONE) - .maxseq(1) - .build()) - .refresh(Refresh.builder().count(1) - .refsettings(singletonList(RefSettings.builder().minint(1).build())) - .build()) - .qty(Qty.builder().multiplier(BigDecimal.ONE).build()) - .dt(0.1) - .ssai(1)))) - .site(Site.builder() - .cattax(1) - .inventorypartnerdomain("inventorypartnerdomain") - .publisher(Publisher.builder().cattax(1).build()) - .content(Content.builder() - .producer(Producer.builder().cattax(1).build()) - .cattax(1) - .kwarray(singletonList("kwarray")) - .langb("langb") - .network(Network.builder().build()) - .channel(Channel.builder().build()) - .build()) - .kwarray(singletonList("kwarray")) - .build()) - .app(App.builder() - .cattax(1) - .inventorypartnerdomain("inventorypartnerdomain") - .publisher(Publisher.builder().cattax(1).build()) - .content(Content.builder() - .producer(Producer.builder().cattax(1).build()) - .cattax(1) - .kwarray(singletonList("kwarray")) - .langb("langb") - .network(Network.builder().build()) - .channel(Channel.builder().build()) - .build()) - .kwarray(singletonList("kwarray")) - .build()) - .dooh(Dooh.builder().build()) - .device(Device.builder().sua(UserAgent.builder().build()).langb("langb").build()) - .user(User.builder().kwarray(singletonList("kwarray")).build()) - .wlangb(singletonList("wlangb")) - .cattax(1)); - - // when - final BidRequest result = target.convert(bidRequest); - - // then - assertThat(result).satisfies(request -> { - assertThat(result.getImp()) - .hasSize(1) - .allSatisfy(imp -> { - assertThat(imp.getVideo()).isEqualTo(Video.builder().build()); - assertThat(imp.getAudio()).isEqualTo(Audio.builder().build()); - assertThat(imp.getSsai()).isNull(); - assertThat(imp.getRefresh()).isNull(); - assertThat(imp.getQty()).isNull(); - assertThat(imp.getDt()).isNull(); - }); - - assertThat(request.getSite()).isEqualTo(Site.builder().build()); - assertThat(request.getApp()).isEqualTo(App.builder().build()); - assertThat(request.getDevice()).isEqualTo(Device.builder().build()); - assertThat(request.getUser()).isEqualTo(User.builder().build()); - assertThat(request.getWlangb()).isNull(); - assertThat(request.getCattax()).isNull(); - }); - } - private static BidRequest givenBidRequest(UnaryOperator bidRequestCustomizer) { return bidRequestCustomizer.apply(BidRequest.builder().imp(emptyList())).build(); } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json index 348d06b2871..db4e61dfe97 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/algorix/test-algorix-bid-request.json @@ -4,6 +4,7 @@ { "id": "imp_id", "secure": 1, + "rwdd": 1, "banner": { "w": 300, "h": 250 diff --git a/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json index 755609f67df..850609a42f2 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/bidmachine/test-bidmachine-bid-request.json @@ -4,6 +4,7 @@ { "id": "imp_id", "secure": 1, + "rwdd": 1, "banner": { "w": 320, "h": 480, diff --git a/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json index b4895753bb0..697daed2ae1 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/generic_core_functionality/test-generic-bid-request.json @@ -38,6 +38,7 @@ "tid" : "${json-unit.any-string}" }, "regs" : { + "gpp_sid" : [ 1, 3, 7 ], "ext" : { "gdpr" : 0, "dsa": { From b318b1afd8c424c23e8d3d8ee2cb76313acfab34 Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Tue, 21 May 2024 11:16:16 +0200 Subject: [PATCH 48/58] Prebid Server prepare release 3.0.0 --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 7 +++---- pom.xml | 5 ++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 454a9b0de5b..1b80b4bad74 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 7e1bfc91bd9..d8ad554621e 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index 2fe803c1ba6..c047c8b56a7 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index 436fd2a33d3..c63873559f9 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0-SNAPSHOT + 3.0.0 pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 36014ede43a..5b909a6ae42 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index dc0d1be2c02..2115ae9ea20 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -1,18 +1,17 @@ - + 4.0.0 org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - HEAD + 3.0.0 diff --git a/pom.xml b/pom.xml index d01e20873bd..f20b2fba6df 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.prebid prebid-server-aggregator - 3.0.0-SNAPSHOT + 3.0.0 extra/pom.xml From 337c6a0e26ff02fed86c1a7262a253b7652ca098 Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Tue, 21 May 2024 11:18:58 +0200 Subject: [PATCH 49/58] Prebid Server prepare for next development iteration --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 1b80b4bad74..7c515927304 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index d8ad554621e..924ce91e085 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index c047c8b56a7..df0a826e5c9 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index c63873559f9..b402096e626 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.0.0 + 3.1.0-SNAPSHOT pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 5b909a6ae42..0ec5be33e7e 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index 2115ae9ea20..98b9787d161 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - 3.0.0 + HEAD diff --git a/pom.xml b/pom.xml index f20b2fba6df..dfe9152361b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.0.0 + 3.1.0-SNAPSHOT extra/pom.xml From 66fde3ecf99aaf9c0f2270911b5273a97d47a0fc Mon Sep 17 00:00:00 2001 From: onetag-dev <38786435+onetag-dev@users.noreply.github.com> Date: Tue, 21 May 2024 14:41:20 +0200 Subject: [PATCH 50/58] Onetag: Add redirect userSync support (#3100) --- src/main/resources/bidder-config/onetag.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/onetag.yaml b/src/main/resources/bidder-config/onetag.yaml index d761209a15d..34f2d844158 100644 --- a/src/main/resources/bidder-config/onetag.yaml +++ b/src/main/resources/bidder-config/onetag.yaml @@ -21,3 +21,7 @@ adapters: url: https://onetag-sys.com/usync/?redir={{redirect_url}}&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}} support-cors: false uid-macro: '${USER_TOKEN}' + redirect: + url: https://onetag-sys.com/usync/?tag=img&redir={{redirect_url}}&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}} + support-cors: false + uid-macro: '${USER_TOKEN}' From 5991bcf33de3c90552b56078a10c68ebf2c37d67 Mon Sep 17 00:00:00 2001 From: osulzhenko <125548596+osulzhenko@users.noreply.github.com> Date: Tue, 21 May 2024 15:42:50 +0300 Subject: [PATCH 51/58] Roulax: Add Adapter (#3094) --- .../server/bidder/roulax/RoulaxBidder.java | 122 +++++++++ .../ext/request/roulax/ExtImpRoulax.java | 14 + .../config/bidder/RoulaxConfiguration.java | 41 +++ src/main/resources/bidder-config/roulax.yaml | 15 ++ .../static/bidder-params/roulax.json | 22 ++ .../bidder/roulax/RoulaxBidderTest.java | 253 ++++++++++++++++++ .../java/org/prebid/server/it/RoulaxTest.java | 40 +++ .../roulax/test-auction-roulax-request.json | 24 ++ .../roulax/test-auction-roulax-response.json | 34 +++ .../roulax/test-roulax-bid-request.json | 57 ++++ .../roulax/test-roulax-bid-response.json | 16 ++ .../server/it/test-application.properties | 2 + 12 files changed, 640 insertions(+) create mode 100644 src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java create mode 100644 src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java create mode 100644 src/main/resources/bidder-config/roulax.yaml create mode 100644 src/main/resources/static/bidder-params/roulax.json create mode 100644 src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java create mode 100644 src/test/java/org/prebid/server/it/RoulaxTest.java create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json create mode 100644 src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json diff --git a/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java new file mode 100644 index 00000000000..fc887c21f97 --- /dev/null +++ b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java @@ -0,0 +1,122 @@ +package org.prebid.server.bidder.roulax; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.prebid.server.bidder.Bidder; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.DecodeException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.roulax.ExtImpRoulax; +import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.util.BidderUtil; +import org.prebid.server.util.HttpUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +public class RoulaxBidder implements Bidder { + + private final String endpointUrl; + private final JacksonMapper mapper; + + private static final String PUBLISHER_PATH_MACRO = "{{PublisherID}}"; + private static final String ACCOUNT_ID_MACRO = "{{AccountID}}"; + + private static final TypeReference> ROULAX_EXT_TYPE_REFERENCE = + new TypeReference<>() { + }; + + public RoulaxBidder(String endpointUrl, JacksonMapper mapper) { + this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); + this.mapper = Objects.requireNonNull(mapper); + } + + @Override + public Result>> makeHttpRequests(BidRequest bidRequest) { + try { + final ExtImpRoulax extImpRoulax = parseImpExt(bidRequest.getImp().get(0)); + return Result.withValue(BidderUtil.defaultRequest(bidRequest, resolveEndpoint(extImpRoulax), mapper)); + } catch (PreBidException e) { + return Result.withError(BidderError.badInput(e.getMessage())); + } + } + + private ExtImpRoulax parseImpExt(Imp imp) { + try { + return mapper.mapper().convertValue(imp.getExt(), ROULAX_EXT_TYPE_REFERENCE).getBidder(); + } catch (IllegalArgumentException e) { + throw new PreBidException("Failed to deserialize Roulax extension: " + e.getMessage()); + } + } + + private String resolveEndpoint(ExtImpRoulax extImpRoulax) { + return endpointUrl + .replace(PUBLISHER_PATH_MACRO, StringUtils.defaultString(extImpRoulax.getPublisherPath()).trim()) + .replace(ACCOUNT_ID_MACRO, StringUtils.defaultString(extImpRoulax.getPid()).trim()); + } + + @Override + public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { + try { + final List errors = new ArrayList<>(); + final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); + return Result.of(extractBids(bidResponse, errors), errors); + } catch (DecodeException | PreBidException e) { + return Result.withError(BidderError.badServerResponse(e.getMessage())); + } + } + + private static List extractBids(BidResponse bidResponse, List errors) { + if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { + return Collections.emptyList(); + } + + return bidResponse.getSeatbid().stream() + .filter(Objects::nonNull) + .map(SeatBid::getBid) + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .map(bid -> makeBid(bid, bidResponse.getCur(), errors)) + .filter(Objects::nonNull) + .toList(); + } + + private static BidderBid makeBid(Bid bid, String currency, List errors) { + try { + return BidderBid.of(bid, getBidType(bid), currency); + } catch (PreBidException e) { + errors.add(BidderError.badServerResponse(e.getMessage())); + return null; + } + } + + private static BidType getBidType(Bid bid) { + final Integer markupType = bid.getMtype(); + if (markupType == null) { + throw new PreBidException("Missing MType for bid: " + bid.getId()); + } + return switch (markupType) { + case 1 -> BidType.banner; + case 2 -> BidType.video; + case 4 -> BidType.xNative; + default -> throw new PreBidException( + "Unable to fetch mediaType in impID: %s, mType: %d".formatted(bid.getImpid(), bid.getMtype())); + }; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java new file mode 100644 index 00000000000..11d69e39674 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/roulax/ExtImpRoulax.java @@ -0,0 +1,14 @@ +package org.prebid.server.proto.openrtb.ext.request.roulax; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Value; + +@Value(staticConstructor = "of") +public class ExtImpRoulax { + + @JsonProperty("PublisherPath") + String publisherPath; + + @JsonProperty("Pid") + String pid; +} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java new file mode 100644 index 00000000000..01ba4e70e3d --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/RoulaxConfiguration.java @@ -0,0 +1,41 @@ +package org.prebid.server.spring.config.bidder; + +import org.prebid.server.bidder.BidderDeps; +import org.prebid.server.bidder.roulax.RoulaxBidder; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; +import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; +import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; +import org.prebid.server.spring.env.YamlPropertySourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import javax.validation.constraints.NotBlank; + +@Configuration +@PropertySource(value = "classpath:/bidder-config/roulax.yaml", factory = YamlPropertySourceFactory.class) +public class RoulaxConfiguration { + + private static final String BIDDER_NAME = "roulax"; + + @Bean("roulaxConfigurationProperties") + @ConfigurationProperties("adapters.roulax") + BidderConfigurationProperties configurationProperties() { + return new BidderConfigurationProperties(); + } + + @Bean + BidderDeps roulaxBidderDeps(BidderConfigurationProperties roulaxConfigurationProperties, + @NotBlank @Value("${external-url}") String externalUrl, + JacksonMapper mapper) { + + return BidderDepsAssembler.forBidder(BIDDER_NAME) + .withConfig(roulaxConfigurationProperties) + .usersyncerCreator(UsersyncerCreator.create(externalUrl)) + .bidderCreator(config -> new RoulaxBidder(config.getEndpoint(), mapper)) + .assemble(); + } +} diff --git a/src/main/resources/bidder-config/roulax.yaml b/src/main/resources/bidder-config/roulax.yaml new file mode 100644 index 00000000000..b9055e5df4a --- /dev/null +++ b/src/main/resources/bidder-config/roulax.yaml @@ -0,0 +1,15 @@ +adapters: + roulax: + endpoint: http://dsp.rcoreads.com/api/{{PublisherID}}?pid={{AccountID}} + meta-info: + maintainer-email: bussiness@roulax.io + app-media-types: + - banner + - video + - native + site-media-types: + - banner + - video + - native + supported-vendors: + vendor-id: 0 diff --git a/src/main/resources/static/bidder-params/roulax.json b/src/main/resources/static/bidder-params/roulax.json new file mode 100644 index 00000000000..ce7af170136 --- /dev/null +++ b/src/main/resources/static/bidder-params/roulax.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Roulax Adapter Params", + "description": "A schema which validates params accepted by the Roulax adapter", + "type": "object", + "properties": { + "Pid": { + "type": "string", + "minLength": 1, + "description": "PID" + }, + "PublisherPath": { + "type": "string", + "minLength": 1, + "description": "PublisherPath" + } + }, + "required": [ + "Pid", + "PublisherPath" + ] +} diff --git a/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java b/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java new file mode 100644 index 00000000000..a0bea1326a2 --- /dev/null +++ b/src/test/java/org/prebid/server/bidder/roulax/RoulaxBidderTest.java @@ -0,0 +1,253 @@ +package org.prebid.server.bidder.roulax; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.iab.openrtb.request.BidRequest; +import com.iab.openrtb.request.Imp; +import com.iab.openrtb.response.Bid; +import com.iab.openrtb.response.BidResponse; +import com.iab.openrtb.response.SeatBid; +import org.junit.Test; +import org.prebid.server.VertxTest; +import org.prebid.server.bidder.model.BidderBid; +import org.prebid.server.bidder.model.BidderCall; +import org.prebid.server.bidder.model.BidderError; +import org.prebid.server.bidder.model.HttpRequest; +import org.prebid.server.bidder.model.HttpResponse; +import org.prebid.server.bidder.model.Result; +import org.prebid.server.proto.openrtb.ext.ExtPrebid; +import org.prebid.server.proto.openrtb.ext.request.roulax.ExtImpRoulax; + +import java.util.List; +import java.util.function.UnaryOperator; + +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.groups.Tuple.tuple; +import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; +import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; + +public class RoulaxBidderTest extends VertxTest { + + private static final String ENDPOINT_URL = "https://test-url.com/{{PublisherID}}?pid={{AccountID}}"; + + private final RoulaxBidder target = new RoulaxBidder(ENDPOINT_URL, jacksonMapper); + + @Test + public void creationShouldFailOnInvalidEndpointUrl() { + // when and then + assertThatIllegalArgumentException().isThrownBy(() -> new RoulaxBidder("incorrect_url", jacksonMapper)); + } + + @Test + public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { + // given + final BidRequest bidRequest = givenBidRequest(givenInvalidImp()); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).allSatisfy(error -> { + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); + assertThat(error.getMessage()).startsWith("Failed to deserialize Roulax extension:"); + }); + } + + @Test + public void makeHttpRequestsShouldResolveEndpointUrl() { + // given + final Imp imp = givenImp(" testPublisherId ", " testPid "); + final BidRequest bidRequest = givenBidRequest(imp); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()) + .extracting(HttpRequest::getUri) + .containsExactly("https://test-url.com/testPublisherId?pid=testPid"); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeHttpRequestsShouldResolveEndpointWithPidAndPublisherPathBasedOnFirstImp() { + // given + final BidRequest bidRequest = givenBidRequest( + givenImp("testPublisherPath0", "testPid0"), + givenInvalidImp(), + givenImp("testPublisherPath2", "testPid2"), + givenImp(null, null)); + + // when + final Result>> result = target.makeHttpRequests(bidRequest); + + // then + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri, httpRequest -> httpRequest.getPayload().getImp().size()) + .containsExactly( + tuple("https://test-url.com/testPublisherPath0?pid=testPid0", 4)); + assertThat(result.getErrors()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { + // given + final BidderCall httpCall = givenHttpCall("invalid"); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).allSatisfy(error -> { + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(error.getMessage()).startsWith("Failed to decode: Unrecognized token"); + }); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(mapper.writeValueAsString(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).isEmpty(); + } + + @Test + public void makeBidsShouldReturnBannerBidIfBannerIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(1)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(1), banner, "USD")); + } + + @Test + public void makeBidsShouldReturnVideoBidIfVideoIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(2)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(2), video, "USD")); + } + + @Test + public void makeBidsShouldReturnNativeBidIfNativeIsPresentInRequestImp() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(4)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(givenBid(4), xNative, "USD")); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeUnknownNumber() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(0)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Unable to fetch mediaType in impID: impId, mType: 0"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + @Test + public void makeBidsShouldThrowErrorUnableToFetchMediaTypeWhenMTypeNull() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall(givenBid(null)); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()).hasSize(1) + .allSatisfy(error -> { + assertThat(error.getMessage()).startsWith("Missing MType for bid: id"); + assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); + }); + } + + private static BidRequest givenBidRequest(Imp... imps) { + return BidRequest.builder().imp(List.of(imps)).build(); + } + + private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder()).build(); + } + + private static Imp givenImp(String publisherPath, String pid) { + return givenImp(imp -> imp.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRoulax.of(publisherPath, pid))))); + } + + private static Imp givenInvalidImp() { + return givenImp(imp -> imp.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))); + } + + private static String givenBidResponse(Bid... bids) throws JsonProcessingException { + return mapper.writeValueAsString(BidResponse.builder() + .cur("USD") + .seatbid(singletonList(SeatBid.builder().bid(List.of(bids)).build())) + .build()); + } + + private static BidderCall givenHttpCall(Bid... bids) throws JsonProcessingException { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, givenBidResponse(bids)), + null); + } + + private static BidderCall givenHttpCall(String body) { + return BidderCall.succeededHttp( + HttpRequest.builder().payload(null).build(), + HttpResponse.of(200, null, body), + null); + } + + private static Bid givenBid(Integer mtype) { + return Bid.builder().mtype(mtype).id("id").impid("impId").build(); + } +} diff --git a/src/test/java/org/prebid/server/it/RoulaxTest.java b/src/test/java/org/prebid/server/it/RoulaxTest.java new file mode 100644 index 00000000000..e44ce3c0cb3 --- /dev/null +++ b/src/test/java/org/prebid/server/it/RoulaxTest.java @@ -0,0 +1,40 @@ +package org.prebid.server.it; + +import io.restassured.response.Response; +import org.json.JSONException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.prebid.server.model.Endpoint; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static java.util.Collections.singletonList; + +@RunWith(SpringRunner.class) +public class RoulaxTest extends IntegrationTest { + + @Test + public void openrtb2AuctionShouldRespondWithBidsFromTheRoulaxBidder() throws IOException, JSONException { + // given + WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/roulax-exchange/testPublisherPath")) + .withQueryParam("pid", equalTo("testPid")) + .withRequestBody(equalToJson( + jsonFrom("openrtb2/roulax/test-roulax-bid-request.json"))) + .willReturn(aResponse().withBody( + jsonFrom("openrtb2/roulax/test-roulax-bid-response.json")))); + + // when + final Response response = responseFor("openrtb2/roulax/test-auction-roulax-request.json", + Endpoint.openrtb2_auction); + + // then + assertJsonEquals("openrtb2/roulax/test-auction-roulax-response.json", response, + singletonList("roulax")); + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json new file mode 100644 index 00000000000..45800c3e20d --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-request.json @@ -0,0 +1,24 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "roulax": { + "Pid": "testPid", + "PublisherPath": "testPublisherPath" + } + } + } + ], + "tmax": 5000, + "regs": { + "ext": { + "gdpr": 0 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json new file mode 100644 index 00000000000..298f141429f --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-auction-roulax-response.json @@ -0,0 +1,34 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 3.33, + "crid": "creativeId", + "mtype": 1, + "ext": { + "origbidcpm": 3.33, + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "roulax", + "group": 0 + } + ], + "cur": "USD", + "ext": { + "responsetimemillis": { + "roulax": "{{ roulax.response_time_ms }}" + }, + "prebid": { + "auctiontimestamp": 0 + }, + "tmaxrequest": 5000 + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json new file mode 100644 index 00000000000..548a8950eb7 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-request.json @@ -0,0 +1,57 @@ +{ + "id": "request_id", + "imp": [ + { + "id": "imp_id", + "secure": 1, + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "tid": "${json-unit.any-string}", + "bidder": { + "Pid": "testPid", + "PublisherPath": "testPublisherPath" + } + } + } + ], + "source": { + "tid": "${json-unit.any-string}" + }, + "site": { + "domain": "www.example.com", + "page": "http://www.example.com", + "publisher": { + "domain": "example.com" + }, + "ext": { + "amp": 0 + } + }, + "device": { + "ua": "userAgent", + "ip": "193.168.244.1" + }, + "at": 1, + "tmax": "${json-unit.any-number}", + "cur": [ + "USD" + ], + "regs": { + "ext": { + "gdpr": 0 + } + }, + "ext": { + "prebid": { + "server": { + "externalurl": "http://localhost:8080", + "gvlid": 1, + "datacenter": "local", + "endpoint": "/openrtb2/auction" + } + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json new file mode 100644 index 00000000000..6922c116b46 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/roulax/test-roulax-bid-response.json @@ -0,0 +1,16 @@ +{ + "id": "request_id", + "seatbid": [ + { + "bid": [ + { + "id": "bid_id", + "impid": "imp_id", + "price": 3.33, + "crid": "creativeId", + "mtype": 1 + } + ] + } + ] +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index e4f8a793e55..405f016babc 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -318,6 +318,8 @@ adapters.richaudience.enabled=true adapters.richaudience.endpoint=http://localhost:8090/richaudience-exchange adapters.rise.enabled=true adapters.rise.endpoint=http://localhost:8090/rise-exchange +adapters.roulax.enabled=true +adapters.roulax.endpoint=http://localhost:8090/roulax-exchange/{{PublisherID}}?pid={{AccountID}} adapters.rtbhouse.enabled=true adapters.rtbhouse.endpoint=http://localhost:8090/rtbhouse-exchange adapters.rubicon.enabled=true From cb4cae2af26864f9cc2dfee1b05b810e0236fc53 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 21 May 2024 14:46:45 +0200 Subject: [PATCH 52/58] Sonobi: Add Consent Macros to UserSync URL (#3098) --- src/main/resources/bidder-config/sonobi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/bidder-config/sonobi.yaml b/src/main/resources/bidder-config/sonobi.yaml index a093b8dcd45..1c00983ec39 100644 --- a/src/main/resources/bidder-config/sonobi.yaml +++ b/src/main/resources/bidder-config/sonobi.yaml @@ -14,6 +14,6 @@ adapters: usersync: cookie-family-name: sonobi redirect: - url: https://sync.go.sonobi.com/us.gif?loc={{redirect_url}} + url: https://sync.go.sonobi.com/us.gif?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&loc={{redirect_url}} support-cors: false uid-macro: '[UID]' From dd39b7274f2310f5a8b981754a797b1114a6b9c4 Mon Sep 17 00:00:00 2001 From: Laurentiu Badea Date: Tue, 21 May 2024 05:47:55 -0700 Subject: [PATCH 53/58] OpenX: accept incoming string fields to support Prebid.js 9 (#3178) --- .../ext/request/openx/ExtImpOpenx.java | 2 ++ src/main/resources/bidder-config/openx.yaml | 1 + .../resources/static/bidder-params/openx.json | 7 +++-- .../functional/model/bidder/Openx.groovy | 2 +- .../server/bidder/openx/OpenxBidderTest.java | 29 ++++++++++--------- .../openx/test-auction-openx-request.json | 2 +- .../openx/test-openx-bid-request.json | 2 +- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java index 862eb4289ca..0bf40d18264 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/openx/ExtImpOpenx.java @@ -1,5 +1,6 @@ package org.prebid.server.proto.openrtb.ext.request.openx; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import lombok.Builder; @@ -22,6 +23,7 @@ public class ExtImpOpenx { String platform; + @JsonFormat(shape = JsonFormat.Shape.STRING) @JsonProperty("customFloor") BigDecimal customFloor; diff --git a/src/main/resources/bidder-config/openx.yaml b/src/main/resources/bidder-config/openx.yaml index c6fa7e65410..78aa8020d30 100644 --- a/src/main/resources/bidder-config/openx.yaml +++ b/src/main/resources/bidder-config/openx.yaml @@ -1,6 +1,7 @@ adapters: openx: endpoint: http://rtb.openx.net/prebid + endpoint-compression: gzip meta-info: maintainer-email: prebid@openx.com app-media-types: diff --git a/src/main/resources/static/bidder-params/openx.json b/src/main/resources/static/bidder-params/openx.json index 6dbd10178e4..89c0663e0a0 100644 --- a/src/main/resources/static/bidder-params/openx.json +++ b/src/main/resources/static/bidder-params/openx.json @@ -6,7 +6,7 @@ "type": "object", "properties": { "unit": { - "type": "string", + "type": ["number", "string"], "description": "The ad unit id.", "pattern": "^[0-9]+$" }, @@ -22,9 +22,10 @@ "format": "uuid" }, "customFloor": { - "type": "number", + "type": ["number", "string"], "description": "The minimum CPM price in USD.", - "minimum": 0 + "minimum": 0, + "pattern": "^[0-9]+(\\.[0-9]+)?$" }, "customParams": { "type": "object", diff --git a/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy index e6b08baa4c2..932d3cf80a6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Openx.groovy @@ -7,7 +7,7 @@ class Openx implements BidderAdapter { String unit String delDomain String platform - Integer customFloor + String customFloor Map customParams static Openx getDefaultOpenx() { diff --git a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java index 812cc11769e..6816f352b2e 100644 --- a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java @@ -207,18 +207,19 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { ExtImpOpenx.builder() .customParams(givenCustomParams("foo1", singletonList("bar1"))) .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder() .id("impId2") .bidfloor(BigDecimal.valueOf(0.5)) .banner(Banner.builder().build()) .ext(mapper.valueToTree( - ExtPrebid.of(null, - ExtImpOpenx.builder() - .customFloor(BigDecimal.valueOf(0.1)) - .customParams(givenCustomParams("foo2", "bar2")) - .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + Map.of( + "bidder", Map.of( + "customFloor", "0.1", + "customParams", givenCustomParams("foo2", "bar2"), + "delDomain", "se-demo-d.openx.net", + "unit", 123456 + )))).build(), Imp.builder() .id("impId3") .video(Video.builder().build()) @@ -230,7 +231,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { .customFloor(BigDecimal.valueOf(0.1)) .customParams(givenCustomParams("foo3", "bar3")) .delDomain("se-demo-d.openx.net") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder() .id("impId4") .video(Video.builder().build()) @@ -239,7 +240,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { ExtImpOpenx.builder() .customParams(givenCustomParams("foo4", "bar4")) .platform("PLATFORM") - .unit("unitId").build()))).build(), + .unit("555555").build()))).build(), Imp.builder().id("impId1").audio(Audio.builder().build()).build())) .user(User.builder().ext(ExtUser.builder().consent("consent").build()).build()) @@ -264,7 +265,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId1") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("555555") .bidfloor(BigDecimal.valueOf(0.5)) .ext(mapper.valueToTree( ExtImpOpenx.builder() @@ -276,7 +277,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId2") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("123456") .bidfloor(BigDecimal.valueOf(0.5)) .ext(mapper.valueToTree( ExtImpOpenx.builder() @@ -301,7 +302,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { .video(Video.builder() .ext(mapper.valueToTree(OpenxVideoExt.of(1))) .build()) - .tagid("unitId") + .tagid("555555") // check if each of video imps is a part of separate bidRequest .bidfloor(BigDecimal.valueOf(0.1)) .ext(mapper.valueToTree( @@ -326,7 +327,7 @@ public void makeHttpRequestsShouldReturnResultWithExpectedFieldsSet() { Imp.builder() .id("impId4") .video(Video.builder().build()) - .tagid("unitId") + .tagid("555555") .ext(mapper.valueToTree( ExtImpOpenx.builder() .customParams( @@ -418,7 +419,7 @@ public void makeHttpRequestShouldReturnResultWithAuctionEnvironment() { Imp.builder() .id("impId2") .banner(Banner.builder().build()) - .tagid("unitId") + .tagid("555555") .ext(mapper.valueToTree(Map.of("ae", 1, "bidder", Map.of()))) .build())) .build(); diff --git a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json index c09abbda691..afa1eff56d5 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-auction-openx-request.json @@ -11,7 +11,7 @@ "openx": { "unit": "539439964", "delDomain": "se-demo-d.openx.net", - "customFloor": 0.1, + "customFloor": "0.5", "customParams": { "foo": "bar", "multifoo": [ diff --git a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json index 8ef63ebe83d..fac8f6e765c 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/openx/test-openx-bid-request.json @@ -9,7 +9,7 @@ "h": 250 }, "tagid": "539439964", - "bidfloor": 0.1, + "bidfloor": 0.5, "ext": { "customParams": { "foo": "bar", From 3208ea2d321c9c40c1a40d7ea91fd6ae6c2db808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdravko=20Kosanovi=C4=87?= <41286499+zkosanovic@users.noreply.github.com> Date: Tue, 21 May 2024 14:48:51 +0200 Subject: [PATCH 54/58] Rise: Add placementId parameter to bidder ext (#3119) --- .../server/proto/openrtb/ext/request/rise/ExtImpRise.java | 2 ++ src/main/resources/static/bidder-params/rise.json | 4 ++++ .../org/prebid/server/bidder/rise/RiseBidderTest.java | 8 ++++---- src/test/java/org/prebid/server/it/RiseTest.java | 2 +- .../it/openrtb2/rise/test-auction-rise-request.json | 3 ++- .../server/it/openrtb2/rise/test-rise-bid-request.json | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java index 3a3bf301a56..251eb0bc9e9 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/rise/ExtImpRise.java @@ -8,4 +8,6 @@ public class ExtImpRise { String publisherId; String org; + + String placementId; } diff --git a/src/main/resources/static/bidder-params/rise.json b/src/main/resources/static/bidder-params/rise.json index 30dff44d29f..ee8a469cbbc 100644 --- a/src/main/resources/static/bidder-params/rise.json +++ b/src/main/resources/static/bidder-params/rise.json @@ -11,6 +11,10 @@ "publisher_id": { "type": "string", "description": "Deprecated, use org instead." + }, + "placementId": { + "type": "string", + "description": "Placement ID." } }, "oneOf": [ diff --git a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java index 66132621bd8..c26bf6839f8 100644 --- a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java @@ -80,7 +80,7 @@ public void makeHttpRequestsShouldThrowErrorWhenExtImpOrgAndPublisherAbsent() { .imp(singletonList(Imp.builder().id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, null, null)))) .build())) .build(); @@ -104,7 +104,7 @@ public void makeHttpRequestsShouldPasteValueFromExtImpOrgToURLEndpointWhenPublis .id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(" testPublisherId ", null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(" testPublisherId ", null, null)))) .build())) .build(); @@ -127,7 +127,7 @@ public void makeHttpRequestsShouldPasteValueFromExtImpOrgToURLEndpointWhenOrgPre .id("123") .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, " testOrg ")))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of(null, " testOrg ", null)))) .build())) .build(); @@ -265,7 +265,7 @@ private static Imp givenImp(Function impCustomiz return impCustomizer.apply(Imp.builder().id("123")) .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of("testPublisherId", null)))) + .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpRise.of("testPublisherId", null, null)))) .build(); } diff --git a/src/test/java/org/prebid/server/it/RiseTest.java b/src/test/java/org/prebid/server/it/RiseTest.java index adfe66868a4..a36afb22544 100644 --- a/src/test/java/org/prebid/server/it/RiseTest.java +++ b/src/test/java/org/prebid/server/it/RiseTest.java @@ -23,7 +23,7 @@ public class RiseTest extends IntegrationTest { public void openrtb2AuctionShouldRespondWithBidsFromRise() throws IOException, JSONException { // given WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/rise-exchange")) - .withQueryParam("publisher_id", equalTo("testPlacementId")) + .withQueryParam("publisher_id", equalTo("testOrgId")) .withRequestBody(equalToJson(jsonFrom("openrtb2/rise/test-rise-bid-request.json"))) .willReturn(aResponse().withBody(jsonFrom("openrtb2/rise/test-rise-bid-response.json")))); diff --git a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json index a6323ecce86..02cdde6a0bc 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-auction-rise-request.json @@ -9,7 +9,8 @@ }, "ext": { "rise": { - "publisher_id": "testPlacementId" + "org": "testOrgId", + "placementId": "testPlacementId" } } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json index bce8ccb4132..252d03c4565 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/rise/test-rise-bid-request.json @@ -11,7 +11,8 @@ "ext": { "tid": "${json-unit.any-string}", "bidder": { - "publisher_id": "testPlacementId" + "org": "testOrgId", + "placementId": "testPlacementId" } } } From 79c3065d56046c7ea49674821900c57202b492a6 Mon Sep 17 00:00:00 2001 From: aishwaryapatil Date: Tue, 21 May 2024 08:50:13 -0400 Subject: [PATCH 55/58] YahooAdapter: Remove warning message (#3181) --- .../server/bidder/yahooads/YahooAdsBidder.java | 4 ---- .../bidder/yahooads/YahooAdsBidderTest.java | 15 --------------- 2 files changed, 19 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java index 9d35a90c69d..997938e371e 100644 --- a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java +++ b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java @@ -251,10 +251,6 @@ private static List extractBids(BidResponse bidResponse, BidRequest b if (seatBids == null) { return Collections.emptyList(); } - - if (seatBids.isEmpty()) { - throw new PreBidException("Invalid SeatBids count: 0"); - } return bidsFromResponse(bidResponse, bidRequest.getImp()); } diff --git a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java index e2041372583..e38efb41ca8 100644 --- a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java @@ -332,21 +332,6 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso assertThat(result.getValue()).isEmpty(); } - @Test - public void makeBidsShouldReturnErrorIfBidResponseSeatBidIsEmpty() throws JsonProcessingException { - // given - final BidderCall httpCall = givenHttpCall(null, - mapper.writeValueAsString(BidResponse.builder().seatbid(emptyList()).build())); - - // when - final Result> result = target.makeBids(httpCall, null); - - // then - assertThat(result.getErrors()).hasSize(1) - .containsOnly(BidderError.badServerResponse("Invalid SeatBids count: 0")); - assertThat(result.getValue()).isEmpty(); - } - @Test public void makeBidsShouldReturnErrorWhenBidImpIdIsNotPresent() throws JsonProcessingException { // given From ac4a0179fcfb20d13474fe78b54498ccfe2fe769 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Tue, 21 May 2024 14:51:07 +0200 Subject: [PATCH 56/58] Evolution: Add IFrame (#3099) --- src/main/resources/bidder-config/evolution.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/bidder-config/evolution.yaml b/src/main/resources/bidder-config/evolution.yaml index 2101ba5089b..3101dadcfdb 100644 --- a/src/main/resources/bidder-config/evolution.yaml +++ b/src/main/resources/bidder-config/evolution.yaml @@ -19,3 +19,7 @@ adapters: url: https://sync.e-volution.ai/pbserver?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&ccpa={{us_privacy}}&redirect={{redirect_url}} support-cors: false uid-macro: '[UID]' + iframe: + url: https://sync.e-volution.ai/pbserver?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&ccpa={{us_privacy}}&redirect={{redirect_url}} + support-cors: false + uid-macro: '[UID]' From 460081efbc78d26ce78eed2d4e31950d002eb4cc Mon Sep 17 00:00:00 2001 From: Piotr Jaworski <109736938+piotrj-rtbh@users.noreply.github.com> Date: Tue, 21 May 2024 14:53:19 +0200 Subject: [PATCH 57/58] RTB House: Video support (#3130) --- .../bidder/rtbhouse/RtbhouseBidder.java | 2 ++ .../resources/bidder-config/rtbhouse.yaml | 2 ++ .../bidder/rtbhouse/RtbhouseBidderTest.java | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java index 296071b0765..a363c29a0a3 100644 --- a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java +++ b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java @@ -157,6 +157,8 @@ private static BidType getBidType(String impId, List imps) { return BidType.banner; } else if (imp.getXNative() != null) { return BidType.xNative; + } else if (imp.getVideo() != null) { + return BidType.video; } } } diff --git a/src/main/resources/bidder-config/rtbhouse.yaml b/src/main/resources/bidder-config/rtbhouse.yaml index 774ed55715c..a428897379c 100644 --- a/src/main/resources/bidder-config/rtbhouse.yaml +++ b/src/main/resources/bidder-config/rtbhouse.yaml @@ -18,9 +18,11 @@ adapters: app-media-types: - banner - native + - video site-media-types: - banner - native + - video supported-vendors: vendor-id: 16 usersync: diff --git a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java index 6fc275dcd9d..d0e5dd2beba 100644 --- a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java @@ -6,6 +6,7 @@ import com.iab.openrtb.request.Imp; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.Native; +import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; import com.iab.openrtb.response.SeatBid; @@ -40,6 +41,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; +import static org.prebid.server.proto.openrtb.ext.response.BidType.video; public class RtbhouseBidderTest extends VertxTest { @@ -132,6 +134,30 @@ public void makeBidsShouldReturnBannerBidIfBannerIsPresent() throws JsonProcessi .containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); } + @Test + public void makeBidsShouldReturnVideoBidIfVideoIsPresent() throws JsonProcessingException { + // given + final BidRequest bidRequest = BidRequest.builder() + .imp(singletonList(Imp.builder() + .id("123") + .video(Video.builder().build()) + .build())) + .build(); + + final BidderCall httpCall = givenHttpCall( + bidRequest, + mapper.writeValueAsString( + givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, bidRequest); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); + } + @Test public void makeHttpRequestsShouldConvertCurrencyIfRequestCurrencyDoesNotMatchBidderCurrency() { // given From 88ba248d50da2bd226f9047c87ad8addd576c279 Mon Sep 17 00:00:00 2001 From: SerhiiNahornyi Date: Wed, 22 May 2024 11:41:56 +0200 Subject: [PATCH 58/58] Rubicon: Remove imp.ext.context references (#3195) --- .../server/bidder/rubicon/RubiconBidder.java | 69 ++----- .../bidder/rubicon/RubiconBidderTest.java | 188 +++--------------- 2 files changed, 42 insertions(+), 215 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 27d6dc59ff9..5c45d9583ec 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -86,7 +86,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtDeal; import org.prebid.server.proto.openrtb.ext.request.ExtDealLine; import org.prebid.server.proto.openrtb.ext.request.ExtDevice; -import org.prebid.server.proto.openrtb.ext.request.ExtImpContext; import org.prebid.server.proto.openrtb.ext.request.ExtImpContextDataAdserver; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebidFloors; @@ -664,7 +663,6 @@ private RubiconImpExt makeImpExt(Imp imp, String ipfResolvedCurrency, PriceFloorResult priceFloorResult) { - final ExtImpContext context = extImpContext(imp); final RubiconImpExtPrebid rubiconImpExtPrebid = priceFloorResult != null ? makeRubiconExtPrebid(priceFloorResult, ipfResolvedCurrency, imp, bidRequest) : null; @@ -675,7 +673,7 @@ private RubiconImpExt makeImpExt(Imp imp, final RubiconImpExtRp rubiconImpExtRp = RubiconImpExtRp.of( rubiconImpExt.getZoneId(), - makeTarget(imp, rubiconImpExt, site, app, context), + makeTarget(imp, rubiconImpExt, site, app), RubiconImpExtRpTrack.of("", ""), rubiconImpExtRpRtb); @@ -689,26 +687,14 @@ private RubiconImpExt makeImpExt(Imp imp, .build(); } - private ExtImpContext extImpContext(Imp imp) { - final JsonNode context = imp.getExt().get(FPD_CONTEXT_FIELD); - if (context == null || context.isNull()) { - return null; - } - try { - return mapper.mapper().convertValue(context, ExtImpContext.class); - } catch (IllegalArgumentException e) { - throw new PreBidException(e.getMessage(), e); - } - } - - private JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site site, App app, ExtImpContext context) { + private JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site site, App app) { final ObjectNode result = mapper.mapper().createObjectNode(); populateFirstPartyDataAttributes(rubiconImpExt.getInventory(), result); mergeFirstPartyDataFromSite(site, result); mergeFirstPartyDataFromApp(app, result); - mergeFirstPartyDataFromImp(imp, rubiconImpExt, context, result); + mergeFirstPartyDataFromImp(imp, rubiconImpExt, result); return result.size() > 0 ? result : null; } @@ -771,19 +757,12 @@ private void mergeFirstPartyDataFromApp(App app, ObjectNode result) { private void mergeFirstPartyDataFromImp(Imp imp, ExtImpRubicon rubiconImpExt, - ExtImpContext context, ObjectNode result) { - mergeFirstPartyDataFromData(imp, context, result); - mergeFirstPartyDataKeywords(imp, context, result); + mergeFirstPartyDataFromData(imp, result); + mergeFirstPartyDataKeywords(imp, result); // merge OPENRTB.imp[].ext.rubicon.keywords to XAPI.imp[].ext.rp.target.keywords mergeCollectionAttributeIntoArray(result, rubiconImpExt, ExtImpRubicon::getKeywords, FPD_KEYWORDS_FIELD); - // merge OPENRTB.imp[].ext.context.search to XAPI.imp[].ext.rp.target.search - mergeStringAttributeIntoArray( - result, - context, - extContext -> getTextValueFromNode(extContext.getProperty(FPD_SEARCH_FIELD)), - FPD_SEARCH_FIELD); // merge OPENRTB.imp[].ext.data.search to XAPI.imp[].ext.rp.target.search mergeStringAttributeIntoArray( result, @@ -792,42 +771,31 @@ private void mergeFirstPartyDataFromImp(Imp imp, FPD_SEARCH_FIELD); } - private void mergeFirstPartyDataFromData(Imp imp, ExtImpContext context, ObjectNode result) { - final ObjectNode contextDataNode = toObjectNode( - ObjectUtil.getIfNotNull(context, ExtImpContext::getData)); - // merge OPENRTB.imp[].ext.context.data.* to XAPI.imp[].ext.rp.target.* - populateFirstPartyDataAttributes(contextDataNode, result); - + private void mergeFirstPartyDataFromData(Imp imp, ObjectNode result) { final ObjectNode dataNode = toObjectNode(imp.getExt().get(FPD_DATA_FIELD)); // merge OPENRTB.imp[].ext.data.* to XAPI.imp[].ext.rp.target.* populateFirstPartyDataAttributes(dataNode, result); // override XAPI.imp[].ext.rp.target.* with OPENRTB.imp[].ext.data.* - overrideFirstPartyDataAttributes(contextDataNode, dataNode, result); + overrideFirstPartyDataAttributes(dataNode, result); } - private void overrideFirstPartyDataAttributes(ObjectNode contextDataNode, ObjectNode dataNode, ObjectNode result) { + private void overrideFirstPartyDataAttributes(ObjectNode dataNode, ObjectNode result) { final JsonNode pbadslotNode = dataNode.get(FPD_DATA_PBADSLOT_FIELD); if (pbadslotNode != null && pbadslotNode.isTextual()) { // copy imp[].ext.data.pbadslot to XAPI.imp[].ext.rp.target.pbadslot result.set(FPD_DATA_PBADSLOT_FIELD, pbadslotNode); } else { // copy adserver.adslot value to XAPI field imp[].ext.rp.target.dfp_ad_unit_code - final String resolvedDfpAdUnitCode = getAdSlot(contextDataNode, dataNode); + final String resolvedDfpAdUnitCode = getAdSlotFromAdServer(dataNode); if (resolvedDfpAdUnitCode != null) { result.set(DFP_ADUNIT_CODE_FIELD, TextNode.valueOf(resolvedDfpAdUnitCode)); } } - } - private void mergeFirstPartyDataKeywords(Imp imp, ExtImpContext context, ObjectNode result) { - // merge OPENRTB.imp[].ext.context.keywords to XAPI.imp[].ext.rp.target.keywords - final JsonNode keywordsNode = context != null ? context.getProperty("keywords") : null; - final String keywords = getTextValueFromNode(keywordsNode); - if (StringUtils.isNotBlank(keywords)) { - mergeIntoArray(result, FPD_KEYWORDS_FIELD, keywords.split(",")); - } + } + private void mergeFirstPartyDataKeywords(Imp imp, ObjectNode result) { // merge OPENRTB.imp[].ext.data.keywords to XAPI.imp[].ext.rp.target.keywords final String dataKeywords = getTextValueFromNodeByPath(imp.getExt().get(FPD_DATA_FIELD), FPD_KEYWORDS_FIELD); if (StringUtils.isNotBlank(dataKeywords)) { @@ -977,19 +945,10 @@ private ObjectNode getSkadn(ObjectNode impExt) { return skadnNode != null && skadnNode.isObject() ? (ObjectNode) skadnNode : null; } - private String getAdSlot(Imp imp, ExtImpContext context) { - final ObjectNode contextDataNode = context != null ? context.getData() : null; + private String getAdSlot(Imp imp) { final ObjectNode dataNode = toObjectNode(imp.getExt().get(FPD_DATA_FIELD)); - return getAdSlot(contextDataNode, dataNode); - } - - private String getAdSlot(ObjectNode contextDataNode, ObjectNode dataNode) { - return ObjectUtils.firstNonNull( - // or imp[].ext.context.data.adserver.adslot - getAdSlotFromAdServer(contextDataNode), - // or imp[].ext.data.adserver.adslot - getAdSlotFromAdServer(dataNode)); + return getAdSlotFromAdServer(dataNode); } private String getAdSlotFromAdServer(JsonNode dataNode) { @@ -1558,7 +1517,7 @@ private BidRequest createLineItemBidRequest(ExtDealLine lineItem, BidRequest bid final Imp dealsImp = imp.toBuilder() .banner(modifyBanner(imp.getBanner(), lineItem.getSizes())) .ext(modifyRubiconImpExt(imp.getExt(), bidRequest.getExt(), lineItem.getExtLineItemId(), - getAdSlot(imp, extImpContext(imp)))) + getAdSlot(imp))) .build(); return bidRequest.toBuilder() diff --git a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java index 9ee7f0a07c0..536c4e9d18d 100644 --- a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java @@ -2373,7 +2373,7 @@ public void makeHttpRequestsShouldCreateRequestPerImp() { } @Test - public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldCopyAndModifyDataFieldsToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( identity(), @@ -2381,9 +2381,6 @@ public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToR identity()); bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode() - .set("data", mapper.createObjectNode() - .set("property1", mapper.createArrayNode().add("value1")))) .set("data", mapper.createObjectNode() .set("property2", mapper.createArrayNode().add("value2"))); @@ -2400,7 +2397,6 @@ public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataAndDataFieldsToR .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() - .set("property1", mapper.createArrayNode().add("value1")) .set("property2", mapper.createArrayNode().add("value2"))); } @@ -2425,66 +2421,6 @@ public void makeHttpRequestsShouldPassThroughImpExtGpid() { .containsExactly(TextNode.valueOf("gpidvalue")); } - @Test - public void makeHttpRequestsShouldNotCopyAdSlotFromAdServerWhenAdServerNameIsNotGam() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - impBuilder -> impBuilder.video(Video.builder().build()), - identity()); - - bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode() - .set("data", mapper.createObjectNode() - .put("property", "value") - .set("adserver", mapper.createObjectNode() - .put("name", "not-gam") - .put("adslot", "/test-adserver")))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) - .extracting(RubiconImpExt::getRp) - .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.createObjectNode() - .set("property", mapper.createArrayNode().add("value"))); - } - - @Test - public void makeHttpRequestsShouldNotCopyAndModifyImpExtContextDataAdslotToRubiconImpExtRpTargetDfpAdUnitCode() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), - impBuilder -> impBuilder.video(Video.builder().build()), - identity()); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ObjectNode impExtContextDataNode = mapper.createObjectNode() - .set("adslot", mapper.createArrayNode().add("123")); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextDataNode))); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) - .extracting(RubiconImpExt::getRp) - .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.createObjectNode().set("adslot", mapper.createArrayNode().add("123"))); - } - @Test public void makeHttpRequestsShouldCopySiteExtDataFieldsToRubiconImpExtRpTarget() { // given @@ -2538,7 +2474,7 @@ public void makeHttpRequestsShouldCopyAppExtDataFieldsToRubiconImpExtRpTarget() } @Test - public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() throws IOException { // given final ObjectNode siteExtDataNode = mapper.createObjectNode() @@ -2559,6 +2495,8 @@ public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRub final Result>> result = target.makeHttpRequests(bidRequest); // then + final ArrayNode siteNode = mapper.createArrayNode(); + siteNode.add("value1"); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) @@ -2567,17 +2505,16 @@ public void makeHttpRequestsShouldCopySiteExtDataAndImpExtContextDataFieldsToRub .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"imp_ext\":[\"value2\"],\"site\":[\"value1\"]}")); + .extracting(target -> target.get("site")) + .containsExactly(siteNode); } @Test - public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldCopyAppExtDataFieldToRubiconImpExtRpTarget() throws IOException { // given final ObjectNode appExtDataNode = mapper.createObjectNode() .set("app", mapper.createArrayNode().add("value1")); - final ObjectNode impExtContextDataNode = mapper.createObjectNode() - .set("imp_ext", mapper.createArrayNode().add("value2")); final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder @@ -2585,13 +2522,12 @@ public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubi impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextDataNode))); - // when final Result>> result = target.makeHttpRequests(bidRequest); // then + final ArrayNode appNode = mapper.createArrayNode(); + appNode.add("value1"); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) @@ -2600,11 +2536,12 @@ public void makeHttpRequestsShouldCopyAppExtDataAndImpExtContextDataFieldsToRubi .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"imp_ext\":[\"value2\"],\"app\":[\"value1\"]}")); + .extracting(target -> target.get("app")) + .containsExactly(appNode); } @Test - public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToRubiconImpExtRpTargetKeywords() + public void makeHttpRequestsShouldMergeImpExtRubiconAndDataKeywordsToRubiconImpExtRpTargetKeywords() throws IOException { // given @@ -2614,9 +2551,6 @@ public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToR identity()); final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("keywords", new TextNode("imp,ext,context,keywords")); - impExt.set("context", mapper.valueToTree(extImpContext)); impExt.set("data", mapper.createObjectNode() .put("keywords", "imp,ext,data,keywords")); impExt.set( @@ -2637,19 +2571,13 @@ public void makeHttpRequestsShouldMergeImpExtRubiconAndContextAndDataKeywordsToR .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"keywords\":[" - + "\"imp,ext,data,keywords\"," - + " \"imp\"," - + " \"ext\"," - + " \"context\"," - + " \"keywords\"," - + " \"data\"," - + " \"rubicon\"" - + "]}")); + .extracting(target -> target.get("keywords")) + .containsOnly(mapper.readTree("[\"imp,ext,data,keywords\"," + + "\"imp\",\"ext\",\"data\",\"keywords\",\"rubicon\"]")); } @Test - public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtRpTargetSearch() throws IOException { + public void makeHttpRequestsShouldCopyDataSearchToRubiconImpExtRpTargetSearch() throws IOException { // given final BidRequest bidRequest = givenBidRequest( identity(), @@ -2657,9 +2585,6 @@ public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtR identity()); final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("search", new TextNode("imp ext context search")); - impExt.set("context", mapper.valueToTree(extImpContext)); impExt.set("data", mapper.createObjectNode().put("search", "imp ext data search")); // when @@ -2674,7 +2599,7 @@ public void makeHttpRequestsShouldCopyImpExtContextAndDataSearchToRubiconImpExtR .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"search\":[\"imp ext data search\", \"imp ext context search\"]}")); + .containsOnly(mapper.readTree("{\"search\":[\"imp ext data search\"]}")); } @Test @@ -2698,7 +2623,7 @@ public void makeHttpRequestsShouldCopyImpExtVideoLanguageToSiteContentLanguage() } @Test - public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyToRubiconImpExtRpTarget() + public void makeHttpRequestsShouldMergeSiteSearchAndCopyToRubiconImpExtRpTarget() throws JsonProcessingException { // given final BidRequest bidRequest = givenBidRequest( @@ -2706,11 +2631,6 @@ public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyTo impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - final ExtImpContext extImpContext = ExtImpContext.of(null); - extImpContext.addProperty("search", new TextNode("imp ext search")); - impExt.set("context", mapper.valueToTree(extImpContext)); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2723,11 +2643,11 @@ public void makeHttpRequestsShouldMergeImpExtContextSearchAndSiteSearchAndCopyTo .extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class)) .extracting(RubiconImpExt::getRp) .extracting(RubiconImpExtRp::getTarget) - .containsOnly(mapper.readTree("{\"search\":[\"site search\", \"imp ext search\"]}")); + .containsOnly(mapper.readTree("{\"search\":[\"site search\"]}")); } @Test - public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopyToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldMergeSiteAttributesAndCopyToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder.site(Site.builder() @@ -2740,16 +2660,6 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopy impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExtContextData = mapper.createObjectNode() - .set("sectioncat", mapper.createArrayNode().add("imp ext sectioncat")) - .set("pagecat", mapper.createArrayNode().add("imp ext pagecat")) - .put("page", "imp ext page") - .put("ref", "imp ext ref") - .put("search", "imp ext search"); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextData))); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2764,20 +2674,15 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndSiteAttributesAndCopy .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() .set("sectioncat", mapper.createArrayNode() - .add("site sectioncat") - .add("imp ext sectioncat")) + .add("site sectioncat")) .set("pagecat", mapper.createArrayNode() - .add("site pagecat") - .add("imp ext pagecat")) + .add("site pagecat")) .set("page", mapper.createArrayNode() - .add("site page") - .add("imp ext page")) + .add("site page")) .set("ref", mapper.createArrayNode() - .add("site ref") - .add("imp ext ref")) + .add("site ref")) .set("search", mapper.createArrayNode() - .add("site search") - .add("imp ext search"))); + .add("site search"))); } @Test @@ -2832,35 +2737,7 @@ public void makeHttpRequestsShouldOverrideDfpAdunitCodeIfAdslotPresentInImpExtDa } @Test - public void makeHttpRequestsShouldOverrideDfpAdunitCodeIfAdslotPresentInImpExtContextDataAndAndAdserverNameIsGam() { - // given - final BidRequest bidRequest = givenBidRequest( - identity(), impBuilder -> impBuilder.video(Video.builder().build()), identity()); - - final ObjectNode dataNode = - mapper.createObjectNode() - .set("adserver", mapper.createObjectNode() - .put("adslot", "adslotvalue") - .put("name", "gam")); - - bidRequest.getImp().get(0).getExt() - .set("context", mapper.createObjectNode().set("data", dataNode)); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .flatExtracting(BidRequest::getImp) - .extracting(Imp::getExt) - .extracting(ext -> ext.at("/rp/target/dfp_ad_unit_code")) - .containsExactly(TextNode.valueOf("adslotvalue")); - } - - @Test - public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyToRubiconImpExtRpTarget() { + public void makeHttpRequestsShouldMergeAppAttributesAndCopyToRubiconImpExtRpTarget() { // given final BidRequest bidRequest = givenBidRequest( requestBuilder -> requestBuilder.app(App.builder() @@ -2870,13 +2747,6 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyT impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExtContextData = mapper.createObjectNode() - .set("sectioncat", mapper.createArrayNode().add("imp ext sectioncat")) - .set("pagecat", mapper.createArrayNode().add("imp ext pagecat")); - - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); - impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextData))); - // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2891,11 +2761,9 @@ public void makeHttpRequestsShouldMergeImpExtContextDataAndAppAttributesAndCopyT .extracting(RubiconImpExtRp::getTarget) .containsOnly(mapper.createObjectNode() .set("sectioncat", mapper.createArrayNode() - .add("app sectioncat") - .add("imp ext sectioncat")) + .add("app sectioncat")) .set("pagecat", mapper.createArrayNode() - .add("app pagecat") - .add("imp ext pagecat"))); + .add("app pagecat"))); } @Test