From 87fa5016883f6a9e8585c6313772828db20b3950 Mon Sep 17 00:00:00 2001 From: Serhii Kolomiiets Date: Fri, 17 Nov 2023 14:52:03 +0200 Subject: [PATCH] Added test for configurable targeting prefix --- .../auction/TargetingKeywordsCreatorTest.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/prebid/server/auction/TargetingKeywordsCreatorTest.java b/src/test/java/org/prebid/server/auction/TargetingKeywordsCreatorTest.java index 327440342c7..c4d131e9336 100644 --- a/src/test/java/org/prebid/server/auction/TargetingKeywordsCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/TargetingKeywordsCreatorTest.java @@ -8,6 +8,8 @@ import org.prebid.server.proto.openrtb.ext.request.ExtGranularityRange; import org.prebid.server.proto.openrtb.ext.request.ExtPriceGranularity; import org.prebid.server.settings.model.Account; +import org.prebid.server.settings.model.AccountAuctionConfig; +import org.prebid.server.settings.model.AccountTargetingConfig; import java.math.BigDecimal; import java.util.Map; @@ -549,6 +551,38 @@ public void shouldNotIncludeDealBidTargetingIfAlwaysIncludeDealsFlagIsFalse() { @Test public void shouldReturnTargetingKeywordsWithCustomPrefixForOrdinaryBidOpenrtb() { - //TODO: + // given + final String expected = "test_"; + final AccountTargetingConfig targetingConfig = AccountTargetingConfig.builder() + .targetingPrefix(expected) + .build(); + final AccountAuctionConfig auctionConfig = AccountAuctionConfig.builder().targeting(targetingConfig).build(); + final Account account = Account.builder().auction(auctionConfig).build(); + final Bid bid = Bid.builder().price(BigDecimal.ONE) + .dealid("dealId1").w(50).h(100).build(); + + // when + final Map keywords = TargetingKeywordsCreator.create( + ExtPriceGranularity.of( + 2, + singletonList(ExtGranularityRange.of(BigDecimal.valueOf(5), BigDecimal.valueOf(0.5)))), + true, + true, + false, + false, + false, + 0, + null, + null, + null, + account) + .makeFor(bid, "bidder1", false, null, null, null, null); + + // then + assertThat(keywords).containsOnly( + entry(expected + "pb_bidder1", "1.00"), + entry(expected + "bidder_bidder1", "bidder1"), + entry(expected + "size_bidder1", "50x100"), + entry(expected + "deal_bidder1", "dealId1")); } }