@@ -62,7 +62,7 @@ public void creationShouldFailOnInvalidEndpointUrl() {
6262
6363 @ Test
6464 public void makeHttpRequestsShouldReturnErrorIfNoValidImps () {
65- // Given
65+ // given
6666 final BidRequest bidRequest = BidRequest .builder ()
6767 .cur (singletonList ("USD" ))
6868 .imp (singletonList (Imp .builder ()
@@ -73,103 +73,74 @@ public void makeHttpRequestsShouldReturnErrorIfNoValidImps() {
7373 when (currencyConversionService .convertCurrency (any (), any (), any (), any ()))
7474 .thenThrow (new PreBidException ("Currency conversion failed" ));
7575
76- // When
76+ // when
7777 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
7878
79- // Then
79+ // then
8080 assertThat (result .getErrors ())
8181 .hasSize (1 )
8282 .extracting (BidderError ::getMessage )
8383 .containsExactlyInAnyOrder ("Currency conversion failed" );
8484 }
8585
86- @ Test
87- public void makeBidsShouldReturnEmptyListWhenBidResponseIsNull () {
88- // Given
89- final BidderCall <BidRequest > httpCall = givenHttpCallWithBody ("null" );
90-
91- // When
92- final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
93-
94- // Then
95- assertThat (result .getValue ()).isEmpty ();
96- assertThat (result .getErrors ()).isEmpty ();
97- }
98-
99- @ Test
100- public void makeBidsShouldReturnEmptyListWhenSeatbidIsEmpty () throws JsonProcessingException {
101- // Given
102- final BidResponse bidResponse = BidResponse .builder ()
103- .seatbid (Collections .emptyList ())
104- .build ();
105- final BidderCall <BidRequest > httpCall = givenHttpCall (bidResponse );
106-
107- // When
108- final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
109-
110- // Then
111- assertThat (result .getValue ()).isEmpty ();
112- assertThat (result .getErrors ()).isEmpty ();
113- }
114-
11586 @ Test
11687 public void makeHttpRequestsShouldConvertBidFloorCurrency () {
117- // Given
88+ // given
11889 final BidRequest bidRequest = givenBidRequest (bidRequestBuilder -> bidRequestBuilder
11990 .cur (singletonList ("EUR" )),
12091 imp -> imp .bidfloor (BigDecimal .ONE ).bidfloorcur ("EUR" )
12192 .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpKobler .of (false )))));
12293
12394 when (currencyConversionService .convertCurrency (any (), any (), any (), any ())).thenReturn (BigDecimal .TEN );
12495
125- // When
96+ // when
12697 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
12798
128- // Then
99+ // then
129100 assertThat (result .getErrors ()).isEmpty ();
130101 assertThat (result .getValue ().get (0 ).getPayload ().getImp ())
131102 .extracting (Imp ::getBidfloor , Imp ::getBidfloorcur )
132103 .containsExactly (tuple (BigDecimal .TEN , "USD" ));
133104 }
134105
135106 @ Test
136- public void makeHttpRequestsShouldUseDevEndpointWhenTestModeEnabled () {
137- // Given
107+ public void makeHttpRequestsShouldUseDevEndpointwhenTestModeEnabled () {
108+ // given
138109 final BidRequest bidRequest = givenBidRequest (bidRequestBuilder -> bidRequestBuilder
139110 .cur (singletonList ("EUR" )),
140111 imp -> imp .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpKobler .of (true )))));
141112
142- // When
113+ // when
143114 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
144115
145- // Then
116+ // then
146117 assertThat (result .getValue ()).hasSize (1 );
147118 assertThat (result .getValue ().get (0 ).getUri ()).isEqualTo (DEV_ENDPOINT );
148119 }
149120
150121 @ Test
151122 public void makeHttpRequestsShouldAddUsdToCurrenciesIfMissing () {
152- // Given
123+ // given
153124 final BidRequest bidRequest = givenBidRequest (imp ->
154125 imp .ext (mapper .valueToTree (ExtPrebid .of (null , ExtImpKobler .of (false ))))).toBuilder ()
155126 .cur (singletonList ("EUR" )).build ();
156127
157- // When
128+ // when
158129 final Result <List <HttpRequest <BidRequest >>> result = target .makeHttpRequests (bidRequest );
159130
160- // Then
131+ // then
161132 assertThat (result .getValue ().get (0 ).getPayload ().getCur ()).containsExactlyInAnyOrder ("EUR" , "USD" );
162133 }
163134
164135 @ Test
165136 public void makeBidsShouldReturnErrorIfResponseBodyIsInvalid () {
166- // Given
137+ // given
167138 final BidderCall <BidRequest > httpCall = givenHttpCall ();
168139
169- // When
140+ // when
170141 final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
171142
172- // Then
143+ // then
173144 assertThat (result .getErrors ()).hasSize (1 ).allSatisfy (error -> {
174145 assertThat (error .getType ()).isEqualTo (BidderError .Type .bad_server_response );
175146 assertThat (error .getMessage ()).startsWith ("Failed to decode" );
@@ -178,7 +149,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyIsInvalid() {
178149
179150 @ Test
180151 public void makeBidsShouldReturnBidsWithCorrectTypes () throws JsonProcessingException {
181- // Given
152+ // given
182153 final ObjectNode bidExt = mapper .createObjectNode ()
183154 .set ("prebid" , mapper .createObjectNode ().put ("type" , "banner" ));
184155
@@ -188,16 +159,45 @@ public void makeBidsShouldReturnBidsWithCorrectTypes() throws JsonProcessingExce
188159 .bid (singletonList (Bid .builder ()
189160 .impid ("123" ).ext (bidExt ).build ())).build ())).build ());
190161
191- // When
162+ // when
192163 final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
193164
194- // Then
165+ // then
195166 assertThat (result .getErrors ()).isEmpty ();
196167 assertThat (result .getValue ()).extracting (BidderBid ::getType ).containsExactly (BidType .banner );
197168 }
198169
199170 @ Test
200- public void makeHttpRequestsShouldUseDevEndpointWhenImpExtTestIsTrue () {
171+ public void makeBidsShouldReturnEmptyListwhenBidResponseIsNull () {
172+ // given
173+ final BidderCall <BidRequest > httpCall = givenHttpCallWithBody ("null" );
174+
175+ // when
176+ final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
177+
178+ // then
179+ assertThat (result .getValue ()).isEmpty ();
180+ assertThat (result .getErrors ()).isEmpty ();
181+ }
182+
183+ @ Test
184+ public void makeBidsShouldReturnEmptyListwhenSeatbidIsEmpty () throws JsonProcessingException {
185+ // given
186+ final BidResponse bidResponse = BidResponse .builder ()
187+ .seatbid (Collections .emptyList ())
188+ .build ();
189+ final BidderCall <BidRequest > httpCall = givenHttpCall (bidResponse );
190+
191+ // when
192+ final Result <List <BidderBid >> result = target .makeBids (httpCall , BidRequest .builder ().build ());
193+
194+ // then
195+ assertThat (result .getValue ()).isEmpty ();
196+ assertThat (result .getErrors ()).isEmpty ();
197+ }
198+
199+ @ Test
200+ public void makeHttpRequestsShouldUseDevEndpointwhenImpExtTestIsTrue () {
201201 // given
202202 final ObjectNode extNode = jacksonMapper .mapper ().createObjectNode ();
203203 extNode .putObject ("bidder" ).put ("test" , true );
0 commit comments