Skip to content

Commit

Permalink
Add test for yieldlab targeting fix (#1132)
Browse files Browse the repository at this point in the history
* Add test for yieldlab targeting fix

* Remove too much empty lines

* [GD-2625] Don't use java11 APIs
  • Loading branch information
muuki88 authored and nickluck8 committed Aug 10, 2021
1 parent 19c3996 commit f5c530f
Showing 1 changed file with 55 additions and 0 deletions.
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

0 comments on commit f5c530f

Please sign in to comment.