Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add test for yieldlab targeting fix #1132

Merged
merged 3 commits into from
Feb 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,6 +112,60 @@ public void makeHttpRequestsShouldSendRequestToModifiedUrlWithHeaders() {
tuple("Cookie", "id=buyeruid"));
}

@Test
public void constructExtImpShouldWorkWithDuplicateKeysTargeting() {
// given
final Map<String, String> targeting = new HashMap<>();
targeting.put("key1", "value1");

final List<Imp> imps = new ArrayList<Imp>();
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<List<HttpRequest<Void>>> 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
Expand Down