1616import com .iab .openrtb .response .BidResponse ;
1717import com .iab .openrtb .response .SeatBid ;
1818import org .junit .jupiter .api .Test ;
19+ import org .junit .jupiter .params .ParameterizedTest ;
20+ import org .junit .jupiter .params .provider .Arguments ;
21+ import org .junit .jupiter .params .provider .MethodSource ;
1922import org .prebid .server .VertxTest ;
2023import org .prebid .server .bidder .model .BidderBid ;
2124import org .prebid .server .bidder .model .BidderCall ;
4346import java .util .Collections ;
4447import java .util .List ;
4548import java .util .Map ;
49+ import java .util .stream .Stream ;
4650
4751import static java .util .Arrays .asList ;
4852import static java .util .Collections .emptyList ;
@@ -992,9 +996,7 @@ private static BidderCall<BidRequest> givenHttpCall(String body) {
992996 return BidderCall .succeededHttp (null , HttpResponse .of (200 , null , body ), null );
993997 }
994998
995- @ Test
996- public void makeBidsShouldReturnBidMeta () throws JsonProcessingException {
997- // given
999+ private static Stream <Arguments > makeBidsShouldReturnBidWithExtBidPrebidMetaArgs () throws JsonProcessingException {
9981000 final ObjectNode allBuyerExt = new ObjectNode (JsonNodeFactory .instance );
9991001 final ObjectNode onlyBrandExt = new ObjectNode (JsonNodeFactory .instance );
10001002 final ObjectNode badExt = new ObjectNode (JsonNodeFactory .instance );
@@ -1005,46 +1007,41 @@ public void makeBidsShouldReturnBidMeta() throws JsonProcessingException {
10051007
10061008 final String allBuyerExpectedExtJson = "{\" dsp_id\" :\" 1\" ,\" buyer_id\" :\" 2\" ,\" brand_id\" :\" 3\" ,\" prebid\" :"
10071009 + "{\" meta\" :{\" advertiserId\" :2,\" brandId\" :3,\" networkId\" :1}}}" ;
1008- final String onlyBrandExpectedExtJson = "{\" brand_id\" :\" 4\" ,\" prebid\" :{\" meta\" :{\" advertiserId\" :0,"
1009- + "\" brandId\" :4,\" networkId\" :0}}}" ;
1010+ final String onlyBrandExpectedExtJson = "{\" brand_id\" :\" 4\" ,\" prebid\" :{\" meta\" :{\" brandId\" :4}}}" ;
10101011 final String badExpectedExtJson = "{\" dsp_id\" :\" abc\" ,\" brand_id\" :\" cba\" }" ;
10111012
10121013 final ObjectNode allBuyerExpectedExt = (ObjectNode ) mapper .readTree (allBuyerExpectedExtJson );
10131014 final ObjectNode onlyBrandExpectedExt = (ObjectNode ) mapper .readTree (onlyBrandExpectedExtJson );
10141015 final ObjectNode badExpectedExt = (ObjectNode ) mapper .readTree (badExpectedExtJson );
10151016
1016- final BidderCall <BidRequest > httpCall = givenHttpCall (mapper .writeValueAsString (BidResponse .builder ()
1017- .seatbid (singletonList (SeatBid .builder ()
1018- .bid (List .of (
1019- Bid .builder ()
1020- .w (200 )
1021- .h (150 )
1022- .price (BigDecimal .ONE )
1023- .impid ("impId1" )
1024- .dealid ("dealid" )
1025- .adm ("<div>This is an Ad</div>" )
1026- .ext (allBuyerExt )
1027- .build (),
1028- Bid .builder ()
1029- .w (200 )
1030- .h (150 )
1031- .price (BigDecimal .ONE )
1032- .impid ("impId1" )
1033- .dealid ("dealid2" )
1034- .adm ("<div>This is an Ad</div>" )
1035- .ext (onlyBrandExt )
1036- .build (),
1037- Bid .builder ()
1038- .w (200 )
1039- .h (150 )
1040- .price (BigDecimal .ONE )
1041- .impid ("impId1" )
1042- .dealid ("dealid3" )
1043- .adm ("<div>This is an Ad</div>" )
1044- .ext (badExt )
1045- .build ()))
1046- .build ()))
1047- .build ()));
1017+ return Stream .of (
1018+ Arguments .of (allBuyerExt , allBuyerExpectedExt ),
1019+ Arguments .of (onlyBrandExt , onlyBrandExpectedExt ),
1020+ Arguments .of (badExt , badExpectedExt )
1021+ );
1022+ }
1023+
1024+ @ ParameterizedTest
1025+ @ MethodSource ("makeBidsShouldReturnBidWithExtBidPrebidMetaArgs" )
1026+ public void makeBidsShouldReturnBidWithExtBidPrebidMeta (
1027+ ObjectNode bidExt ,
1028+ ObjectNode expectedExtWithBidMeta ) throws JsonProcessingException {
1029+ // given
1030+ final BidderCall <BidRequest > httpCall = givenHttpCall (mapper .writeValueAsString (
1031+ BidResponse .builder ()
1032+ .seatbid (singletonList (SeatBid .builder ()
1033+ .bid (List .of (
1034+ Bid .builder ()
1035+ .w (200 )
1036+ .h (150 )
1037+ .price (BigDecimal .ONE )
1038+ .impid ("impId1" )
1039+ .dealid ("dealid" )
1040+ .adm ("<div>This is an Ad</div>" )
1041+ .ext (bidExt )
1042+ .build ()))
1043+ .build ()))
1044+ .build ()));
10481045
10491046 final BidRequest bidRequest = BidRequest .builder ()
10501047 .id ("bidRequestId" )
@@ -1060,7 +1057,7 @@ public void makeBidsShouldReturnBidMeta() throws JsonProcessingException {
10601057
10611058 // then
10621059 assertThat (result .getErrors ()).isEmpty ();
1063- assertThat (result .getBids ()).hasSize (3 ).containsExactlyInAnyOrder (
1060+ assertThat (result .getBids ()).hasSize (1 ).containsExactlyInAnyOrder (
10641061 BidderBid .of (
10651062 Bid .builder ()
10661063 .impid ("impId1" )
@@ -1069,29 +1066,7 @@ public void makeBidsShouldReturnBidMeta() throws JsonProcessingException {
10691066 .w (200 )
10701067 .h (150 )
10711068 .adm ("<div>This is an Ad</div>" )
1072- .ext (allBuyerExpectedExt )
1073- .build (),
1074- BidType .banner , "USD" ),
1075- BidderBid .of (
1076- Bid .builder ()
1077- .impid ("impId1" )
1078- .price (BigDecimal .ONE )
1079- .dealid ("dealid2" )
1080- .w (200 )
1081- .h (150 )
1082- .adm ("<div>This is an Ad</div>" )
1083- .ext (onlyBrandExpectedExt )
1084- .build (),
1085- BidType .banner , "USD" ),
1086- BidderBid .of (
1087- Bid .builder ()
1088- .impid ("impId1" )
1089- .price (BigDecimal .ONE )
1090- .dealid ("dealid3" )
1091- .w (200 )
1092- .h (150 )
1093- .adm ("<div>This is an Ad</div>" )
1094- .ext (badExpectedExt )
1069+ .ext (expectedExtWithBidMeta )
10951070 .build (),
10961071 BidType .banner , "USD" )
10971072 );
0 commit comments