From 2c4e117223f7e79b6c63aac424280ff1defb9967 Mon Sep 17 00:00:00 2001 From: Serhii Nesprava Date: Mon, 30 Dec 2024 12:28:37 +0100 Subject: [PATCH] add makeHttpRequestsShouldReturnResultWithSingleBidRequestForMultiFormatImps --- .../server/bidder/openx/OpenxBidderTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) 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 f38a8d34b19..cbe1e22c7ca 100644 --- a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java @@ -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>> 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