Skip to content

Commit

Permalink
Rubicon: Video SizeId Pass-Through Logic (#3317)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoxaAntoxic authored Jul 23, 2024
1 parent 7cf8154 commit c12de27
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ private Video makeVideo(Imp imp, RubiconVideoParams rubiconVideoParams, String r

final Integer skip = rubiconVideoParams != null ? rubiconVideoParams.getSkip() : null;
final Integer skipDelay = rubiconVideoParams != null ? rubiconVideoParams.getSkipdelay() : null;
final Integer resolvedSizeId = useVideoSizeLogic ? resolveSizeId(rubiconVideoParams, imp, referer) : null;
final Integer resolvedSizeId = resolveSizeId(rubiconVideoParams, imp, referer);

final Integer rewarded = imp.getRwdd();
final String videoType = rewarded != null && rewarded == 1 ? "rewarded" : null;
Expand All @@ -1013,7 +1013,7 @@ private Integer resolveSizeId(RubiconVideoParams rubiconVideoParams, Imp imp, St
final Integer sizeId = rubiconVideoParams != null ? rubiconVideoParams.getSizeId() : null;
final Video video = imp.getVideo();
final Integer resolvedSizeId = BidderUtil.isNullOrZero(sizeId)
? resolveVideoSizeId(video.getPlacement(), imp.getInstl())
? useVideoSizeLogic ? resolveVideoSizeId(video.getPlacement(), imp.getInstl()) : null
: sizeId;
validateVideoSizeId(resolvedSizeId, referer, imp.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ public void makeHttpRequestsShouldIgnoreBidRequestIfCurrencyServiceThrowsAnExcep
}

@Test
public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabled() {
public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabledAndBidderParamsIsMissingSizeId() {
// given
target = new RubiconBidder(
BIDDER_NAME,
Expand Down Expand Up @@ -857,6 +857,40 @@ public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabled() {
.containsOnlyNulls();
}

@Test
public void shouldSetSizeFromBidderParamsWhenVideoSizeProcessingLogicIsDisabled() {
// given
target = new RubiconBidder(
BIDDER_NAME,
ENDPOINT_URL,
USERNAME,
PASSWORD,
SUPPORTED_VENDORS,
true,
false,
currencyConversionService,
priceFloorResolver,
jacksonMapper);
final BidRequest bidRequest = givenBidRequest(
builder -> builder.instl(1).video(Video.builder().placement(1).build()),
builder -> builder.video(RubiconVideoParams.builder().sizeId(14).build()));

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

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1).doesNotContainNull()
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getVideo).doesNotContainNull()
.extracting(Video::getExt).doesNotContainNull()
.extracting(ext -> mapper.treeToValue(ext, RubiconVideoExt.class))
.extracting(RubiconVideoExt::getRp)
.extracting(RubiconVideoExtRp::getSizeId)
.containsOnly(14);
}

@Test
public void shouldSetSizeIdTo201IfPlacementIs1AndSizeIdIsNotPresent() {
// given
Expand Down

0 comments on commit c12de27

Please sign in to comment.