2828
2929import java .math .BigDecimal ;
3030import java .util .List ;
31- import java .util .Set ;
3231import java .util .function .Function ;
3332
3433import static org .mockito .ArgumentMatchers .any ;
@@ -78,9 +77,12 @@ public void creationShouldFailOnInvalidEndpointUrl() {
7877 @ Test
7978 public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed () {
8079 // given
81- final BidRequest bidRequest = givenBidRequest (
82- impBuilder -> impBuilder
83- .ext (mapper .valueToTree (ExtPrebid .of (null , mapper .createArrayNode ()))));
80+ final BidRequest bidRequest = BidRequest .builder ()
81+ .site (Site .builder ().page ("https://test-example.com" ).build ())
82+ .imp (singletonList (Imp .builder ()
83+ .ext (mapper .valueToTree (ExtPrebid .of (null , mapper .createArrayNode ())))
84+ .build ()))
85+ .build ();
8486
8587 // when
8688 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
@@ -104,6 +106,7 @@ public void makeHttpRequestsShouldReturnErrorWhenSitePageIsEmpty() {
104106
105107 // then
106108 assertThat (result .getErrors ()).hasSize (1 );
109+ assertThat (result .getErrors ().get (0 ).getMessage ()).isEqualTo ("BidRequest.site.page is required" );
107110 assertThat (result .getValue ()).isEmpty ();
108111 }
109112
@@ -120,13 +123,14 @@ public void makeHttpRequestsShouldReturnErrorWhenAppBundleIsEmpty() {
120123
121124 // then
122125 assertThat (result .getErrors ()).hasSize (1 );
126+ assertThat (result .getErrors ().get (0 ).getMessage ()).isEqualTo ("BidRequest.app.bundle is required" );
123127 assertThat (result .getValue ()).isEmpty ();
124128 }
125129
126130 @ Test
127131 public void makeHttpRequestsShouldCreateCorrectURL () {
128132 // given
129- final BidRequest bidRequest = givenBidRequest (identity () );
133+ final BidRequest bidRequest = givenBidRequest ();
130134
131135 // when
132136 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
@@ -140,7 +144,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() {
140144 @ Test
141145 public void makeHttpRequestsShouldReturnPbsVersion () {
142146 // given
143- final BidRequest bidRequest = givenBidRequest (identity () );
147+ final BidRequest bidRequest = givenBidRequest ();
144148
145149 // when
146150 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
@@ -221,19 +225,16 @@ public void makeHttpRequestsShouldCreateSingleRequestForAllImps() {
221225 // then
222226 assertThat (result .getErrors ()).isEmpty ();
223227 assertThat (result .getValue ()).hasSize (1 )
224- .extracting (HttpRequest ::getImpIds )
225- .containsOnly (Set .of ("imp1" , "imp2" ));
226-
227- final BidRequest outgoingRequest = result .getValue ().get (0 ).getPayload ();
228- assertThat (outgoingRequest .getImp ()).hasSize (2 )
228+ .extracting (HttpRequest ::getPayload )
229+ .flatExtracting (BidRequest ::getImp )
229230 .extracting (Imp ::getId )
230231 .containsExactly ("imp1" , "imp2" );
231232 }
232233
233234 @ Test
234235 public void makeHttpRequestsShouldSetCorrectHeaders () {
235236 // given
236- final BidRequest bidRequest = givenBidRequest (identity () );
237+ final BidRequest bidRequest = givenBidRequest ();
237238
238239 // when
239240 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
@@ -299,8 +300,7 @@ public void makeBidsShouldReturnVideoBidByDefaultWhenMtypeIsUnknown() throws Jso
299300 // then
300301 assertThat (result .getErrors ()).isEmpty ();
301302 assertThat (result .getValue ())
302- .extracting (BidderBid ::getBid , BidderBid ::getType )
303- .containsExactly (tuple (Bid .builder ().impid ("123" ).mtype (99 ).build (), video ));
303+ .containsOnly (BidderBid .of (Bid .builder ().impid ("123" ).mtype (99 ).build (), video , null ));
304304 }
305305
306306 @ Test
@@ -327,10 +327,10 @@ public void makeBidsShouldReturnMultipleBids() throws JsonProcessingException {
327327 tuple (Bid .builder ().impid ("456" ).mtype (2 ).price (BigDecimal .TEN ).build (), video ));
328328 }
329329
330- private static BidRequest givenBidRequest (Function < Imp . ImpBuilder , Imp . ImpBuilder > impCustomizer ) {
330+ private static BidRequest givenBidRequest () {
331331 return BidRequest .builder ()
332332 .site (Site .builder ().page ("https://test-example.com" ).build ())
333- .imp (singletonList (givenImp (impCustomizer )))
333+ .imp (singletonList (givenImp (identity () )))
334334 .build ();
335335 }
336336
@@ -359,4 +359,3 @@ private static BidderCall<BidRequest> givenHttpCall(BidResponse bidResponse)
359359 null );
360360 }
361361}
362-
0 commit comments