Skip to content

Commit

Permalink
Rubicon: Remove use-video-size-id-logic processing (#3410)
Browse files Browse the repository at this point in the history
  • Loading branch information
Compile-Ninja authored Sep 3, 2024
1 parent 537ff6c commit af21014
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public class RubiconBidder implements Bidder<BidRequest> {
private final String xapiUsername;
private final Set<String> supportedVendors;
private final boolean generateBidId;
private final boolean useVideoSizeLogic;
private final CurrencyConversionService currencyConversionService;
private final PriceFloorResolver floorResolver;
private final PrebidVersionProvider versionProvider;
Expand All @@ -203,7 +202,6 @@ public RubiconBidder(String bidderName,
String xapiPassword,
List<String> supportedVendors,
boolean generateBidId,
boolean useVideoSizeLogic,
CurrencyConversionService currencyConversionService,
PriceFloorResolver floorResolver,
PrebidVersionProvider versionProvider,
Expand All @@ -215,7 +213,6 @@ public RubiconBidder(String bidderName,
this.xapiUsername = Objects.requireNonNull(xapiUsername);
this.supportedVendors = Set.copyOf(Objects.requireNonNull(supportedVendors));
this.generateBidId = generateBidId;
this.useVideoSizeLogic = useVideoSizeLogic;
this.currencyConversionService = Objects.requireNonNull(currencyConversionService);
this.floorResolver = Objects.requireNonNull(floorResolver);
this.versionProvider = Objects.requireNonNull(versionProvider);
Expand Down Expand Up @@ -1027,9 +1024,8 @@ private Video makeVideo(Imp imp, RubiconVideoParams rubiconVideoParams, String r

private Integer resolveSizeId(RubiconVideoParams rubiconVideoParams, Imp imp, String referer) {
final Integer sizeId = rubiconVideoParams != null ? rubiconVideoParams.getSizeId() : null;
final Video video = imp.getVideo();
final Integer resolvedSizeId = BidderUtil.isNullOrZero(sizeId)
? useVideoSizeLogic ? resolveVideoSizeId(video.getPlacement(), imp.getInstl()) : null
? null
: sizeId;
validateVideoSizeId(resolvedSizeId, referer, imp.getId());

Expand All @@ -1046,23 +1042,6 @@ private static void validateVideoSizeId(Integer resolvedSizeId, String referer,
}
}

private static Integer resolveVideoSizeId(Integer placement, Integer instl) {
if (placement != null) {
if (placement == 1) {
return 201;
}
if (placement == 3) {
return 203;
}
}

if (instl != null && instl == 1) {
return 202;
}

return null;
}

private Banner makeBanner(Imp imp) {
final Banner banner = imp.getBanner();
final Integer width = banner.getW();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ BidderDeps rubiconBidderDeps(RubiconConfigurationProperties rubiconConfiguration
config.getXapi().getPassword(),
config.getMetaInfo().getSupportedVendors(),
config.getGenerateBidId(),
config.getUseVideoSizeIdLogic(),
currencyConversionService,
floorResolver,
versionProvider,
Expand All @@ -76,9 +75,6 @@ private static class RubiconConfigurationProperties extends BidderConfigurationP

@NotNull
private Boolean generateBidId;

@NotNull
private Boolean useVideoSizeIdLogic;
}

@Data
Expand Down
114 changes: 3 additions & 111 deletions src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public void setUp() {
PASSWORD,
SUPPORTED_VENDORS,
false,
true,
currencyConversionService,
priceFloorResolver,
versionProvider,
Expand All @@ -195,7 +194,6 @@ public void creationShouldFailOnInvalidEndpointUrl() {
PASSWORD,
SUPPORTED_VENDORS,
false,
true,
currencyConversionService,
priceFloorResolver,
versionProvider,
Expand Down Expand Up @@ -865,7 +863,7 @@ public void makeHttpRequestsShouldIgnoreBidRequestIfCurrencyServiceThrowsAnExcep
}

@Test
public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabledAndBidderParamsIsMissingSizeId() {
public void shouldNotSetSizeIfBidderParamsIsMissingSizeId() {
// given
target = new RubiconBidder(
BIDDER_NAME,
Expand All @@ -875,7 +873,6 @@ public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabledAndBidderParamsI
PASSWORD,
SUPPORTED_VENDORS,
true,
false,
currencyConversionService,
priceFloorResolver,
versionProvider,
Expand All @@ -897,111 +894,6 @@ public void shouldNotSetSizeIfVideoSizeProcessingLogicIsDisabledAndBidderParamsI
.containsOnlyNulls();
}

@Test
public void shouldSetSizeFromBidderParamsWhenVideoSizeProcessingLogicIsDisabled() {
// given
target = new RubiconBidder(
BIDDER_NAME,
ENDPOINT_URL,
EXTERNAL_URL,
USERNAME,
PASSWORD,
SUPPORTED_VENDORS,
true,
false,
currencyConversionService,
priceFloorResolver,
versionProvider,
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
final BidRequest bidRequest = givenBidRequest(
builder -> builder.instl(1).video(Video.builder().placement(1).build()),
builder -> builder.video(RubiconVideoParams.builder().sizeId(null).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(201);
}

@Test
public void shouldSetSizeIdTo203IfPlacementIs3AndSizeIdIsNotPresent() {
// given
final BidRequest bidRequest = givenBidRequest(
builder -> builder.instl(1).video(Video.builder().placement(3).build()),
builder -> builder.video(RubiconVideoParams.builder().sizeId(null).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(203);
}

@Test
public void shouldSetSizeIdTo202UsingInstlFlagIfPlacementAndSizeIdAreNotPresent() {
// given
final BidRequest bidRequest = givenBidRequest(
builder -> builder.instl(1).video(Video.builder().placement(null).build()),
builder -> builder.video(RubiconVideoParams.builder().sizeId(null).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(202);
}

@Test
public void makeHttpRequestsShouldFillVideoExt() {
// given
Expand Down Expand Up @@ -3785,7 +3677,7 @@ public void makeBidsShouldReturnNativeBidIfNativeIsPresent() throws JsonProcessi
public void makeBidsShouldReturnBidWithRandomlyGeneratedId() throws JsonProcessingException {
// given
target = new RubiconBidder(
BIDDER_NAME, ENDPOINT_URL, ENDPOINT_URL, USERNAME, PASSWORD, SUPPORTED_VENDORS, true, true,
BIDDER_NAME, ENDPOINT_URL, ENDPOINT_URL, USERNAME, PASSWORD, SUPPORTED_VENDORS, true,
currencyConversionService, priceFloorResolver, versionProvider, jacksonMapper);

final BidderCall<BidRequest> httpCall = givenHttpCall(givenBidRequest(identity()),
Expand All @@ -3811,7 +3703,7 @@ public void makeBidsShouldReturnBidWithRandomlyGeneratedId() throws JsonProcessi
public void makeBidsShouldReturnBidWithCurrencyFromBidResponse() throws JsonProcessingException {
// given
target = new RubiconBidder(
BIDDER_NAME, ENDPOINT_URL, EXTERNAL_URL, USERNAME, PASSWORD, SUPPORTED_VENDORS, true, true,
BIDDER_NAME, ENDPOINT_URL, EXTERNAL_URL, USERNAME, PASSWORD, SUPPORTED_VENDORS, true,
currencyConversionService, priceFloorResolver, versionProvider, jacksonMapper);

final BidderCall<BidRequest> httpCall = givenHttpCall(givenBidRequest(identity()),
Expand Down

0 comments on commit af21014

Please sign in to comment.