Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoxaAntoxic committed Nov 22, 2024
1 parent e473136 commit 809a9f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ private static ImpMediaType resolveBidAdjustmentVideoMediaType(String bidImpId,
.orElse(null);

if (bidImpVideo == null) {
return null;
return ImpMediaType.video_outstream;
}

final Integer placement = bidImpVideo.getPlacement();
final Integer plcmt = bidImpVideo.getPlcmt();

if (placement == null && plcmt == null) {
return null;
}

return Objects.equals(placement, 1) || Objects.equals(plcmt, 1)
? ImpMediaType.video_instream
: ImpMediaType.video_outstream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private List<ExtRequestBidAdjustmentsRule> findRules(BidAdjustments bidAdjustmen

private PrebidConfigParameters createParameters(ImpMediaType mediaType, String bidder, String dealId) {
final List<PrebidConfigParameter> conditionsMatchers = List.of(
mediaType != null ? SimpleDirectParameter.of(mediaType.toString()) : PrebidConfigParameter.wildcard(),
SimpleDirectParameter.of(mediaType.toString()),
SimpleDirectParameter.of(bidder),
StringUtils.isNotBlank(dealId) ? SimpleDirectParameter.of(dealId) : PrebidConfigParameter.wildcard());

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

@Test
public void shouldReturnBidsWithAdjustedPricesWithNullMediaTypeIfVideoPlacementAndPlcmtIsMissing() {
public void shouldReturnBidsWithAdjustedPricesWithVideoOutstreamMediaTypeIfVideoPlacementAndPlcmtIsMissing() {
// given
final BidderResponse bidderResponse = BidderResponse.of(
"bidder",
Expand All @@ -542,7 +542,7 @@ public void shouldReturnBidsWithAdjustedPricesWithNullMediaTypeIfVideoPlacementA
.mediatypes(new EnumMap<>(singletonMap(ImpMediaType.video,
singletonMap("bidder", BigDecimal.valueOf(3.456)))))
.build();
given(bidAdjustmentFactorResolver.resolve(null, givenAdjustments, "bidder"))
given(bidAdjustmentFactorResolver.resolve(ImpMediaType.video_outstream, givenAdjustments, "bidder"))
.willReturn(BigDecimal.valueOf(3.456));

final BidRequest bidRequest = givenBidRequest(singletonList(givenImp(singletonMap("bidder", 2), impBuilder ->
Expand All @@ -568,13 +568,13 @@ public void shouldReturnBidsWithAdjustedPricesWithNullMediaTypeIfVideoPlacementA
eq(Price.of("USD", BigDecimal.valueOf(6.912))),
eq(bidRequest),
eq(givenBidAdjustments()),
eq(null),
eq(ImpMediaType.video_outstream),
eq("bidder"),
eq("dealId"));
}

@Test
public void shouldReturnBidAdjustmentMediaTypeNullIfImpIdNotEqualBidImpId() {
public void shouldReturnBidAdjustmentMediaTypeVideoOutstreamIfImpIdNotEqualBidImpId() {
// given
final BidderResponse bidderResponse = BidderResponse.of(
"bidder",
Expand Down Expand Up @@ -614,12 +614,12 @@ public void shouldReturnBidAdjustmentMediaTypeNullIfImpIdNotEqualBidImpId() {
.extracting(Bid::getPrice)
.containsExactly(BigDecimal.valueOf(2));

verify(bidAdjustmentFactorResolver).resolve(null, givenAdjustments, "bidder");
verify(bidAdjustmentFactorResolver).resolve(ImpMediaType.video_outstream, givenAdjustments, "bidder");
verify(bidAdjustmentsResolver).resolve(
eq(Price.of("USD", BigDecimal.valueOf(2))),
eq(bidRequest),
eq(givenBidAdjustments()),
eq(null),
eq(ImpMediaType.video_outstream),
eq("bidder"),
eq("dealId"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,6 @@ public void resolveShouldPickAndApplyRulesByWildcardDealIdWhenDealIdIsNull() {
verify(currencyService).convertCurrency(new BigDecimal("25"), givenBidRequest, "JPY", "USD");
}

@Test
public void resolveShouldPickAndApplyRulesByWildcardMediatypeWhenMediatypeIsNull() {
// given
final BidAdjustments givenBidAdjustments = BidAdjustments.of(Map.of(
"banner|*|dealId", List.of(givenCpm("15", "EUR"), givenCpm("15", "JPY")),
"*|*|*", List.of(givenCpm("25", "UAH"), givenCpm("25", "JPY"))));
final BidRequest givenBidRequest = BidRequest.builder().build();

// when
final Price actual = target.resolve(
Price.of("USD", BigDecimal.ONE),
givenBidRequest,
givenBidAdjustments,
null,
"bidderName",
"dealId");

// then
assertThat(actual).isEqualTo(Price.of("USD", new BigDecimal("-499")));
verify(currencyService).convertCurrency(new BigDecimal("25"), givenBidRequest, "UAH", "USD");
verify(currencyService).convertCurrency(new BigDecimal("25"), givenBidRequest, "JPY", "USD");
}

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

0 comments on commit 809a9f3

Please sign in to comment.