2323import org .prebid .server .bidder .model .Result ;
2424import org .prebid .server .proto .openrtb .ext .ExtPrebid ;
2525import org .prebid .server .proto .openrtb .ext .request .gumgum .ExtImpGumgum ;
26+ import org .prebid .server .proto .openrtb .ext .request .gumgum .ExtImpGumgumBanner ;
2627import org .prebid .server .proto .openrtb .ext .request .gumgum .ExtImpGumgumVideo ;
2728
2829import java .math .BigDecimal ;
@@ -58,9 +59,8 @@ public void creationShouldFailOnInvalidEndpointUrl() {
5859 @ Test
5960 public void makeHttpRequestsShouldReturnErrorsIfImpExtCouldNotBeParsed () {
6061 // given
61- final BidRequest bidRequest = givenBidRequest (
62- impBuilder -> impBuilder
63- .ext (mapper .valueToTree (ExtPrebid .of (null , mapper .createArrayNode ()))));
62+ final BidRequest bidRequest = givenBidRequest (impBuilder ->
63+ impBuilder .ext (mapper .valueToTree (ExtPrebid .of (null , mapper .createArrayNode ()))));
6464
6565 // when
6666 final Result <List <HttpRequest <BidRequest >>> result = gumgumBidder .makeHttpRequests (bidRequest );
@@ -101,7 +101,8 @@ public void makeHttpRequestsShouldReturnErrorIfVideoFieldsAreNotValid() {
101101 final BidRequest bidRequest = BidRequest .builder ()
102102 .imp (singletonList (Imp .builder ()
103103 .video (Video .builder ().w (0 ).build ())
104- .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" ))))
104+ .ext (mapper .valueToTree (ExtPrebid .of (null ,
105+ ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" , null ))))
105106 .build ()))
106107 .build ();
107108
@@ -128,7 +129,8 @@ public void makeHttpRequestsShouldModifyVideoExtOfIrisIdIsPresent() {
128129 .placement (33 )
129130 .linearity (233 )
130131 .build ())
131- .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" ))))
132+ .ext (mapper .valueToTree (ExtPrebid .of (null ,
133+ ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" , null ))))
132134 .build ()))
133135 .build ();
134136
@@ -149,12 +151,11 @@ public void makeHttpRequestsShouldModifyVideoExtOfIrisIdIsPresent() {
149151 @ Test
150152 public void makeHttpRequestsShouldNotChangeBannerWidthAndHeightIfPresent () {
151153 // given
152- final BidRequest bidRequest = givenBidRequest (
153- impBuilder -> impBuilder
154- .banner (Banner .builder ()
155- .format (singletonList (Format .builder ().w (300 ).h (450 ).build ()))
156- .w (600 ).h (900 )
157- .build ()));
154+ final BidRequest bidRequest = givenBidRequest (impBuilder ->
155+ impBuilder .banner (Banner .builder ()
156+ .format (singletonList (Format .builder ().w (300 ).h (450 ).build ()))
157+ .w (600 ).h (900 )
158+ .build ()));
158159
159160 // when
160161 final Result <List <HttpRequest <BidRequest >>> result = gumgumBidder .makeHttpRequests (bidRequest );
@@ -236,7 +237,7 @@ public void makeHttpRequestsShouldSetSiteIdFromLastValidImpExtZone() {
236237 givenImp (impBuilder -> impBuilder
237238 .banner (Banner .builder ().build ())
238239 .ext (mapper .valueToTree (ExtPrebid .of (null ,
239- ExtImpGumgum .of ("ignored zone" , BigInteger .TEN , "irisId" ))))),
240+ ExtImpGumgum .of ("ignored zone" , BigInteger .TEN , "irisId" , null ))))),
240241 givenImp (identity ())))
241242 .build ();
242243
@@ -252,6 +253,69 @@ public void makeHttpRequestsShouldSetSiteIdFromLastValidImpExtZone() {
252253 .containsExactly ("zone" );
253254 }
254255
256+ @ Test
257+ public void makeHttpRequestsShouldNotModifyBannerExtIfSlotIsZeroOrNull () {
258+ // given
259+ final BidRequest bidRequest = BidRequest .builder ()
260+ .site (Site .builder ().build ())
261+ .imp (asList (
262+ givenImp (impBuilder -> impBuilder
263+ .id ("123" )
264+ .banner (Banner .builder ()
265+ .format (singletonList (Format .builder ().w (1 ).h (1 ).build ()))
266+ .build ())
267+ .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpGumgum .of ("ignored zone" ,
268+ BigInteger .TEN , "irisId" , 0L ))))),
269+ givenImp (impBuilder -> impBuilder
270+ .id ("345" )
271+ .banner (Banner .builder ()
272+ .format (singletonList (Format .builder ().w (1 ).h (1 ).build ()))
273+ .build ())
274+ .ext (mapper .valueToTree (ExtPrebid .of (null ,
275+ ExtImpGumgum .of ("ignored zone" , BigInteger .TEN , "irisId" , null ))))
276+ )))
277+ .build ();
278+
279+ // when
280+ final Result <List <HttpRequest <BidRequest >>> result = gumgumBidder .makeHttpRequests (bidRequest );
281+
282+ // then
283+ assertThat (result .getErrors ()).isEmpty ();
284+ assertThat (result .getValue ())
285+ .extracting (HttpRequest ::getPayload )
286+ .flatExtracting (BidRequest ::getImp )
287+ .extracting (Imp ::getBanner )
288+ .extracting (Banner ::getExt )
289+ .containsExactly (null , null );
290+ }
291+
292+ @ Test
293+ public void makeHttpRequestsShouldSetBannerExtWithBiggestBannerFormatIfSlotIsNotZero () {
294+ // given
295+ final BidRequest bidRequest = givenBidRequest (impBuilder -> impBuilder
296+ .id ("123" )
297+ .banner (Banner .builder ()
298+ .format (asList (
299+ Format .builder ().w (120 ).h (80 ).build (),
300+ Format .builder ().w (120 ).h (100 ).build (),
301+ Format .builder ().w (100 ).h (100 ).build ()))
302+ .build ())
303+ .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpGumgum .of ("ignored zone" ,
304+ BigInteger .TEN , "irisId" , 42L )))));
305+
306+ // when
307+ final Result <List <HttpRequest <BidRequest >>> result = gumgumBidder .makeHttpRequests (bidRequest );
308+
309+ // then
310+ assertThat (result .getErrors ()).isEmpty ();
311+ assertThat (result .getValue ())
312+ .extracting (HttpRequest ::getPayload )
313+ .flatExtracting (BidRequest ::getImp )
314+ .extracting (Imp ::getBanner )
315+ .extracting (Banner ::getExt )
316+ .containsExactly (mapper .valueToTree (ExtImpGumgumBanner .of (42L , 120 , 100 )));
317+ }
318+
255319 @ Test
256320 public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed () {
257321 // given
@@ -370,7 +434,7 @@ private static BidRequest givenBidRequest(
370434 Function <Imp .ImpBuilder , Imp .ImpBuilder > impCustomizer ) {
371435
372436 return bidRequestCustomizer .apply (BidRequest .builder ()
373- .imp (singletonList (givenImp (impCustomizer ))))
437+ .imp (singletonList (givenImp (impCustomizer ))))
374438 .build ();
375439 }
376440
@@ -380,9 +444,10 @@ private static BidRequest givenBidRequest(Function<Imp.ImpBuilder, Imp.ImpBuilde
380444
381445 private static Imp givenImp (Function <Imp .ImpBuilder , Imp .ImpBuilder > impCustomizer ) {
382446 return impCustomizer .apply (Imp .builder ()
383- .id ("123" )
384- .banner (Banner .builder ().id ("banner_id" ).build ())
385- .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" )))))
447+ .id ("123" )
448+ .banner (Banner .builder ().id ("banner_id" ).build ())
449+ .ext (mapper .valueToTree (ExtPrebid .of (null ,
450+ ExtImpGumgum .of ("zone" , BigInteger .TEN , "irisId" , 1L )))))
386451 .build ();
387452 }
388453
0 commit comments