|
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; |
4 | 4 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 5 | +import com.iab.openrtb.request.App; |
5 | 6 | import com.iab.openrtb.request.BidRequest; |
6 | 7 | import com.iab.openrtb.request.Device; |
7 | 8 | import com.iab.openrtb.request.Imp; |
@@ -191,6 +192,47 @@ public void makeHttpRequestsShouldNotSendImpsWhenHasNotPublisherIdAndImpsWithOgu |
191 | 192 | BidderError.badInput("Invalid request. assetKey/adUnitId or request.site.publisher.id required")); |
192 | 193 | } |
193 | 194 |
|
| 195 | + @Test |
| 196 | + public void makeHttpRequestsAppShouldSendOnlyImpsWithOguryParamsIfPresent() { |
| 197 | + // given |
| 198 | + final BidRequest bidrequest = givenBidRequest( |
| 199 | + bidRequest -> bidRequest.app(givenApp()), |
| 200 | + givenImp(imp -> imp.id("without_ogury_keys").ext(givenEmptyImpExt())), |
| 201 | + givenImp(imp -> imp.id("with_ogury_keys").ext(givenImpExtWithOguryKeys()))); |
| 202 | + |
| 203 | + // when |
| 204 | + final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidrequest); |
| 205 | + |
| 206 | + // then |
| 207 | + assertThat(result.getValue()).hasSize(1) |
| 208 | + .extracting(HttpRequest::getPayload) |
| 209 | + .flatExtracting(BidRequest::getImp) |
| 210 | + .extracting(Imp::getId) |
| 211 | + .containsExactly("with_ogury_keys"); |
| 212 | + |
| 213 | + assertThat(result.getErrors()).isEmpty(); |
| 214 | + } |
| 215 | + |
| 216 | + @Test |
| 217 | + public void makeHttpRequestsAppShouldNotSendImpsWhenImpsWithOguryIsEmpty() { |
| 218 | + // given |
| 219 | + final ObjectNode emptyImpExt = givenEmptyImpExt(); |
| 220 | + |
| 221 | + final BidRequest bidrequest = givenBidRequest( |
| 222 | + bidRequest -> bidRequest.app(givenApp()), |
| 223 | + givenImp(imp -> imp.id("id1").ext(emptyImpExt)), |
| 224 | + givenImp(imp -> imp.id("id2").ext(emptyImpExt))); |
| 225 | + |
| 226 | + // when |
| 227 | + final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidrequest); |
| 228 | + |
| 229 | + // then |
| 230 | + assertThat(result.getValue()).isEmpty(); |
| 231 | + |
| 232 | + assertThat(result.getErrors()).containsExactly( |
| 233 | + BidderError.badInput("Invalid request. assetKey/adUnitId required")); |
| 234 | + } |
| 235 | + |
194 | 236 | @Test |
195 | 237 | public void makeHttpRequestsShouldCopyImpIdToTagId() { |
196 | 238 | // given |
@@ -564,6 +606,10 @@ private Site givenSite() { |
564 | 606 | .build(); |
565 | 607 | } |
566 | 608 |
|
| 609 | + private App givenApp() { |
| 610 | + return App.builder().bundle("app_bundle").build(); |
| 611 | + } |
| 612 | + |
567 | 613 | private ObjectNode givenEmptyImpExt() { |
568 | 614 | final ObjectNode ext = mapper.createObjectNode(); |
569 | 615 | ext.putIfAbsent("bidder", mapper.createObjectNode()); |
|
0 commit comments