11package org .prebid .server .bidder .sspbc ;
22
33import com .fasterxml .jackson .core .JsonProcessingException ;
4- import com .iab .openrtb .request .Banner ;
54import com .iab .openrtb .request .BidRequest ;
6- import com .iab .openrtb .request .Format ;
75import com .iab .openrtb .request .Imp ;
86import com .iab .openrtb .request .Site ;
97import com .iab .openrtb .response .Bid ;
108import com .iab .openrtb .response .BidResponse ;
119import com .iab .openrtb .response .SeatBid ;
12- import org .apache .commons .lang3 .StringUtils ;
1310import org .junit .jupiter .api .Test ;
1411import org .prebid .server .VertxTest ;
1512import org .prebid .server .bidder .model .BidderBid ;
1613import org .prebid .server .bidder .model .BidderCall ;
1714import org .prebid .server .bidder .model .BidderError ;
1815import org .prebid .server .bidder .model .HttpRequest ;
1916import org .prebid .server .bidder .model .HttpResponse ;
20- import org .prebid .server .bidder .model .Result ;
21- import org .prebid .server .proto .openrtb .ext .ExtPrebid ;
22- import org .prebid .server .proto .openrtb .ext .request .sspbc .ExtImpSspbc ;
17+ import org .prebid .server .bidder .model .Result ;
2318import org .prebid .server .proto .openrtb .ext .response .BidType ;
2419
2520import java .util .List ;
@@ -47,7 +42,7 @@ public void makeHttpRequestsShouldCreateExpectedUrl() {
4742 final BidRequest bidRequest = givenBidRequest (identity ());
4843
4944 // when
50- final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
45+ final Result <List <HttpRequest <SspbcRequest >>> result = target .makeHttpRequests (bidRequest );
5146
5247 // then
5348 assertThat (result .getErrors ()).isEmpty ();
@@ -59,7 +54,7 @@ public void makeHttpRequestsShouldCreateExpectedUrl() {
5954 @ Test
6055 public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed () {
6156 // given
62- final BidderCall <BidRequest > httpCall = givenHttpCall (null , "invalid" );
57+ final BidderCall <SspbcRequest > httpCall = givenHttpCall (null , "invalid" );
6358
6459 // when
6560 final Result <List <BidderBid >> result = target .makeBids (httpCall , null );
@@ -76,7 +71,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() {
7671 @ Test
7772 public void makeBidsShouldReturnEmptyListIfBidResponseIsNull () throws JsonProcessingException {
7873 // given
79- final BidderCall <BidRequest > httpCall = givenHttpCall (null , mapper .writeValueAsString (null ));
74+ final BidderCall <SspbcRequest > httpCall = givenHttpCall (null , mapper .writeValueAsString (null ));
8075
8176 // when
8277 final Result <List <BidderBid >> result = target .makeBids (httpCall , null );
@@ -86,25 +81,10 @@ public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProces
8681 assertThat (result .getValue ()).isEmpty ();
8782 }
8883
89- @ Test
90- public void makeBidsShouldReturnErrorWhenImpIdNotEqualsBidImpId () throws JsonProcessingException {
91- // given
92- final BidderCall <BidRequest > httpCall = givenHttpCall (givenBidRequest (identity ()),
93- mapper .writeValueAsString (givenBidResponse (bidBuilder -> bidBuilder .adm ("Any adm" ))));
94-
95- // when
96- final Result <List <BidderBid >> result = target .makeBids (httpCall , null );
97-
98- // then
99- assertThat (result .getValue ()).isEmpty ();
100- assertThat (result .getErrors ())
101- .containsExactly (BidderError .badServerResponse ("imp not found" ));
102- }
103-
10484 @ Test
10585 public void makeBidsShouldReturnErrorWhenAdmIsEmpty () throws JsonProcessingException {
10686 // given
107- final BidderCall <BidRequest > httpCall = givenHttpCall (givenBidRequest (identity (),
87+ final BidderCall <SspbcRequest > httpCall = givenHttpCall (givenBidRequest (identity (),
10888 impBuilder -> impBuilder .id ("id" ).tagid ("tagId" )),
10989 mapper .writeValueAsString (givenBidResponse (bidBuilder ->
11090 bidBuilder
@@ -123,7 +103,7 @@ public void makeBidsShouldReturnErrorWhenAdmIsEmpty() throws JsonProcessingExcep
123103 @ Test
124104 public void makeBidsShouldReturnErrorWhenMTypeIsIncorrect () throws JsonProcessingException {
125105 // given
126- final BidderCall <BidRequest > httpCall = givenHttpCall (givenBidRequest (identity (),
106+ final BidderCall <SspbcRequest > httpCall = givenHttpCall (givenBidRequest (identity (),
127107 impBuilder -> impBuilder .id ("id" ).tagid ("tagId" )),
128108 mapper .writeValueAsString (givenBidResponse (bidBuilder ->
129109 bidBuilder
@@ -137,13 +117,13 @@ public void makeBidsShouldReturnErrorWhenMTypeIsIncorrect() throws JsonProcessin
137117 // then
138118 assertThat (result .getValue ()).isEmpty ();
139119 assertThat (result .getErrors ())
140- .containsExactly (BidderError .badServerResponse ("Bid type not supported : 100." ));
120+ .containsExactly (BidderError .badServerResponse ("unsupported MType : 100." ));
141121 }
142122
143123 @ Test
144124 public void makeBidsShouldParseBid () throws JsonProcessingException {
145125 // given
146- final BidderCall <BidRequest > httpCall = givenHttpCall (givenBidRequest (
126+ final BidderCall <SspbcRequest > httpCall = givenHttpCall (givenBidRequest (
147127 bidRequestBuilder -> bidRequestBuilder
148128 .id ("bidRequestId" )
149129 .site (Site .builder ()
@@ -155,7 +135,7 @@ public void makeBidsShouldParseBid() throws JsonProcessingException {
155135 bidBuilder
156136 .impid ("id" )
157137 .adm ("anyAdm" )
158- .mtype (BidType . banner . ordinal () ))));
138+ .mtype (1 ))));
159139
160140 // when
161141 final Result <List <BidderBid >> result = target .makeBids (httpCall , null );
@@ -197,9 +177,9 @@ private static BidResponse givenBidResponse(UnaryOperator<Bid.BidBuilder> bidCus
197177 .build ();
198178 }
199179
200- private static BidderCall <BidRequest > givenHttpCall (BidRequest bidRequest , String body ) {
180+ private static BidderCall <SspbcRequest > givenHttpCall (BidRequest bidRequest , String body ) {
201181 return BidderCall .succeededHttp (
202- HttpRequest .<BidRequest >builder ().payload (bidRequest ).build (),
182+ HttpRequest .<SspbcRequest >builder ().payload (SspbcRequest . of ( bidRequest ) ).build (),
203183 HttpResponse .of (200 , null , body ),
204184 null );
205185 }
0 commit comments