Skip to content

Commit

Permalink
add makeHttpRequestsShouldReturnResultWithSingleBidRequestForMultiFor…
Browse files Browse the repository at this point in the history
…matImps
  • Loading branch information
sergseven committed Dec 30, 2024
1 parent f2119e7 commit 2c4e117
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,68 @@ public void makeHttpRequestsShouldReturnResultWithSingleBidRequestForMultipleBan
.build());
}

@Test
public void makeHttpRequestsShouldReturnResultWithSingleBidRequestForMultiFormatImps() {
// given
final BidRequest bidRequest = BidRequest.builder()
.id("bidRequestId")
.imp(asList(
Imp.builder()
.id("impId1")
.banner(Banner.builder().w(320).h(200).build())
.video(Video.builder().maxduration(10).build())
.ext(mapper.valueToTree(
ExtPrebid.of(null, ExtImpOpenx.builder().unit("1").build())))
.build(),
Imp.builder()
.id("impId2")
.banner(Banner.builder().w(300).h(150).build())
.xNative(Native.builder().request("{\"version\":1}").build())
.ext(mapper.valueToTree(
ExtPrebid.of(null, ExtImpOpenx.builder().unit("2").build())))
.build()))
.user(User.builder().ext(ExtUser.builder().consent("consent").build()).build())
.regs(Regs.builder().coppa(0).ext(ExtRegs.of(1, null, null, null)).build())
.build();

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();

assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.containsExactly(
// check if all native and banner imps are part of single bidRequest
BidRequest.builder()
.id("bidRequestId")
.imp(asList(
// verify banner and video media types are preserved in a single imp
Imp.builder()
.id("impId1")
.tagid("1")
.banner(Banner.builder().w(320).h(200).build())
.video(Video.builder().maxduration(10).build())
.ext(mapper.valueToTree(ExtImpOpenx.builder().build())).build(),
// verify banner and native media types are preserved in a single imp
Imp.builder()
.id("impId2")
.tagid("2")
.banner(Banner.builder().w(300).h(150).build())
.xNative(Native.builder().request("{\"version\":1}").build())
.ext(mapper.valueToTree(ExtImpOpenx.builder().build()))
.build()))
.ext(jacksonMapper.fillExtension(
ExtRequest.empty(),
OpenxRequestExt.of(null, null, "hb_pbs_1.0.0")))
.user(User.builder()
.ext(ExtUser.builder().consent("consent").build())
.build())
.regs(Regs.builder().coppa(0).ext(ExtRegs.of(1, null, null, null)).build())
.build());
}

@Test
public void makeHttpRequestsShouldPassThroughImpExt() {
// given
Expand Down

0 comments on commit 2c4e117

Please sign in to comment.