Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/java/org/prebid/server/bidder/ix/IxBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.iab.openrtb.response.Response;
import com.iab.openrtb.response.SeatBid;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.prebid.server.bidder.Bidder;
import org.prebid.server.bidder.ix.model.response.IxBidResponse;
Expand Down Expand Up @@ -142,16 +143,18 @@ private UpdateResult<Banner> modifyImpBanner(Banner banner) {
if (banner == null) {
return UpdateResult.unaltered(null);
}

final List<Format> formats = banner.getFormat();
final List<Format> formats = ListUtils.emptyIfNull(banner.getFormat()).stream()
.filter(Objects::nonNull)
.toList();
final Integer w = banner.getW();
final Integer h = banner.getH();
final boolean hasNoFormats = CollectionUtils.isEmpty(formats);

if (CollectionUtils.isEmpty(formats) && h != null && w != null) {
if (hasNoFormats && h != null && w != null) {
final List<Format> newFormats = Collections.singletonList(Format.builder().w(w).h(h).build());
final Banner modifiedBanner = banner.toBuilder().format(newFormats).build();
return UpdateResult.updated(modifiedBanner);
} else if (formats.size() == 1) {
} else if (!hasNoFormats && formats.size() == 1) {
final Format format = formats.getFirst();
final Banner modifiedBanner = banner.toBuilder().w(format.getW()).h(format.getH()).build();
return UpdateResult.updated(modifiedBanner);
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,32 @@ public void makeHttpRequestsShouldSetImpBannerFormatsToFormatWithWidthAndHeightI
.containsExactly(expectedBanner);
}

@Test
public void makeHttpRequestsShouldSetImpBannerFormatsToFormatWithWidthAndHeightIfFormatsAreNullList() {
// given
final BidRequest bidRequest = givenBidRequest(
impBuilder -> impBuilder
.banner(Banner.builder().w(1).h(2).format(null).build())
.ext(givenImpExt(null, null)));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
final Banner expectedBanner = Banner.builder()
.w(1)
.h(2)
.format(singletonList(Format.builder().w(1).h(2).build()))
.build();

assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getBanner)
.containsExactly(expectedBanner);
}

@Test
public void makeHttpRequestsShouldSetImpBannerWidthAndHeightIfTheyAreAbsentAndBannerHasOnlyOneFormat() {
// given
Expand Down
Loading