From f5c530fd42be2eba321aea518db0e89cd8f613ff Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Thu, 4 Feb 2021 15:44:49 +0100 Subject: [PATCH] Add test for yieldlab targeting fix (#1132) * Add test for yieldlab targeting fix * Remove too much empty lines * [GD-2625] Don't use java11 APIs --- .../bidder/yieldlab/YieldlabBidderTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java index 8c3d365358f..8b6d89ae13c 100644 --- a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java @@ -27,6 +27,7 @@ import java.math.BigDecimal; import java.time.Instant; +import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; @@ -111,6 +112,60 @@ public void makeHttpRequestsShouldSendRequestToModifiedUrlWithHeaders() { tuple("Cookie", "id=buyeruid")); } + @Test + public void constructExtImpShouldWorkWithDuplicateKeysTargeting() { + // given + final Map targeting = new HashMap<>(); + targeting.put("key1", "value1"); + + final List imps = new ArrayList(); + imps.add(Imp.builder() + .banner(Banner.builder().w(1).h(1).build()) + .ext(mapper.valueToTree(ExtPrebid.of(null, + ExtImpYieldlab.builder() + .adslotId("1") + .supplyId("2") + .adSize("adSize") + .targeting(targeting) + .extId("extId") + .build()))) + .build() + ); + imps.add(Imp.builder() + .banner(Banner.builder().w(1).h(1).build()) + .ext(mapper.valueToTree(ExtPrebid.of(null, + ExtImpYieldlab.builder() + .adslotId("2") + .supplyId("2") + .adSize("adSize") + .targeting(targeting) + .extId("extId") + .build()))) + .build() + ); + + final BidRequest bidRequest = BidRequest.builder() + .imp(imps) + .device(Device.builder().ip("ip").ua("Agent").language("fr").devicetype(1).build()) + .regs(Regs.of(1, ExtRegs.of(1, "usPrivacy"))) + .user(User.builder().buyeruid("buyeruid").ext(ExtUser.builder().consent("consent").build()).build()) + .site(Site.builder().page("http://www.example.com").build()) + .build(); + + // when + final Result>> result = yieldlabBidder.makeHttpRequests(bidRequest); + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).hasSize(1) + .extracting(HttpRequest::getUri) + .allSatisfy(uri -> { + assertThat(uri).startsWith("https://test.endpoint.com/1,2?content=json&pvid=true&ts="); + assertThat(uri).endsWith("&t=key1%3Dvalue1&ids=buyeruid&yl_rtb_ifa&" + + "yl_rtb_devicetype=1&gdpr=1&consent=consent"); + }); + + } + @Test public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // given