From 98d42d7c6ea4a9ee39760ab6808090d4df18728e Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Tue, 28 May 2024 15:07:06 +0300 Subject: [PATCH 1/9] Test: Increase coverage for targeting spec (#3088) --- .../model/request/amp/AmpRequest.groovy | 2 + .../service/PrebidServerService.groovy | 21 ++- .../functional/tests/TargetingSpec.groovy | 171 ++++++++++-------- 3 files changed, 120 insertions(+), 74 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/request/amp/AmpRequest.groovy b/src/test/groovy/org/prebid/server/functional/model/request/amp/AmpRequest.groovy index 40f9115b484..fffb2c86e05 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/amp/AmpRequest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/amp/AmpRequest.groovy @@ -27,6 +27,8 @@ class AmpRequest { Boolean gdprApplies String addtlConsent String gppSid + String unknownField + Integer secondUnknownField static AmpRequest getDefaultAmpRequest() { def request = new AmpRequest() diff --git a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy index fc1b4784c70..fd0bcac255c 100644 --- a/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy +++ b/src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy @@ -93,6 +93,13 @@ class PrebidServerService implements ObjectMapperWrapper { } } + AmpResponse sendAmpRequestWithAdditionalQueries(AmpRequest ampRequest, Map queries = [:]) { + def response = getAmp(ampRequest, [:], queries) + + checkResponseStatusCode(response) + decode(response.body.asString(), AmpResponse) + } + AmpResponse sendAmpRequest(AmpRequest ampRequest, Map headers = [:]) { def response = getAmp(ampRequest, headers) @@ -314,10 +321,18 @@ class PrebidServerService implements ObjectMapperWrapper { requestSpecification.post(COOKIE_SYNC_ENDPOINT) } - private Response getAmp(AmpRequest ampRequest, Map headers = [:]) { + private Response getAmp(AmpRequest ampRequest, + Map headers = [:], + Map queries = [:]) { + def map = toMap(ampRequest) + + if (!queries.isEmpty()) { + map.putAll(queries) + } + given(requestSpecification).headers(headers) - .queryParams(toMap(ampRequest)) - .get(AMP_ENDPOINT) + .queryParams(map) + .get(AMP_ENDPOINT) } private void checkResponseStatusCode(Response response, int statusCode = 200) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index d58e6e3a781..67b5f69b1d5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -390,7 +390,7 @@ class TargetingSpec extends BaseSpec { } and: "Account in the DB" - def targetingLength = PBSUtils.getRandomNumber(2,10) + def targetingLength = PBSUtils.getRandomNumber(2, 10) def account = new Account(uuid: accountId, truncateTargetAttr: targetingLength) accountDao.save(account) @@ -435,7 +435,7 @@ class TargetingSpec extends BaseSpec { storedRequestDao.save(storedRequest) and: "Create and save account in the DB" - def account = new Account(uuid: ampRequest.account, truncateTargetAttr: PBSUtils.getRandomNumber(1,10)) + def account = new Account(uuid: ampRequest.account, truncateTargetAttr: PBSUtils.getRandomNumber(1, 10)) accountDao.save(account) when: "PBS processes amp request" @@ -458,7 +458,8 @@ class TargetingSpec extends BaseSpec { ext.prebid.targeting = Targeting.createWithAllValuesSetTo(true).tap { priceGranularity = new PriceGranularity().tap { it.precision = precision - ranges = [new Range(max: max, increment: PBSUtils.randomDecimal)]} + ranges = [new Range(max: max, increment: PBSUtils.randomDecimal)] + } } } @@ -527,7 +528,7 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert targeting.size() == 6 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } } def "PBS auction should use default targeting prefix when auction.config.targeting.prefix is biggest that twenty"() { @@ -539,7 +540,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: bidRequest.accountId,config: new AccountConfig(auction: config) ) + def account = new Account(uuid: bidRequest.accountId, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes auction request" @@ -548,7 +549,7 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert targeting.size() == 6 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } } def "PBS auction should default targeting prefix when ext.prebid.targeting.prefix is #prefix"() { @@ -563,9 +564,10 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert targeting.size() == 6 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } - where: prefix << [null, ""] + where: + prefix << [null, ""] } def "PBS auction should default targeting prefix when auction.targeting.prefix is #prefix"() { @@ -576,7 +578,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: bidRequest.accountId,config: new AccountConfig(auction: config) ) + def account = new Account(uuid: bidRequest.accountId, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes auction request" @@ -585,9 +587,10 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert targeting.size() == 6 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } - where: prefix << [null, ""] + where: + prefix << [null, ""] } def "PBS auction should update targeting prefix when ext.prebid.targeting.prefix specified"() { @@ -603,7 +606,7 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain targeting with requested prefix" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS auction should update prefix name for targeting when account specified"() { @@ -615,7 +618,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: bidRequest.accountId,config: new AccountConfig(auction: config) ) + def account = new Account(uuid: bidRequest.accountId, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes auction request" @@ -623,7 +626,7 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain targeting key with specified prefix in account level" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS auction should update targeting prefix and take precedence request level over account when prefix specified in both place"() { @@ -635,7 +638,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: "account_")) - def account = new Account(uuid: bidRequest.accountId,config: new AccountConfig(auction: config) ) + def account = new Account(uuid: bidRequest.accountId, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes auction request" @@ -643,7 +646,7 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain targeting key with specified prefix in account level" def targeting = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should trim targeting prefix when ext.prebid.targeting.prefix targeting is biggest that twenty"() { @@ -666,7 +669,7 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain default targeting prefix" def targeting = ampResponse.targeting assert targeting.size() == 12 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } } def "PBS amp should trim targeting prefix when auction.config.targeting.prefix targeting is biggest that twenty"() { @@ -679,7 +682,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def prefix = PBSUtils.getRandomString(30) def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config) ) + def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config)) accountDao.save(account) and: "Create and save stored request into DB" @@ -692,7 +695,7 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert targeting.size() == 12 - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } } def "PBS amp should default targeting prefix when auction.config.targeting.prefix is #prefix"() { @@ -708,7 +711,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config) ) + def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes amp request" @@ -717,9 +720,10 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } - where: prefix << [null, ""] + where: + prefix << [null, ""] } def "PBS amp should default targeting prefix when ext.prebid.targeting is #prefix"() { @@ -741,9 +745,10 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } - where: prefix << [null, ""] + where: + prefix << [null, ""] } def "PBS amp should update targeting prefix when specified in account prefix"() { @@ -760,7 +765,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: prefix)) - def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config) ) + def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes amp request" @@ -769,7 +774,7 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should use custom prefix for targeting when stored request ext.prebid.targeting.prefix specified"() { @@ -792,7 +797,7 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain custom targeting prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should take precedence from ext.prebid.targeting.prefix when specified in account targeting prefix"() { @@ -811,7 +816,7 @@ class TargetingSpec extends BaseSpec { and: "Account in the DB" def config = new AccountAuctionConfig(targeting: new Targeting(prefix: "account_")) - def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config) ) + def account = new Account(uuid: ampRequest.account, config: new AccountConfig(auction: config)) accountDao.save(account) when: "PBS processes amp request" @@ -820,7 +825,7 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should move targeting key to imp.ext.data"() { @@ -830,7 +835,7 @@ class TargetingSpec extends BaseSpec { } and: "Encode Targeting to String" - def encodeTargeting = URLEncoder.encode(encode(targeting), StandardCharsets.UTF_8) + def encodeTargeting = URLEncoder.encode(encode(targeting), StandardCharsets.UTF_8) and: "Amp request with targeting" def ampRequest = AmpRequest.defaultAmpRequest.tap { @@ -853,10 +858,10 @@ class TargetingSpec extends BaseSpec { } def "PBS amp should use long account targeting prefix when settings.targeting.truncate-attr-chars override"() { - given:"PBS config with setting.targeting" - def prefixMaxChars = PBSUtils.getRandomNumber(35,MAX_TRUNCATE_ATTR_CHARS) + given: "PBS config with setting.targeting" + def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -880,14 +885,14 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { - given:"PBS config with setting.targeting" - def prefixMaxChars = PBSUtils.getRandomNumber(35,MAX_TRUNCATE_ATTR_CHARS) + given: "PBS config with setting.targeting" + def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -908,16 +913,16 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain targeting response with custom prefix" def targeting = ampResponse.targeting assert !targeting.isEmpty() - assert targeting.keySet().every { it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS auction should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { - given:"PBS config with setting.targeting" - def prefixMaxChars = PBSUtils.getRandomNumber(35,MAX_TRUNCATE_ATTR_CHARS) + given: "PBS config with setting.targeting" + def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) - and:"Bid request with prefix" + and: "Bid request with prefix" def prefix = PBSUtils.getRandomString(prefixMaxChars - TARGETING_PREFIX_LENGTH) def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.targeting = new Targeting(prefix: prefix) @@ -929,14 +934,14 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS auction should use long account targeting prefix when settings.targeting.truncate-attr-chars override"() { - given:"PBS config with setting.targeting" - def prefixMaxChars = PBSUtils.getRandomNumber(35,MAX_TRUNCATE_ATTR_CHARS) + given: "PBS config with setting.targeting" + def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) and: "Bid request with empty targeting" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -955,14 +960,14 @@ class TargetingSpec extends BaseSpec { then: "PBS response should contain default targeting prefix" def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(prefix)} + assert targeting.keySet().every { it -> it.startsWith(prefix) } } def "PBS amp should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { - given:"PBS config with setting.targeting" - def targetingChars = PBSUtils.getRandomNumber(2,10) + given: "PBS config with setting.targeting" + def targetingChars = PBSUtils.getRandomNumber(2, 10) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + ["settings.targeting.truncate-attr-chars": targetingChars as String]) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -985,15 +990,15 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain warning" assert ampResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + - "Decrease custom prefix length or increase truncateattrchars by " + - "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + "Decrease custom prefix length or increase truncateattrchars by " + + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] } def "PBS amp should ignore and add a warning to ext.warnings when value of the request prefix is longer then settings.targeting.truncate-attr-chars"() { - given:"PBS config with setting.targeting" - def targetingChars = PBSUtils.getRandomNumber(2,10) + given: "PBS config with setting.targeting" + def targetingChars = PBSUtils.getRandomNumber(2, 10) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + ["settings.targeting.truncate-attr-chars": targetingChars as String]) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -1013,17 +1018,17 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain warning" assert ampResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + - "Decrease custom prefix length or increase truncateattrchars by " + - "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + "Decrease custom prefix length or increase truncateattrchars by " + + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] } def "PBS auction should ignore and add a warning to ext.warnings when value of the request prefix is longer then settings.targeting.truncate-attr-chars"() { - given:"PBS config with setting.targeting" - def targetingChars = PBSUtils.getRandomNumber(2,10) + given: "PBS config with setting.targeting" + def targetingChars = PBSUtils.getRandomNumber(2, 10) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + ["settings.targeting.truncate-attr-chars": targetingChars as String]) - and:"Bid request with prefix" + and: "Bid request with prefix" def prefixSize = targetingChars + 1 def prefix = PBSUtils.getRandomString(prefixSize) def bidRequest = BidRequest.defaultBidRequest.tap { @@ -1036,17 +1041,17 @@ class TargetingSpec extends BaseSpec { then: "Bid response should contain warning" def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } assert bidResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + - "Decrease custom prefix length or increase truncateattrchars by " + - "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + "Decrease custom prefix length or increase truncateattrchars by " + + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] } def "PBS auction should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { given: "PBS config with setting.targeting" - def targetingChars = PBSUtils.getRandomNumber(2,10) + def targetingChars = PBSUtils.getRandomNumber(2, 10) def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + ["settings.targeting.truncate-attr-chars": targetingChars as String]) and: "Bid request" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -1065,17 +1070,41 @@ class TargetingSpec extends BaseSpec { then: "Bid response should contain warning" def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() - assert targeting.keySet().every{it -> it.startsWith(DEFAULT_TARGETING_PREFIX)} + assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } assert bidResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + - "Decrease custom prefix length or increase truncateattrchars by " + - "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + "Decrease custom prefix length or increase truncateattrchars by " + + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + } + + def "PBS amp should apply data from query to ext.prebid.amp.data"() { + given: "Default AmpRequest" + def ampRequest = AmpRequest.defaultAmpRequest + + and: "Bid request" + def ampStoredRequest = BidRequest.defaultBidRequest + + and: "Create and save stored request into DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + when: "PBS processes amp request" + def unknownValue = PBSUtils.randomString + def secondUnknownValue = PBSUtils.randomNumber + defaultPbsService.sendAmpRequestWithAdditionalQueries(ampRequest, ["unknown_field" : unknownValue, + "second_unknown_field": secondUnknownValue]) + + then: "Amp should contain data from query request" + def bidderRequests = bidder.getBidderRequest(ampStoredRequest.id) + def ampData = bidderRequests.ext.prebid.amp.data + assert ampData.unknownField == unknownValue + assert ampData.secondUnknownField == secondUnknownValue } - private PrebidServerService getEnabledWinBidsPbsService() { + private static PrebidServerService getEnabledWinBidsPbsService() { pbsServiceFactory.getService(["auction.cache.only-winning-bids": "true"]) } - private PrebidServerService getDisabledWinBidsPbsService() { + private static PrebidServerService getDisabledWinBidsPbsService() { pbsServiceFactory.getService(["auction.cache.only-winning-bids": "false"]) } } From d0c97aab7633b60d8e407011491d0ac9a8166f33 Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Tue, 28 May 2024 15:08:43 +0300 Subject: [PATCH 2/9] Tests: `nbr` field (#3189) --- .../model/response/auction/BidResponse.groovy | 2 +- .../response/auction/NoBidResponse.groovy | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/test/groovy/org/prebid/server/functional/model/response/auction/NoBidResponse.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy index 99e37de76ab..fab76cfc309 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidResponse.groovy @@ -18,7 +18,7 @@ class BidResponse implements ResponseModel { String bidid Currency cur String customdata - Integer nbr + NoBidResponse nbr BidResponseExt ext static BidResponse getDefaultBidResponse(BidRequest bidRequest, BidderName bidderName = GENERIC) { diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/NoBidResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/NoBidResponse.groovy new file mode 100644 index 00000000000..c402d1c2d4a --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/NoBidResponse.groovy @@ -0,0 +1,35 @@ +package org.prebid.server.functional.model.response.auction + +import com.fasterxml.jackson.annotation.JsonValue +import groovy.transform.ToString + +@ToString(includeNames = true, ignoreNulls = true) +enum NoBidResponse { + + UNKNOWN_ERROR(0), + TECHNICAL_ERROR(1), + INVALID_REQUEST(2), + KNOWN_WEB_CRAWLER(3), + SUSPECTED_NON_HUMAN_TRAFFIC(4), + CLOUD_DATA_CENTER_OR_PROXY_IP(5), + UNSUPPORTED_DEVICE(6), + BLOCKED_PUBLISHER_OR_SITE(7), + UNMATCHED_USER(8), + DAILY_USER_CAP_MET(9), + DAILY_DOMAIN_CAP_MET(10), + ADS_TXT_AUTHORIZATION_UNAVAILABLE(11), + ADS_TXT_AUTHORIZATION_VIOLATION(12), + ADS_CART_AUTHORIZATION_UNAVAILABLE(13), + ADS_CART_AUTHORIZATION_VIOLATION(14), + INSUFFICIENT_AUCTION_TIME(15), + INCOMPLETE_SUPPLY_CHAIN(16), + BLOCKED_SUPPLY_CHAIN(17), + EXCHANGE_SPECIFIC_VALUES(500) + + @JsonValue + final Integer nbr + + NoBidResponse(Integer nbr) { + this.nbr = nbr + } +} From dbef995c424f822726c7e8e37e19fa857120c468 Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Wed, 29 May 2024 13:45:06 +0200 Subject: [PATCH 3/9] Prebid Server prepare release 3.1.0 --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 7c515927304..88266393279 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0-SNAPSHOT + 3.1.0 ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 924ce91e085..24c868d914c 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0-SNAPSHOT + 3.1.0 confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index df0a826e5c9..9b49c6f5cda 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0-SNAPSHOT + 3.1.0 ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index b402096e626..c1ff7cd2656 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0-SNAPSHOT + 3.1.0 pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 0ec5be33e7e..64282d5ad14 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0-SNAPSHOT + 3.1.0 ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index 98b9787d161..41051606a8d 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 3.1.0-SNAPSHOT + 3.1.0 pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - HEAD + 3.1.0 diff --git a/pom.xml b/pom.xml index dfe9152361b..3e55ba60f52 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0-SNAPSHOT + 3.1.0 extra/pom.xml From e02e0942f056307d2b502cf5dd2c899e61257aba Mon Sep 17 00:00:00 2001 From: serhiinahornyi Date: Wed, 29 May 2024 13:50:01 +0200 Subject: [PATCH 4/9] Prebid Server prepare for next development iteration --- extra/bundle/pom.xml | 2 +- extra/modules/confiant-ad-quality/pom.xml | 2 +- extra/modules/ortb2-blocking/pom.xml | 2 +- extra/modules/pb-richmedia-filter/pom.xml | 2 +- extra/modules/pom.xml | 2 +- extra/pom.xml | 4 ++-- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extra/bundle/pom.xml b/extra/bundle/pom.xml index 88266393279..e13a3a0917a 100644 --- a/extra/bundle/pom.xml +++ b/extra/bundle/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0 + 3.2.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/modules/confiant-ad-quality/pom.xml b/extra/modules/confiant-ad-quality/pom.xml index 24c868d914c..ca0c45ff937 100644 --- a/extra/modules/confiant-ad-quality/pom.xml +++ b/extra/modules/confiant-ad-quality/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0 + 3.2.0-SNAPSHOT confiant-ad-quality diff --git a/extra/modules/ortb2-blocking/pom.xml b/extra/modules/ortb2-blocking/pom.xml index 9b49c6f5cda..61e5baefffd 100644 --- a/extra/modules/ortb2-blocking/pom.xml +++ b/extra/modules/ortb2-blocking/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0 + 3.2.0-SNAPSHOT ortb2-blocking diff --git a/extra/modules/pb-richmedia-filter/pom.xml b/extra/modules/pb-richmedia-filter/pom.xml index c1ff7cd2656..b74d4c353d8 100644 --- a/extra/modules/pb-richmedia-filter/pom.xml +++ b/extra/modules/pb-richmedia-filter/pom.xml @@ -5,7 +5,7 @@ org.prebid.server.hooks.modules all-modules - 3.1.0 + 3.2.0-SNAPSHOT pb-richmedia-filter diff --git a/extra/modules/pom.xml b/extra/modules/pom.xml index 64282d5ad14..1d0241dcafa 100644 --- a/extra/modules/pom.xml +++ b/extra/modules/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0 + 3.2.0-SNAPSHOT ../../extra/pom.xml diff --git a/extra/pom.xml b/extra/pom.xml index 41051606a8d..4376956f9c7 100644 --- a/extra/pom.xml +++ b/extra/pom.xml @@ -4,14 +4,14 @@ org.prebid prebid-server-aggregator - 3.1.0 + 3.2.0-SNAPSHOT pom https://github.com/prebid/prebid-server-java scm:git:git@github.com:prebid/prebid-server-java.git scm:git:git@github.com:prebid/prebid-server-java.git - 3.1.0 + HEAD diff --git a/pom.xml b/pom.xml index 3e55ba60f52..ffd5341da83 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.prebid prebid-server-aggregator - 3.1.0 + 3.2.0-SNAPSHOT extra/pom.xml From edd4dd17c170d14b57835bd86b8215e25e391bda Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Wed, 29 May 2024 14:52:00 +0300 Subject: [PATCH 5/9] CodeStyle: Fixed a bunch of inspection issues. (#3215) --- .../reporter/AnalyticsReporterDelegator.java | 75 +++++++++---------- .../reporter/log/LogAnalyticsReporter.java | 27 +++---- .../pubstack/PubstackAnalyticsReporter.java | 26 +++---- .../pubstack/PubstackEventHandler.java | 4 +- .../server/auction/BidResponseCreator.java | 4 +- .../server/auction/ExchangeService.java | 6 +- .../server/auction/InterstitialProcessor.java | 2 +- .../auction/StoredResponseProcessor.java | 2 +- .../BasicCategoryMappingService.java | 4 +- .../requestfactory/AmpRequestFactory.java | 6 +- .../server/bidder/HttpBidderRequester.java | 2 +- .../server/bidder/aceex/AceexBidder.java | 4 +- .../bidder/acuityads/AcuityadsBidder.java | 4 +- .../bidder/adelement/AdelementBidder.java | 10 +-- .../adgeneration/AdgenerationBidder.java | 2 +- .../server/bidder/adhese/AdheseBidder.java | 6 +- .../bidder/adkerneladn/AdkernelAdnBidder.java | 3 +- .../server/bidder/admixer/AdmixerBidder.java | 2 +- .../bidder/adnuntius/AdnuntiusBidder.java | 8 +- .../prebid/server/bidder/adot/AdotBidder.java | 2 +- .../server/bidder/adpone/AdponeBidder.java | 2 +- .../bidder/adtarget/AdtargetBidder.java | 2 +- .../bidder/adtelligent/AdtelligentBidder.java | 2 +- .../advangelists/AdvangelistsBidder.java | 4 +- .../server/bidder/adview/AdviewBidder.java | 2 +- .../bidder/adyoulike/AdyoulikeBidder.java | 2 +- .../server/bidder/aidem/AidemBidder.java | 6 +- .../server/bidder/algorix/AlgorixBidder.java | 2 +- .../bidder/appnexus/AppnexusBidder.java | 2 +- .../prebid/server/bidder/axis/AxisBidder.java | 4 +- .../server/bidder/axonix/AxonixBidder.java | 2 +- .../bidder/beachfront/BeachfrontBidder.java | 8 +- .../server/bidder/beintoo/BeintooBidder.java | 2 +- .../server/bidder/between/BetweenBidder.java | 2 +- .../bidder/bidmyadz/BidmyadzBidder.java | 4 +- .../bidder/bidstack/BidstackBidder.java | 3 +- .../bidder/bizzclick/BizzclickBidder.java | 4 +- .../server/bidder/bliink/BliinkBidder.java | 2 +- .../server/bidder/bluesea/BlueSeaBidder.java | 2 - .../server/bidder/boldwin/BoldwinBidder.java | 2 +- .../server/bidder/brave/BraveBidder.java | 2 +- .../bidder/connectad/ConnectadBidder.java | 4 +- .../bidder/deepintent/DeepintentBidder.java | 2 +- .../prebid/server/bidder/dmx/DmxBidder.java | 4 +- .../bidder/emxdigital/EmxDigitalBidder.java | 2 +- .../server/bidder/epsilon/EpsilonBidder.java | 4 +- .../bidder/evolution/EvolutionBidder.java | 2 +- .../server/bidder/flipp/FlippBidder.java | 4 +- .../server/bidder/gamma/GammaBidder.java | 2 +- .../server/bidder/gamoshi/GamoshiBidder.java | 4 +- .../bidder/gotthamads/GothamAdsBidder.java | 4 +- .../prebid/server/bidder/grid/GridBidder.java | 2 +- .../server/bidder/gumgum/GumgumBidder.java | 2 +- .../bidder/huaweiads/HuaweiAdmBuilder.java | 4 +- .../bidder/huaweiads/HuaweiDeviceBuilder.java | 8 +- .../model/response/MonitorEventType.java | 27 +++---- .../server/bidder/inmobi/InmobiBidder.java | 4 +- .../InteractiveOffersBidder.java | 2 +- .../bidder/intertech/IntertechBidder.java | 4 +- .../org/prebid/server/bidder/ix/IxBidder.java | 2 +- .../server/bidder/kayzen/KayzenBidder.java | 2 +- .../bidder/krushmedia/KrushmediaBidder.java | 4 +- .../lemmadigital/LemmaDigitalBidder.java | 4 +- .../bidder/lunamedia/LunamediaBidder.java | 2 +- .../bidder/marsmedia/MarsmediaBidder.java | 6 +- .../bidder/mobfoxpb/MobfoxpbBidder.java | 2 +- .../server/bidder/motorik/MotorikBidder.java | 4 +- .../nextmillennium/NextMillenniumBidder.java | 4 +- .../server/bidder/openx/OpenxBidder.java | 2 +- .../bidder/operaads/OperaadsBidder.java | 2 +- .../server/bidder/preciso/PrecisoBidder.java | 6 +- .../bidder/pubmatic/PubmaticBidder.java | 2 +- .../bidder/pubnative/PubnativeBidder.java | 9 ++- .../server/bidder/roulax/RoulaxBidder.java | 2 +- .../bidder/rtbhouse/RtbhouseBidder.java | 6 +- .../server/bidder/rubicon/RubiconBidder.java | 10 +-- .../bidder/salunamedia/SaLunamediaBidder.java | 4 +- .../bidder/screencore/ScreencoreBidder.java | 4 +- .../bidder/silverpush/SilverPushBidder.java | 4 +- .../server/bidder/smaato/SmaatoBidder.java | 6 +- .../bidder/smarthub/SmarthubBidder.java | 6 +- .../bidder/smartyads/SmartyAdsBidder.java | 2 +- .../bidder/smilewanted/SmileWantedBidder.java | 2 +- .../bidder/smrtconnect/SmrtconnectBidder.java | 2 +- .../server/bidder/tappx/TappxBidder.java | 4 +- .../server/bidder/teads/TeadsBidder.java | 2 +- .../server/bidder/telaria/TelariaBidder.java | 4 +- .../bidder/ucfunnel/UcfunnelBidder.java | 2 +- .../bidder/undertone/UndertoneBidder.java | 2 +- .../server/bidder/unicorn/UnicornBidder.java | 2 +- .../bidder/videoheroes/VideoHeroesBidder.java | 4 +- .../server/bidder/vidoomy/VidoomyBidder.java | 2 +- .../bidder/yahooads/YahooAdsBidder.java | 2 +- .../server/bidder/yandex/YandexBidder.java | 4 +- .../bidder/yieldone/YieldoneBidder.java | 2 +- .../server/cookie/CookieSyncService.java | 2 +- .../currency/CurrencyConversionService.java | 2 +- .../floors/BasicPriceFloorEnforcer.java | 2 +- .../floors/BasicPriceFloorProcessor.java | 2 +- .../floors/BasicPriceFloorResolver.java | 8 +- .../MaxMindGeoLocationService.java | 2 +- .../server/handler/CookieSyncHandler.java | 47 ++++++------ .../prebid/server/handler/SetuidHandler.java | 44 ++++++----- .../server/handler/openrtb2/AmpHandler.java | 2 +- .../settings/CachingApplicationSettings.java | 5 -- .../AccountActivityRuleConfigResolver.java | 2 +- .../config/database/model/DatabaseType.java | 2 +- .../server/validation/RequestValidator.java | 2 +- .../ActivityInfrastructureCreatorTest.java | 2 +- .../auction/BidResponseCreatorTest.java | 10 +-- .../server/auction/ExchangeServiceTest.java | 12 +-- .../auction/StoredRequestProcessorTest.java | 4 +- .../auction/VideoResponseFactoryTest.java | 2 +- .../server/bidder/aceex/AceexBidderTest.java | 2 +- .../bidder/acuityads/AcuityadsBidderTest.java | 12 +-- .../adgeneration/AdgenerationBidderTest.java | 16 ++-- .../bidder/adhese/AdheseBidderTest.java | 2 +- .../bidder/adkernel/AdkernelBidderTest.java | 4 +- .../adkerneladn/AdkernelAdnBidderTest.java | 8 +- .../server/bidder/adman/AdmanBidderTest.java | 2 +- .../bidder/adocean/AdoceanBidderTest.java | 6 +- .../bidder/adoppler/AdopplerBidderTest.java | 6 +- .../server/bidder/adot/AdotBidderTest.java | 4 +- .../bidder/adpone/AdponeBidderTest.java | 10 +-- .../bidder/adprime/AdprimeBidderTest.java | 6 +- .../bidder/adtarget/AdtargetBidderTest.java | 2 +- .../advangelists/AdvangelistsBidderTest.java | 2 +- .../server/bidder/adxcg/AdxcgBidderTest.java | 4 +- .../server/bidder/aja/AjaBidderTest.java | 6 +- .../bidder/appnexus/AppnexusBidderTest.java | 4 +- .../server/bidder/aso/AsoBidderTest.java | 4 +- .../AudienceNetworkBidderTest.java | 5 +- .../bidder/avocet/AvocetBidderTest.java | 4 +- .../beachfront/BeachfrontBidderTest.java | 8 +- .../bidder/beintoo/BeintooBidderTest.java | 18 ++--- .../bidmachine/BidmachineBidderTest.java | 4 +- .../bidder/bidstack/BidstackBidderTest.java | 2 +- .../bidder/bluesea/BlueSeaBidderTest.java | 10 +-- .../server/bidder/brave/BraveBidderTest.java | 2 +- .../bidder/coinzilla/CoinzillaBidderTest.java | 2 +- .../bidder/colossus/ColossusBidderTest.java | 8 +- .../bidder/connectad/ConnectadBidderTest.java | 6 +- .../consumable/ConsumableBidderTest.java | 8 +- .../bidder/cpmstar/CpmStarBidderTest.java | 6 +- .../datablocks/DatablocksBidderTest.java | 6 +- .../server/bidder/dmx/DmxBidderTest.java | 8 +- .../bidder/dxkulture/DxKultureBidderTest.java | 6 +- .../emxdigital/EmxDigitalBidderTest.java | 20 ++--- .../bidder/eplanning/EplanningBidderTest.java | 6 +- .../server/bidder/flipp/FlippBidderTest.java | 4 +- .../server/bidder/gamma/GammaBidderTest.java | 8 +- .../bidder/gamoshi/GamoshiBidderTest.java | 10 +-- .../bidder/impactify/ImpactifyBidderTest.java | 2 +- .../ImprovedigitalBidderTest.java | 6 +- .../bidder/invibes/InvibesBidderTest.java | 16 ++-- .../prebid/server/bidder/ix/IxBidderTest.java | 6 +- .../server/bidder/kidoz/KidozBidderTest.java | 8 +- .../krushmedia/KrushmediaBidderTest.java | 6 +- .../LimeLightDigitalBidderTest.java | 8 +- .../lockerdome/LockerdomeBidderTest.java | 6 +- .../bidder/logicad/LogicadBidderTest.java | 6 +- .../bidder/lunamedia/LunamediaBidderTest.java | 2 +- .../server/bidder/mgid/MgidBidderTest.java | 2 +- .../server/bidder/mgidx/MgidxBidderTest.java | 2 +- .../bidder/motorik/MotorikBidderTest.java | 2 +- .../NextMillenniumBidderTest.java | 4 +- .../server/bidder/openx/OpenxBidderTest.java | 4 +- .../bidder/orbidder/OrbidderBidderTest.java | 2 +- .../bidder/outbrain/OutbrainBidderTest.java | 4 +- .../bidder/preciso/PrecisoBidderTest.java | 4 +- .../bidder/pubmatic/PubmaticBidderTest.java | 8 +- .../bidder/pubnative/PubnativeBidderTest.java | 6 +- .../pulsepoint/PulsepointBidderTest.java | 6 +- .../resetdigital/ResetDigitalBidderTest.java | 18 ++--- .../revcontent/RevcontentBidderTest.java | 4 +- .../richaudience/RichaudienceBidderTest.java | 6 +- .../server/bidder/rise/RiseBidderTest.java | 6 +- .../bidder/rtbhouse/RtbhouseBidderTest.java | 4 +- .../bidder/rubicon/RubiconBidderTest.java | 30 ++++---- .../sharethrough/SharethroughBidderTest.java | 6 +- .../bidder/smaato/SmaatoBidderTest.java | 4 +- .../SmartadserverBidderTest.java | 2 +- .../bidder/smartrtb/SmartrtbBidderTest.java | 6 +- .../bidder/smartyads/SmartyAdsBidderTest.java | 4 +- .../bidder/sonobi/SonobiBidderTest.java | 8 +- .../server/bidder/sovrn/SovrnBidderTest.java | 2 +- .../bidder/sovrnxsp/SovrnXspBidderTest.java | 2 +- .../stroeercore/StroeerCoreBidderTest.java | 2 +- .../bidder/taboola/TaboolaBidderTest.java | 2 +- .../server/bidder/tappx/TappxBidderTest.java | 6 +- .../bidder/telaria/TelariaBidderTest.java | 2 +- .../bidder/theadx/TheadxBidderTest.java | 4 +- .../server/bidder/tpmn/TpmnBidderTest.java | 4 +- .../trafficgate/TrafficGateBidderTest.java | 6 +- .../triplelift/TripleliftBidderTest.java | 8 +- .../TripleliftNativeBidderTest.java | 14 ++-- .../bidder/ucfunnel/UcfunnelBidderTest.java | 4 +- .../bidder/undertone/UndertoneBidderTest.java | 6 +- .../bidder/unruly/UnrulyBidderTest.java | 4 +- .../videoheroes/VideoHeroesBidderTest.java | 2 +- .../server/bidder/visx/VisxBidderTest.java | 4 +- .../bidder/vrtcal/VrtcalBidderTest.java | 4 +- .../bidder/xeworks/XeworksBidderTest.java | 2 +- .../bidder/yahooads/YahooAdsBidderTest.java | 12 +-- .../bidder/yandex/YandexBidderTest.java | 2 +- .../bidder/yieldlab/YieldlabBidderTest.java | 10 +-- .../bidder/yieldmo/YieldmoBidderTest.java | 6 +- .../bidder/yieldone/YieldoneBidderTest.java | 6 +- .../ZeroclickfraudBidderTest.java | 8 +- .../bidder/zmaticoo/ZMaticooBidderTest.java | 2 +- .../execution/HookStageExecutorTest.java | 22 +++--- ...ntActivityRulesConfigDeserializerTest.java | 2 +- .../settings/HttpApplicationSettingsTest.java | 6 +- .../validation/BidderParamValidatorTest.java | 1 + .../validation/RequestValidatorTest.java | 4 +- 215 files changed, 615 insertions(+), 629 deletions(-) diff --git a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java index adaf4aaf888..fa2b48746aa 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/reporter/AnalyticsReporterDelegator.java @@ -166,28 +166,33 @@ private static boolean isNotEmptyObjectNode(JsonNode analytics) { private static boolean isAllowedAdapter(T event, String adapter) { final ActivityInfrastructure activityInfrastructure; final ActivityInvocationPayload activityInvocationPayload; - if (event instanceof AuctionEvent auctionEvent) { - final AuctionContext auctionContext = auctionEvent.getAuctionContext(); - activityInfrastructure = auctionContext != null ? auctionContext.getActivityInfrastructure() : null; - activityInvocationPayload = auctionContext != null - ? BidRequestActivityInvocationPayload.of( - activityInvocationPayload(adapter), - auctionContext.getBidRequest()) - : null; - } else if (event instanceof AmpEvent ampEvent) { - final AuctionContext auctionContext = ampEvent.getAuctionContext(); - activityInfrastructure = auctionContext != null ? auctionContext.getActivityInfrastructure() : null; - activityInvocationPayload = auctionContext != null - ? BidRequestActivityInvocationPayload.of( - activityInvocationPayload(adapter), - auctionContext.getBidRequest()) - : null; - } else if (event instanceof NotificationEvent notificationEvent) { - activityInfrastructure = notificationEvent.getActivityInfrastructure(); - activityInvocationPayload = activityInvocationPayload(adapter); - } else { - activityInfrastructure = null; - activityInvocationPayload = null; + switch (event) { + case AuctionEvent auctionEvent -> { + final AuctionContext auctionContext = auctionEvent.getAuctionContext(); + activityInfrastructure = auctionContext != null ? auctionContext.getActivityInfrastructure() : null; + activityInvocationPayload = auctionContext != null + ? BidRequestActivityInvocationPayload.of( + activityInvocationPayload(adapter), + auctionContext.getBidRequest()) + : null; + } + case AmpEvent ampEvent -> { + final AuctionContext auctionContext = ampEvent.getAuctionContext(); + activityInfrastructure = auctionContext != null ? auctionContext.getActivityInfrastructure() : null; + activityInvocationPayload = auctionContext != null + ? BidRequestActivityInvocationPayload.of( + activityInvocationPayload(adapter), + auctionContext.getBidRequest()) + : null; + } + case NotificationEvent notificationEvent -> { + activityInfrastructure = notificationEvent.getActivityInfrastructure(); + activityInvocationPayload = activityInvocationPayload(adapter); + } + case null, default -> { + activityInfrastructure = null; + activityInvocationPayload = null; + } } return isAllowedActivity(activityInfrastructure, Activity.REPORT_ANALYTICS, activityInvocationPayload); @@ -318,23 +323,15 @@ private Future processFail(Throwable exception, T event, String report } private void updateMetricsByEventType(T event, String analyticsCode, MetricName result) { - final MetricName eventType; - - if (event instanceof AmpEvent) { - eventType = MetricName.event_amp; - } else if (event instanceof AuctionEvent) { - eventType = MetricName.event_auction; - } else if (event instanceof CookieSyncEvent) { - eventType = MetricName.event_cookie_sync; - } else if (event instanceof NotificationEvent) { - eventType = MetricName.event_notification; - } else if (event instanceof SetuidEvent) { - eventType = MetricName.event_setuid; - } else if (event instanceof VideoEvent) { - eventType = MetricName.event_video; - } else { - eventType = MetricName.event_unknown; - } + final MetricName eventType = switch (event) { + case AmpEvent ampEvent -> MetricName.event_amp; + case AuctionEvent auctionEvent -> MetricName.event_auction; + case CookieSyncEvent cookieSyncEvent -> MetricName.event_cookie_sync; + case NotificationEvent notificationEvent -> MetricName.event_notification; + case SetuidEvent setuidEvent -> MetricName.event_setuid; + case VideoEvent videoEvent -> MetricName.event_video; + case null, default -> MetricName.event_unknown; + }; metrics.updateAnalyticEventMetric(analyticsCode, eventType, result); } diff --git a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java index 070bea19992..63f8a364dd6 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/log/LogAnalyticsReporter.java @@ -30,25 +30,18 @@ public LogAnalyticsReporter(JacksonMapper mapper) { @Override public Future processEvent(T event) { - final LogEvent logEvent; - - if (event instanceof AmpEvent ampEvent) { - logEvent = LogEvent.of("/openrtb2/amp", ampEvent.getBidResponse()); - } else if (event instanceof AuctionEvent auctionEvent) { - logEvent = LogEvent.of("/openrtb2/auction", auctionEvent.getBidResponse()); - } else if (event instanceof CookieSyncEvent cookieSyncEvent) { - logEvent = LogEvent.of("/cookie_sync", cookieSyncEvent.getBidderStatus()); - } else if (event instanceof NotificationEvent notificationEvent) { - logEvent = LogEvent.of("/event", notificationEvent.getType() + notificationEvent.getBidId()); - } else if (event instanceof SetuidEvent setuidEvent) { - logEvent = LogEvent.of( + final LogEvent logEvent = switch (event) { + case AmpEvent ampEvent -> LogEvent.of("/openrtb2/amp", ampEvent.getBidResponse()); + case AuctionEvent auctionEvent -> LogEvent.of("/openrtb2/auction", auctionEvent.getBidResponse()); + case CookieSyncEvent cookieSyncEvent -> LogEvent.of("/cookie_sync", cookieSyncEvent.getBidderStatus()); + case NotificationEvent notificationEvent -> + LogEvent.of("/event", notificationEvent.getType() + notificationEvent.getBidId()); + case SetuidEvent setuidEvent -> LogEvent.of( "/setuid", setuidEvent.getBidder() + ":" + setuidEvent.getUid() + ":" + setuidEvent.getSuccess()); - } else if (event instanceof VideoEvent videoEvent) { - logEvent = LogEvent.of("/openrtb2/video", videoEvent.getBidResponse()); - } else { - logEvent = LogEvent.of("unknown", null); - } + case VideoEvent videoEvent -> LogEvent.of("/openrtb2/video", videoEvent.getBidResponse()); + case null, default -> LogEvent.of("unknown", null); + }; logger.debug(mapper.encodeToString(logEvent)); diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java index 09daf73343d..0bddcbe05ca 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackAnalyticsReporter.java @@ -89,23 +89,15 @@ private static String buildEventEndpointUrl(String endpoint, EventType eventType @Override public Future processEvent(T event) { - final EventType eventType; - - if (event instanceof AmpEvent) { - eventType = EventType.amp; - } else if (event instanceof AuctionEvent) { - eventType = EventType.auction; - } else if (event instanceof CookieSyncEvent) { - eventType = EventType.cookiesync; - } else if (event instanceof NotificationEvent) { - eventType = EventType.notification; - } else if (event instanceof SetuidEvent) { - eventType = EventType.setuid; - } else if (event instanceof VideoEvent) { - eventType = EventType.video; - } else { - eventType = null; - } + final EventType eventType = switch (event) { + case AmpEvent ampEvent -> EventType.amp; + case AuctionEvent auctionEvent -> EventType.auction; + case CookieSyncEvent cookieSyncEvent -> EventType.cookiesync; + case NotificationEvent notificationEvent -> EventType.notification; + case SetuidEvent setuidEvent -> EventType.setuid; + case VideoEvent videoEvent -> EventType.video; + case null, default -> null; + }; if (eventType != null) { eventHandlers.get(eventType).handle(event); diff --git a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java index 8c77665bede..3dc927ba0bf 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java +++ b/src/main/java/org/prebid/server/analytics/reporter/pubstack/PubstackEventHandler.java @@ -89,7 +89,7 @@ public void handle(T event) { public void reportEvents() { if (enabled) { - reportEventsOnCondition(events -> events.get().size() > 0, events); + reportEventsOnCondition(events -> !events.get().isEmpty(), events); } } @@ -179,7 +179,7 @@ private long setReportTtlTimer() { } private void sendOnTimer() { - final boolean requestWasSent = reportEventsOnCondition(events -> events.get().size() > 0, events); + final boolean requestWasSent = reportEventsOnCondition(events -> !events.get().isEmpty(), events); if (!requestWasSent) { setReportTtlTimer(); } diff --git a/src/main/java/org/prebid/server/auction/BidResponseCreator.java b/src/main/java/org/prebid/server/auction/BidResponseCreator.java index c1ccc7922f9..7d54153883c 100644 --- a/src/main/java/org/prebid/server/auction/BidResponseCreator.java +++ b/src/main/java/org/prebid/server/auction/BidResponseCreator.java @@ -501,7 +501,7 @@ private Future cacheBidsAndCreateResponse(List return Future.succeededFuture(BidResponse.builder() .id(bidRequest.getId()) - .cur(bidRequest.getCur().get(0)) + .cur(bidRequest.getCur().getFirst()) .nbr(0) // signal "Unknown Error" .seatbid(Collections.emptyList()) .ext(extBidResponse) @@ -1130,7 +1130,7 @@ private BidResponse toBidResponse(List bidderResponseInfos, return BidResponse.builder() .id(bidRequest.getId()) - .cur(bidRequest.getCur().get(0)) + .cur(bidRequest.getCur().getFirst()) .seatbid(seatBids) .ext(extBidResponse) .build(); diff --git a/src/main/java/org/prebid/server/auction/ExchangeService.java b/src/main/java/org/prebid/server/auction/ExchangeService.java index be303320f51..34ce0addc5f 100644 --- a/src/main/java/org/prebid/server/auction/ExchangeService.java +++ b/src/main/java/org/prebid/server/auction/ExchangeService.java @@ -839,7 +839,7 @@ private AuctionParticipation createAuctionParticipation( final OrtbVersion ortbVersion = bidderSupportedOrtbVersion(bidder, bidderAliases); // stored bid response supported only for single imp requests final String storedBidResponse = impBidderToStoredBidResponse.size() == 1 - ? impBidderToStoredBidResponse.get(imps.get(0).getId()).get(bidder) + ? impBidderToStoredBidResponse.get(imps.getFirst().getId()).get(bidder) : null; final BidRequest preparedBidRequest = prepareBidRequest( bidderPrivacyResult, @@ -1460,7 +1460,7 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar final List requestCurrencies = bidRequest.getCur(); if (requestCurrencies.size() > 1) { errors.add(BidderError.badInput("Cur parameter contains more than one currency. %s will be used" - .formatted(requestCurrencies.get(0)))); + .formatted(requestCurrencies.getFirst()))); } final List bids = seatBid.getBids(); @@ -1526,7 +1526,7 @@ private AuctionParticipation applyBidPriceChanges(AuctionParticipation auctionPa final List updatedBidderBids = new ArrayList<>(bidderBids.size()); final List errors = new ArrayList<>(seatBid.getErrors()); - final String adServerCurrency = bidRequest.getCur().get(0); + final String adServerCurrency = bidRequest.getCur().getFirst(); for (final BidderBid bidderBid : bidderBids) { try { diff --git a/src/main/java/org/prebid/server/auction/InterstitialProcessor.java b/src/main/java/org/prebid/server/auction/InterstitialProcessor.java index dd523aff4f6..af31064f99d 100644 --- a/src/main/java/org/prebid/server/auction/InterstitialProcessor.java +++ b/src/main/java/org/prebid/server/auction/InterstitialProcessor.java @@ -55,7 +55,7 @@ private Imp processInterstitialImp(Imp imp, Device device, int minWidthPerc, int } final List formats = banner.getFormat(); - final Format firstFormat = CollectionUtils.isEmpty(formats) ? null : formats.get(0); + final Format firstFormat = CollectionUtils.isEmpty(formats) ? null : formats.getFirst(); Integer maxHeight = firstFormat != null ? firstFormat.getH() : null; Integer maxWidth = firstFormat != null ? firstFormat.getW() : null; diff --git a/src/main/java/org/prebid/server/auction/StoredResponseProcessor.java b/src/main/java/org/prebid/server/auction/StoredResponseProcessor.java index 466c1197527..502fcf8849e 100644 --- a/src/main/java/org/prebid/server/auction/StoredResponseProcessor.java +++ b/src/main/java/org/prebid/server/auction/StoredResponseProcessor.java @@ -121,7 +121,7 @@ private static AuctionParticipation updateStoredBidResponse(AuctionParticipation final BidderResponse bidderResponse = auctionParticipation.getBidderResponse(); final BidderSeatBid initialSeatBid = bidderResponse.getSeatBid(); - final BidderSeatBid adjustedSeatBid = updateSeatBid(initialSeatBid, imps.get(0).getId()); + final BidderSeatBid adjustedSeatBid = updateSeatBid(initialSeatBid, imps.getFirst().getId()); return auctionParticipation.with(bidderResponse.with(adjustedSeatBid)); } diff --git a/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java b/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java index 41e8bd02a91..b13cf522b49 100644 --- a/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java +++ b/src/main/java/org/prebid/server/auction/categorymapping/BasicCategoryMappingService.java @@ -205,7 +205,7 @@ private Future resolveCategory(String primaryAdServer, return Future.failedFuture( new RejectedBidException(bid.getId(), bidder, "Bid has more than one category")); } - final String category = CollectionUtils.isNotEmpty(iabCategories) ? iabCategories.get(0) : null; + final String category = CollectionUtils.isNotEmpty(iabCategories) ? iabCategories.getFirst() : null; if (StringUtils.isBlank(category)) { return Future.failedFuture( new RejectedBidException(bid.getId(), bidder, "Bid did not contain a category")); @@ -556,7 +556,7 @@ private Integer resolveDuration(List durations, BidderBid bidderBid, St final String bidId = bidderBid.getBid().getId(); - final int maxDuration = durations.get(durations.size() - 1); + final int maxDuration = durations.getLast(); if (duration > maxDuration) { throw new RejectedBidException( bidId, bidder, "Bid duration '%s' exceeds maximum '%s'".formatted(duration, maxDuration)); diff --git a/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java index 76c8b921196..b4e6061e1da 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/AmpRequestFactory.java @@ -454,7 +454,7 @@ private static BidRequest validateStoredBidRequest(String tagId, BidRequest bidR private BidRequest fillExplicitParameters(BidRequest bidRequest) { final List imps = bidRequest.getImp(); // Force HTTPS as AMP requires it, but pubs can forget to set it. - final Imp imp = imps.get(0); + final Imp imp = imps.getFirst(); final Integer secure = imp.getSecure(); final boolean setSecure = secure == null || secure != 1; @@ -485,7 +485,7 @@ private BidRequest fillExplicitParameters(BidRequest bidRequest) { || setDefaultCache) { result = bidRequest.toBuilder() - .imp(setSecure ? Collections.singletonList(imps.get(0).toBuilder().secure(1).build()) : imps) + .imp(setSecure ? Collections.singletonList(imps.getFirst().toBuilder().secure(1).build()) : imps) .ext(extRequest( bidRequest, setDefaultTargeting, @@ -507,7 +507,7 @@ private BidRequest overrideParameters(BidRequest bidRequest, HttpRequestContext ortbTypesResolver.normalizeTargeting(targetingNode, errors, referer); final Site updatedSite = overrideSite(bidRequest.getSite()); - final Imp updatedImp = overrideImp(bidRequest.getImp().get(0), httpRequest, targetingNode); + final Imp updatedImp = overrideImp(bidRequest.getImp().getFirst(), httpRequest, targetingNode); if (ObjectUtils.anyNotNull(updatedSite, updatedImp)) { return bidRequest.toBuilder() diff --git a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java index b751cd3aea4..02d2632d6d6 100644 --- a/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java +++ b/src/main/java/org/prebid/server/bidder/HttpBidderRequester.java @@ -110,7 +110,7 @@ public Future requestBids(Bidder bidder, // stored response available only for single request interaction for the moment. final Stream>> httpCalls = isStoredResponse(httpRequests, storedResponse, bidderName) - ? Stream.of(makeStoredHttpCall(httpRequests.get(0), storedResponse)) + ? Stream.of(makeStoredHttpCall(httpRequests.getFirst(), storedResponse)) : httpRequests.stream().map(httpRequest -> doRequest(httpRequest, timeout)); // httpCalls contains recovered and mapped to succeeded Future with error inside diff --git a/src/main/java/org/prebid/server/bidder/aceex/AceexBidder.java b/src/main/java/org/prebid/server/bidder/aceex/AceexBidder.java index e5a616ab05d..841d888e064 100644 --- a/src/main/java/org/prebid/server/bidder/aceex/AceexBidder.java +++ b/src/main/java/org/prebid/server/bidder/aceex/AceexBidder.java @@ -45,7 +45,7 @@ public AceexBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { - final Imp firstImp = request.getImp().get(0); + final Imp firstImp = request.getImp().getFirst(); final ExtImpAceex extImpAceex; try { @@ -96,7 +96,7 @@ public final Result> makeBids(BidderCall httpCall, B private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { final List seatBids = ObjectUtil.getIfNotNull(bidResponse, BidResponse::getSeatbid); - final SeatBid firstSeatBid = CollectionUtils.isNotEmpty(seatBids) ? seatBids.get(0) : null; + final SeatBid firstSeatBid = CollectionUtils.isNotEmpty(seatBids) ? seatBids.getFirst() : null; if (firstSeatBid == null) { throw new PreBidException("Empty SeatBid array"); } diff --git a/src/main/java/org/prebid/server/bidder/acuityads/AcuityadsBidder.java b/src/main/java/org/prebid/server/bidder/acuityads/AcuityadsBidder.java index 4bd41d15c86..f44d3d6f934 100644 --- a/src/main/java/org/prebid/server/bidder/acuityads/AcuityadsBidder.java +++ b/src/main/java/org/prebid/server/bidder/acuityads/AcuityadsBidder.java @@ -53,7 +53,7 @@ public Result>> makeHttpRequests(BidRequest request final String url; try { - extImpAcuityads = parseImpExt(request.getImp().get(0)); + extImpAcuityads = parseImpExt(request.getImp().getFirst()); url = resolveEndpoint(extImpAcuityads.getHost(), extImpAcuityads.getAccountId()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); @@ -140,7 +140,7 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); final List bids = firstSeatBid.getBid(); if (CollectionUtils.isEmpty(bids)) { diff --git a/src/main/java/org/prebid/server/bidder/adelement/AdelementBidder.java b/src/main/java/org/prebid/server/bidder/adelement/AdelementBidder.java index ded4e7ef685..c7e0443407b 100644 --- a/src/main/java/org/prebid/server/bidder/adelement/AdelementBidder.java +++ b/src/main/java/org/prebid/server/bidder/adelement/AdelementBidder.java @@ -43,7 +43,7 @@ public AdelementBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - final Imp firstImp = bidRequest.getImp().get(0); + final Imp firstImp = bidRequest.getImp().getFirst(); final ExtImpAdelement extImpAdelement; try { @@ -71,7 +71,7 @@ private String resolveEndpoint(String supplyId) { public Result> makeBids(BidderCall httpCall, BidRequest bidRequest) { try { final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return Result.withValues(extractBids(httpCall.getRequest().getPayload(), bidResponse)); + return Result.withValues(extractBids(bidResponse)); } catch (DecodeException e) { return Result.withError(BidderError.badServerResponse("Bad Server Response")); } catch (PreBidException e) { @@ -79,14 +79,14 @@ public Result> makeBids(BidderCall httpCall, BidRequ } } - private static List extractBids(BidRequest bidRequest, BidResponse bidResponse) { + private static List extractBids(BidResponse bidResponse) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); } - return bidsFromResponse(bidRequest, bidResponse); + return bidsFromResponse(bidResponse); } - private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { + private static List bidsFromResponse(BidResponse bidResponse) { return bidResponse.getSeatbid().stream() .filter(Objects::nonNull) .map(SeatBid::getBid) diff --git a/src/main/java/org/prebid/server/bidder/adgeneration/AdgenerationBidder.java b/src/main/java/org/prebid/server/bidder/adgeneration/AdgenerationBidder.java index d859ca2ae3d..22fc3dc5309 100644 --- a/src/main/java/org/prebid/server/bidder/adgeneration/AdgenerationBidder.java +++ b/src/main/java/org/prebid/server/bidder/adgeneration/AdgenerationBidder.java @@ -152,7 +152,7 @@ private static String getCurrency(BidRequest bidRequest) { final List currencies = bidRequest.getCur(); return CollectionUtils.isEmpty(currencies) ? DEFAULT_REQUEST_CURRENCY - : currencies.contains(DEFAULT_REQUEST_CURRENCY) ? DEFAULT_REQUEST_CURRENCY : currencies.get(0); + : currencies.contains(DEFAULT_REQUEST_CURRENCY) ? DEFAULT_REQUEST_CURRENCY : currencies.getFirst(); } private static HttpRequest createSingleRequest(String uri, Device device) { diff --git a/src/main/java/org/prebid/server/bidder/adhese/AdheseBidder.java b/src/main/java/org/prebid/server/bidder/adhese/AdheseBidder.java index 7ad12b530aa..29ee5177d40 100644 --- a/src/main/java/org/prebid/server/bidder/adhese/AdheseBidder.java +++ b/src/main/java/org/prebid/server/bidder/adhese/AdheseBidder.java @@ -58,7 +58,7 @@ public Result>> makeHttpRequests(BidRequest request final ExtImpAdhese extImpAdhese; try { - extImpAdhese = parseImpExt(request.getImp().get(0)); + extImpAdhese = parseImpExt(request.getImp().getFirst()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); } @@ -89,7 +89,7 @@ private BidRequest modifyBidRequest(BidRequest bidRequest, ExtImpAdhese extImpAd final ObjectNode adheseExtInnerNode = mapper.mapper().valueToTree(parameterMap); final ObjectNode adheseExtNode = mapper.mapper().createObjectNode().set("adhese", adheseExtInnerNode); - final Imp imp = bidRequest.getImp().get(0).toBuilder() + final Imp imp = bidRequest.getImp().getFirst().toBuilder() .ext(adheseExtNode) .build(); @@ -166,7 +166,7 @@ private static BidType getBidType(BidRequest bidRequest) { throw new PreBidException("No Imps available"); } - final Imp firstImp = impList.get(0); + final Imp firstImp = impList.getFirst(); if (firstImp.getBanner() != null) { return BidType.banner; } else if (firstImp.getVideo() != null) { diff --git a/src/main/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidder.java b/src/main/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidder.java index 5a762d81ec4..886a4a9ec48 100644 --- a/src/main/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidder.java +++ b/src/main/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidder.java @@ -40,7 +40,6 @@ public class AdkernelAdnBidder implements Bidder { private static final TypeReference> ADKERNELADN_EXT_TYPE_REFERENCE = new TypeReference<>() { }; - private static final String DEFAULT_DOMAIN = "tag.adkernel.com"; private static final String URL_PUBLISHER_ID_MACRO = "{{PublisherID}}"; private final String endpointUrl; @@ -141,7 +140,7 @@ private static void compatBannerImpression(Imp.ImpBuilder impBuilder, Banner com throw new PreBidException("Expected at least one banner.format entry or explicit w/h"); } - final Format format = compatBannerFormat.get(0); + final Format format = compatBannerFormat.getFirst(); final Banner.BannerBuilder bannerBuilder = compatBanner.toBuilder(); if (compatBannerFormat.size() > 1) { diff --git a/src/main/java/org/prebid/server/bidder/admixer/AdmixerBidder.java b/src/main/java/org/prebid/server/bidder/admixer/AdmixerBidder.java index 19423e13ef7..4ddb522f74f 100644 --- a/src/main/java/org/prebid/server/bidder/admixer/AdmixerBidder.java +++ b/src/main/java/org/prebid/server/bidder/admixer/AdmixerBidder.java @@ -119,7 +119,7 @@ public Result> makeBids(BidderCall httpCall, BidRequ if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid()) - || CollectionUtils.isEmpty(bidResponse.getSeatbid().get(0).getBid())) { + || CollectionUtils.isEmpty(bidResponse.getSeatbid().getFirst().getBid())) { return Result.empty(); } diff --git a/src/main/java/org/prebid/server/bidder/adnuntius/AdnuntiusBidder.java b/src/main/java/org/prebid/server/bidder/adnuntius/AdnuntiusBidder.java index e97db214f3c..d6ab2363a52 100644 --- a/src/main/java/org/prebid/server/bidder/adnuntius/AdnuntiusBidder.java +++ b/src/main/java/org/prebid/server/bidder/adnuntius/AdnuntiusBidder.java @@ -283,10 +283,10 @@ private static AdnuntiusMetaData createMetaData(User user) { .map(User::getExt) .map(ExtUser::getEids) .filter(CollectionUtils::isNotEmpty) - .map(eids -> eids.get(0)) + .map(eids -> eids.getFirst()) .map(Eid::getUids) .filter(CollectionUtils::isNotEmpty) - .map(uids -> uids.get(0)) + .map(uids -> uids.getFirst()) .map(Uid::getId)) .map(AdnuntiusMetaData::of) .orElse(null); @@ -351,7 +351,7 @@ private List extractBids(BidRequest bidRequest, AdnuntiusResponse adn continue; } - final AdnuntiusAd ad = adsUnit.getAds().get(0); + final AdnuntiusAd ad = adsUnit.getAds().getFirst(); final String impId = imp.getId(); final String bidType = extImpAdnuntius.getBidType(); currency = ObjectUtil.getIfNotNull(ad.getBid(), AdnuntiusBid::getCurrency); @@ -371,7 +371,7 @@ private List extractBids(BidRequest bidRequest, AdnuntiusResponse adn private static boolean validateAdsUnit(AdnuntiusAdsUnit adsUnit) { final List ads = adsUnit != null ? adsUnit.getAds() : null; - return CollectionUtils.isNotEmpty(ads) && ads.get(0) != null; + return CollectionUtils.isNotEmpty(ads) && ads.getFirst() != null; } private static Bid createBid(AdnuntiusAd ad, String adm, String impId, String bidType) { diff --git a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java index 1c406402069..49bbb0456b8 100644 --- a/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java +++ b/src/main/java/org/prebid/server/bidder/adot/AdotBidder.java @@ -56,7 +56,7 @@ public AdotBidder(String endpointUrl, JacksonMapper mapper) { public Result>> makeHttpRequests(BidRequest bidRequest) { final List errors = new ArrayList<>(); - final Imp firstImp = bidRequest.getImp().get(0); + final Imp firstImp = bidRequest.getImp().getFirst(); final String publisherPath = StringUtils.defaultString( ObjectUtil.getIfNotNull(parseImpExt(firstImp), ExtImpAdot::getPublisherPath)); diff --git a/src/main/java/org/prebid/server/bidder/adpone/AdponeBidder.java b/src/main/java/org/prebid/server/bidder/adpone/AdponeBidder.java index 21bf160eab6..42e5534a6e8 100644 --- a/src/main/java/org/prebid/server/bidder/adpone/AdponeBidder.java +++ b/src/main/java/org/prebid/server/bidder/adpone/AdponeBidder.java @@ -37,7 +37,7 @@ public AdponeBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest bidRequest) { try { - mapper.mapper().convertValue(bidRequest.getImp().get(0).getExt().get("bidder"), ExtImpAdpone.class); + mapper.mapper().convertValue(bidRequest.getImp().getFirst().getExt().get("bidder"), ExtImpAdpone.class); } catch (IllegalArgumentException e) { return Result.withError(BidderError.badInput(e.getMessage())); } diff --git a/src/main/java/org/prebid/server/bidder/adtarget/AdtargetBidder.java b/src/main/java/org/prebid/server/bidder/adtarget/AdtargetBidder.java index b5d23fc60fe..606fc880894 100644 --- a/src/main/java/org/prebid/server/bidder/adtarget/AdtargetBidder.java +++ b/src/main/java/org/prebid/server/bidder/adtarget/AdtargetBidder.java @@ -98,7 +98,7 @@ private static void validateImpression(Imp imp) { } final ObjectNode impExt = imp.getExt(); - if (impExt == null || impExt.size() == 0) { + if (impExt == null || impExt.isEmpty()) { throw new PreBidException("ignoring imp id=%s, extImpBidder is empty".formatted(impId)); } } diff --git a/src/main/java/org/prebid/server/bidder/adtelligent/AdtelligentBidder.java b/src/main/java/org/prebid/server/bidder/adtelligent/AdtelligentBidder.java index 95ec877d975..1c88bed9005 100644 --- a/src/main/java/org/prebid/server/bidder/adtelligent/AdtelligentBidder.java +++ b/src/main/java/org/prebid/server/bidder/adtelligent/AdtelligentBidder.java @@ -156,7 +156,7 @@ private void validateImpression(Imp imp) { } final ObjectNode impExt = imp.getExt(); - if (impExt == null || impExt.size() == 0) { + if (impExt == null || impExt.isEmpty()) { throw new PreBidException("ignoring imp id=%s, extImpBidder is empty".formatted(impId)); } } diff --git a/src/main/java/org/prebid/server/bidder/advangelists/AdvangelistsBidder.java b/src/main/java/org/prebid/server/bidder/advangelists/AdvangelistsBidder.java index 7c071ac370e..0075573bbc8 100644 --- a/src/main/java/org/prebid/server/bidder/advangelists/AdvangelistsBidder.java +++ b/src/main/java/org/prebid/server/bidder/advangelists/AdvangelistsBidder.java @@ -127,7 +127,7 @@ private static Banner modifyImpBanner(Banner banner) { } final List formatSkipFirst = bannerFormats.subList(1, bannerFormats.size()); - final Format firstFormat = bannerFormats.get(0); + final Format firstFormat = bannerFormats.getFirst(); return banner.toBuilder() .format(formatSkipFirst) @@ -211,7 +211,7 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); final List bids = firstSeatBid.getBid(); if (CollectionUtils.isEmpty(bids)) { diff --git a/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java b/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java index 89973ed8437..8c1de16d03d 100644 --- a/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java +++ b/src/main/java/org/prebid/server/bidder/adview/AdviewBidder.java @@ -122,7 +122,7 @@ private static Imp modifyImp(Imp imp, String masterTagId, Price bidFloorPrice) { private static Banner resolveBanner(Banner banner) { final List formats = banner != null ? banner.getFormat() : null; if (CollectionUtils.isNotEmpty(formats)) { - final Format firstFormat = formats.get(0); + final Format firstFormat = formats.getFirst(); return firstFormat != null ? banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build() : banner; diff --git a/src/main/java/org/prebid/server/bidder/adyoulike/AdyoulikeBidder.java b/src/main/java/org/prebid/server/bidder/adyoulike/AdyoulikeBidder.java index 4c13f48efcf..4c0b4510f80 100644 --- a/src/main/java/org/prebid/server/bidder/adyoulike/AdyoulikeBidder.java +++ b/src/main/java/org/prebid/server/bidder/adyoulike/AdyoulikeBidder.java @@ -70,7 +70,7 @@ public Result>> makeHttpRequests(BidRequest request } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { return Result.withErrors(errors); } diff --git a/src/main/java/org/prebid/server/bidder/aidem/AidemBidder.java b/src/main/java/org/prebid/server/bidder/aidem/AidemBidder.java index f78e7ebeffc..2a1c1aced68 100644 --- a/src/main/java/org/prebid/server/bidder/aidem/AidemBidder.java +++ b/src/main/java/org/prebid/server/bidder/aidem/AidemBidder.java @@ -46,7 +46,7 @@ public AidemBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { try { - final ExtImpAidem impExt = parseImpExt(bidRequest.getImp().get(0)); + final ExtImpAidem impExt = parseImpExt(bidRequest.getImp().getFirst()); return Result.withValue(BidderUtil.defaultRequest(bidRequest, makeUrl(impExt), mapper)); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); @@ -93,12 +93,12 @@ private static List extractBids(BidRequest bidRequest, .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(Objects::nonNull) - .map(bid -> makeBidderBid(bid, bidRequest.getImp(), bidResponse.getCur(), errors)) + .map(bid -> makeBidderBid(bid, bidResponse.getCur(), errors)) .filter(Objects::nonNull) .toList(); } - private static BidderBid makeBidderBid(Bid bid, List imps, String currency, List errors) { + private static BidderBid makeBidderBid(Bid bid, String currency, List errors) { try { return BidderBid.of(bid, resolveBidType(bid), currency); } catch (PreBidException e) { diff --git a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java index 0ddf5827f9a..b2b02f4b3bb 100644 --- a/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java +++ b/src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java @@ -115,7 +115,7 @@ private Imp updateBannerImp(Imp imp) { final Banner banner = imp.getBanner(); if (!(isValidSizeValue(banner.getW()) && isValidSizeValue(banner.getH())) && CollectionUtils.isNotEmpty(banner.getFormat())) { - final Format firstFormat = banner.getFormat().get(FIRST_INDEX); + final Format firstFormat = banner.getFormat().getFirst(); return imp.toBuilder() .banner(banner.toBuilder() .w(firstFormat.getW()) diff --git a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java index 053b87c5ec2..8fe709d9ecc 100644 --- a/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java +++ b/src/main/java/org/prebid/server/bidder/appnexus/AppnexusBidder.java @@ -218,7 +218,7 @@ private static Banner updateBanner(Banner banner, ExtImpAppnexus extImpAppnexus) final Integer height = banner.getH(); final List formats = banner.getFormat(); final Format firstFormat = CollectionUtils.isNotEmpty(formats) - ? formats.get(0) + ? formats.getFirst() : null; final boolean replaceWithFirstFormat = firstFormat != null && width == null && height == null; diff --git a/src/main/java/org/prebid/server/bidder/axis/AxisBidder.java b/src/main/java/org/prebid/server/bidder/axis/AxisBidder.java index f038aec67fe..d5f2a867f8c 100644 --- a/src/main/java/org/prebid/server/bidder/axis/AxisBidder.java +++ b/src/main/java/org/prebid/server/bidder/axis/AxisBidder.java @@ -53,7 +53,7 @@ public Result>> makeHttpRequests(BidRequest request } catch (PreBidException e) { continue; } - httpRequests.add(makeRequest(request, imp, extImpAxis)); + httpRequests.add(makeRequest(request, imp)); } return Result.withValues(httpRequests); @@ -67,7 +67,7 @@ private ExtImpAxis parseImpExt(Imp imp) { } } - private HttpRequest makeRequest(BidRequest bidRequest, Imp imp, ExtImpAxis extImpAxis) { + private HttpRequest makeRequest(BidRequest bidRequest, Imp imp) { final BidRequest modifyBidRequest = bidRequest.toBuilder() .imp(Collections.singletonList(imp)) .build(); diff --git a/src/main/java/org/prebid/server/bidder/axonix/AxonixBidder.java b/src/main/java/org/prebid/server/bidder/axonix/AxonixBidder.java index 7894a0bb274..7bbc9cb1463 100644 --- a/src/main/java/org/prebid/server/bidder/axonix/AxonixBidder.java +++ b/src/main/java/org/prebid/server/bidder/axonix/AxonixBidder.java @@ -49,7 +49,7 @@ public AxonixBidder(String endpointUrl, JacksonMapper mapper) { public Result>> makeHttpRequests(BidRequest request) { final ExtImpAxonix extImpAxonix; try { - extImpAxonix = parseImpExt(request.getImp().get(0)); + extImpAxonix = parseImpExt(request.getImp().getFirst()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); } diff --git a/src/main/java/org/prebid/server/bidder/beachfront/BeachfrontBidder.java b/src/main/java/org/prebid/server/bidder/beachfront/BeachfrontBidder.java index 5ea46e61611..f9bdfa88e78 100644 --- a/src/main/java/org/prebid/server/bidder/beachfront/BeachfrontBidder.java +++ b/src/main/java/org/prebid/server/bidder/beachfront/BeachfrontBidder.java @@ -152,7 +152,7 @@ private String resolveVideoUri(String appId, Boolean isPrebid) { private static boolean checkFormats(Banner banner) { final List formats = banner != null ? banner.getFormat() : null; - final Format firstFormat = CollectionUtils.isNotEmpty(formats) ? formats.get(0) : null; + final Format firstFormat = CollectionUtils.isNotEmpty(formats) ? formats.getFirst() : null; final boolean isHeightNonZero = firstFormat != null && !Objects.equals(firstFormat.getH(), 0); final boolean isWidthNonZero = firstFormat != null && !Objects.equals(firstFormat.getW(), 0); return isHeightNonZero && isWidthNonZero; @@ -207,7 +207,7 @@ private BeachfrontBannerRequest getBannerRequest(BidRequest bidRequest, } final Site site = bidRequest.getSite(); - final Integer firstImpSecure = bannerImps.get(0).getSecure(); + final Integer firstImpSecure = bannerImps.getFirst().getSecure(); if (site != null) { final String page = site.getPage(); @@ -503,7 +503,7 @@ private List processVideoResponse(String responseBody, HttpRequest bids = bidResponse.getSeatbid().get(0).getBid(); + final List bids = bidResponse.getSeatbid().getFirst().getBid(); final List updatedBids = httpRequest.getUri().contains(NURL_VIDEO_ENDPOINT_SUFFIX) ? updateNurlVideoBids(bids, videoRequest.getRequest().getImp()) : updateVideoBids(bids); @@ -556,7 +556,7 @@ private BidderBid updateBidderBid(BidderBid bidderBid) { } final List cat = bid.getCat(); - final String primaryCategory = CollectionUtils.isNotEmpty(cat) ? cat.get(0) : null; + final String primaryCategory = CollectionUtils.isNotEmpty(cat) ? cat.getFirst() : null; final Bid resolvedBid = bid.toBuilder().ext(resolveBidExt(duration, primaryCategory)).build(); return BidderBid.of(resolvedBid, bidderBid.getType(), bidderBid.getBidCurrency()); diff --git a/src/main/java/org/prebid/server/bidder/beintoo/BeintooBidder.java b/src/main/java/org/prebid/server/bidder/beintoo/BeintooBidder.java index 0b8af084ada..eb3eb6a27e7 100644 --- a/src/main/java/org/prebid/server/bidder/beintoo/BeintooBidder.java +++ b/src/main/java/org/prebid/server/bidder/beintoo/BeintooBidder.java @@ -141,7 +141,7 @@ private static Banner modifyImpBanner(Banner banner) { final List formatSkipFirst = originalFormat.subList(1, originalFormat.size()); bannerBuilder.format(formatSkipFirst); - final Format firstFormat = originalFormat.get(0); + final Format firstFormat = originalFormat.getFirst(); bannerBuilder.w(firstFormat.getW()); bannerBuilder.h(firstFormat.getH()); diff --git a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java index 101fb1f75a5..a795a3efbb9 100644 --- a/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java +++ b/src/main/java/org/prebid/server/bidder/between/BetweenBidder.java @@ -119,7 +119,7 @@ private static Imp modifyImp(Imp imp, Integer secure) { private static Banner resolveBanner(Banner banner) { if (banner.getW() == null && banner.getH() == null) { final List bannerFormat = banner.getFormat(); - final Format firstFormat = bannerFormat.get(0); + final Format firstFormat = bannerFormat.getFirst(); final List formatSkipFirst = bannerFormat.subList(1, bannerFormat.size()); return banner.toBuilder() .format(formatSkipFirst) diff --git a/src/main/java/org/prebid/server/bidder/bidmyadz/BidmyadzBidder.java b/src/main/java/org/prebid/server/bidder/bidmyadz/BidmyadzBidder.java index ce06699d970..e871390d01e 100644 --- a/src/main/java/org/prebid/server/bidder/bidmyadz/BidmyadzBidder.java +++ b/src/main/java/org/prebid/server/bidder/bidmyadz/BidmyadzBidder.java @@ -90,13 +90,13 @@ private BidderBid extractBids(BidResponse bidResponse) { } private BidderBid bidsFromResponse(BidResponse bidResponse) { - final List bids = bidResponse.getSeatbid().get(0).getBid(); + final List bids = bidResponse.getSeatbid().getFirst().getBid(); if (CollectionUtils.isEmpty(bids)) { throw new PreBidException("Empty SeatBid.Bids"); } - final Bid bid = bids.get(0); + final Bid bid = bids.getFirst(); return BidderBid.of(bid, getBidType(bid.getExt()), bidResponse.getCur()); } diff --git a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java index 201c782c409..0a3997e9074 100644 --- a/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java +++ b/src/main/java/org/prebid/server/bidder/bidstack/BidstackBidder.java @@ -130,7 +130,8 @@ private BigDecimal convertBidFloorCurrency(BigDecimal bidFloor, } private MultiMap constructHeaders(BidRequest bidRequest) { - final String publishedId = StringUtils.defaultString(parseExtImp(bidRequest.getImp().get(0)).getPublisherId()); + final String publishedId = StringUtils.defaultString( + parseExtImp(bidRequest.getImp().getFirst()).getPublisherId()); return HttpUtil.headers() .add(HttpUtil.AUTHORIZATION_HEADER.toString(), "Bearer " + publishedId); } diff --git a/src/main/java/org/prebid/server/bidder/bizzclick/BizzclickBidder.java b/src/main/java/org/prebid/server/bidder/bizzclick/BizzclickBidder.java index 19e077624c6..2fc8185e301 100644 --- a/src/main/java/org/prebid/server/bidder/bizzclick/BizzclickBidder.java +++ b/src/main/java/org/prebid/server/bidder/bizzclick/BizzclickBidder.java @@ -53,7 +53,7 @@ public Result>> makeHttpRequests(BidRequest request final List imps = request.getImp(); final ExtImpBizzclick extImpBizzclick; try { - extImpBizzclick = parseImpExt(imps.get(0)); + extImpBizzclick = parseImpExt(imps.getFirst()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); } @@ -134,7 +134,7 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi throw new PreBidException("Empty SeatBid array"); } - final SeatBid seatBid = bidResponse.getSeatbid().get(0); + final SeatBid seatBid = bidResponse.getSeatbid().getFirst(); if (seatBid == null || CollectionUtils.isEmpty(seatBid.getBid())) { return Collections.emptyList(); } diff --git a/src/main/java/org/prebid/server/bidder/bliink/BliinkBidder.java b/src/main/java/org/prebid/server/bidder/bliink/BliinkBidder.java index a66883f4730..18fe5bd5d3a 100644 --- a/src/main/java/org/prebid/server/bidder/bliink/BliinkBidder.java +++ b/src/main/java/org/prebid/server/bidder/bliink/BliinkBidder.java @@ -76,7 +76,7 @@ private static List extractBids(BidRequest bidRequest, return Collections.emptyList(); } - return Optional.ofNullable(bidResponse.getSeatbid().get(0)) + return Optional.ofNullable(bidResponse.getSeatbid().getFirst()) .map(SeatBid::getBid) .orElseGet(Collections::emptyList) .stream() diff --git a/src/main/java/org/prebid/server/bidder/bluesea/BlueSeaBidder.java b/src/main/java/org/prebid/server/bidder/bluesea/BlueSeaBidder.java index 90bd3537eb1..8c93ba9f73d 100644 --- a/src/main/java/org/prebid/server/bidder/bluesea/BlueSeaBidder.java +++ b/src/main/java/org/prebid/server/bidder/bluesea/BlueSeaBidder.java @@ -32,11 +32,9 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.Set; public class BlueSeaBidder implements Bidder { - private static final Set SUPPORTED_BID_TYPES_TEXTUAL = Set.of("banner", "video", "native"); private static final TypeReference> BLUE_SEA_EXT_TYPE_REFERENCE = new TypeReference<>() { }; diff --git a/src/main/java/org/prebid/server/bidder/boldwin/BoldwinBidder.java b/src/main/java/org/prebid/server/bidder/boldwin/BoldwinBidder.java index d0c702d42bf..0ddb3be524d 100644 --- a/src/main/java/org/prebid/server/bidder/boldwin/BoldwinBidder.java +++ b/src/main/java/org/prebid/server/bidder/boldwin/BoldwinBidder.java @@ -129,7 +129,7 @@ private static List extractBids(BidResponse bidResponse) { } private static BidType getBidType(Bid bid) { - final Integer mType = bid.getMtype() != null ? bid.getMtype() : 999; + final int mType = bid.getMtype() != null ? bid.getMtype() : 999; return switch (mType) { case 1 -> BidType.banner; case 2 -> BidType.video; diff --git a/src/main/java/org/prebid/server/bidder/brave/BraveBidder.java b/src/main/java/org/prebid/server/bidder/brave/BraveBidder.java index 7260d454584..0819e42479a 100644 --- a/src/main/java/org/prebid/server/bidder/brave/BraveBidder.java +++ b/src/main/java/org/prebid/server/bidder/brave/BraveBidder.java @@ -50,7 +50,7 @@ public Result>> makeHttpRequests(BidRequest request final String url; try { - final ExtImpBrave extImpBrave = parseImpExt(request.getImp().get(0)); + final ExtImpBrave extImpBrave = parseImpExt(request.getImp().getFirst()); url = resolveEndpoint(extImpBrave.getPlacementId()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); diff --git a/src/main/java/org/prebid/server/bidder/connectad/ConnectadBidder.java b/src/main/java/org/prebid/server/bidder/connectad/ConnectadBidder.java index 6ff542fefe1..b05ac222b00 100644 --- a/src/main/java/org/prebid/server/bidder/connectad/ConnectadBidder.java +++ b/src/main/java/org/prebid/server/bidder/connectad/ConnectadBidder.java @@ -117,10 +117,10 @@ private Imp updateImp(Imp imp, Integer secure, Integer siteId, BigDecimal bidFlo if (CollectionUtils.isEmpty(banner.getFormat())) { throw new PreBidException("At least one size is required"); } - final Format format = banner.getFormat().get(0); + final Format format = banner.getFormat().getFirst(); final List slicedFormatList = new ArrayList<>(banner.getFormat()); - slicedFormatList.remove(0); + slicedFormatList.removeFirst(); updatedImp.banner(banner.toBuilder().format(slicedFormatList).w(format.getW()).h(format.getH()).build()); } diff --git a/src/main/java/org/prebid/server/bidder/deepintent/DeepintentBidder.java b/src/main/java/org/prebid/server/bidder/deepintent/DeepintentBidder.java index 4a848edb85b..d85f782ba03 100644 --- a/src/main/java/org/prebid/server/bidder/deepintent/DeepintentBidder.java +++ b/src/main/java/org/prebid/server/bidder/deepintent/DeepintentBidder.java @@ -78,7 +78,7 @@ private Banner buildImpBanner(Banner banner, String impId) { if (CollectionUtils.isEmpty(banner.getFormat())) { throw new PreBidException("At least one size is required, imp : " + impId); } - final Format format = bannerFormats.get(0); + final Format format = bannerFormats.getFirst(); return banner.toBuilder().w(format.getW()).h(format.getH()).build(); } diff --git a/src/main/java/org/prebid/server/bidder/dmx/DmxBidder.java b/src/main/java/org/prebid/server/bidder/dmx/DmxBidder.java index 281b1a9cb5f..3df9ed64eda 100644 --- a/src/main/java/org/prebid/server/bidder/dmx/DmxBidder.java +++ b/src/main/java/org/prebid/server/bidder/dmx/DmxBidder.java @@ -76,7 +76,7 @@ public Result>> makeHttpRequests(BidRequest request String updatedPublisherId = null; String updatedSellerId = null; try { - final ExtImpDmx extImp = parseImpExt(imps.get(0)); + final ExtImpDmx extImp = parseImpExt(imps.getFirst()); final String extImpPublisherId = extImp.getPublisherId(); updatedPublisherId = StringUtils.isNotBlank(extImpPublisherId) ? extImpPublisherId : extImp.getMemberId(); updatedSellerId = extImp.getSellerId(); @@ -203,7 +203,7 @@ private static Banner resolveBanner(Banner banner) { final List format = banner != null ? banner.getFormat() : null; if ((height == null || width == null) && CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); if (firstFormat != null) { return banner.toBuilder() .w(firstFormat.getW()) diff --git a/src/main/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidder.java b/src/main/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidder.java index c511ba6f371..0c3ce43b489 100644 --- a/src/main/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidder.java +++ b/src/main/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidder.java @@ -197,7 +197,7 @@ private static Banner modifyImpBanner(Banner banner) { final List formatSkipFirst = originalFormat.subList(1, originalFormat.size()); bannerBuilder.format(formatSkipFirst); - final Format firstFormat = originalFormat.get(0); + final Format firstFormat = originalFormat.getFirst(); bannerBuilder.w(firstFormat.getW()); bannerBuilder.h(firstFormat.getH()); diff --git a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java index 276aa0e39b7..77d4d60defb 100644 --- a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java +++ b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java @@ -87,7 +87,7 @@ private BidRequest createOutgoingRequest(BidRequest bidRequest) { modifiedImps.add(modifyImp(imp, impExt)); } - final Imp firstImp = requestImps.get(0); + final Imp firstImp = requestImps.getFirst(); final ExtImpEpsilon extImp = parseImpExt(firstImp, 0); final String siteId = extImp.getSiteId(); final Site requestSite = bidRequest.getSite(); @@ -217,7 +217,7 @@ private List extractBids(BidderCall httpCall) { } private List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); final List bids = firstSeatBid.getBid(); if (CollectionUtils.isEmpty(bids)) { diff --git a/src/main/java/org/prebid/server/bidder/evolution/EvolutionBidder.java b/src/main/java/org/prebid/server/bidder/evolution/EvolutionBidder.java index 378027e8e0f..9bc64b3c12b 100644 --- a/src/main/java/org/prebid/server/bidder/evolution/EvolutionBidder.java +++ b/src/main/java/org/prebid/server/bidder/evolution/EvolutionBidder.java @@ -57,7 +57,7 @@ private List extractBids(BidResponse bidResponse) { } private List bidsFromResponse(BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); return CollectionUtils.emptyIfNull(firstSeatBid.getBid()).stream() .filter(Objects::nonNull) .map(bid -> BidderBid.of(bid, getBidMediaType(bid.getExt()), bidResponse.getCur())) diff --git a/src/main/java/org/prebid/server/bidder/flipp/FlippBidder.java b/src/main/java/org/prebid/server/bidder/flipp/FlippBidder.java index aba3e2b2d1f..7fc42804347 100644 --- a/src/main/java/org/prebid/server/bidder/flipp/FlippBidder.java +++ b/src/main/java/org/prebid/server/bidder/flipp/FlippBidder.java @@ -144,7 +144,7 @@ private static PrebidRequest createPrebidRequest(Imp imp, ExtImpFlipp extImp) { final Format format = Optional.ofNullable(imp.getBanner()) .map(Banner::getFormat) .filter(CollectionUtils::isNotEmpty) - .map(formats -> formats.get(0)) + .map(formats -> formats.getFirst()) .orElse(null); return PrebidRequest.builder() @@ -297,7 +297,7 @@ private static boolean isInlineValid(BidRequest bidRequest, Inline inline) { private static Bid constructBid(Inline inline) { final Prebid prebid = inline.getPrebid(); final Data data = Optional.ofNullable(inline.getContents()) - .map(content -> content.get(0)) + .map(content -> content.getFirst()) .map(Content::getData) .orElse(null); diff --git a/src/main/java/org/prebid/server/bidder/gamma/GammaBidder.java b/src/main/java/org/prebid/server/bidder/gamma/GammaBidder.java index 6a1e1fc7d3c..c92786904f0 100644 --- a/src/main/java/org/prebid/server/bidder/gamma/GammaBidder.java +++ b/src/main/java/org/prebid/server/bidder/gamma/GammaBidder.java @@ -98,7 +98,7 @@ private static Imp modifyImp(Imp imp) { if (banner != null) { final List format = banner.getFormat(); if (banner.getW() == null && banner.getH() == null && CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); final Banner modifiedBanner = banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build(); return imp.toBuilder().banner(modifiedBanner).build(); } diff --git a/src/main/java/org/prebid/server/bidder/gamoshi/GamoshiBidder.java b/src/main/java/org/prebid/server/bidder/gamoshi/GamoshiBidder.java index 88ee576791e..6d85c4ff511 100644 --- a/src/main/java/org/prebid/server/bidder/gamoshi/GamoshiBidder.java +++ b/src/main/java/org/prebid/server/bidder/gamoshi/GamoshiBidder.java @@ -62,7 +62,7 @@ public Result>> makeHttpRequests(BidRequest request final ExtImpGamoshi firstImpExt; try { - firstImpExt = parseAndValidateImpExt(validImps.get(0)); + firstImpExt = parseAndValidateImpExt(validImps.getFirst()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); } @@ -87,7 +87,7 @@ private static Imp processImp(Imp imp) { final Banner banner = imp.getBanner(); if (banner != null && banner.getH() == null && banner.getW() == null && CollectionUtils.isNotEmpty(banner.getFormat())) { - final Format firstFormat = banner.getFormat().get(0); + final Format firstFormat = banner.getFormat().getFirst(); final Banner modifiedBanner = banner.toBuilder() .h(firstFormat.getH()) .w(firstFormat.getW()) diff --git a/src/main/java/org/prebid/server/bidder/gotthamads/GothamAdsBidder.java b/src/main/java/org/prebid/server/bidder/gotthamads/GothamAdsBidder.java index fe2ac533dc4..e444038f329 100644 --- a/src/main/java/org/prebid/server/bidder/gotthamads/GothamAdsBidder.java +++ b/src/main/java/org/prebid/server/bidder/gotthamads/GothamAdsBidder.java @@ -48,7 +48,7 @@ public GothamAdsBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { final GothamAdsImpExt impExt; - final Imp firstImp = request.getImp().get(0); + final Imp firstImp = request.getImp().getFirst(); try { impExt = parseImpExt(firstImp); } catch (PreBidException e) { @@ -77,7 +77,7 @@ private GothamAdsImpExt parseImpExt(Imp imp) { private static BidRequest cleanUpFirstImpExt(BidRequest request) { final List imps = new ArrayList<>(request.getImp()); - imps.set(0, request.getImp().get(0).toBuilder().ext(null).build()); + imps.set(0, request.getImp().getFirst().toBuilder().ext(null).build()); return request.toBuilder().imp(imps).build(); } diff --git a/src/main/java/org/prebid/server/bidder/grid/GridBidder.java b/src/main/java/org/prebid/server/bidder/grid/GridBidder.java index 8ecabeff5ab..22e6eb6b40d 100644 --- a/src/main/java/org/prebid/server/bidder/grid/GridBidder.java +++ b/src/main/java/org/prebid/server/bidder/grid/GridBidder.java @@ -68,7 +68,7 @@ public Result>> makeHttpRequests(BidRequest request return Result.withErrors(errors); } - final Keywords firstImpKeywords = getKeywordsFromImpExt(imps.get(0).getExt()); + final Keywords firstImpKeywords = getKeywordsFromImpExt(imps.getFirst().getExt()); final BidRequest modifiedRequest = modifyRequest(request, firstImpKeywords, modifiedImps); return Result.of(Collections.singletonList( diff --git a/src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java b/src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java index a1d3c563cdf..783caad5d1a 100644 --- a/src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java +++ b/src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java @@ -148,7 +148,7 @@ private Imp modifyImp(Imp imp, ExtImpGumgum extImp) { private Banner resolveBanner(Banner banner, ExtImpGumgum extImpGumgum) { final List format = banner.getFormat(); if (banner.getH() == null && banner.getW() == null && CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); final Long slot = extImpGumgum.getSlot(); final ObjectNode bannerExt = slot != null && slot != 0L diff --git a/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiAdmBuilder.java b/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiAdmBuilder.java index c1d6e0d2002..5c4bb8f2235 100644 --- a/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiAdmBuilder.java +++ b/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiAdmBuilder.java @@ -210,13 +210,13 @@ private String buildRewardedVideoPart(Content content, Integer adWidth, Integer final String contentId = content.getContentId(); final List iconList = metaData.getIconList(); - final Icon firstIcon = CollectionUtils.isNotEmpty(iconList) ? iconList.get(0) : null; + final Icon firstIcon = CollectionUtils.isNotEmpty(iconList) ? iconList.getFirst() : null; if (firstIcon != null && StringUtils.isNotBlank(firstIcon.getUrl())) { return buildIconRewardedPart(contentId, clickUrl, adWidth, adHeight, firstIcon); } final List imageInfoList = metaData.getImageInfoList(); - final ImageInfo firstImage = CollectionUtils.isNotEmpty(imageInfoList) ? imageInfoList.get(0) : null; + final ImageInfo firstImage = CollectionUtils.isNotEmpty(imageInfoList) ? imageInfoList.getFirst() : null; if (firstImage != null && StringUtils.isNotBlank(firstImage.getUrl())) { return buildImageRewardedPart(contentId, clickUrl, adWidth, adHeight, firstImage); } diff --git a/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiDeviceBuilder.java b/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiDeviceBuilder.java index 4f7c5a1b781..ff95dcd40ea 100644 --- a/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiDeviceBuilder.java +++ b/src/main/java/org/prebid/server/bidder/huaweiads/HuaweiDeviceBuilder.java @@ -79,9 +79,9 @@ private Device makeDeviceWithDeviceId(com.iab.openrtb.request.Device device, Use final String gaid = isGaidEmpty ? deviceIfa.orElseThrow(() -> new PreBidException("getDeviceID: openRTBRequest.User.Ext is nil " + "and device.Gaid is not specified.")) - : userData.getGaid().get(0); - final String oaid = isOaidEmpty ? null : userData.getOaid().get(0); - final String imei = isImeiEmpty ? null : userData.getImei().get(0); + : userData.getGaid().getFirst(); + final String oaid = isOaidEmpty ? null : userData.getOaid().getFirst(); + final String imei = isImeiEmpty ? null : userData.getImei().getFirst(); final String clientTime = Optional.ofNullable(userData) .map(ExtUserDataDeviceIdHuaweiAds::getClientTime) .map(this::formatClientTime) @@ -104,7 +104,7 @@ private ExtUserDataDeviceIdHuaweiAds parseUserExtData(ExtUser extUser) { } private String formatClientTime(List clientTimes) { - return CollectionUtils.isEmpty(clientTimes) ? null : clientTimeFormatter.format(clientTimes.get(0)); + return CollectionUtils.isEmpty(clientTimes) ? null : clientTimeFormatter.format(clientTimes.getFirst()); } } diff --git a/src/main/java/org/prebid/server/bidder/huaweiads/model/response/MonitorEventType.java b/src/main/java/org/prebid/server/bidder/huaweiads/model/response/MonitorEventType.java index 0abd4455b4d..e74273a7046 100644 --- a/src/main/java/org/prebid/server/bidder/huaweiads/model/response/MonitorEventType.java +++ b/src/main/java/org/prebid/server/bidder/huaweiads/model/response/MonitorEventType.java @@ -3,8 +3,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; @Getter @@ -33,19 +31,18 @@ public static MonitorEventType of(String monitorEvent) { private static final Map EVENT_TYPE_MAP = stringToEventTypeMap(); private static Map stringToEventTypeMap() { - final Map result = new HashMap<>(); - result.put("imp", IMP); - result.put("click", CLICK); - result.put("vastError", VAST_ERROR); - result.put("userclose", USER_CLOSE); - result.put("playStart", PLAY_START); - result.put("playEnd", PLAY_END); - result.put("playResume", PLAY_RESUME); - result.put("playPause", PLAY_PAUSE); - result.put("soundClickOff", SOUND_CLICK_OFF); - result.put("soundClickOn", SOUND_CLICK_ON); - result.put("win", WIN); - return Collections.unmodifiableMap(result); + return Map.ofEntries( + Map.entry("imp", IMP), + Map.entry("click", CLICK), + Map.entry("vastError", VAST_ERROR), + Map.entry("userclose", USER_CLOSE), + Map.entry("playStart", PLAY_START), + Map.entry("playEnd", PLAY_END), + Map.entry("playResume", PLAY_RESUME), + Map.entry("playPause", PLAY_PAUSE), + Map.entry("soundClickOff", SOUND_CLICK_OFF), + Map.entry("soundClickOn", SOUND_CLICK_ON), + Map.entry("win", WIN)); } } diff --git a/src/main/java/org/prebid/server/bidder/inmobi/InmobiBidder.java b/src/main/java/org/prebid/server/bidder/inmobi/InmobiBidder.java index 62e8c8df7a9..4a32a504fb8 100644 --- a/src/main/java/org/prebid/server/bidder/inmobi/InmobiBidder.java +++ b/src/main/java/org/prebid/server/bidder/inmobi/InmobiBidder.java @@ -49,7 +49,7 @@ public InmobiBidder(String endpointUrl, JacksonMapper mapper) { public Result>> makeHttpRequests(BidRequest request) { final List errors = new ArrayList<>(); - final Imp imp = request.getImp().get(FIRST_IMP_INDEX); + final Imp imp = request.getImp().getFirst(); final ExtImpInmobi extImpInmobi; try { @@ -84,7 +84,7 @@ private Imp updateImp(Imp imp) { if (banner != null) { if ((banner.getW() == null || banner.getH() == null || banner.getW() == 0 || banner.getH() == 0) && CollectionUtils.isNotEmpty(banner.getFormat())) { - final Format format = banner.getFormat().get(0); + final Format format = banner.getFormat().getFirst(); return imp.toBuilder().banner(banner.toBuilder().w(format.getW()).h(format.getH()).build()).build(); } } diff --git a/src/main/java/org/prebid/server/bidder/interactiveoffers/InteractiveOffersBidder.java b/src/main/java/org/prebid/server/bidder/interactiveoffers/InteractiveOffersBidder.java index c52bef8888b..adb7aae4a04 100644 --- a/src/main/java/org/prebid/server/bidder/interactiveoffers/InteractiveOffersBidder.java +++ b/src/main/java/org/prebid/server/bidder/interactiveoffers/InteractiveOffersBidder.java @@ -36,7 +36,7 @@ public InteractiveOffersBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { - final ObjectNode impExt = request.getImp().get(0).getExt(); + final ObjectNode impExt = request.getImp().getFirst().getExt(); final String resolvedPartnerId = StringUtils.defaultString(resolvePartnerId(impExt)); final String resolvedEndpointUrl = endpointUrl.replace("{{PartnerId}}", resolvedPartnerId); diff --git a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java index 60f05103c1f..8f6b2afd4ea 100644 --- a/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java +++ b/src/main/java/org/prebid/server/bidder/intertech/IntertechBidder.java @@ -83,7 +83,7 @@ private String getReferer(BidRequest request) { private String getCur(BidRequest request) { final List curs = request.getCur(); - return curs != null && !curs.isEmpty() ? curs.get(0) : ""; + return curs != null && !curs.isEmpty() ? curs.getFirst() : ""; } private ExtImpIntertech parseAndValidateImpExt(ObjectNode impExtNode, final String impId) { @@ -124,7 +124,7 @@ private static Banner updateBanner(Banner banner) { final List format = banner.getFormat(); if (w == null || h == null || w == 0 || h == 0) { if (CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); return banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build(); } throw new PreBidException("Invalid sizes provided for Banner %sx%s".formatted(w, h)); diff --git a/src/main/java/org/prebid/server/bidder/ix/IxBidder.java b/src/main/java/org/prebid/server/bidder/ix/IxBidder.java index 9843eedca9e..4f53d19019a 100644 --- a/src/main/java/org/prebid/server/bidder/ix/IxBidder.java +++ b/src/main/java/org/prebid/server/bidder/ix/IxBidder.java @@ -166,7 +166,7 @@ private UpdateResult modifyImpBanner(Banner banner) { final Banner modifiedBanner = banner.toBuilder().format(newFormats).build(); return UpdateResult.updated(modifiedBanner); } else if (formats.size() == 1) { - final Format format = formats.get(0); + final Format format = formats.getFirst(); final Banner modifiedBanner = banner.toBuilder().w(format.getW()).h(format.getH()).build(); return UpdateResult.updated(modifiedBanner); } diff --git a/src/main/java/org/prebid/server/bidder/kayzen/KayzenBidder.java b/src/main/java/org/prebid/server/bidder/kayzen/KayzenBidder.java index d20a592ac73..342c64dee21 100644 --- a/src/main/java/org/prebid/server/bidder/kayzen/KayzenBidder.java +++ b/src/main/java/org/prebid/server/bidder/kayzen/KayzenBidder.java @@ -47,7 +47,7 @@ public KayzenBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { final List originalImps = request.getImp(); - final Imp firstImp = originalImps.get(FIRST_IMP_INDEX); + final Imp firstImp = originalImps.getFirst(); final ExtImpKayzen extImpKayzen; try { diff --git a/src/main/java/org/prebid/server/bidder/krushmedia/KrushmediaBidder.java b/src/main/java/org/prebid/server/bidder/krushmedia/KrushmediaBidder.java index c4b63560247..835d3781a1a 100644 --- a/src/main/java/org/prebid/server/bidder/krushmedia/KrushmediaBidder.java +++ b/src/main/java/org/prebid/server/bidder/krushmedia/KrushmediaBidder.java @@ -53,7 +53,7 @@ public Result>> makeHttpRequests(BidRequest request final String url; try { - extImpKrushmedia = parseImpExt(request.getImp().get(0)); + extImpKrushmedia = parseImpExt(request.getImp().getFirst()); url = resolveEndpoint(extImpKrushmedia.getAccountId()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); @@ -127,7 +127,7 @@ private List extractBids(BidRequest bidRequest, BidResponse bidRespon } private List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); return firstSeatBid.getBid().stream() .filter(Objects::nonNull) diff --git a/src/main/java/org/prebid/server/bidder/lemmadigital/LemmaDigitalBidder.java b/src/main/java/org/prebid/server/bidder/lemmadigital/LemmaDigitalBidder.java index 200ae89580f..beae5890d09 100644 --- a/src/main/java/org/prebid/server/bidder/lemmadigital/LemmaDigitalBidder.java +++ b/src/main/java/org/prebid/server/bidder/lemmadigital/LemmaDigitalBidder.java @@ -49,7 +49,7 @@ public Result>> makeHttpRequests(BidRequest bidRequ return Result.withError(BidderError.badInput("Impression array should not be empty")); } - final Imp imp = bidRequest.getImp().get(0); + final Imp imp = bidRequest.getImp().getFirst(); final ExtImpLemmaDigital extImpLemmaDigital; try { @@ -116,6 +116,6 @@ private static List bidsFromResponse(BidRequest bidRequest, BidRespon } private static BidType resolveBidType(BidRequest bidRequest) { - return bidRequest.getImp().get(0).getVideo() != null ? BidType.video : BidType.banner; + return bidRequest.getImp().getFirst().getVideo() != null ? BidType.video : BidType.banner; } } diff --git a/src/main/java/org/prebid/server/bidder/lunamedia/LunamediaBidder.java b/src/main/java/org/prebid/server/bidder/lunamedia/LunamediaBidder.java index 728ac621f39..a0ef293d3d0 100644 --- a/src/main/java/org/prebid/server/bidder/lunamedia/LunamediaBidder.java +++ b/src/main/java/org/prebid/server/bidder/lunamedia/LunamediaBidder.java @@ -130,7 +130,7 @@ private static Banner modifyImpBanner(Banner banner) { final List formatSkipFirst = originalFormat.subList(1, originalFormat.size()); bannerBuilder.format(formatSkipFirst); - final Format firstFormat = originalFormat.get(0); + final Format firstFormat = originalFormat.getFirst(); bannerBuilder.w(firstFormat.getW()); bannerBuilder.h(firstFormat.getH()); diff --git a/src/main/java/org/prebid/server/bidder/marsmedia/MarsmediaBidder.java b/src/main/java/org/prebid/server/bidder/marsmedia/MarsmediaBidder.java index 07277179d63..ea7e4f9b4f2 100644 --- a/src/main/java/org/prebid/server/bidder/marsmedia/MarsmediaBidder.java +++ b/src/main/java/org/prebid/server/bidder/marsmedia/MarsmediaBidder.java @@ -51,7 +51,7 @@ public Result>> makeHttpRequests(BidRequest bidRequ final String firstImpZone; final BidRequest outgoingRequest; try { - firstImpZone = resolveExtZone(bidRequest.getImp().get(0)); + firstImpZone = resolveExtZone(bidRequest.getImp().getFirst()); outgoingRequest = createRequest(bidRequest); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); @@ -110,7 +110,7 @@ private static BidRequest createRequest(BidRequest request) { } private static Banner updateBanner(Banner banner) { - final Format firstFormat = banner.getFormat().get(0); + final Format firstFormat = banner.getFormat().getFirst(); return banner.toBuilder() .w(ObjectUtils.defaultIfNull(firstFormat.getW(), 0)) .h(ObjectUtils.defaultIfNull(firstFormat.getH(), 0)) @@ -147,7 +147,7 @@ private static List extractBids(BidResponse bidResponse, BidRequest b } private static List bidsFromResponse(List seatbid, List imps, String currency) { - final SeatBid firstSeatBid = seatbid.get(0); + final SeatBid firstSeatBid = seatbid.getFirst(); return firstSeatBid != null ? firstSeatBid.getBid().stream() .filter(Objects::nonNull) .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), imps), currency)) diff --git a/src/main/java/org/prebid/server/bidder/mobfoxpb/MobfoxpbBidder.java b/src/main/java/org/prebid/server/bidder/mobfoxpb/MobfoxpbBidder.java index 54cd4d19b67..9a322b2ae0d 100644 --- a/src/main/java/org/prebid/server/bidder/mobfoxpb/MobfoxpbBidder.java +++ b/src/main/java/org/prebid/server/bidder/mobfoxpb/MobfoxpbBidder.java @@ -55,7 +55,7 @@ public final Result>> makeHttpRequests(BidRequest b final BidRequest outgoingRequest; final String uri; try { - final Imp firstImp = bidRequest.getImp().get(0); + final Imp firstImp = bidRequest.getImp().getFirst(); final ExtImpMobfoxpb impExt = parseImpExt(firstImp); uri = buildUri(impExt.getKey()); diff --git a/src/main/java/org/prebid/server/bidder/motorik/MotorikBidder.java b/src/main/java/org/prebid/server/bidder/motorik/MotorikBidder.java index aafd9c38ec9..3fa086747b4 100644 --- a/src/main/java/org/prebid/server/bidder/motorik/MotorikBidder.java +++ b/src/main/java/org/prebid/server/bidder/motorik/MotorikBidder.java @@ -50,7 +50,7 @@ public Result>> makeHttpRequests(BidRequest request final ExtImpMotorik firstImpExt; try { - firstImpExt = parseImpExt(request.getImp().get(0)); + firstImpExt = parseImpExt(request.getImp().getFirst()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); } @@ -71,7 +71,7 @@ private static BidRequest createRequest(BidRequest request) { } private static List prepareFirstImp(List imps) { - final Imp firstImp = imps.get(0); + final Imp firstImp = imps.getFirst(); final List updatedImps = new ArrayList<>(imps); updatedImps.set(0, firstImp.toBuilder().ext(null).build()); diff --git a/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java b/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java index c8cb6418de9..84c3f68e8bb 100644 --- a/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java +++ b/src/main/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidder.java @@ -115,7 +115,7 @@ private static String resolveStoredRequestId(BidRequest bidRequest, ExtImpNextMi return extImpNextMillennium.getPlacementId(); } - final String size = formattedSizeFromBanner(bidRequest.getImp().get(0).getBanner()); + final String size = formattedSizeFromBanner(bidRequest.getImp().getFirst().getBanner()); final String domain = ObjectUtils.firstNonNull( ObjectUtil.getIfNotNull(bidRequest.getSite(), Site::getDomain), ObjectUtil.getIfNotNull(bidRequest.getApp(), App::getDomain), @@ -130,7 +130,7 @@ private static String formattedSizeFromBanner(Banner banner) { } final List formats = banner.getFormat(); - final Format firstFormat = CollectionUtils.isNotEmpty(formats) ? formats.get(0) : null; + final Format firstFormat = CollectionUtils.isNotEmpty(formats) ? formats.getFirst() : null; return ObjectUtils.firstNonNull( formatSize( diff --git a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java index 9c3fd9818aa..fec1f7d2ddf 100644 --- a/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java +++ b/src/main/java/org/prebid/server/bidder/openx/OpenxBidder.java @@ -169,7 +169,7 @@ private BidRequest createSingleRequest(List imps, BidRequest bidRequest, Li return CollectionUtils.isNotEmpty(processedImps) ? bidRequest.toBuilder() .imp(processedImps) - .ext(makeReqExt(imps.get(0))) + .ext(makeReqExt(imps.getFirst())) .build() : null; } diff --git a/src/main/java/org/prebid/server/bidder/operaads/OperaadsBidder.java b/src/main/java/org/prebid/server/bidder/operaads/OperaadsBidder.java index 655578064e2..b3ce9f10a17 100644 --- a/src/main/java/org/prebid/server/bidder/operaads/OperaadsBidder.java +++ b/src/main/java/org/prebid/server/bidder/operaads/OperaadsBidder.java @@ -134,7 +134,7 @@ private static Banner modifyBanner(Banner banner) { if (w == null || w == 0 || h == null || h == 0) { if (CollectionUtils.isNotEmpty(formats)) { - final Format firstFormat = formats.get(0); + final Format firstFormat = formats.getFirst(); return banner.toBuilder() .w(firstFormat.getW()) .h(firstFormat.getH()) diff --git a/src/main/java/org/prebid/server/bidder/preciso/PrecisoBidder.java b/src/main/java/org/prebid/server/bidder/preciso/PrecisoBidder.java index 1e8012b4720..3c29aa13b6d 100644 --- a/src/main/java/org/prebid/server/bidder/preciso/PrecisoBidder.java +++ b/src/main/java/org/prebid/server/bidder/preciso/PrecisoBidder.java @@ -71,7 +71,7 @@ public Result>> makeHttpRequests(BidRequest bidRequ } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { return Result.withErrors(errors); } @@ -126,7 +126,9 @@ private Price resolveBidFloor(Imp imp, ExtImpPreciso impExt, BidRequest bidReque final Price initialBidFloorPrice = Price.of(imp.getBidfloorcur(), imp.getBidfloor()); final BigDecimal impExtBidFloor = impExt.getBidFloor(); - final String impExtCurrency = impExtBidFloor != null && brCur != null && brCur.size() > 0 ? brCur.get(0) : null; + final String impExtCurrency = impExtBidFloor != null && brCur != null && !brCur.isEmpty() + ? brCur.getFirst() + : null; final Price impExtBidFloorPrice = Price.of(impExtCurrency, impExtBidFloor); final Price resolvedPrice = initialBidFloorPrice.getValue() == null ? impExtBidFloorPrice : initialBidFloorPrice; diff --git a/src/main/java/org/prebid/server/bidder/pubmatic/PubmaticBidder.java b/src/main/java/org/prebid/server/bidder/pubmatic/PubmaticBidder.java index 4ce93dea167..6598e53cd57 100644 --- a/src/main/java/org/prebid/server/bidder/pubmatic/PubmaticBidder.java +++ b/src/main/java/org/prebid/server/bidder/pubmatic/PubmaticBidder.java @@ -277,7 +277,7 @@ private static Banner assignSizesIfMissing(Banner banner) { return banner; } - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); return modifyWithSizeParams(banner, firstFormat.getW(), firstFormat.getH()); } diff --git a/src/main/java/org/prebid/server/bidder/pubnative/PubnativeBidder.java b/src/main/java/org/prebid/server/bidder/pubnative/PubnativeBidder.java index c90d350705c..c536066ab27 100644 --- a/src/main/java/org/prebid/server/bidder/pubnative/PubnativeBidder.java +++ b/src/main/java/org/prebid/server/bidder/pubnative/PubnativeBidder.java @@ -121,7 +121,7 @@ private static Banner resolveBanner(Banner banner) { throw new PreBidException("Size information missing for banner"); } - final Format firstFormat = formats.get(0); + final Format firstFormat = formats.getFirst(); return banner.toBuilder() .w(firstFormat.getW()) .h(firstFormat.getH()) @@ -148,7 +148,7 @@ private static String resolveBidFloorCurrency(BidRequest bidRequest, String bidF return bidFloorCurrency; } final List bidRequestCurrencies = bidRequest.getCur(); - return CollectionUtils.isNotEmpty(bidRequestCurrencies) ? bidRequestCurrencies.get(0) : null; + return CollectionUtils.isNotEmpty(bidRequestCurrencies) ? bidRequestCurrencies.getFirst() : null; } private HttpRequest createHttpRequest(BidRequest outgoingRequest, ExtImpPubnative impExt) { @@ -234,13 +234,14 @@ private static Format resolveBidSizeFromBanner(Banner banner) { ? Format.builder().w(width).h(height).build() : null; } else if (formats.size() == 1) { - result = formats.get(0); + result = formats.getFirst(); } return result; } private static boolean isOnlyOneSize(Integer width, Integer height, List formats) { - return CollectionUtils.isEmpty(formats) || (formats.size() == 1 && isSameFormat(width, height, formats.get(0))); + return CollectionUtils.isEmpty(formats) + || (formats.size() == 1 && isSameFormat(width, height, formats.getFirst())); } private static boolean isSameFormat(Integer width, Integer height, Format format) { diff --git a/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java index fc887c21f97..d21dd3f4b68 100644 --- a/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java +++ b/src/main/java/org/prebid/server/bidder/roulax/RoulaxBidder.java @@ -49,7 +49,7 @@ public RoulaxBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest bidRequest) { try { - final ExtImpRoulax extImpRoulax = parseImpExt(bidRequest.getImp().get(0)); + final ExtImpRoulax extImpRoulax = parseImpExt(bidRequest.getImp().getFirst()); return Result.withValue(BidderUtil.defaultRequest(bidRequest, resolveEndpoint(extImpRoulax), mapper)); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); diff --git a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java index a363c29a0a3..91a8b5b09c4 100644 --- a/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java +++ b/src/main/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidder.java @@ -71,7 +71,7 @@ public Result>> makeHttpRequests(BidRequest bidRequ } } - if (errors.size() > 0) { + if (!errors.isEmpty()) { return Result.withErrors(errors); } @@ -186,8 +186,8 @@ private Price resolveBidFloor(Imp imp, ExtImpRtbhouse impExt, BidRequest bidRequ final Price initialBidFloorPrice = Price.of(imp.getBidfloorcur(), imp.getBidfloor()); final BigDecimal impExtBidFloor = impExt.getBidFloor(); - final String impExtCurrency = impExtBidFloor != null && brCur != null && brCur.size() > 0 - ? brCur.get(0) : null; + final String impExtCurrency = impExtBidFloor != null && brCur != null && !brCur.isEmpty() + ? brCur.getFirst() : null; final Price impExtBidFloorPrice = Price.of(impExtCurrency, impExtBidFloor); final Price resolvedPrice = initialBidFloorPrice.getValue() == null ? impExtBidFloorPrice : initialBidFloorPrice; diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 5c45d9583ec..6e0bb270728 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -317,7 +317,7 @@ public Map extractTargeting(ObjectNode extBidBidder) { return targetings != null ? targetings.stream() .filter(targeting -> !CollectionUtils.isEmpty(targeting.getValues())) - .collect(Collectors.toMap(RubiconTargeting::getKey, targeting -> targeting.getValues().get(0))) + .collect(Collectors.toMap(RubiconTargeting::getKey, targeting -> targeting.getValues().getFirst())) : Collections.emptyMap(); } @@ -696,7 +696,7 @@ private JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site site, App mergeFirstPartyDataFromApp(app, result); mergeFirstPartyDataFromImp(imp, rubiconImpExt, result); - return result.size() > 0 ? result : null; + return !result.isEmpty() ? result : null; } private RubiconImpExtPrebid makeRubiconExtPrebid(PriceFloorResult priceFloorResult, @@ -929,7 +929,7 @@ private Integer getMaxBids(ExtRequest extRequest) { final List multibids = extRequestPrebid != null ? extRequestPrebid.getMultibid() : null; final ExtRequestPrebidMultiBid extRequestPrebidMultiBid = - CollectionUtils.isNotEmpty(multibids) ? multibids.get(0) : null; + CollectionUtils.isNotEmpty(multibids) ? multibids.getFirst() : null; final Integer multibidMaxBids = extRequestPrebidMultiBid != null ? extRequestPrebidMultiBid.getMaxBids() : null; return multibidMaxBids != null ? multibidMaxBids : 1; @@ -1502,7 +1502,7 @@ private static boolean hasDeals(Imp imp) { } private List> createDealsRequests(BidRequest bidRequest, String uri) { - final Imp singleImp = bidRequest.getImp().get(0); + final Imp singleImp = bidRequest.getImp().getFirst(); return singleImp.getPmp().getDeals().stream() .map(deal -> mapper.mapper().convertValue(deal.getExt(), ExtDeal.class)) .filter(Objects::nonNull) @@ -1694,7 +1694,7 @@ private Float cpmOverrideFromImp(Imp imp) { } private static BidType bidType(BidRequest bidRequest) { - final ImpMediaType impMediaType = impType(bidRequest.getImp().get(0)); + final ImpMediaType impMediaType = impType(bidRequest.getImp().getFirst()); return switch (impMediaType) { case video -> BidType.video; case banner -> BidType.banner; diff --git a/src/main/java/org/prebid/server/bidder/salunamedia/SaLunamediaBidder.java b/src/main/java/org/prebid/server/bidder/salunamedia/SaLunamediaBidder.java index e0e1c8cc6af..0dcdd206050 100644 --- a/src/main/java/org/prebid/server/bidder/salunamedia/SaLunamediaBidder.java +++ b/src/main/java/org/prebid/server/bidder/salunamedia/SaLunamediaBidder.java @@ -54,13 +54,13 @@ private List extractBids(BidResponse bidResponse) { throw new PreBidException("Empty SeatBid"); } - final SeatBid firstSeatBid = seatBids.get(0); + final SeatBid firstSeatBid = seatBids.getFirst(); final List bids = firstSeatBid != null ? firstSeatBid.getBid() : null; if (CollectionUtils.isEmpty(bids)) { throw new PreBidException("Empty SeatBid.Bids"); } - final Bid firstBid = bids.get(0); + final Bid firstBid = bids.getFirst(); final ObjectNode firstBidExt = firstBid != null ? firstBid.getExt() : null; if (firstBidExt == null) { throw new PreBidException("Missing BidExt"); diff --git a/src/main/java/org/prebid/server/bidder/screencore/ScreencoreBidder.java b/src/main/java/org/prebid/server/bidder/screencore/ScreencoreBidder.java index 9a6a6ba24ce..51e05ddfd24 100644 --- a/src/main/java/org/prebid/server/bidder/screencore/ScreencoreBidder.java +++ b/src/main/java/org/prebid/server/bidder/screencore/ScreencoreBidder.java @@ -48,7 +48,7 @@ public ScreencoreBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { final ScreencoreImpExt impExt; - final Imp firstImp = request.getImp().get(0); + final Imp firstImp = request.getImp().getFirst(); try { impExt = parseImpExt(firstImp); } catch (PreBidException e) { @@ -84,7 +84,7 @@ private ScreencoreImpExt parseImpExt(Imp imp) { private static BidRequest cleanUpFirstImpExt(BidRequest request) { final List imps = new ArrayList<>(request.getImp()); - imps.set(0, request.getImp().get(0).toBuilder().ext(null).build()); + imps.set(0, request.getImp().getFirst().toBuilder().ext(null).build()); return request.toBuilder().imp(imps).build(); } diff --git a/src/main/java/org/prebid/server/bidder/silverpush/SilverPushBidder.java b/src/main/java/org/prebid/server/bidder/silverpush/SilverPushBidder.java index cfa91c1df5b..212e1558283 100644 --- a/src/main/java/org/prebid/server/bidder/silverpush/SilverPushBidder.java +++ b/src/main/java/org/prebid/server/bidder/silverpush/SilverPushBidder.java @@ -154,7 +154,7 @@ private static boolean isValidEids(List eids) { } for (Eid eid : eids) { final List uids = eid.getUids(); - if (CollectionUtils.isNotEmpty(uids) && StringUtils.isNotBlank(uids.get(0).getId())) { + if (CollectionUtils.isNotEmpty(uids) && StringUtils.isNotBlank(uids.getFirst().getId())) { return true; } } @@ -230,7 +230,7 @@ private static Banner resolveBanner(Banner banner) { throw new PreBidException("No sizes provided for Banner."); } - final Format firstFormat = banner.getFormat().get(0); + final Format firstFormat = banner.getFormat().getFirst(); return banner.toBuilder() .w(firstFormat.getW()) .h(firstFormat.getH()) diff --git a/src/main/java/org/prebid/server/bidder/smaato/SmaatoBidder.java b/src/main/java/org/prebid/server/bidder/smaato/SmaatoBidder.java index 1c62d283687..c3cbbbb4eb8 100644 --- a/src/main/java/org/prebid/server/bidder/smaato/SmaatoBidder.java +++ b/src/main/java/org/prebid/server/bidder/smaato/SmaatoBidder.java @@ -198,7 +198,7 @@ private static String extractPod(Imp imp) { private BidRequest preparePodRequest(BidRequest bidRequest, List imps, List errors) { try { - final ObjectNode impExt = imps.get(0).getExt(); + final ObjectNode impExt = imps.getFirst().getExt(); final ExtImpSmaato extImpSmaato = mapper.mapper().convertValue(impExt, SMAATO_EXT_TYPE_REFERENCE).getBidder(); final String publisherId = getIfNotNullOrThrow(extImpSmaato, ExtImpSmaato::getPublisherId, "publisherId"); @@ -326,7 +326,7 @@ private static Banner modifyBanner(Banner banner) { if (CollectionUtils.isEmpty(format)) { throw new PreBidException("No sizes provided for Banner."); } - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); return banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build(); } @@ -395,7 +395,7 @@ private ExtBidPrebidVideo getExtBidPrebidVideo(Bid bid, BidType bidType) { } final List categories = bid.getCat(); - final String primaryCategory = CollectionUtils.isNotEmpty(categories) ? categories.get(0) : null; + final String primaryCategory = CollectionUtils.isNotEmpty(categories) ? categories.getFirst() : null; try { final SmaatoBidExt smaatoBidExt = mapper.mapper().convertValue(bidExt, SmaatoBidExt.class); return ExtBidPrebidVideo.of(smaatoBidExt.getDuration(), primaryCategory); diff --git a/src/main/java/org/prebid/server/bidder/smarthub/SmarthubBidder.java b/src/main/java/org/prebid/server/bidder/smarthub/SmarthubBidder.java index 272480a7123..ae00fa4675e 100644 --- a/src/main/java/org/prebid/server/bidder/smarthub/SmarthubBidder.java +++ b/src/main/java/org/prebid/server/bidder/smarthub/SmarthubBidder.java @@ -45,7 +45,7 @@ public SmarthubBidder(String endpointTemplate, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { - final Imp firstImp = request.getImp().get(0); + final Imp firstImp = request.getImp().getFirst(); final ExtImpSmarthub extImpSmarthub; try { extImpSmarthub = mapper.mapper().convertValue(firstImp.getExt(), SMARTHUB_EXT_TYPE_REFERENCE).getBidder(); @@ -84,9 +84,9 @@ public Result> makeBids(BidderCall httpCall, BidRequ private List extractBids(BidResponse bidResponse) { final List seatBid = bidResponse != null ? bidResponse.getSeatbid() : null; - final SeatBid firstSeatBid = CollectionUtils.isNotEmpty(seatBid) ? seatBid.get(0) : null; + final SeatBid firstSeatBid = CollectionUtils.isNotEmpty(seatBid) ? seatBid.getFirst() : null; final List bids = firstSeatBid != null ? firstSeatBid.getBid() : null; - final Bid firstBid = CollectionUtils.isNotEmpty(bids) ? bids.get(0) : null; + final Bid firstBid = CollectionUtils.isNotEmpty(bids) ? bids.getFirst() : null; if (firstBid == null) { throw new PreBidException("SeatBid[0].Bid[0] cannot be empty"); diff --git a/src/main/java/org/prebid/server/bidder/smartyads/SmartyAdsBidder.java b/src/main/java/org/prebid/server/bidder/smartyads/SmartyAdsBidder.java index 1f5c17dde55..f605e564a49 100644 --- a/src/main/java/org/prebid/server/bidder/smartyads/SmartyAdsBidder.java +++ b/src/main/java/org/prebid/server/bidder/smartyads/SmartyAdsBidder.java @@ -146,7 +146,7 @@ private List extractBids(BidderCall httpCall) { } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(FIRST_SEAT_BID_INDEX); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); return CollectionUtils.emptyIfNull(firstSeatBid.getBid()).stream() .filter(Objects::nonNull) .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), bidRequest.getImp()), bidResponse.getCur())) diff --git a/src/main/java/org/prebid/server/bidder/smilewanted/SmileWantedBidder.java b/src/main/java/org/prebid/server/bidder/smilewanted/SmileWantedBidder.java index af8c52bf8ab..a36057f2c33 100644 --- a/src/main/java/org/prebid/server/bidder/smilewanted/SmileWantedBidder.java +++ b/src/main/java/org/prebid/server/bidder/smilewanted/SmileWantedBidder.java @@ -73,7 +73,7 @@ private static List extractBids(BidRequest bidRequest, BidResponse bi } private static List bidsFromResponse(BidRequest bidRequest, BidResponse bidResponse) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); return CollectionUtils.emptyIfNull(firstSeatBid.getBid()).stream() .filter(Objects::nonNull) .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), bidRequest.getImp()), bidResponse.getCur())) diff --git a/src/main/java/org/prebid/server/bidder/smrtconnect/SmrtconnectBidder.java b/src/main/java/org/prebid/server/bidder/smrtconnect/SmrtconnectBidder.java index 9e7e8f56369..869701e33a3 100644 --- a/src/main/java/org/prebid/server/bidder/smrtconnect/SmrtconnectBidder.java +++ b/src/main/java/org/prebid/server/bidder/smrtconnect/SmrtconnectBidder.java @@ -43,7 +43,7 @@ public SmrtconnectBidder(String endpointUrl, JacksonMapper mapper) { @Override public final Result>> makeHttpRequests(BidRequest bidRequest) { - final Imp firstImp = bidRequest.getImp().get(0); + final Imp firstImp = bidRequest.getImp().getFirst(); final ExtImpSmrtconnect extImpSmrtconnect; try { diff --git a/src/main/java/org/prebid/server/bidder/tappx/TappxBidder.java b/src/main/java/org/prebid/server/bidder/tappx/TappxBidder.java index 846101e0685..ac511bb03b9 100644 --- a/src/main/java/org/prebid/server/bidder/tappx/TappxBidder.java +++ b/src/main/java/org/prebid/server/bidder/tappx/TappxBidder.java @@ -62,7 +62,7 @@ public Result>> makeHttpRequests(BidRequest request final ExtImpTappx extImpTappx; final String url; try { - extImpTappx = parseImpExt(imps.get(0)); + extImpTappx = parseImpExt(imps.getFirst()); url = resolveUrl(extImpTappx, request.getTest()); } catch (PreBidException e) { return Result.withError(BidderError.badInput(e.getMessage())); @@ -82,7 +82,7 @@ private ExtImpTappx parseImpExt(Imp imp) { private static List modifyImps(List imps, ExtImpTappx extImpTappx) { final List modifiedImps = new ArrayList<>(imps); - modifiedImps.set(0, modifyImp(imps.get(0), extImpTappx)); + modifiedImps.set(0, modifyImp(imps.getFirst(), extImpTappx)); return modifiedImps; } diff --git a/src/main/java/org/prebid/server/bidder/teads/TeadsBidder.java b/src/main/java/org/prebid/server/bidder/teads/TeadsBidder.java index dd745e668a2..05a9b72a51e 100644 --- a/src/main/java/org/prebid/server/bidder/teads/TeadsBidder.java +++ b/src/main/java/org/prebid/server/bidder/teads/TeadsBidder.java @@ -82,7 +82,7 @@ private static Banner modifyBanner(Banner banner) { if (banner != null) { final List format = banner.getFormat(); if (CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); return banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build(); } } diff --git a/src/main/java/org/prebid/server/bidder/telaria/TelariaBidder.java b/src/main/java/org/prebid/server/bidder/telaria/TelariaBidder.java index 516dbacfcf9..b65f4f45982 100644 --- a/src/main/java/org/prebid/server/bidder/telaria/TelariaBidder.java +++ b/src/main/java/org/prebid/server/bidder/telaria/TelariaBidder.java @@ -61,7 +61,7 @@ public Result>> makeHttpRequests(BidRequest bidRequ final String publisherId = getPublisherId(bidRequest); final String seatCode; final ExtImpTelaria extImp; - Imp modifyImp = bidRequest.getImp().get(0); + Imp modifyImp = bidRequest.getImp().getFirst(); try { extImp = parseImpExt(modifyImp); @@ -193,7 +193,7 @@ private List extractBids(BidResponse bidResponse, BidRequest bidReque } private static List bidsFromResponse(BidResponse bidResponse, BidRequest bidRequest) { - final SeatBid firstSeatBid = bidResponse.getSeatbid().get(0); + final SeatBid firstSeatBid = bidResponse.getSeatbid().getFirst(); final List bids = firstSeatBid.getBid(); final List imps = bidRequest.getImp(); diff --git a/src/main/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidder.java b/src/main/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidder.java index 3e6548f3e21..ae3e814c249 100644 --- a/src/main/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidder.java +++ b/src/main/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidder.java @@ -52,7 +52,7 @@ public Result>> makeHttpRequests(BidRequest request String partnerId = null; try { - final ExtImpUcfunnel extImpUcfunnel = parseImpExt(request.getImp().get(0)); + final ExtImpUcfunnel extImpUcfunnel = parseImpExt(request.getImp().getFirst()); final String adUnitId = extImpUcfunnel.getAdunitid(); partnerId = extImpUcfunnel.getPartnerid(); if (StringUtils.isEmpty(partnerId) || StringUtils.isEmpty(adUnitId)) { diff --git a/src/main/java/org/prebid/server/bidder/undertone/UndertoneBidder.java b/src/main/java/org/prebid/server/bidder/undertone/UndertoneBidder.java index 99e2d20e733..2ba1663a87e 100644 --- a/src/main/java/org/prebid/server/bidder/undertone/UndertoneBidder.java +++ b/src/main/java/org/prebid/server/bidder/undertone/UndertoneBidder.java @@ -204,7 +204,7 @@ private Map getIdImpMap(BidRequest bidRequest) { .collect(Collectors.groupingBy(Imp::getId)) .entrySet() .stream() - .collect(Collectors.toMap(Map.Entry::getKey, imps -> imps.getValue().get(0))); + .collect(Collectors.toMap(Map.Entry::getKey, imps -> imps.getValue().getFirst())); } private BidType getBidType(Bid bid, Map idImpMap) { diff --git a/src/main/java/org/prebid/server/bidder/unicorn/UnicornBidder.java b/src/main/java/org/prebid/server/bidder/unicorn/UnicornBidder.java index 8c1acc49751..110786c683a 100644 --- a/src/main/java/org/prebid/server/bidder/unicorn/UnicornBidder.java +++ b/src/main/java/org/prebid/server/bidder/unicorn/UnicornBidder.java @@ -61,7 +61,7 @@ public Result>> makeHttpRequests(BidRequest request try { validateRegs(request.getRegs()); - firstImpExt = parseImpExt(request.getImp().get(0)).getBidder(); + firstImpExt = parseImpExt(request.getImp().getFirst()).getBidder(); modifiedImps = request.getImp().stream().map(this::modifyImp).toList(); modifiedSource = modifySource(request.getSource()); modifiedApp = modifyApp(request.getApp(), firstImpExt.getMediaId(), firstImpExt.getPublisherId()); diff --git a/src/main/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidder.java b/src/main/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidder.java index 015e0b4b755..7ce127d79cd 100644 --- a/src/main/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidder.java +++ b/src/main/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidder.java @@ -47,7 +47,7 @@ public VideoHeroesBidder(String endpointUrl, JacksonMapper mapper) { @Override public Result>> makeHttpRequests(BidRequest request) { final List requestImps = request.getImp(); - final Imp firstImp = requestImps.get(FIRST_IMP_INDEX); + final Imp firstImp = requestImps.getFirst(); final ExtImpVideoHeroes impExt; try { @@ -61,7 +61,7 @@ public Result>> makeHttpRequests(BidRequest request private static List modifyFirstImp(List imp) { final List modifiedImps = new ArrayList<>(imp); - final Imp modifiedFirstImp = imp.get(FIRST_IMP_INDEX).toBuilder().ext(null).build(); + final Imp modifiedFirstImp = imp.getFirst().toBuilder().ext(null).build(); modifiedImps.set(FIRST_IMP_INDEX, modifiedFirstImp); return modifiedImps; diff --git a/src/main/java/org/prebid/server/bidder/vidoomy/VidoomyBidder.java b/src/main/java/org/prebid/server/bidder/vidoomy/VidoomyBidder.java index 0784be520c1..68cb8709694 100644 --- a/src/main/java/org/prebid/server/bidder/vidoomy/VidoomyBidder.java +++ b/src/main/java/org/prebid/server/bidder/vidoomy/VidoomyBidder.java @@ -72,7 +72,7 @@ private static Imp modifyImp(Imp imp) { validateBannerSizes(width, height, formats); final boolean useFormatSize = width == null || height == null; - final Format firstFormat = useFormatSize ? formats.get(0) : null; + final Format firstFormat = useFormatSize ? formats.getFirst() : null; return imp.toBuilder() .banner(banner.toBuilder() .w(useFormatSize ? zeroIfFormatMeasureNull(firstFormat, Format::getW) : width) diff --git a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java index 997938e371e..3e15eb554a3 100644 --- a/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java +++ b/src/main/java/org/prebid/server/bidder/yahooads/YahooAdsBidder.java @@ -162,7 +162,7 @@ private static Banner modifyBanner(Banner banner) { if (CollectionUtils.isEmpty(bannerFormats)) { throw new PreBidException("No sizes provided for Banner"); } - final Format firstFormat = bannerFormats.get(0); + final Format firstFormat = bannerFormats.getFirst(); return banner.toBuilder() .w(firstFormat.getW()) diff --git a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java index 3a9bbf1ce88..46ed20a06f1 100644 --- a/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java +++ b/src/main/java/org/prebid/server/bidder/yandex/YandexBidder.java @@ -86,7 +86,7 @@ private static String getReferer(BidRequest request) { private static String getCurrency(BidRequest request) { final List currencies = request.getCur(); - final String currency = CollectionUtils.isNotEmpty(currencies) ? currencies.get(0) : null; + final String currency = CollectionUtils.isNotEmpty(currencies) ? currencies.getFirst() : null; return StringUtils.defaultString(currency); } @@ -126,7 +126,7 @@ private static Banner modifyBanner(Banner banner) { final List format = banner.getFormat(); if (weight == null || height == null || weight == 0 || height == 0) { if (CollectionUtils.isNotEmpty(format)) { - final Format firstFormat = format.get(0); + final Format firstFormat = format.getFirst(); return banner.toBuilder().w(firstFormat.getW()).h(firstFormat.getH()).build(); } throw new PreBidException("Invalid sizes provided for Banner %sx%s".formatted(weight, height)); diff --git a/src/main/java/org/prebid/server/bidder/yieldone/YieldoneBidder.java b/src/main/java/org/prebid/server/bidder/yieldone/YieldoneBidder.java index 4e4744b06fb..cb5ae6968b5 100644 --- a/src/main/java/org/prebid/server/bidder/yieldone/YieldoneBidder.java +++ b/src/main/java/org/prebid/server/bidder/yieldone/YieldoneBidder.java @@ -69,7 +69,7 @@ private Imp modifyImp(Imp imp) { final Banner banner = imp.getBanner(); if (banner != null) { if (banner.getH() == null && banner.getW() == null && CollectionUtils.isNotEmpty(banner.getFormat())) { - final Format firstFormat = banner.getFormat().get(0); + final Format firstFormat = banner.getFormat().getFirst(); final Banner modifiedBanner = banner.toBuilder() .h(firstFormat.getH()) .w(firstFormat.getW()) diff --git a/src/main/java/org/prebid/server/cookie/CookieSyncService.java b/src/main/java/org/prebid/server/cookie/CookieSyncService.java index 074fab249af..2d381bfa665 100644 --- a/src/main/java/org/prebid/server/cookie/CookieSyncService.java +++ b/src/main/java/org/prebid/server/cookie/CookieSyncService.java @@ -497,7 +497,7 @@ private List aliasSyncedAsRootStatuses(Set bidders final Set allowedRequestedBidders = cookieSyncContext.getBiddersContext().allowedRequestedBidders(); return biddersToSync.stream() - .filter(bidder -> allowedRequestedBidders.contains(bidder)) + .filter(allowedRequestedBidders::contains) .filter(this::isAliasSyncedAsRootFamily) .map(this::warningForAliasSyncedAsRootFamily) .toList(); diff --git a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java index 09f5c16f46d..5adba78d6e8 100644 --- a/src/main/java/org/prebid/server/currency/CurrencyConversionService.java +++ b/src/main/java/org/prebid/server/currency/CurrencyConversionService.java @@ -318,7 +318,7 @@ private static BigDecimal findIntermediateConversionRate(Map if (!sharedCurrencies.isEmpty()) { // pick any found shared currency - final String sharedCurrency = sharedCurrencies.get(0); + final String sharedCurrency = sharedCurrencies.getFirst(); final BigDecimal directCurrencyRateIntermediate = directCurrencyRates.get(sharedCurrency); final BigDecimal reverseCurrencyRateIntermediate = reverseCurrencyRates.get(sharedCurrency); conversionRate = directCurrencyRateIntermediate.divide(reverseCurrencyRateIntermediate, diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java index c5bb0e5aa1e..5157ec6fd1c 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorEnforcer.java @@ -261,7 +261,7 @@ private BigDecimal convertCurrency(BigDecimal floor, private static String resolveBidRequestCurrency(BidRequest bidRequest) { final List currencies = ObjectUtil.getIfNotNull(bidRequest, BidRequest::getCur); - return CollectionUtils.isEmpty(currencies) ? null : currencies.get(0); + return CollectionUtils.isEmpty(currencies) ? null : currencies.getFirst(); } private static Imp correspondingImp(Bid bid, List imps) { diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java index c8b6dd17969..746228dae3c 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorProcessor.java @@ -314,7 +314,7 @@ private static PriceFloorModelGroup extractFloorModelGroup(PriceFloorRules floor final PriceFloorData data = ObjectUtil.getIfNotNull(floors, PriceFloorRules::getData); final List modelGroups = ObjectUtil.getIfNotNull(data, PriceFloorData::getModelGroups); - return CollectionUtils.isNotEmpty(modelGroups) ? modelGroups.get(0) : null; + return CollectionUtils.isNotEmpty(modelGroups) ? modelGroups.getFirst() : null; } private Imp updateImpWithFloors(Imp imp, diff --git a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java index 87e293d3b7d..90113637a80 100644 --- a/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java +++ b/src/main/java/org/prebid/server/floors/BasicPriceFloorResolver.java @@ -184,7 +184,7 @@ private static PriceFloorModelGroup extractFloorModelGroup(PriceFloorRules floor final PriceFloorData data = ObjectUtil.getIfNotNull(floors, PriceFloorRules::getData); final List modelGroups = ObjectUtil.getIfNotNull(data, PriceFloorData::getModelGroups); - return CollectionUtils.isNotEmpty(modelGroups) ? modelGroups.get(0) : null; + return CollectionUtils.isNotEmpty(modelGroups) ? modelGroups.getFirst() : null; } private static Map keysToLowerCase(Map map) { @@ -313,7 +313,7 @@ private static PrebidConfigParameter mediaTypeFrom(List impMediaTy return PrebidConfigParameter.wildcard(); } - final ImpMediaType impMediaType = impMediaTypes.get(0); + final ImpMediaType impMediaType = impMediaTypes.getFirst(); return impMediaType == ImpMediaType.video ? SimpleDirectParameter.of(List.of(impMediaType.toString(), VIDEO_ALIAS)) : SimpleDirectParameter.of(impMediaType.toString()); @@ -331,7 +331,7 @@ private static Format resolveFormatFromImp(Imp imp, List mediaType return null; } - return switch (mediaTypes.get(0)) { + return switch (mediaTypes.getFirst()) { case banner -> resolveFormatFromBannerImp(imp); case video -> resolveFormatFromVideoImp(imp); default -> null; @@ -346,7 +346,7 @@ private static Format resolveFormatFromBannerImp(Imp imp) { case 0 -> formatOf( ObjectUtil.getIfNotNull(banner, Banner::getW), ObjectUtil.getIfNotNull(banner, Banner::getH)); - case 1 -> formats.get(0); + case 1 -> formats.getFirst(); default -> null; }; } diff --git a/src/main/java/org/prebid/server/geolocation/MaxMindGeoLocationService.java b/src/main/java/org/prebid/server/geolocation/MaxMindGeoLocationService.java index b258f14a531..2cea7119714 100644 --- a/src/main/java/org/prebid/server/geolocation/MaxMindGeoLocationService.java +++ b/src/main/java/org/prebid/server/geolocation/MaxMindGeoLocationService.java @@ -101,7 +101,7 @@ private static String resolveCountry(CityResponse cityResponse) { private static String resolveRegion(CityResponse cityResponse) { final List subdivisions = cityResponse != null ? cityResponse.getSubdivisions() : null; - final Subdivision firstSubdivision = CollectionUtils.isEmpty(subdivisions) ? null : subdivisions.get(0); + final Subdivision firstSubdivision = CollectionUtils.isEmpty(subdivisions) ? null : subdivisions.getFirst(); return firstSubdivision != null ? firstSubdivision.getIsoCode() : null; } diff --git a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java index 5ce337fe134..746dffb5fc7 100644 --- a/src/main/java/org/prebid/server/handler/CookieSyncHandler.java +++ b/src/main/java/org/prebid/server/handler/CookieSyncHandler.java @@ -232,27 +232,32 @@ private void respondWithError(Throwable error, RoutingContext routingContext) { final HttpResponseStatus status; final String body; - if (error instanceof InvalidCookieSyncRequestException) { - status = HttpResponseStatus.BAD_REQUEST; - body = "Invalid request format: " + message; - - metrics.updateUserSyncBadRequestMetric(); - BAD_REQUEST_LOGGER.info(message, logSamplingRate); - } else if (error instanceof UnauthorizedUidsException) { - status = HttpResponseStatus.UNAUTHORIZED; - body = "Unauthorized: " + message; - - metrics.updateUserSyncOptoutMetric(); - } else if (error instanceof InvalidAccountConfigException) { - status = HttpResponseStatus.BAD_REQUEST; - body = "Invalid account configuration: " + message; - - BAD_REQUEST_LOGGER.info(message, logSamplingRate); - } else { - status = HttpResponseStatus.INTERNAL_SERVER_ERROR; - body = "Unexpected setuid processing error: " + message; - - logger.warn(body, error); + switch (error) { + case InvalidCookieSyncRequestException invalidCookieSyncRequestException -> { + status = HttpResponseStatus.BAD_REQUEST; + body = "Invalid request format: " + message; + + metrics.updateUserSyncBadRequestMetric(); + BAD_REQUEST_LOGGER.info(message, logSamplingRate); + } + case UnauthorizedUidsException unauthorizedUidsException -> { + status = HttpResponseStatus.UNAUTHORIZED; + body = "Unauthorized: " + message; + + metrics.updateUserSyncOptoutMetric(); + } + case InvalidAccountConfigException invalidAccountConfigException -> { + status = HttpResponseStatus.BAD_REQUEST; + body = "Invalid account configuration: " + message; + + BAD_REQUEST_LOGGER.info(message, logSamplingRate); + } + default -> { + status = HttpResponseStatus.INTERNAL_SERVER_ERROR; + body = "Unexpected setuid processing error: " + message; + + logger.warn(body, error); + } } HttpUtil.executeSafely(routingContext, Endpoint.cookie_sync, diff --git a/src/main/java/org/prebid/server/handler/SetuidHandler.java b/src/main/java/org/prebid/server/handler/SetuidHandler.java index bbe0244cc1b..c036bb310cd 100644 --- a/src/main/java/org/prebid/server/handler/SetuidHandler.java +++ b/src/main/java/org/prebid/server/handler/SetuidHandler.java @@ -364,25 +364,31 @@ private void handleErrors(Throwable error, RoutingContext routingContext, TcfCon final String message = error.getMessage(); final HttpResponseStatus status; final String body; - if (error instanceof InvalidRequestException) { - metrics.updateUserSyncBadRequestMetric(); - status = HttpResponseStatus.BAD_REQUEST; - body = "Invalid request format: " + message; - } else if (error instanceof UnauthorizedUidsException) { - metrics.updateUserSyncOptoutMetric(); - status = HttpResponseStatus.UNAUTHORIZED; - body = "Unauthorized: " + message; - } else if (error instanceof UnavailableForLegalReasonsException) { - status = HttpResponseStatus.valueOf(451); - body = "Unavailable For Legal Reasons."; - } else if (error instanceof InvalidAccountConfigException) { - metrics.updateUserSyncBadRequestMetric(); - status = HttpResponseStatus.BAD_REQUEST; - body = "Invalid account configuration: " + message; - } else { - status = HttpResponseStatus.INTERNAL_SERVER_ERROR; - body = "Unexpected setuid processing error: " + message; - logger.warn(body, error); + switch (error) { + case InvalidRequestException invalidRequestException -> { + metrics.updateUserSyncBadRequestMetric(); + status = HttpResponseStatus.BAD_REQUEST; + body = "Invalid request format: " + message; + } + case UnauthorizedUidsException unauthorizedUidsException -> { + metrics.updateUserSyncOptoutMetric(); + status = HttpResponseStatus.UNAUTHORIZED; + body = "Unauthorized: " + message; + } + case UnavailableForLegalReasonsException unavailableForLegalReasonsException -> { + status = HttpResponseStatus.valueOf(451); + body = "Unavailable For Legal Reasons."; + } + case InvalidAccountConfigException invalidAccountConfigException -> { + metrics.updateUserSyncBadRequestMetric(); + status = HttpResponseStatus.BAD_REQUEST; + body = "Invalid account configuration: " + message; + } + default -> { + status = HttpResponseStatus.INTERNAL_SERVER_ERROR; + body = "Unexpected setuid processing error: " + message; + logger.warn(body, error); + } } HttpUtil.executeSafely(routingContext, Endpoint.setuid, diff --git a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java index f238694a593..c1d9c58dca6 100644 --- a/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java +++ b/src/main/java/org/prebid/server/handler/openrtb2/AmpHandler.java @@ -369,7 +369,7 @@ private static String originFrom(RoutingContext routingContext) { String origin = null; final List ampSourceOrigin = routingContext.queryParam("__amp_source_origin"); if (CollectionUtils.isNotEmpty(ampSourceOrigin)) { - origin = ampSourceOrigin.get(0); + origin = ampSourceOrigin.getFirst(); } if (origin == null) { // Just to be safe diff --git a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java index f6e8d1f4868..4cc20f7aba3 100644 --- a/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java +++ b/src/main/java/org/prebid/server/settings/CachingApplicationSettings.java @@ -251,11 +251,6 @@ public void invalidateAccountCache(String accountId) { logger.debug("Account with id {} was invalidated", accountId); } - public void invalidateAllAccountCache() { - accountCache.clear(); - logger.debug("All accounts cache were invalidated"); - } - private static void noOp(ANY any) { } } diff --git a/src/main/java/org/prebid/server/settings/model/activity/rule/resolver/AccountActivityRuleConfigResolver.java b/src/main/java/org/prebid/server/settings/model/activity/rule/resolver/AccountActivityRuleConfigResolver.java index f02acacb382..42140d329da 100644 --- a/src/main/java/org/prebid/server/settings/model/activity/rule/resolver/AccountActivityRuleConfigResolver.java +++ b/src/main/java/org/prebid/server/settings/model/activity/rule/resolver/AccountActivityRuleConfigResolver.java @@ -19,7 +19,7 @@ public static Class resolve(JsonNode ruleNo return MATCHERS.stream() .filter(matcher -> matcher.matches(ruleNode)) .findFirst() - .orElseGet(() -> MATCHERS.get(MATCHERS.size() - 1)) + .orElseGet(() -> MATCHERS.getLast()) .type(); } } diff --git a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java index a521ea0c583..fd7373a1aab 100644 --- a/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java +++ b/src/main/java/org/prebid/server/spring/config/database/model/DatabaseType.java @@ -6,5 +6,5 @@ public enum DatabaseType { postgres, - mysql; + mysql } diff --git a/src/main/java/org/prebid/server/validation/RequestValidator.java b/src/main/java/org/prebid/server/validation/RequestValidator.java index 4b0c1ddfe7f..375a0012764 100644 --- a/src/main/java/org/prebid/server/validation/RequestValidator.java +++ b/src/main/java/org/prebid/server/validation/RequestValidator.java @@ -1013,7 +1013,7 @@ private void validateImpExtPrebidBidder(JsonNode extPrebidBidder, } } - if (extPrebidBidder.size() == 0) { + if (extPrebidBidder.isEmpty()) { warnings.add("WARNING: request.imp[%d].ext must contain at least one valid bidder".formatted(impIndex)); } } diff --git a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java index d938ec69aa0..2d7b2f1e23f 100644 --- a/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java +++ b/src/test/java/org/prebid/server/activity/infrastructure/creator/ActivityInfrastructureCreatorTest.java @@ -123,7 +123,7 @@ public void parseShouldReturnExpectedResult() { final GppContext gppContext = GppContextCreator.from(null, null).build().getGppContext(); given(activityRuleFactory.from( - same(account.getPrivacy().getActivities().get(Activity.TRANSMIT_UFPD).getRules().get(0)), + same(account.getPrivacy().getActivities().get(Activity.TRANSMIT_UFPD).getRules().getFirst()), argThat(arg -> arg.getGppContext() == gppContext))) .willReturn(TestRule.disallowIfMatches(payload -> true)); diff --git a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java index 58a9386de55..7d2a4215dfd 100644 --- a/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java +++ b/src/test/java/org/prebid/server/auction/BidResponseCreatorTest.java @@ -3055,7 +3055,7 @@ public void shouldPopulateBidResponseExtErrorIfImpExtIsInvalid() { final BidResponse bidResponse = bidResponseCreator.create(auctionContext, CACHE_INFO, MULTI_BIDS).result(); // then - assertThat(bidResponse.getExt().getErrors().get("prebid").get(0).getMessage()).isEqualTo(errorMessage); + assertThat(bidResponse.getExt().getErrors().get("prebid").getFirst().getMessage()).isEqualTo(errorMessage); } @Test @@ -3107,7 +3107,7 @@ public void shouldThrowExceptionWhenBidAdmIsParsedButImpNativeNotFound() throws assertThat(bidResponse.getExt()) .extracting(ExtBidResponse::getErrors) .extracting(error -> error.get(bidder1)) - .extracting(extBidderErrors -> extBidderErrors.get(0)) + .extracting(extBidderErrors -> extBidderErrors.getFirst()) .isEqualTo(ExtBidderError.of(3, "Could not find native imp")); } @@ -3148,7 +3148,7 @@ public void shouldThrowExceptionWhenNativeRequestIsInvalid() throws JsonProcessi assertThat(bidResponse.getExt()) .extracting(ExtBidResponse::getErrors) .extracting(error -> error.get(bidder1)) - .extracting(extBidderErrors -> extBidderErrors.get(0)) + .extracting(extBidderErrors -> extBidderErrors.getFirst()) .isEqualTo(ExtBidderError.of(3, "No content to map due to end-of-input\n" + " at [Source: (String)\"\"; line: 1, column: 0]")); } @@ -3186,9 +3186,9 @@ public void shouldPopulateBidAdmIfResponseAssetsIsNull() throws JsonProcessingEx // then assertThat(bidResponse) .extracting(BidResponse::getSeatbid) - .extracting(seatBids -> seatBids.get(0)) + .extracting(seatBids -> seatBids.getFirst()) .extracting(SeatBid::getBid) - .extracting(bids -> bids.get(0)) + .extracting(bids -> bids.getFirst()) .extracting(Bid::getAdm) .isEqualTo(adm); } diff --git a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java index 7194b1d70ea..d29764eb1a1 100644 --- a/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java +++ b/src/test/java/org/prebid/server/auction/ExchangeServiceTest.java @@ -1124,7 +1124,7 @@ public void shouldExtractMultipleRequestsForTheSameBidderIfAliasesWereUsed() { assertThat(capturedBidderRequests).hasSize(2) .extracting(BidderRequest::getBidRequest) - .extracting(capturedBidRequest -> capturedBidRequest.getImp().get(0).getExt().get("bidder").asInt()) + .extracting(capturedBidRequest -> capturedBidRequest.getImp().getFirst().getExt().get("bidder").asInt()) .containsOnly(2, 1); } @@ -3135,7 +3135,7 @@ public void shouldDropBidIfPrebidExceptionWasThrownDuringCurrencyConversion() { final BidderError expectedError = BidderError.generic("Unable to convert bid currency CUR to desired ad server currency USD"); - final BidderSeatBid firstSeatBid = auctionParticipations.get(0).getBidderResponse().getSeatBid(); + final BidderSeatBid firstSeatBid = auctionParticipations.getFirst().getBidderResponse().getSeatBid(); assertThat(firstSeatBid.getBids()).isEmpty(); assertThat(firstSeatBid.getErrors()).containsOnly(expectedError); } @@ -3171,7 +3171,7 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndPriceAdjustmentFactor() assertThat(auctionParticipations).hasSize(1); final BigDecimal updatedPrice = BigDecimal.valueOf(100); - final BidderSeatBid firstSeatBid = auctionParticipations.get(0).getBidderResponse().getSeatBid(); + final BidderSeatBid firstSeatBid = auctionParticipations.getFirst().getBidderResponse().getSeatBid(); assertThat(firstSeatBid.getBids()) .extracting(BidderBid::getBid) .flatExtracting(Bid::getPrice) @@ -3217,7 +3217,7 @@ public void shouldUpdatePriceForOneBidAndDropAnotherIfPrebidExceptionHappensForS final BidderError expectedError = BidderError.generic("Unable to convert bid currency CUR2 to desired ad server currency USD"); - final BidderSeatBid firstSeatBid = auctionParticipations.get(0).getBidderResponse().getSeatBid(); + final BidderSeatBid firstSeatBid = auctionParticipations.getFirst().getBidderResponse().getSeatBid(); assertThat(firstSeatBid.getBids()).containsOnly(expectedBidderBid); assertThat(firstSeatBid.getErrors()).containsOnly(expectedError); } @@ -3302,7 +3302,7 @@ public void shouldUpdateBidPriceWithCurrencyConversionAndAddErrorAboutMultipleCu final BidderError expectedError = BidderError.badInput("Cur parameter contains more than one currency." + " CUR1 will be used"); - final BidderSeatBid firstSeatBid = auctionParticipations.get(0).getBidderResponse().getSeatBid(); + final BidderSeatBid firstSeatBid = auctionParticipations.getFirst().getBidderResponse().getSeatBid(); assertThat(firstSeatBid.getBids()) .extracting(BidderBid::getBid) .flatExtracting(Bid::getPrice) @@ -4533,7 +4533,7 @@ public void shouldResponseWithEmptySeatBidIfBidderNotSupportProvidedMediaTypes() .willReturn(MediaTypeProcessingResult.rejected(Collections.singletonList( BidderError.badInput("MediaTypeProcessor error.")))); given(bidResponseCreator.create( - argThat(argument -> argument.getAuctionParticipations().get(0) + argThat(argument -> argument.getAuctionParticipations().getFirst() .getBidderResponse() .equals(BidderResponse.of( "bidder1", diff --git a/src/test/java/org/prebid/server/auction/StoredRequestProcessorTest.java b/src/test/java/org/prebid/server/auction/StoredRequestProcessorTest.java index 7bfbd666bb1..86e9952e436 100644 --- a/src/test/java/org/prebid/server/auction/StoredRequestProcessorTest.java +++ b/src/test/java/org/prebid/server/auction/StoredRequestProcessorTest.java @@ -509,7 +509,7 @@ public void shouldReturnBidRequestWithMergedImp() throws IOException { // then assertThat(bidRequestFuture.succeeded()).isTrue(); assertThat(bidRequestFuture.result().hasStoredBidRequest()).isTrue(); - assertThat(bidRequestFuture.result().bidRequest().getImp().get(0)).isEqualTo(Imp.builder() + assertThat(bidRequestFuture.result().bidRequest().getImp().getFirst()).isEqualTo(Imp.builder() .banner(Banner.builder().format(singletonList(Format.builder().w(300).h(250).build())).build()) .ext(mapper.valueToTree( ExtImp.of(ExtImpPrebid.builder().storedrequest(ExtStoredRequest.of("123")).build(), null))) @@ -575,7 +575,7 @@ public void shouldReturnImpAndBidRequestWithoutChangesIfStoredRequestIsAbsentInP verifyNoInteractions(applicationSettings, metrics); assertThat(bidRequestFuture.succeeded()).isTrue(); assertThat(bidRequestFuture.result().hasStoredBidRequest()).isFalse(); - assertThat(bidRequestFuture.result().bidRequest().getImp().get(0)).isSameAs(imp); + assertThat(bidRequestFuture.result().bidRequest().getImp().getFirst()).isSameAs(imp); assertThat(bidRequestFuture.result().bidRequest()).isSameAs(bidRequest); } diff --git a/src/test/java/org/prebid/server/auction/VideoResponseFactoryTest.java b/src/test/java/org/prebid/server/auction/VideoResponseFactoryTest.java index af3711ea1d9..7eb37e2f626 100644 --- a/src/test/java/org/prebid/server/auction/VideoResponseFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/VideoResponseFactoryTest.java @@ -74,7 +74,7 @@ public void shouldUpdateCachedDebugLogAndResponseWhenZeroAdPods() { assertThat(result.getAdPods()).hasSize(1) .extracting(ExtAdPod::getTargeting) .hasSize(1) - .extracting(extResponseVideoTargetings -> extResponseVideoTargetings.get(0)) + .extracting(extResponseVideoTargetings -> extResponseVideoTargetings.getFirst()) .extracting(ExtResponseVideoTargeting::getHbCacheID) .containsOnly("generatedId"); assertThat(cachedDebugLog.hasBids()).isFalse(); diff --git a/src/test/java/org/prebid/server/bidder/aceex/AceexBidderTest.java b/src/test/java/org/prebid/server/bidder/aceex/AceexBidderTest.java index f205cf634c5..c9c4515fb4d 100644 --- a/src/test/java/org/prebid/server/bidder/aceex/AceexBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/aceex/AceexBidderTest.java @@ -41,7 +41,7 @@ public class AceexBidderTest extends VertxTest { private static final String ENDPOINT_URL = "https://test-url.com/?param={{AccountId}}"; - private AceexBidder target = new AceexBidder(ENDPOINT_URL, jacksonMapper); + private final AceexBidder target = new AceexBidder(ENDPOINT_URL, jacksonMapper); @Test public void creationShouldFailOnInvalidEndpointUrl() { diff --git a/src/test/java/org/prebid/server/bidder/acuityads/AcuityadsBidderTest.java b/src/test/java/org/prebid/server/bidder/acuityads/AcuityadsBidderTest.java index 17ca4790436..83d0b0d6b09 100644 --- a/src/test/java/org/prebid/server/bidder/acuityads/AcuityadsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/acuityads/AcuityadsBidderTest.java @@ -53,7 +53,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("ext.bidder not provided"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("ext.bidder not provided"); } @Test @@ -66,7 +66,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtIsNull() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("ext.bidder not provided"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("ext.bidder not provided"); } @Test @@ -80,7 +80,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtHostParamIsEmpty() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Missed host param"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Missed host param"); } @Test @@ -94,7 +94,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtAccountIdParamIsEmpty() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Missed accountId param"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Missed accountId param"); } @Test @@ -139,8 +139,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adgeneration/AdgenerationBidderTest.java b/src/test/java/org/prebid/server/bidder/adgeneration/AdgenerationBidderTest.java index 333aaffdefe..fbf91eca901 100644 --- a/src/test/java/org/prebid/server/bidder/adgeneration/AdgenerationBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adgeneration/AdgenerationBidderTest.java @@ -61,7 +61,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test @@ -297,8 +297,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -341,7 +341,7 @@ public void makeBidsShouldReturnCorrectBidderBid() throws JsonProcessingExceptio .build(), BidType.banner, "JPY"); - assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm); + assertThat(result.getValue().getFirst().getBid().getAdm()).isEqualTo(adm); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).doesNotContainNull() .hasSize(1).element(0).isEqualTo(expected); @@ -365,7 +365,7 @@ public void makeBidsShouldReturnCorrectAdmIfBodyTagOfAdIsAbsent() throws JsonPro // then final String adm = "ad"; - assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm); + assertThat(result.getValue().getFirst().getBid().getAdm()).isEqualTo(adm); } @Test @@ -387,7 +387,7 @@ public void makeBidsShouldReturnCorrectAdmIfBodyTagExistsInAd() throws JsonProce // then final String adm = "adscriptbeacon"; - assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm); + assertThat(result.getValue().getFirst().getBid().getAdm()).isEqualTo(adm); } @Test @@ -409,7 +409,7 @@ public void makeBidsShouldReturnCorrectAdmIfBeaconIsBlank() throws JsonProcessin // then final String adm = "adscript"; - assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm); + assertThat(result.getValue().getFirst().getBid().getAdm()).isEqualTo(adm); } @Test @@ -434,7 +434,7 @@ public void makeBidsShouldReturnIfImpExtCouldNotBeParsed() throws JsonProcessing // then // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } private static BidRequest givenBidRequest( diff --git a/src/test/java/org/prebid/server/bidder/adhese/AdheseBidderTest.java b/src/test/java/org/prebid/server/bidder/adhese/AdheseBidderTest.java index f82e5027600..c5685203484 100644 --- a/src/test/java/org/prebid/server/bidder/adhese/AdheseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adhese/AdheseBidderTest.java @@ -74,7 +74,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adkernel/AdkernelBidderTest.java b/src/test/java/org/prebid/server/bidder/adkernel/AdkernelBidderTest.java index f3834e99309..8f12754e45d 100644 --- a/src/test/java/org/prebid/server/bidder/adkernel/AdkernelBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adkernel/AdkernelBidderTest.java @@ -135,7 +135,7 @@ public void makeHttpRequestsShouldSetExpectedMethodUrlAndHeaders() { assertThat(result.getValue()).hasSize(1).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("https://test.com?zone=3426", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), @@ -236,7 +236,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { assertThat(result.getErrors()).hasSize(1); assertThat(result.getErrors()).allMatch(error -> error.getType() == BidderError.Type.bad_server_response && error.getMessage().startsWith("Failed to decode: Unrecognized token")); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidderTest.java b/src/test/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidderTest.java index 25d5ad5a364..3fb97d06e58 100644 --- a/src/test/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adkerneladn/AdkernelAdnBidderTest.java @@ -84,7 +84,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -144,7 +144,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { assertThat(result.getValue()).hasSize(1).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("https://test.com/test?account=50357", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), @@ -311,8 +311,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adman/AdmanBidderTest.java b/src/test/java/org/prebid/server/bidder/adman/AdmanBidderTest.java index aefbf8e897e..5642ba1b6ca 100644 --- a/src/test/java/org/prebid/server/bidder/adman/AdmanBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adman/AdmanBidderTest.java @@ -51,7 +51,7 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidString").build())) + .imp(singletonList(bidRequest.getImp().getFirst().toBuilder().tagid("tagidString").build())) .build(); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()) diff --git a/src/test/java/org/prebid/server/bidder/adocean/AdoceanBidderTest.java b/src/test/java/org/prebid/server/bidder/adocean/AdoceanBidderTest.java index 6bfe5b06583..08c86844ce6 100644 --- a/src/test/java/org/prebid/server/bidder/adocean/AdoceanBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adocean/AdoceanBidderTest.java @@ -309,7 +309,7 @@ public void makeHttpRequestsShouldSetExpectedHeadersIfDeviceIpIsPresent() { final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactly(tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), tuple(HttpUtil.ACCEPT_HEADER.toString(), HttpHeaderValues.APPLICATION_JSON.toString()), @@ -340,7 +340,7 @@ public void makeHttpRequestsShouldSetExpectedHeadersIfDeviceIpv6IsPresent() { final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactly(tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), tuple(HttpUtil.ACCEPT_HEADER.toString(), HttpHeaderValues.APPLICATION_JSON.toString()), @@ -402,7 +402,7 @@ public void makeBidsShouldReturnCorrectBidderBid() throws JsonProcessingExceptio .h(250) .build(), BidType.banner, "EUR"); - assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm); + assertThat(result.getValue().getFirst().getBid().getAdm()).isEqualTo(adm); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).doesNotContainNull().hasSize(1).element(0).isEqualTo(expected); } diff --git a/src/test/java/org/prebid/server/bidder/adoppler/AdopplerBidderTest.java b/src/test/java/org/prebid/server/bidder/adoppler/AdopplerBidderTest.java index f314d6d55dc..428c4b68b54 100644 --- a/src/test/java/org/prebid/server/bidder/adoppler/AdopplerBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adoppler/AdopplerBidderTest.java @@ -71,7 +71,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("http://clientId.test.com/some/path/adUnit"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("http://clientId.test.com/some/path/adUnit"); } @Test @@ -87,7 +87,7 @@ public void makeHttpRequestsShouldCreateUrlWithDefaultAppParamIfClientIsMissing( // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("http://app.test.com/some/path/adUnit"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("http://app.test.com/some/path/adUnit"); } @Test @@ -100,7 +100,7 @@ public void makeHttpRequestsShouldSetExpectedHeaders() { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactlyInAnyOrder(tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.5"), tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), diff --git a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java index fea318e7022..3e21e17dcef 100644 --- a/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adot/AdotBidderTest.java @@ -137,8 +137,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adpone/AdponeBidderTest.java b/src/test/java/org/prebid/server/bidder/adpone/AdponeBidderTest.java index d17a6bc6d78..88de33ffaa9 100644 --- a/src/test/java/org/prebid/server/bidder/adpone/AdponeBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adpone/AdponeBidderTest.java @@ -51,7 +51,7 @@ public void makeHttpRequestsShouldReturnErrorIfFirstImpExtCannotBeParsed() { final List errors = result.getErrors(); assertThat(errors).hasSize(1); - assertThat(errors.get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(errors.getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test @@ -69,7 +69,7 @@ public void makeHttpRequestsShouldNotModifyIncomingBidRequestAndPassItOn() { assertThat(httpRequests).hasSize(1) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) .containsOnly(bidRequest); - assertThat(httpRequests.get(0).getPayload()).isSameAs(bidRequest); + assertThat(httpRequests.getFirst().getPayload()).isSameAs(bidRequest); } @Test @@ -84,7 +84,7 @@ public void makeHttpRequestsShouldFillExpectedHeaders() { assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getHeaders()) + assertThat(result.getValue().getFirst().getHeaders()) .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple("Content-Type", "application/json;charset=utf-8"), @@ -102,9 +102,9 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adprime/AdprimeBidderTest.java b/src/test/java/org/prebid/server/bidder/adprime/AdprimeBidderTest.java index fd7532c8eaa..9da4ee70452 100644 --- a/src/test/java/org/prebid/server/bidder/adprime/AdprimeBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adprime/AdprimeBidderTest.java @@ -58,7 +58,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Unable to decode the impression ext for id"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Unable to decode the impression ext for id"); assertThat(result.getValue()).isEmpty(); } @@ -205,8 +205,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/adtarget/AdtargetBidderTest.java b/src/test/java/org/prebid/server/bidder/adtarget/AdtargetBidderTest.java index 758caf4cb1b..e9e600c83c8 100644 --- a/src/test/java/org/prebid/server/bidder/adtarget/AdtargetBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adtarget/AdtargetBidderTest.java @@ -56,7 +56,7 @@ public void makeHttpRequestsShouldReturnHttpRequestWithCorrectBodyHeadersAndMeth // then final BidRequest expectedBidRequest = bidRequest .toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder() + .imp(singletonList(bidRequest.getImp().getFirst().toBuilder() .bidfloor(BigDecimal.valueOf(3)) .ext(mapper.valueToTree(AdtargetImpExt.of( ExtImpAdtarget.of(15, 1, 2, BigDecimal.valueOf(3))))) diff --git a/src/test/java/org/prebid/server/bidder/advangelists/AdvangelistsBidderTest.java b/src/test/java/org/prebid/server/bidder/advangelists/AdvangelistsBidderTest.java index 69fce60e7ab..9ed3b25e549 100644 --- a/src/test/java/org/prebid/server/bidder/advangelists/AdvangelistsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/advangelists/AdvangelistsBidderTest.java @@ -170,7 +170,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { assertThat(result.getValue()).hasSize(1).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("http://test/get?pubid=pubid", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), diff --git a/src/test/java/org/prebid/server/bidder/adxcg/AdxcgBidderTest.java b/src/test/java/org/prebid/server/bidder/adxcg/AdxcgBidderTest.java index 74fe9481780..cd8377ca1a3 100644 --- a/src/test/java/org/prebid/server/bidder/adxcg/AdxcgBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/adxcg/AdxcgBidderTest.java @@ -74,8 +74,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/aja/AjaBidderTest.java b/src/test/java/org/prebid/server/bidder/aja/AjaBidderTest.java index 7da9b3a801e..708d1f2336d 100644 --- a/src/test/java/org/prebid/server/bidder/aja/AjaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/aja/AjaBidderTest.java @@ -52,7 +52,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to unmarshal ext.bidder impID"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to unmarshal ext.bidder impID"); assertThat(result.getValue()).isEmpty(); } @@ -66,8 +66,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/appnexus/AppnexusBidderTest.java b/src/test/java/org/prebid/server/bidder/appnexus/AppnexusBidderTest.java index 20e76ccb7c1..b5c2e1a1eaf 100644 --- a/src/test/java/org/prebid/server/bidder/appnexus/AppnexusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/appnexus/AppnexusBidderTest.java @@ -644,11 +644,11 @@ public void makeHttpRequestsShouldGenerateProperAdPodIds() { assertThat(result.getValue()) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getExt) - .satisfies(exts -> assertThat(exts.get(0)).isNotSameAs(exts.get(1))) + .satisfies(exts -> assertThat(exts.getFirst()).isNotSameAs(exts.get(1))) .extracting(ext -> ext.getProperty("appnexus")) .extracting(appnexus -> appnexus.get("adpod_id")) .hasSize(2) - .satisfies(ids -> assertThat(ids.get(0)).isNotSameAs(ids.get(1))); + .satisfies(ids -> assertThat(ids.getFirst()).isNotSameAs(ids.get(1))); assertThat(result.getErrors()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java b/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java index 46e3375e8f4..9d99e1bd6ff 100644 --- a/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/aso/AsoBidderTest.java @@ -163,8 +163,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/audiencenetwork/AudienceNetworkBidderTest.java b/src/test/java/org/prebid/server/bidder/audiencenetwork/AudienceNetworkBidderTest.java index 210283caedf..285642e7df5 100644 --- a/src/test/java/org/prebid/server/bidder/audiencenetwork/AudienceNetworkBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/audiencenetwork/AudienceNetworkBidderTest.java @@ -117,7 +117,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCannotBeParsed() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value of"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value of"); } @Test @@ -557,7 +557,8 @@ public void makeBidsShouldReturnErrorWhenBidAdmCouldNotBeParsed() throws JsonPro // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token 'invalid'"); + assertThat(result.getErrors().getFirst().getMessage()) + .startsWith("Failed to decode: Unrecognized token 'invalid'"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/avocet/AvocetBidderTest.java b/src/test/java/org/prebid/server/bidder/avocet/AvocetBidderTest.java index 7369fc5aea8..ff22b5f0e7f 100644 --- a/src/test/java/org/prebid/server/bidder/avocet/AvocetBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/avocet/AvocetBidderTest.java @@ -68,8 +68,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/beachfront/BeachfrontBidderTest.java b/src/test/java/org/prebid/server/bidder/beachfront/BeachfrontBidderTest.java index fe2aa127e43..986bc326d57 100644 --- a/src/test/java/org/prebid/server/bidder/beachfront/BeachfrontBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/beachfront/BeachfrontBidderTest.java @@ -122,7 +122,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith( + assertThat(result.getErrors().getFirst().getMessage()).startsWith( "ignoring imp id=123, error while decoding extImpBeachfront, err: Cannot deserialize value"); } @@ -364,7 +364,7 @@ public void makeHttpRequestsShouldReturnRequestWithExpectedBasicHeadersAndAdditi final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()) + assertThat(result.getValue().getFirst().getHeaders()) .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), @@ -385,7 +385,7 @@ public void makeHttpRequestsShouldAdditionalCookieHeaderForVideoRequestWhenBuyer final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()) + assertThat(result.getValue().getFirst().getHeaders()) .extracting(Map.Entry::getKey, Map.Entry::getValue) .contains( tuple(HttpUtil.COOKIE_HEADER.toString(), "__io_cid=4125")); @@ -598,7 +598,7 @@ public void makeBidsShouldReturnErrorWhenResponseBodyIsInvalid() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .isEqualTo("server response failed to unmarshal as valid rtb. " + "Run with request.debug = 1 for more info"); } diff --git a/src/test/java/org/prebid/server/bidder/beintoo/BeintooBidderTest.java b/src/test/java/org/prebid/server/bidder/beintoo/BeintooBidderTest.java index c05e3959afe..19ace2098e0 100644 --- a/src/test/java/org/prebid/server/bidder/beintoo/BeintooBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/beintoo/BeintooBidderTest.java @@ -61,7 +61,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -81,7 +81,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpNotContainsBanner() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Request needs to include a Banner object"); assertThat(result.getValue()).isEmpty(); } @@ -102,7 +102,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsNull() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid must be a String of numbers"); assertThat(result.getValue()).isEmpty(); } @@ -123,7 +123,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsNotNumbe // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid must be a String of numbers"); assertThat(result.getValue()).isEmpty(); } @@ -144,7 +144,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsZero() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid cant be 0"); assertThat(result.getValue()).isEmpty(); } @@ -165,7 +165,7 @@ public void makeHttpRequestsShouldReturnErrorWhenWidthAndHeightIsNullAndBannerFo // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Need at least one size to build request"); assertThat(result.getValue()).isEmpty(); } @@ -186,7 +186,7 @@ public void makeHttpRequestsShouldReturnErrorWhenWidthAndHeightIsNullAndBannerFo // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Need at least one size to build request"); assertThat(result.getValue()).isEmpty(); } @@ -301,9 +301,9 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()) + assertThat(result.getErrors().getFirst().getType()) .isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/bidmachine/BidmachineBidderTest.java b/src/test/java/org/prebid/server/bidder/bidmachine/BidmachineBidderTest.java index df31a11c865..df222561759 100644 --- a/src/test/java/org/prebid/server/bidder/bidmachine/BidmachineBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/bidmachine/BidmachineBidderTest.java @@ -143,7 +143,7 @@ public void makeHttpRequestsShouldModifyImplIfPrebidIsRequestAndBannerBattrDoesN assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(imps -> imps.get(0)) + .extracting(imps -> imps.getFirst()) .flatExtracting(currImp -> currImp.getBanner().getBattr()) .containsExactly(1, 16); } @@ -169,7 +169,7 @@ public void makeHttpRequestsShouldModifyImplIfPrebidIsRequestAndVideoBattrDoesNo assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(imps -> imps.get(0)) + .extracting(imps -> imps.getFirst()) .flatExtracting(currImp -> currImp.getVideo().getBattr()) .containsExactly(1, 16); } diff --git a/src/test/java/org/prebid/server/bidder/bidstack/BidstackBidderTest.java b/src/test/java/org/prebid/server/bidder/bidstack/BidstackBidderTest.java index aa30cdb448c..097d96df551 100644 --- a/src/test/java/org/prebid/server/bidder/bidstack/BidstackBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/bidstack/BidstackBidderTest.java @@ -204,7 +204,7 @@ public void makeBidsWithInvalidBodyShouldResultInError() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/bluesea/BlueSeaBidderTest.java b/src/test/java/org/prebid/server/bidder/bluesea/BlueSeaBidderTest.java index 20d012f1389..6e29b930d2f 100644 --- a/src/test/java/org/prebid/server/bidder/bluesea/BlueSeaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/bluesea/BlueSeaBidderTest.java @@ -57,7 +57,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -113,8 +113,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -252,10 +252,6 @@ private static BidRequest givenBidRequest( return requestCustomizer.apply(BidRequest.builder().imp(singletonList(givenImp(impCustomizer)))).build(); } - private static BidRequest givenBidRequest(Function impCustomizer) { - return givenBidRequest(impCustomizer, identity()); - } - private static Imp givenImp(Function impCustomizer) { return impCustomizer.apply(Imp.builder().id("123")) .banner(Banner.builder().build()) diff --git a/src/test/java/org/prebid/server/bidder/brave/BraveBidderTest.java b/src/test/java/org/prebid/server/bidder/brave/BraveBidderTest.java index 959bca5d96d..cf81b626f53 100644 --- a/src/test/java/org/prebid/server/bidder/brave/BraveBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/brave/BraveBidderTest.java @@ -53,7 +53,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("ext.bidder not provided"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("ext.bidder not provided"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/coinzilla/CoinzillaBidderTest.java b/src/test/java/org/prebid/server/bidder/coinzilla/CoinzillaBidderTest.java index d6a940d2f5e..41183fea694 100644 --- a/src/test/java/org/prebid/server/bidder/coinzilla/CoinzillaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/coinzilla/CoinzillaBidderTest.java @@ -68,7 +68,7 @@ public void makeHttpRequestsShouldHaveCorrectBody() throws JsonProcessingExcepti } @Test - public void makeHttpRequestsShouldHaveCorrectHeaders() throws JsonProcessingException { + public void makeHttpRequestsShouldHaveCorrectHeaders() { // given final BidRequest bidRequest = givenBidRequest(identity()); diff --git a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java index f6dd5ece202..b4381a458e6 100644 --- a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java @@ -54,7 +54,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -68,7 +68,7 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidString").build())) + .imp(singletonList(bidRequest.getImp().getFirst().toBuilder().tagid("tagidString").build())) .build(); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) @@ -108,8 +108,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/connectad/ConnectadBidderTest.java b/src/test/java/org/prebid/server/bidder/connectad/ConnectadBidderTest.java index cd7ca05cfe4..274186f7356 100644 --- a/src/test/java/org/prebid/server/bidder/connectad/ConnectadBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/connectad/ConnectadBidderTest.java @@ -74,8 +74,8 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -175,7 +175,7 @@ public void impSecureShouldBeOneIfSitePageStartsFromHttps() { .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) .hasSize(1) - .extracting(imp -> imp.get(0).getSecure()) + .extracting(imp -> imp.getFirst().getSecure()) .hasSize(1) .containsOnly(1); } diff --git a/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java b/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java index 50463bd776e..e5dcae7fa32 100644 --- a/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/consumable/ConsumableBidderTest.java @@ -63,7 +63,7 @@ public void setUp() { } @Test - public void makeHttpRequestsShouldHaveCorrectHeaders() throws JsonProcessingException { + public void makeHttpRequestsShouldHaveCorrectHeaders() { // given final BidRequest bidRequest = givenSiteBidRequest(identity()); @@ -84,7 +84,7 @@ public void makeHttpRequestsShouldHaveCorrectHeaders() throws JsonProcessingExce } @Test - public void makeHttpRequestsShouldHaveCorrectURIForSiteRequest() throws JsonProcessingException { + public void makeHttpRequestsShouldHaveCorrectURIForSiteRequest() { // given final BidRequest bidRequest = givenSiteBidRequest(identity()); @@ -99,7 +99,7 @@ public void makeHttpRequestsShouldHaveCorrectURIForSiteRequest() throws JsonProc } @Test - public void makeHttpRequestsShouldHaveCorrectURIForAppRequest() throws JsonProcessingException { + public void makeHttpRequestsShouldHaveCorrectURIForAppRequest() { // given final BidRequest bidRequest = givenAppBidRequest(identity()); @@ -141,7 +141,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/cpmstar/CpmStarBidderTest.java b/src/test/java/org/prebid/server/bidder/cpmstar/CpmStarBidderTest.java index 0498d36f60e..aaf627e605a 100644 --- a/src/test/java/org/prebid/server/bidder/cpmstar/CpmStarBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/cpmstar/CpmStarBidderTest.java @@ -54,7 +54,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -97,8 +97,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/datablocks/DatablocksBidderTest.java b/src/test/java/org/prebid/server/bidder/datablocks/DatablocksBidderTest.java index a3414d2c676..8dde4a36285 100644 --- a/src/test/java/org/prebid/server/bidder/datablocks/DatablocksBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/datablocks/DatablocksBidderTest.java @@ -51,7 +51,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -140,8 +140,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/dmx/DmxBidderTest.java b/src/test/java/org/prebid/server/bidder/dmx/DmxBidderTest.java index d36943a989a..27148710f7b 100644 --- a/src/test/java/org/prebid/server/bidder/dmx/DmxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/dmx/DmxBidderTest.java @@ -113,7 +113,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(2); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test @@ -410,7 +410,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://test.endpoint.com?sellerid=sellerId"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://test.endpoint.com?sellerid=sellerId"); } @Test @@ -423,8 +423,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/dxkulture/DxKultureBidderTest.java b/src/test/java/org/prebid/server/bidder/dxkulture/DxKultureBidderTest.java index 5d5c7ff53fb..ab1c84e421d 100644 --- a/src/test/java/org/prebid/server/bidder/dxkulture/DxKultureBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/dxkulture/DxKultureBidderTest.java @@ -61,7 +61,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -148,8 +148,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidderTest.java b/src/test/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidderTest.java index 7a7925370fb..338b18b04c7 100644 --- a/src/test/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/emxdigital/EmxDigitalBidderTest.java @@ -66,7 +66,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -86,7 +86,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpNotContainsBanner() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Request needs to include a Banner object"); assertThat(result.getValue()).isEmpty(); } @@ -107,7 +107,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsNull() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid must be a String of numbers"); assertThat(result.getValue()).isEmpty(); } @@ -128,7 +128,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsNotNumbe // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid must be a String of numbers"); assertThat(result.getValue()).isEmpty(); } @@ -149,7 +149,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtEmxDigitalTagidIsZero() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("tagid cant be 0"); assertThat(result.getValue()).isEmpty(); } @@ -170,7 +170,7 @@ public void makeHttpRequestsShouldReturnErrorWhenWidthAndHeightIsNullAndBannerFo // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Need at least one size to build request"); assertThat(result.getValue()).isEmpty(); } @@ -191,7 +191,7 @@ public void makeHttpRequestsShouldReturnErrorWhenWidthAndHeightIsNullAndBannerFo // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Need at least one size to build request"); assertThat(result.getValue()).isEmpty(); } @@ -331,7 +331,7 @@ public void requestSecureShouldBeOneIfPageStartsWithHttps() { assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .extracting(request -> request.getImp().get(0).getSecure()) + .extracting(request -> request.getImp().getFirst().getSecure()) .containsExactly(1); } @@ -500,9 +500,9 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()) + assertThat(result.getErrors().getFirst().getType()) .isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/eplanning/EplanningBidderTest.java b/src/test/java/org/prebid/server/bidder/eplanning/EplanningBidderTest.java index ca83ae5d092..f9136a140e9 100644 --- a/src/test/java/org/prebid/server/bidder/eplanning/EplanningBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/eplanning/EplanningBidderTest.java @@ -81,7 +81,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Ignoring imp id=123, error while decoding extImpBidder, err: Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -423,8 +423,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/flipp/FlippBidderTest.java b/src/test/java/org/prebid/server/bidder/flipp/FlippBidderTest.java index c60133ee64c..616bb4c0792 100644 --- a/src/test/java/org/prebid/server/bidder/flipp/FlippBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/flipp/FlippBidderTest.java @@ -768,7 +768,7 @@ public void makeBidsShouldPopulateBidCridFromInlineCreativeId() throws JsonProce final BidRequest bidRequest = givenBidRequest(identity()); // and - final Integer creativeId = 1; + final int creativeId = 1; final BidderCall httpCall = givenHttpCall(CampaignRequestBody.builder().build(), mapper.writeValueAsString(givenCampaignResponseBody(inlineBuilder -> inlineBuilder.creativeId(creativeId)))); @@ -781,7 +781,7 @@ public void makeBidsShouldPopulateBidCridFromInlineCreativeId() throws JsonProce assertThat(result.getValue()).hasSize(1) .extracting(BidderBid::getBid) .extracting(Bid::getCrid) - .containsExactly(creativeId.toString()); + .containsExactly(Integer.toString(creativeId)); } @Test diff --git a/src/test/java/org/prebid/server/bidder/gamma/GammaBidderTest.java b/src/test/java/org/prebid/server/bidder/gamma/GammaBidderTest.java index 998fe5e6516..57b2e784c46 100644 --- a/src/test/java/org/prebid/server/bidder/gamma/GammaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/gamma/GammaBidderTest.java @@ -140,7 +140,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { .returns(HttpMethod.GET, HttpRequest::getMethod) .returns("https://test.endpoint.com/?id=id&zid=zid&wid=wid&bidid=&hb=pbmobile", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple("Accept", "*/*"), @@ -184,7 +184,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeadersWhenDeviceAn + "&device_ip=123.123.123.12&device_model=Model&device_os=OS&device_ua=userAgent" + "&device_ifa=ifa&app_id=appId&app_bundle=bundle&app_name=appName", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple("Accept", "*/*"), @@ -220,8 +220,8 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("bad server response: body is empty"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("bad server response: body is empty"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/gamoshi/GamoshiBidderTest.java b/src/test/java/org/prebid/server/bidder/gamoshi/GamoshiBidderTest.java index 28615026a13..9d71ed4ec03 100644 --- a/src/test/java/org/prebid/server/bidder/gamoshi/GamoshiBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/gamoshi/GamoshiBidderTest.java @@ -105,7 +105,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -139,7 +139,7 @@ public void makeHttpRequestsShouldSetExpectedRequestUrlAndDefaultHeaders() { assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getUri) .containsOnly("https://test.endpoint.com/r/supply/bidr?bidder=prebid-server"); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly(tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.4"), tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), @@ -159,7 +159,7 @@ public void makeHttpRequestsShouldSetAdditionalHeaders() { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .contains(tuple(HttpUtil.USER_AGENT_HEADER.toString(), "ua"), tuple(HttpUtil.X_FORWARDED_FOR_HEADER.toString(), "ip"), @@ -224,8 +224,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/impactify/ImpactifyBidderTest.java b/src/test/java/org/prebid/server/bidder/impactify/ImpactifyBidderTest.java index ad6bfe68b77..acecfd3f510 100644 --- a/src/test/java/org/prebid/server/bidder/impactify/ImpactifyBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/impactify/ImpactifyBidderTest.java @@ -266,7 +266,7 @@ public void makeBidsWithInvalidBodyShouldResultInError() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java b/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java index 439be3a40e6..1315f034d26 100644 --- a/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java @@ -345,8 +345,8 @@ private void makeBidsShouldSetProperMtypeInBidsAgainstSingleFormatImpression( // then assertThat(result.getErrors()).hasSize(0); assertThat(result.getValue()).isNotEmpty(); - assertThat(result.getValue().get(0).getBid().getMtype()).isEqualTo(expectedMType); - assertThat(result.getValue().get(0).getType()).isEqualTo(expectedType); + assertThat(result.getValue().getFirst().getBid().getMtype()).isEqualTo(expectedMType); + assertThat(result.getValue().getFirst().getType()).isEqualTo(expectedType); } @Test @@ -433,7 +433,7 @@ public void makeBidsShouldDetermineCorrectBidTypeForMultiFormatImpressionWhenMty // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getType()).isEqualTo(banner); + assertThat(result.getValue().getFirst().getType()).isEqualTo(banner); } @Test diff --git a/src/test/java/org/prebid/server/bidder/invibes/InvibesBidderTest.java b/src/test/java/org/prebid/server/bidder/invibes/InvibesBidderTest.java index 813a812d30d..31211cb5347 100644 --- a/src/test/java/org/prebid/server/bidder/invibes/InvibesBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/invibes/InvibesBidderTest.java @@ -82,7 +82,7 @@ public void makeHttpRequestsShouldCreateCorrectURLFor1003Zone() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://bid3.videostep.com/bid/"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://bid3.videostep.com/bid/"); } @Test @@ -99,7 +99,7 @@ public void makeHttpRequestsShouldCreateCorrectURLFor0Zone() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://bid.videostep.com/bid/"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://bid.videostep.com/bid/"); } @Test @@ -116,7 +116,7 @@ public void makeHttpRequestsShouldCreateCorrectURLFor1Zone() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://bid.videostep.com/bid/"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://bid.videostep.com/bid/"); } @Test @@ -133,7 +133,7 @@ public void makeHttpRequestsShouldCreateCorrectURLFor1001Zone() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://bid.videostep.com/bid/"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://bid.videostep.com/bid/"); } @Test @@ -150,7 +150,7 @@ public void makeHttpRequestsShouldCreateCorrectURLFor999Zone() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://bid999.videostep.com/bid/"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://bid999.videostep.com/bid/"); } @Test @@ -168,7 +168,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Error parsing invibesExt parameters"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Error parsing invibesExt parameters"); assertThat(result.getValue()).isEmpty(); } @@ -350,8 +350,8 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java b/src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java index cd0147f0270..272654f9a46 100644 --- a/src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java @@ -101,7 +101,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test @@ -320,8 +320,8 @@ public void makeBidderResponseShouldReturnErrorIfResponseBodyCouldNotBeParsed() // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getBids()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/kidoz/KidozBidderTest.java b/src/test/java/org/prebid/server/bidder/kidoz/KidozBidderTest.java index e004d82d02a..4ea4601078b 100644 --- a/src/test/java/org/prebid/server/bidder/kidoz/KidozBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/kidoz/KidozBidderTest.java @@ -66,7 +66,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -168,7 +168,7 @@ public void makeHttpRequestsShouldSetDefaultHeaders() { final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly(tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.5"), tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), @@ -185,8 +185,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/krushmedia/KrushmediaBidderTest.java b/src/test/java/org/prebid/server/bidder/krushmedia/KrushmediaBidderTest.java index f28dc0e9c3b..bdf63256ff1 100644 --- a/src/test/java/org/prebid/server/bidder/krushmedia/KrushmediaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/krushmedia/KrushmediaBidderTest.java @@ -53,7 +53,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Error while unmarshalling bidder extension"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Error while unmarshalling bidder extension"); } @Test @@ -98,8 +98,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/limelightdigital/LimeLightDigitalBidderTest.java b/src/test/java/org/prebid/server/bidder/limelightdigital/LimeLightDigitalBidderTest.java index 4abceea9c3e..690baf53b7c 100644 --- a/src/test/java/org/prebid/server/bidder/limelightdigital/LimeLightDigitalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/limelightdigital/LimeLightDigitalBidderTest.java @@ -199,8 +199,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -242,7 +242,7 @@ public void makeBidsShouldReturnErrorIfNoBidTypeIsPresent() throws JsonProcessin final Result> result = target.makeBids(httpCall, null); // then - assertThat(result.getErrors().get(0).getMessage()).isEqualTo("Unknown media type of imp: '123'"); + assertThat(result.getErrors().getFirst().getMessage()).isEqualTo("Unknown media type of imp: '123'"); } @Test @@ -331,7 +331,7 @@ public void makeBidsShouldThrowExcceptionIsNoImpressionWithIdFound() throws Json // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Bid contains unknown imp id: '321'"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Bid contains unknown imp id: '321'"); } private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { diff --git a/src/test/java/org/prebid/server/bidder/lockerdome/LockerdomeBidderTest.java b/src/test/java/org/prebid/server/bidder/lockerdome/LockerdomeBidderTest.java index 19dd28d595c..72aed48db27 100644 --- a/src/test/java/org/prebid/server/bidder/lockerdome/LockerdomeBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/lockerdome/LockerdomeBidderTest.java @@ -65,7 +65,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(2); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -139,8 +139,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/logicad/LogicadBidderTest.java b/src/test/java/org/prebid/server/bidder/logicad/LogicadBidderTest.java index c866acb9ad1..742bd2e4eb9 100644 --- a/src/test/java/org/prebid/server/bidder/logicad/LogicadBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/logicad/LogicadBidderTest.java @@ -53,7 +53,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -120,8 +120,8 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/lunamedia/LunamediaBidderTest.java b/src/test/java/org/prebid/server/bidder/lunamedia/LunamediaBidderTest.java index 06d69379514..e74c4b537ff 100644 --- a/src/test/java/org/prebid/server/bidder/lunamedia/LunamediaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/lunamedia/LunamediaBidderTest.java @@ -170,7 +170,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { assertThat(result.getValue()).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("http://test/get?pubid=pubid", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactlyInAnyOrder( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), diff --git a/src/test/java/org/prebid/server/bidder/mgid/MgidBidderTest.java b/src/test/java/org/prebid/server/bidder/mgid/MgidBidderTest.java index 114b68e442f..8143e6f813b 100644 --- a/src/test/java/org/prebid/server/bidder/mgid/MgidBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/mgid/MgidBidderTest.java @@ -82,7 +82,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtAccIdIsBlank() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).isEqualToIgnoringCase("accountId is not set"); + assertThat(result.getErrors().getFirst().getMessage()).isEqualToIgnoringCase("accountId is not set"); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/mgidx/MgidxBidderTest.java b/src/test/java/org/prebid/server/bidder/mgidx/MgidxBidderTest.java index 4cb6f9a9535..9d4ec48eba7 100644 --- a/src/test/java/org/prebid/server/bidder/mgidx/MgidxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/mgidx/MgidxBidderTest.java @@ -116,7 +116,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCannotBeParsed() { final List errors = result.getErrors(); assertThat(errors).hasSize(1); - assertThat(errors.get(0).getMessage()) + assertThat(errors.getFirst().getMessage()) .startsWith("Cannot deserialize value of type "); } diff --git a/src/test/java/org/prebid/server/bidder/motorik/MotorikBidderTest.java b/src/test/java/org/prebid/server/bidder/motorik/MotorikBidderTest.java index 389e3fdab8d..dd06fbef54e 100644 --- a/src/test/java/org/prebid/server/bidder/motorik/MotorikBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/motorik/MotorikBidderTest.java @@ -62,7 +62,7 @@ public void makeHttpRequestsShouldRemoveOnlyFirstImpExt() { assertThat(result.getValue()) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(imps -> imps.get(0)) + .extracting(imps -> imps.getFirst()) .extracting(Imp::getExt) .containsOnlyNulls(); diff --git a/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java b/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java index 375ac6e4c73..990b370d99c 100644 --- a/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/nextmillennium/NextMillenniumBidderTest.java @@ -442,7 +442,7 @@ public void makeHttpRequestsImpExtComparison() { assertThat(result.getValue()) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(imps -> imps.get(0)) + .extracting(imps -> imps.getFirst()) .extracting(Imp::getExt) .isNotEqualTo(givenImp.getExt()) .extracting(jsonNodes -> mapper.treeToValue(jsonNodes, ExtRequest.class)) @@ -487,7 +487,7 @@ public void makeHttpRequestsImpShouldBeIdenticalExceptExt() { assertThat(result.getValue()) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(imps -> imps.get(0)) + .extracting(imps -> imps.getFirst()) .element(0) .usingRecursiveComparison() .ignoringFields("ext") diff --git a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java index 6816f352b2e..cae703f09bb 100644 --- a/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/openx/OpenxBidderTest.java @@ -188,7 +188,7 @@ public void makeHttpRequestsShouldReturnResultWithErrorWhenImpExtOpenxMalformed( // then assertThat(result.getValue()).isEmpty(); - assertThat(result.getErrors().get(0).getMessage()) + assertThat(result.getErrors().getFirst().getMessage()) .startsWith("Cannot deserialize value of"); } @@ -381,7 +381,7 @@ public void makeHttpRequestsShouldPassThroughImpExt() { .flatExtracting(BidRequest::getImp) .extracting(Imp::getExt) .isNotNull(); - final ObjectNode ext = result.getValue().get(0).getPayload().getImp().get(0).getExt(); + final ObjectNode ext = result.getValue().getFirst().getPayload().getImp().getFirst().getExt(); assertThat(ext) .isInstanceOf(JsonNode.class) .usingRecursiveComparison() diff --git a/src/test/java/org/prebid/server/bidder/orbidder/OrbidderBidderTest.java b/src/test/java/org/prebid/server/bidder/orbidder/OrbidderBidderTest.java index d1fcdddae9a..22c493712cb 100644 --- a/src/test/java/org/prebid/server/bidder/orbidder/OrbidderBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/orbidder/OrbidderBidderTest.java @@ -108,7 +108,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { final Result> result = target.makeBids(httpCall, null); // then - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java b/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java index 8e7947b5a3a..ad41a8a67af 100644 --- a/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java @@ -164,8 +164,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/preciso/PrecisoBidderTest.java b/src/test/java/org/prebid/server/bidder/preciso/PrecisoBidderTest.java index e2bf992e9d1..d00328b3758 100644 --- a/src/test/java/org/prebid/server/bidder/preciso/PrecisoBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/preciso/PrecisoBidderTest.java @@ -75,8 +75,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/pubmatic/PubmaticBidderTest.java b/src/test/java/org/prebid/server/bidder/pubmatic/PubmaticBidderTest.java index aa22e625f18..9dacd4dc0da 100644 --- a/src/test/java/org/prebid/server/bidder/pubmatic/PubmaticBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/pubmatic/PubmaticBidderTest.java @@ -82,7 +82,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -883,7 +883,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { .hasSize(1).element(0) .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("http://test.endpoint.com/translator?source=prebid-server", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), @@ -902,8 +902,8 @@ public void makeBidderResponseShouldReturnErrorIfResponseBodyCouldNotBeParsed() // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getBids()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/pubnative/PubnativeBidderTest.java b/src/test/java/org/prebid/server/bidder/pubnative/PubnativeBidderTest.java index 6a4c3f1f01d..48829903ed6 100644 --- a/src/test/java/org/prebid/server/bidder/pubnative/PubnativeBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/pubnative/PubnativeBidderTest.java @@ -125,7 +125,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -300,8 +300,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/pulsepoint/PulsepointBidderTest.java b/src/test/java/org/prebid/server/bidder/pulsepoint/PulsepointBidderTest.java index 7ac3318ca39..f7cef57308a 100644 --- a/src/test/java/org/prebid/server/bidder/pulsepoint/PulsepointBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/pulsepoint/PulsepointBidderTest.java @@ -57,7 +57,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -245,8 +245,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/resetdigital/ResetDigitalBidderTest.java b/src/test/java/org/prebid/server/bidder/resetdigital/ResetDigitalBidderTest.java index 2409ce437ec..6a9762acc84 100644 --- a/src/test/java/org/prebid/server/bidder/resetdigital/ResetDigitalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/resetdigital/ResetDigitalBidderTest.java @@ -114,21 +114,21 @@ public void makeHttpRequestShouldReturnSeparateResponseWithBannerAndVideoAndAudi assertThat(result.getValue().get(0)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getBanner) .isNotNull(); assertThat(result.getValue().get(1)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getVideo) .isNotNull(); assertThat(result.getValue().get(2)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getAudio) .isNotNull(); } @@ -150,14 +150,14 @@ public void makeHttpRequestShouldReturnSeparateResponseWithBannerAndVideoImp() { assertThat(result.getValue().get(0)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getBanner) .isNotNull(); assertThat(result.getValue().get(1)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getVideo) .isNotNull(); } @@ -179,14 +179,14 @@ public void makeHttpRequestShouldReturnSeparateResponseWithBannerAndAudioImp() { assertThat(result.getValue().get(0)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getBanner) .isNotNull(); assertThat(result.getValue().get(1)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getAudio) .isNotNull(); } @@ -210,14 +210,14 @@ public void makeHttpRequestShouldReturnSeparateResponseWithVideoAndAudioImp() { assertThat(result.getValue().get(0)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getVideo) .isNotNull(); assertThat(result.getValue().get(1)) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(a -> a.get(0)) + .extracting(a -> a.getFirst()) .extracting(Imp::getAudio) .isNotNull(); } diff --git a/src/test/java/org/prebid/server/bidder/revcontent/RevcontentBidderTest.java b/src/test/java/org/prebid/server/bidder/revcontent/RevcontentBidderTest.java index e1d3dc79879..171c8a64b9f 100644 --- a/src/test/java/org/prebid/server/bidder/revcontent/RevcontentBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/revcontent/RevcontentBidderTest.java @@ -123,8 +123,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/richaudience/RichaudienceBidderTest.java b/src/test/java/org/prebid/server/bidder/richaudience/RichaudienceBidderTest.java index 12040e73c67..d75ff16308d 100644 --- a/src/test/java/org/prebid/server/bidder/richaudience/RichaudienceBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/richaudience/RichaudienceBidderTest.java @@ -88,7 +88,7 @@ public void makeHttpRequestsShouldReturnErrorIfSomeImpBannerIsInvalid() { // then assertThat(result.getValue()).hasSize(1) - .extracting(request -> request.getPayload().getImp().get(0).getId(), HttpRequest::getImpIds) + .extracting(request -> request.getPayload().getImp().getFirst().getId(), HttpRequest::getImpIds) .containsExactly(tuple("imp_id1", Set.of("imp_id1"))); assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badInput("Banner W/H/Format is required. ImpId: imp_id2")); @@ -106,7 +106,7 @@ public void makeHttpRequestsShouldReturnErrorIfSomeImpVideoIsInvalid() { // then assertThat(result.getValue()).hasSize(1) - .extracting(request -> request.getPayload().getImp().get(0).getId(), HttpRequest::getImpIds) + .extracting(request -> request.getPayload().getImp().getFirst().getId(), HttpRequest::getImpIds) .containsExactly(tuple("imp_id1", Set.of("imp_id1"))); assertThat(result.getErrors()).hasSize(1) .containsExactly(BidderError.badInput("Video W and H are required. ImpId: imp_id2")); @@ -128,7 +128,7 @@ public void makeHttpRequestsShouldReturnErrorIfSomeImpsAreInvalid() { // then assertThat(result.getValue()).hasSize(4) - .extracting(request -> request.getPayload().getImp().get(0).getId(), HttpRequest::getImpIds) + .extracting(request -> request.getPayload().getImp().getFirst().getId(), HttpRequest::getImpIds) .containsExactly( tuple("imp_id1", Set.of("imp_id1")), tuple("imp_id3", Set.of("imp_id3")), diff --git a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java index c26bf6839f8..4b15586e7d2 100644 --- a/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rise/RiseBidderTest.java @@ -54,7 +54,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -152,8 +152,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java index d0e5dd2beba..a856340122e 100644 --- a/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rtbhouse/RtbhouseBidderTest.java @@ -79,8 +79,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java index 536c4e9d18d..599f8fc582a 100644 --- a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java @@ -185,7 +185,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { assertThat(result.getValue()).hasSize(1).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns(ENDPOINT_URL, HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.AUTHORIZATION_HEADER.toString(), "Basic dXNlcm5hbWU6cGFzc3dvcmQ="), @@ -598,7 +598,7 @@ public void makeHttpRequestsShouldFillImpExt() { final ObjectNode givenSkadn = mapper.createObjectNode(); givenSkadn.put("property1", "value1"); givenSkadn.put("property2", 2); - Optional.ofNullable(bidRequest.getImp().get(0)) + Optional.ofNullable(bidRequest.getImp().getFirst()) .map(Imp::getExt) .ifPresent(s -> s.set("skadn", givenSkadn)); @@ -2380,7 +2380,7 @@ public void makeHttpRequestsShouldCopyAndModifyDataFieldsToRubiconImpExtRpTarget impBuilder -> impBuilder.video(Video.builder().build()), identity()); - bidRequest.getImp().get(0).getExt() + bidRequest.getImp().getFirst().getExt() .set("data", mapper.createObjectNode() .set("property2", mapper.createArrayNode().add("value2"))); @@ -2406,7 +2406,7 @@ public void makeHttpRequestsShouldPassThroughImpExtGpid() { final BidRequest bidRequest = givenBidRequest( identity(), impBuilder -> impBuilder.video(Video.builder().build()), identity()); - bidRequest.getImp().get(0).getExt().set("gpid", TextNode.valueOf("gpidvalue")); + bidRequest.getImp().getFirst().getExt().set("gpid", TextNode.valueOf("gpidvalue")); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2474,8 +2474,7 @@ public void makeHttpRequestsShouldCopyAppExtDataFieldsToRubiconImpExtRpTarget() } @Test - public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() - throws IOException { + public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() { // given final ObjectNode siteExtDataNode = mapper.createObjectNode() .set("site", mapper.createArrayNode().add("value1")); @@ -2488,7 +2487,7 @@ public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); + final ObjectNode impExt = bidRequest.getImp().getFirst().getExt(); impExt.set("context", mapper.valueToTree(ExtImpContext.of(impExtContextDataNode))); // when @@ -2510,8 +2509,7 @@ public void makeHttpRequestsShouldCopySiteExtDataFieldToRubiconImpExtRpTarget() } @Test - public void makeHttpRequestsShouldCopyAppExtDataFieldToRubiconImpExtRpTarget() - throws IOException { + public void makeHttpRequestsShouldCopyAppExtDataFieldToRubiconImpExtRpTarget() { // given final ObjectNode appExtDataNode = mapper.createObjectNode() .set("app", mapper.createArrayNode().add("value1")); @@ -2550,7 +2548,7 @@ public void makeHttpRequestsShouldMergeImpExtRubiconAndDataKeywordsToRubiconImpE impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); + final ObjectNode impExt = bidRequest.getImp().getFirst().getExt(); impExt.set("data", mapper.createObjectNode() .put("keywords", "imp,ext,data,keywords")); impExt.set( @@ -2584,7 +2582,7 @@ public void makeHttpRequestsShouldCopyDataSearchToRubiconImpExtRpTargetSearch() impBuilder -> impBuilder.video(Video.builder().build()), identity()); - final ObjectNode impExt = bidRequest.getImp().get(0).getExt(); + final ObjectNode impExt = bidRequest.getImp().getFirst().getExt(); impExt.set("data", mapper.createObjectNode().put("search", "imp ext data search")); // when @@ -2694,7 +2692,7 @@ public void makeHttpRequestsShouldOverridePbadslotIfPresentInRequestImpExt() { final ObjectNode dataNode = mapper.createObjectNode() .set("pbadslot", TextNode.valueOf("pbadslotvalue")); - bidRequest.getImp().get(0).getExt().set("data", dataNode); + bidRequest.getImp().getFirst().getExt().set("data", dataNode); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2721,7 +2719,7 @@ public void makeHttpRequestsShouldOverrideDfpAdunitCodeIfAdslotPresentInImpExtDa .put("adslot", "adslotvalue") .put("name", "gam")); - bidRequest.getImp().get(0).getExt().set("data", dataNode); + bidRequest.getImp().getFirst().getExt().set("data", dataNode); // when final Result>> result = target.makeHttpRequests(bidRequest); @@ -2823,7 +2821,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).hasSize(1); } @@ -3432,8 +3430,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/sharethrough/SharethroughBidderTest.java b/src/test/java/org/prebid/server/bidder/sharethrough/SharethroughBidderTest.java index 603d8e44ba5..559fbf74068 100644 --- a/src/test/java/org/prebid/server/bidder/sharethrough/SharethroughBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/sharethrough/SharethroughBidderTest.java @@ -277,14 +277,14 @@ public void makeHttpRequestsShouldSplitImpressionsByMediaType() { assertThat(httpRequests) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(impressions -> impressions.get(0)) + .extracting(impressions -> impressions.getFirst()) .allSatisfy(impression -> assertThat(impression.getId()).isEqualTo("123")); // The multiformat bid request is split into a bid request per media type assertThat(httpRequests) .extracting(HttpRequest::getPayload) .extracting(BidRequest::getImp) - .extracting(impressions -> impressions.get(0)) + .extracting(impressions -> impressions.getFirst()) // Ignore audio impressions because it is currently not supported .satisfiesExactlyInAnyOrder( impression -> { @@ -325,7 +325,7 @@ public void makeHttpRequestsShouldReturnErrorWhenCalledWithUnsupportedMediaType( // then final List errors = result.getErrors(); assertThat(errors).hasSize(1); - assertThat(errors.get(0).getMessage()) + assertThat(errors.getFirst().getMessage()) .isEqualTo("Invalid MediaType. Sharethrough only supports Banner, Video and Native."); } diff --git a/src/test/java/org/prebid/server/bidder/smaato/SmaatoBidderTest.java b/src/test/java/org/prebid/server/bidder/smaato/SmaatoBidderTest.java index c0109adadc8..656edb41e00 100644 --- a/src/test/java/org/prebid/server/bidder/smaato/SmaatoBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/smaato/SmaatoBidderTest.java @@ -732,8 +732,8 @@ public void makeBidsShouldReturnErrorIfAdmIsInvalid() throws JsonProcessingExcep // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot decode bid.adm:"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_input); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot decode bid.adm:"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_input); } @Test diff --git a/src/test/java/org/prebid/server/bidder/smartadserver/SmartadserverBidderTest.java b/src/test/java/org/prebid/server/bidder/smartadserver/SmartadserverBidderTest.java index 1568e62259c..a529fd17fd3 100644 --- a/src/test/java/org/prebid/server/bidder/smartadserver/SmartadserverBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/smartadserver/SmartadserverBidderTest.java @@ -75,7 +75,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .isEqualTo("https://test.endpoint.com/path/api/bid?testParam=testVal&callerId=5"); } diff --git a/src/test/java/org/prebid/server/bidder/smartrtb/SmartrtbBidderTest.java b/src/test/java/org/prebid/server/bidder/smartrtb/SmartrtbBidderTest.java index 579d7040cba..01bfafc3e5b 100644 --- a/src/test/java/org/prebid/server/bidder/smartrtb/SmartrtbBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/smartrtb/SmartrtbBidderTest.java @@ -95,7 +95,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo(ENDPOINT_URL + "publisherID"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo(ENDPOINT_URL + "publisherID"); } @Test @@ -111,7 +111,7 @@ public void makeHttpRequestsShouldSetExpectedRequestUrlAndDefaultHeaders() { assertThat(result.getValue()).hasSize(1) .extracting(HttpRequest::getUri) .containsOnly("https://test.endpoint.com/publisherID"); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly(tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.5"), tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), @@ -127,7 +127,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { final Result> result = target.makeBids(httpCall, null); // then - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/smartyads/SmartyAdsBidderTest.java b/src/test/java/org/prebid/server/bidder/smartyads/SmartyAdsBidderTest.java index e581c3ceb1d..92a7367b1e6 100644 --- a/src/test/java/org/prebid/server/bidder/smartyads/SmartyAdsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/smartyads/SmartyAdsBidderTest.java @@ -61,7 +61,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("ext.bidder not provided"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("ext.bidder not provided"); } @Test @@ -118,7 +118,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .isEqualTo("http://testHost.test.com/bid?param1=testSourceId¶m2=testAccountId"); } diff --git a/src/test/java/org/prebid/server/bidder/sonobi/SonobiBidderTest.java b/src/test/java/org/prebid/server/bidder/sonobi/SonobiBidderTest.java index c340e919344..46fbb7bd4d5 100644 --- a/src/test/java/org/prebid/server/bidder/sonobi/SonobiBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/sonobi/SonobiBidderTest.java @@ -55,7 +55,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -69,7 +69,7 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder() + .imp(singletonList(bidRequest.getImp().getFirst().toBuilder() .tagid("tagidString").build())) .build(); assertThat(result.getErrors()).isEmpty(); @@ -111,8 +111,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/sovrn/SovrnBidderTest.java b/src/test/java/org/prebid/server/bidder/sovrn/SovrnBidderTest.java index a788d9c3283..77754de671d 100644 --- a/src/test/java/org/prebid/server/bidder/sovrn/SovrnBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/sovrn/SovrnBidderTest.java @@ -409,7 +409,7 @@ public void makeHttpRequestsShouldSkipImpAndAddErrorIfRequestNotContainsBothTagi } @Test - public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() throws JsonProcessingException { + public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // given final BidderCall httpCall = givenHttpCall(null, "invalid"); diff --git a/src/test/java/org/prebid/server/bidder/sovrnxsp/SovrnXspBidderTest.java b/src/test/java/org/prebid/server/bidder/sovrnxsp/SovrnXspBidderTest.java index fdc566f5c00..fac80245a18 100644 --- a/src/test/java/org/prebid/server/bidder/sovrnxsp/SovrnXspBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/sovrnxsp/SovrnXspBidderTest.java @@ -235,7 +235,7 @@ public void makeHttpRequestsShouldReturnImpWithTagIdAsImpExtZoneId() { final Result>> results = target.makeHttpRequests(bidRequest); // then - final Imp expectedImp = bidRequest.getImp().get(0).toBuilder().tagid("imp_ext_zone_id").build(); + final Imp expectedImp = bidRequest.getImp().getFirst().toBuilder().tagid("imp_ext_zone_id").build(); final BidRequest expectedBidRequest = bidRequest.toBuilder() .imp(Collections.singletonList(expectedImp)) .build(); diff --git a/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java b/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java index a8467d4b2df..60f4197b216 100644 --- a/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java @@ -92,7 +92,7 @@ public void makeHttpRequestsShouldReturnExpectedHeaders() { final Result>> result = target.makeHttpRequests(bidRequest); // then - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsExactly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), diff --git a/src/test/java/org/prebid/server/bidder/taboola/TaboolaBidderTest.java b/src/test/java/org/prebid/server/bidder/taboola/TaboolaBidderTest.java index 6c4980379cf..01816e92052 100644 --- a/src/test/java/org/prebid/server/bidder/taboola/TaboolaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/taboola/TaboolaBidderTest.java @@ -537,7 +537,7 @@ public void makeBidsShouldReturnErrorOnInvalidResponseBody() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/tappx/TappxBidderTest.java b/src/test/java/org/prebid/server/bidder/tappx/TappxBidderTest.java index 9823776320d..30d5156ed0b 100644 --- a/src/test/java/org/prebid/server/bidder/tappx/TappxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/tappx/TappxBidderTest.java @@ -52,7 +52,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -232,8 +232,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/telaria/TelariaBidderTest.java b/src/test/java/org/prebid/server/bidder/telaria/TelariaBidderTest.java index 4251fcd7cea..71341eee751 100644 --- a/src/test/java/org/prebid/server/bidder/telaria/TelariaBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/telaria/TelariaBidderTest.java @@ -91,7 +91,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test diff --git a/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java b/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java index 48bf7fe357f..ecef87c8cec 100644 --- a/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/theadx/TheadxBidderTest.java @@ -170,8 +170,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/tpmn/TpmnBidderTest.java b/src/test/java/org/prebid/server/bidder/tpmn/TpmnBidderTest.java index 1e1509ad0f3..2183c96246b 100644 --- a/src/test/java/org/prebid/server/bidder/tpmn/TpmnBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/tpmn/TpmnBidderTest.java @@ -128,8 +128,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/trafficgate/TrafficGateBidderTest.java b/src/test/java/org/prebid/server/bidder/trafficgate/TrafficGateBidderTest.java index 42a13ce167c..6bea3e71a5d 100644 --- a/src/test/java/org/prebid/server/bidder/trafficgate/TrafficGateBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/trafficgate/TrafficGateBidderTest.java @@ -57,7 +57,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -90,8 +90,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/triplelift/TripleliftBidderTest.java b/src/test/java/org/prebid/server/bidder/triplelift/TripleliftBidderTest.java index f89ced11be4..b0670e3a964 100644 --- a/src/test/java/org/prebid/server/bidder/triplelift/TripleliftBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/triplelift/TripleliftBidderTest.java @@ -141,8 +141,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -186,8 +186,8 @@ public void makeBidsShouldReturnErrorWhenBidExtIsEmpty() throws JsonProcessingEx // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Empty ext in bid "); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Empty ext in bid "); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/tripleliftnative/TripleliftNativeBidderTest.java b/src/test/java/org/prebid/server/bidder/tripleliftnative/TripleliftNativeBidderTest.java index 53c744a1026..ba317f217d6 100644 --- a/src/test/java/org/prebid/server/bidder/tripleliftnative/TripleliftNativeBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/tripleliftnative/TripleliftNativeBidderTest.java @@ -100,7 +100,8 @@ public void makeHttpRequestsShouldReturnErrorsWhenSitePublisherIdIsNotInWhitelis // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Unsupported publisher for triplelift_native"); + assertThat(result.getErrors().getFirst().getMessage()) + .startsWith("Unsupported publisher for triplelift_native"); assertThat(result.getValue()).isEmpty(); } @@ -121,7 +122,8 @@ public void makeHttpRequestsShouldReturnErrorsWhenAppPublisherIdIsNotInWhitelist // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Unsupported publisher for triplelift_native"); + assertThat(result.getErrors().getFirst().getMessage()) + .startsWith("Unsupported publisher for triplelift_native"); assertThat(result.getValue()).isEmpty(); } @@ -140,7 +142,8 @@ public void makeHttpRequestsShouldReturnErrorsWhenNoPublisherIdIsSpecified() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Unsupported publisher for triplelift_native"); + assertThat(result.getErrors().getFirst().getMessage()) + .startsWith("Unsupported publisher for triplelift_native"); assertThat(result.getValue()).isEmpty(); } @@ -199,8 +202,9 @@ public void makeBidsShouldReturnErrorWhenResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()) + .startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidderTest.java b/src/test/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidderTest.java index 2074d45cfa9..e5a071e79c6 100644 --- a/src/test/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/ucfunnel/UcfunnelBidderTest.java @@ -106,7 +106,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("https://test.endpoint.com/partnerId/request"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("https://test.endpoint.com/partnerId/request"); } @Test @@ -118,7 +118,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { final Result> result = target.makeBids(httpCall, null); // then - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_input); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_input); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/undertone/UndertoneBidderTest.java b/src/test/java/org/prebid/server/bidder/undertone/UndertoneBidderTest.java index b1c0cf03a04..ef992e59dcd 100644 --- a/src/test/java/org/prebid/server/bidder/undertone/UndertoneBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/undertone/UndertoneBidderTest.java @@ -41,7 +41,7 @@ public void errorOnNoAppSite() { final Result>> result = target.makeHttpRequests(bidRequest); assertThat(result.getErrors()).hasSize(1); - final BidderError bidderError = result.getErrors().get(0); + final BidderError bidderError = result.getErrors().getFirst(); assertThat(bidderError.getMessage()).isEqualTo("invalid bidRequest: no App/Site objects"); assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_input); @@ -63,7 +63,7 @@ public void errorOnNoPublisherId() { final Result>> result = target.makeHttpRequests(bidRequest); assertThat(result.getErrors()).hasSize(1); - final BidderError bidderError = result.getErrors().get(0); + final BidderError bidderError = result.getErrors().getFirst(); assertThat(bidderError.getMessage()).isEqualTo("invalid bidRequest: no publisher-id"); assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_input); @@ -86,7 +86,7 @@ public void errorOnInvalidImps() { final Result>> result = target.makeHttpRequests(bidRequest); assertThat(result.getErrors()).hasSize(1); - final BidderError bidderError = result.getErrors().get(0); + final BidderError bidderError = result.getErrors().getFirst(); assertThat(bidderError.getMessage()).isEqualTo("invalid bidRequest: no valid imps"); assertThat(bidderError.getType()).isEqualTo(BidderError.Type.bad_input); diff --git a/src/test/java/org/prebid/server/bidder/unruly/UnrulyBidderTest.java b/src/test/java/org/prebid/server/bidder/unruly/UnrulyBidderTest.java index abc00d23f9c..e65ae2689cc 100644 --- a/src/test/java/org/prebid/server/bidder/unruly/UnrulyBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/unruly/UnrulyBidderTest.java @@ -74,8 +74,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidderTest.java b/src/test/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidderTest.java index e01e83dab3b..5d789a99a0a 100644 --- a/src/test/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/videoheroes/VideoHeroesBidderTest.java @@ -60,7 +60,7 @@ public void makeHttpRequestsShouldFillMethodAndUrlAndExpectedHeaders() { assertThat(result.getValue()).hasSize(1).element(0).isNotNull() .returns(HttpMethod.POST, HttpRequest::getMethod) .returns("https://test.endpoint.com/?partner=placementId", HttpRequest::getUri); - assertThat(result.getValue().get(0).getHeaders()).isNotNull() + assertThat(result.getValue().getFirst().getHeaders()).isNotNull() .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly( tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), "application/json;charset=utf-8"), diff --git a/src/test/java/org/prebid/server/bidder/visx/VisxBidderTest.java b/src/test/java/org/prebid/server/bidder/visx/VisxBidderTest.java index 011b70efd86..ed2f3c892fa 100644 --- a/src/test/java/org/prebid/server/bidder/visx/VisxBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/visx/VisxBidderTest.java @@ -78,8 +78,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/vrtcal/VrtcalBidderTest.java b/src/test/java/org/prebid/server/bidder/vrtcal/VrtcalBidderTest.java index 5115023feb0..1e28877eb61 100644 --- a/src/test/java/org/prebid/server/bidder/vrtcal/VrtcalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/vrtcal/VrtcalBidderTest.java @@ -86,8 +86,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/xeworks/XeworksBidderTest.java b/src/test/java/org/prebid/server/bidder/xeworks/XeworksBidderTest.java index bd3f61632f3..d5a2e18722e 100644 --- a/src/test/java/org/prebid/server/bidder/xeworks/XeworksBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/xeworks/XeworksBidderTest.java @@ -70,7 +70,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCannotBeParsed() { final List errors = result.getErrors(); assertThat(errors).hasSize(1); - assertThat(errors.get(0).getMessage()) + assertThat(errors.getFirst().getMessage()) .isEqualTo("Failed to deserialize Xeworks extension in impression with id: 123"); } diff --git a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java index e38efb41ca8..a2bf9d8f9fc 100644 --- a/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yahooads/YahooAdsBidderTest.java @@ -88,7 +88,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("imp #0: Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("imp #0: Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -281,7 +281,7 @@ public void makeHttpRequestsShouldSetExpectedHeaders() { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getHeaders()) + assertThat(result.getValue().getFirst().getHeaders()) .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly(tuple("User-Agent", "UA"), tuple("x-openrtb-version", "2.5"), @@ -299,8 +299,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } @@ -421,7 +421,7 @@ public void makeBidsShouldRemoveTheOpenRTB26Regs() { // then assertThat(result.getErrors()).isEmpty(); - final Regs regs = result.getValue().get(0).getPayload().getRegs(); + final Regs regs = result.getValue().getFirst().getPayload().getRegs(); assertThat(regs.getGdpr()).isNull(); assertThat(regs.getUsPrivacy()).isNull(); assertThat(regs.getGpp()).isNull(); @@ -449,7 +449,7 @@ public void makeBidsShouldOverwriteRegsExtValues() { // then assertThat(result.getErrors()).isEmpty(); - final Regs regs = result.getValue().get(0).getPayload().getRegs(); + final Regs regs = result.getValue().getFirst().getPayload().getRegs(); assertThat(regs.getGdpr()).isNull(); assertThat(regs.getUsPrivacy()).isNull(); assertThat(regs.getExt().getGdpr()).isEqualTo(1); diff --git a/src/test/java/org/prebid/server/bidder/yandex/YandexBidderTest.java b/src/test/java/org/prebid/server/bidder/yandex/YandexBidderTest.java index 439a44f52cc..ad1d2ab1554 100644 --- a/src/test/java/org/prebid/server/bidder/yandex/YandexBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yandex/YandexBidderTest.java @@ -381,7 +381,7 @@ public void makeHttpRequestsShouldSetExpectedHeaders() { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getHeaders()) + assertThat(result.getValue().getFirst().getHeaders()) .extracting(Map.Entry::getKey, Map.Entry::getValue) .containsOnly(tuple("Accept-Language", "EN"), tuple("User-Agent", "UA"), diff --git a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java index b16852a80a0..7ca405b458f 100644 --- a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java @@ -337,7 +337,7 @@ public void makeHttpRequestsShouldAddDsaRequestParamsToRequestWhenDsaIsPresent() "&dsatransparency=testDomain%7E1_2_3" ); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .contains(expectations); } @@ -374,7 +374,7 @@ public void makeHttpRequestsEncodesDsaTransparencyCorrectlyWhenBidRequestContain "&dsatransparency=testDomain%7E1_2_3%7E%7EtestDomain2%7E4_5_6" ); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .contains(expectations); } @@ -406,7 +406,7 @@ public void makeHttpRequestsShouldNotSendDsaInfoInBidRequestWhenDsaIsMissing() { "dsadatatopub=3" ); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .contains(expectations); } @@ -438,7 +438,7 @@ public void makeHttpRequestsShouldNotAddDsaTransparencyParamsToBidRequestWhenPar "dsadatatopub=3" ); assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue().get(0).getUri()) + assertThat(result.getValue().getFirst().getUri()) .contains(expectations); } @@ -494,7 +494,7 @@ public void makeBidsShouldAddDsaParamsWhenDsaIsPresentInResponse() throws JsonPr expectedDsa.put("adrender", 2); expectedDsa.set("transparency", transparencies); - final JsonNode actualDsa = result.getValue().get(0).getBid().getExt().get("dsa"); + final JsonNode actualDsa = result.getValue().getFirst().getBid().getExt().get("dsa"); assertThat(result.getErrors()).isEmpty(); assertThat(actualDsa).isEqualTo(expectedDsa); diff --git a/src/test/java/org/prebid/server/bidder/yieldmo/YieldmoBidderTest.java b/src/test/java/org/prebid/server/bidder/yieldmo/YieldmoBidderTest.java index f0e76b2425b..fba50ce0451 100644 --- a/src/test/java/org/prebid/server/bidder/yieldmo/YieldmoBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yieldmo/YieldmoBidderTest.java @@ -61,7 +61,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -167,8 +167,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/yieldone/YieldoneBidderTest.java b/src/test/java/org/prebid/server/bidder/yieldone/YieldoneBidderTest.java index cd6114585e5..a0d4caa3a67 100644 --- a/src/test/java/org/prebid/server/bidder/yieldone/YieldoneBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yieldone/YieldoneBidderTest.java @@ -56,7 +56,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); } @Test @@ -115,7 +115,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { final Result> result = target.makeBids(httpCall, givenBidRequest(identity())); // then - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_input); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_input); assertThat(result.getValue()).isEmpty(); } @@ -148,7 +148,7 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder().build())) + .imp(singletonList(bidRequest.getImp().getFirst().toBuilder().build())) .build(); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) diff --git a/src/test/java/org/prebid/server/bidder/zeroclickfraud/ZeroclickfraudBidderTest.java b/src/test/java/org/prebid/server/bidder/zeroclickfraud/ZeroclickfraudBidderTest.java index 075ba728388..76853fdd16a 100644 --- a/src/test/java/org/prebid/server/bidder/zeroclickfraud/ZeroclickfraudBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/zeroclickfraud/ZeroclickfraudBidderTest.java @@ -52,7 +52,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() { // then assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1); - assertThat(result.getValue().get(0).getUri()).isEqualTo("http://host/openrtb2?sid=10"); + assertThat(result.getValue().getFirst().getUri()).isEqualTo("http://host/openrtb2?sid=10"); } @Test @@ -65,7 +65,7 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Cannot deserialize value"); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Cannot deserialize value"); assertThat(result.getValue()).isEmpty(); } @@ -182,8 +182,8 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() { // then assertThat(result.getErrors()).hasSize(1); - assertThat(result.getErrors().get(0).getMessage()).startsWith("Failed to decode: Unrecognized token"); - assertThat(result.getErrors().get(0).getType()).isEqualTo(BidderError.Type.bad_server_response); + assertThat(result.getErrors().getFirst().getMessage()).startsWith("Failed to decode: Unrecognized token"); + assertThat(result.getErrors().getFirst().getType()).isEqualTo(BidderError.Type.bad_server_response); assertThat(result.getValue()).isEmpty(); } diff --git a/src/test/java/org/prebid/server/bidder/zmaticoo/ZMaticooBidderTest.java b/src/test/java/org/prebid/server/bidder/zmaticoo/ZMaticooBidderTest.java index 182aba5d0a7..df584fa063f 100644 --- a/src/test/java/org/prebid/server/bidder/zmaticoo/ZMaticooBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/zmaticoo/ZMaticooBidderTest.java @@ -60,7 +60,7 @@ public void makeHttpRequestsShouldReturnErrorsOnInvalidImps() { // then assertThat(result.getValue()).isEmpty(); assertThat(result.getErrors()).satisfies(errors -> { - assertThat(errors.get(0)).satisfies(error -> { + assertThat(errors.getFirst()).satisfies(error -> { assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); assertThat(error.getMessage()).startsWith("Cannot deserialize value of type"); }); diff --git a/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java b/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java index a2972ac36c9..a3eef427e23 100644 --- a/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java +++ b/src/test/java/org/prebid/server/hooks/execution/HookStageExecutorTest.java @@ -295,7 +295,7 @@ public void shouldExecuteEntrypointHooksHappyPath(TestContext context) { final List groups = stageOutcome.getGroups(); assertThat(groups).hasSize(2); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks).hasSize(2); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { @@ -473,7 +473,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -588,7 +588,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -689,7 +689,7 @@ public void shouldExecuteEntrypointHooksHonoringStatusAndAction(TestContext cont final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -781,7 +781,7 @@ public void shouldExecuteEntrypointHooksWhenRequestIsRejectedByFirstGroup(TestCo final List groups = stageOutcome.getGroups(); assertThat(groups).hasSize(1); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -861,7 +861,7 @@ public void shouldExecuteEntrypointHooksWhenRequestIsRejectedBySecondGroup(TestC final List groups = stageOutcome.getGroups(); assertThat(groups).hasSize(2); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks).hasSize(2); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { @@ -963,7 +963,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingInvocationResult(Te final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -1051,7 +1051,7 @@ public void shouldExecuteEntrypointHooksAndStoreResultInExecutionContext(TestCon .hasEntrySatisfying( Stage.entrypoint, stageOutcomes -> - assertThat(stageOutcomes.get(0).getGroups().get(0).getHooks().get(0)) + assertThat(stageOutcomes.getFirst().getGroups().getFirst().getHooks().getFirst()) .satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -1306,7 +1306,7 @@ public void shouldExecuteRawAuctionRequestHooksToleratingUnknownHookInAccountPla final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); + final List group0Hooks = groups.getFirst().getHooks(); assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); @@ -2719,8 +2719,8 @@ public void shouldExecuteAuctionResponseHooksAndIgnoreRejection(TestContext cont final List groups = stageOutcome.getGroups(); - final List group0Hooks = groups.get(0).getHooks(); - assertThat(group0Hooks.get(0)).satisfies(hookOutcome -> { + final List group0Hooks = groups.getFirst().getHooks(); + assertThat(group0Hooks.getFirst()).satisfies(hookOutcome -> { assertThat(hookOutcome.getHookId()) .isEqualTo(HookId.of("module-alpha", "hook-a")); assertThat(hookOutcome.getStatus()) diff --git a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java index 946a62d81b3..7cf7617fedd 100644 --- a/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java +++ b/src/test/java/org/prebid/server/json/deserializer/AccountActivityRulesConfigDeserializerTest.java @@ -42,7 +42,7 @@ public class AccountActivityRulesConfigDeserializerTest { private ObjectCodec codec; @Before - public void setUp() throws IOException { + public void setUp() { target = new AccountActivityRulesConfigDeserializer(); } diff --git a/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java b/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java index 9723f3b45a7..a60b304b6e5 100644 --- a/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java +++ b/src/test/java/org/prebid/server/settings/HttpApplicationSettingsTest.java @@ -302,7 +302,7 @@ public void getStoredDataShouldReturnResultWithErrorIfHttpResponseIsMalformed() assertThat(future.succeeded()).isTrue(); assertThat(future.result().getStoredIdToRequest()).isEmpty(); assertThat(future.result().getStoredIdToImp()).isEmpty(); - assertThat(future.result().getErrors().get(0)) + assertThat(future.result().getErrors().getFirst()) .startsWith("Error fetching stored requests for ids [id1] via HTTP: parsing json failed for response: " + "invalid-response with message: Failed to decode"); } @@ -321,7 +321,7 @@ public void getStoredDataShouldReturnResultWithErrorIfStoredRequestObjectIsMalfo assertThat(future.succeeded()).isTrue(); assertThat(future.result().getStoredIdToRequest()).isEmpty(); assertThat(future.result().getStoredIdToImp()).isEmpty(); - assertThat(future.result().getErrors().get(0)) + assertThat(future.result().getErrors().getFirst()) .startsWith("Error fetching stored requests for ids [id1] via HTTP: " + "parsing json failed for response: {\"requests\": {\"id1\":\"invalid-stored-request\"} " + "with message: Failed to decode"); @@ -341,7 +341,7 @@ public void getStoredDataShouldReturnResultWithErrorIfStoredImpObjectIsMalformed assertThat(future.succeeded()).isTrue(); assertThat(future.result().getStoredIdToRequest()).isEmpty(); assertThat(future.result().getStoredIdToImp()).isEmpty(); - assertThat(future.result().getErrors().get(0)) + assertThat(future.result().getErrors().getFirst()) .startsWith("Error fetching stored requests for ids [id1] via HTTP: parsing json failed for response: " + "{\"imps\": {\"id1\":\"invalid-stored-imp\"} with message: Failed to decode"); } diff --git a/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java b/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java index 0cb4aa966d2..a171bc8452a 100644 --- a/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java @@ -316,6 +316,7 @@ public void validateShouldReturnValidationMessagesWhenEplanningExtNotValid() { assertThat(messages.size()).isEqualTo(1); } + @Test public void validateShouldNotReturnValidationMessagesWhenBeachfrontImpExtIsOk() { // given final ExtImpBeachfront ext = ExtImpBeachfront.of("appId", null, BigDecimal.ONE, "adm"); diff --git a/src/test/java/org/prebid/server/validation/RequestValidatorTest.java b/src/test/java/org/prebid/server/validation/RequestValidatorTest.java index fc4102f0f41..995f0860763 100644 --- a/src/test/java/org/prebid/server/validation/RequestValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/RequestValidatorTest.java @@ -3202,7 +3202,7 @@ private static Imp.ImpBuilder validImpBuilder() { private static BidRequest overwriteBannerFormatInFirstImp( BidRequest bidRequest, UnaryOperator formatModifier) { - final Banner banner = bidRequest.getImp().get(0).getBanner().toBuilder() + final Banner banner = bidRequest.getImp().getFirst().getBanner().toBuilder() .format(singletonList(formatModifier.apply(Format.builder()).build())).build(); return bidRequest.toBuilder().imp(singletonList(validImpBuilder().banner(banner).build())).build(); @@ -3210,7 +3210,7 @@ private static BidRequest overwriteBannerFormatInFirstImp( private static BidRequest overwritePmpFirstDealInFirstImp( BidRequest bidRequest, UnaryOperator dealModifier) { - final Pmp pmp = bidRequest.getImp().get(0).getPmp().toBuilder() + final Pmp pmp = bidRequest.getImp().getFirst().getPmp().toBuilder() .deals(singletonList(dealModifier.apply(dealModifier.apply(Deal.builder())).build())).build(); return bidRequest.toBuilder().imp(singletonList(validImpBuilder().pmp(pmp).build())).build(); From 0b89797dcd526a5979fedaa162e5355558b9a9ba Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Wed, 29 May 2024 14:53:06 +0300 Subject: [PATCH 6/9] Tests: `BidResponse validations` (#3114) --- .../model/request/auction/Asset.groovy | 4 +- .../model/request/auction/Banner.groovy | 7 +- .../model/request/auction/Format.groovy | 20 +- .../model/request/auction/Video.groovy | 9 +- .../model/response/auction/Bid.groovy | 20 +- .../testcontainers/scaffolding/Bidder.groovy | 2 +- .../server/functional/tests/AmpSpec.groovy | 14 +- .../functional/tests/BidderFormatSpec.groovy | 855 ++++++++++++++++++ .../pricefloors/PriceFloorsRulesSpec.groovy | 14 +- 9 files changed, 909 insertions(+), 36 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Asset.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Asset.groovy index ff468288f18..4ba1a6bc36f 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Asset.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Asset.groovy @@ -25,11 +25,11 @@ class Asset { } } - static Asset getImgAsset() { + static Asset getImgAsset(String url = PBSUtils.randomString) { new Asset().tap { id = 2 required = 1 - img = new AssetImage(type: 3, w: PBSUtils.randomNumber, h: PBSUtils.randomNumber) + img = new AssetImage(type: 3, w: PBSUtils.randomNumber, h: PBSUtils.randomNumber, url: url) } } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Banner.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Banner.groovy index b9d4faf3e16..b4d6c23f4f5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Banner.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Banner.groovy @@ -1,13 +1,16 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) class Banner { List format - Integer w - Integer h + @JsonProperty("w") + Integer weight + @JsonProperty("h") + Integer height List btype List battr Integer pos diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Format.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Format.groovy index 0f8236481f5..3508dfa60fe 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Format.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Format.groovy @@ -1,20 +1,26 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) class Format { - Integer w - Integer h - Integer wratio - Integer hratio - Integer wmin + @JsonProperty("w") + Integer weight + @JsonProperty("h") + Integer height + @JsonProperty("wratio") + Integer weightRatio + @JsonProperty("hratio") + Integer heightRatio + @JsonProperty("wmin") + Integer weightMin static Format getDefaultFormat() { new Format().tap { - w = 300 - h = 250 + weight = 300 + height = 250 } } } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy index 40b32028217..bc2ef7f5a5c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Video.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @@ -14,8 +15,10 @@ class Video { Integer maxseq Integer poddur List protocols - Integer w - Integer h + @JsonProperty("w") + Integer weight + @JsonProperty("h") + Integer height Integer podid Integer podseq List rqddurs @@ -42,6 +45,6 @@ class Video { List companiontype static Video getDefaultVideo() { - new Video(mimes: ["video/mp4"], w: 300, h: 200) + new Video(mimes: ["video/mp4"], weight: 300, height: 200) } } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy index 9346c228932..e4fb04de375 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/Bid.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.model.response.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.Asset @@ -31,14 +32,19 @@ class Bid implements ObjectMapperWrapper { List apis Integer api Integer protocol - Integer qagmediarating + @JsonProperty("qagmediarating") + Integer qagMediaRating String language String langb String dealid - Integer w - Integer h - Integer wratio - Integer hratio + @JsonProperty("w") + Integer weight + @JsonProperty("h") + Integer height + @JsonProperty("wratio") + Integer weightRatio + @JsonProperty("hratio") + Integer heightRatio Integer exp Integer dur Integer mtype @@ -55,8 +61,8 @@ class Bid implements ObjectMapperWrapper { impid = imp.id price = PBSUtils.getRandomPrice() crid = 1 - h = imp.banner && imp.banner.format ? imp.banner.format.first().h : null - w = imp.banner && imp.banner.format ? imp.banner.format.first().w : null + height = imp.banner && imp.banner.format ? imp.banner.format.first().height : null + weight = imp.banner && imp.banner.format ? imp.banner.format.first().weight : null if (imp.nativeObj || imp.video) { adm = new Adm(assets: [Asset.defaultAsset]) } diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy index 76253716e34..ff0b9f3b4f7 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy @@ -77,7 +77,7 @@ class Bidder extends NetworkScaffolding { def formatNode = it.get("banner") != null ? it.get("banner").get("format") : null new Imp(id: it.get("id").asText(), banner: formatNode != null - ? new Banner(format: [new Format(w: formatNode.first().get("w").asInt(), h: formatNode.first().get("h").asInt())]) + ? new Banner(format: [new Format(weight: formatNode.first().get("w").asInt(), height: formatNode.first().get("h").asInt())]) : null)} def bidRequest = new BidRequest(id: id, imp: imps) def response = BidResponse.getDefaultBidResponse(bidRequest) diff --git a/src/test/groovy/org/prebid/server/functional/tests/AmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AmpSpec.groovy index 555eec86e4e..9205542bbb8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AmpSpec.groovy @@ -84,7 +84,7 @@ class AmpSpec extends BaseSpec { then: "Response should contain information from stored response" def price = storedAuctionResponse.bid[0].price assert response.targeting["hb_pb"] == getRoundedTargetingValueWithDefaultPrecision(price) - assert response.targeting["hb_size"] == "${storedAuctionResponse.bid[0].w}x${storedAuctionResponse.bid[0].h}" + assert response.targeting["hb_size"] == "${storedAuctionResponse.bid[0].weight}x${storedAuctionResponse.bid[0].height}" and: "PBS not send request to bidder" assert bidder.getRequestCount(ampStoredRequest.id) == 0 @@ -122,8 +122,8 @@ class AmpSpec extends BaseSpec { assert bidderRequest.site?.page == ampRequest.curl assert bidderRequest.site?.publisher?.id == ampRequest.account.toString() assert bidderRequest.imp[0]?.tagId == ampRequest.slot - assert bidderRequest.imp[0]?.banner?.format*.h == [ampRequest.h, msH] - assert bidderRequest.imp[0]?.banner?.format*.w == [ampRequest.w, msW] + assert bidderRequest.imp[0]?.banner?.format*.height == [ampRequest.h, msH] + assert bidderRequest.imp[0]?.banner?.format*.weight == [ampRequest.w, msW] assert bidderRequest.regs?.gdpr == (ampRequest.gdprApplies ? 1 : 0) } @@ -150,8 +150,8 @@ class AmpSpec extends BaseSpec { then: "Bidder request should contain parameters from request" def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) - assert bidderRequest.imp[0]?.banner?.format*.h == [ampRequest.oh] - assert bidderRequest.imp[0]?.banner?.format*.w == [ampRequest.ow] + assert bidderRequest.imp[0]?.banner?.format*.height == [ampRequest.oh] + assert bidderRequest.imp[0]?.banner?.format*.weight == [ampRequest.ow] } def "PBS should take parameters from the stored request when it's not specified in the request"() { @@ -176,8 +176,8 @@ class AmpSpec extends BaseSpec { assert bidderRequest.site?.page == ampStoredRequest.site.page assert bidderRequest.site?.publisher?.id == ampStoredRequest.site.publisher.id assert !bidderRequest.imp[0]?.tagId - assert bidderRequest.imp[0]?.banner?.format[0]?.h == ampStoredRequest.imp[0].banner.format[0].h - assert bidderRequest.imp[0]?.banner?.format[0]?.w == ampStoredRequest.imp[0].banner.format[0].w + assert bidderRequest.imp[0]?.banner?.format[0]?.height == ampStoredRequest.imp[0].banner.format[0].height + assert bidderRequest.imp[0]?.banner?.format[0]?.weight == ampStoredRequest.imp[0].banner.format[0].weight assert bidderRequest.regs?.gdpr == ampStoredRequest.regs.ext.gdpr } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy new file mode 100644 index 00000000000..f0e0732e16d --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy @@ -0,0 +1,855 @@ +package org.prebid.server.functional.tests + +import org.prebid.server.functional.model.bidder.BidderName +import org.prebid.server.functional.model.config.AccountAuctionConfig +import org.prebid.server.functional.model.config.AccountBidValidationConfig +import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.BidValidationEnforcement +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.model.db.StoredResponse +import org.prebid.server.functional.model.request.auction.Asset +import org.prebid.server.functional.model.request.auction.Audio +import org.prebid.server.functional.model.request.auction.Banner +import org.prebid.server.functional.model.request.auction.BidRequest +import org.prebid.server.functional.model.request.auction.Format +import org.prebid.server.functional.model.request.auction.Native +import org.prebid.server.functional.model.request.auction.StoredBidResponse +import org.prebid.server.functional.model.request.auction.Video +import org.prebid.server.functional.model.response.auction.Adm +import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.PBSUtils +import spock.lang.PendingFeature +import spock.lang.Shared + +import static org.prebid.server.functional.model.AccountStatus.ACTIVE +import static org.prebid.server.functional.model.config.BidValidationEnforcement.ENFORCE +import static org.prebid.server.functional.model.config.BidValidationEnforcement.SKIP +import static org.prebid.server.functional.model.config.BidValidationEnforcement.WARN +import static org.prebid.server.functional.model.response.auction.ErrorType.GENERIC + +class BidderFormatSpec extends BaseSpec { + + @Shared + private static final RANDOM_NUMBER = PBSUtils.randomNumber + + def "PBS should successfully pass when banner.format weight and height is valid"() { + given: "Default bid request with banner format" + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].banner.format = [new Format(weight: bannerFormatWeight, height: bannerFormatHeight)] + } + + when: "Requesting PBS auction" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "BidResponse should contain the same banner format as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest?.imp[0]?.banner?.format[0].weight == bannerFormatWeight + assert bidderRequest?.imp[0]?.banner?.format[0].height == bannerFormatHeight + + where: + bannerFormatWeight | bannerFormatHeight + 1 | 1 + PBSUtils.randomNumber | PBSUtils.randomNumber + } + + def "PBS should unsuccessfully pass and throw error due to validation banner.format{w.h} when banner.format weight or height is invalid"() { + given: "Default bid request with banner format" + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].banner.format = [new Format(weight: bannerFormatWeight, height: bannerFormatHeight)] + } + + when: "Requesting PBS auction" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "PBs should throw error due to banner.format{w.h} validation" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 400 + assert exception.responseBody == "Invalid request format: " + + "Request imp[0].banner.format[0] must define a valid \"h\" and \"w\" properties" + + where: + bannerFormatWeight | bannerFormatHeight + 0 | PBSUtils.randomNumber + PBSUtils.randomNumber | 0 + null | PBSUtils.randomNumber + PBSUtils.randomNumber | null + PBSUtils.randomNegativeNumber | PBSUtils.randomNumber + PBSUtils.randomNumber | PBSUtils.randomNegativeNumber + } + + def "PBS should unsuccessfully pass and throw error due to validation banner.format{w.h} when banner.format weight and height is invalid"() { + given: "Default bid request with banner format" + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].banner.format = [new Format(weight: bannerFormatWeight, height: bannerFormatHeight)] + } + + when: "Requesting PBS auction" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "PBs should throw error due to banner.format{w.h} validation" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 400 + assert exception.responseBody == "Invalid request format: Request imp[0].banner.format[0] " + + "should define *either* {w, h} (for static size requirements) " + + "*or* {wmin, wratio, hratio} (for flexible sizes) to be non-zero positive" + + where: + bannerFormatWeight | bannerFormatHeight + 0 | 0 + 0 | null + 0 | PBSUtils.randomNegativeNumber + null | null + null | PBSUtils.randomNegativeNumber + PBSUtils.randomNegativeNumber | PBSUtils.randomNegativeNumber + } + + def "PBS should successfully pass when banner weight and height is valid"() { + given: "Default bid request with banner format" + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].banner = new Banner(weight: bannerFormatWeight, height: bannerFormatHeight) + } + + when: "Requesting PBS auction" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "BidResponse should contain the same banner{w.h} as on request" + def bidderRequest = bidder.getBidderRequest(bidRequest.id) + assert bidderRequest?.imp[0]?.banner?.weight == bannerFormatWeight + assert bidderRequest?.imp[0]?.banner?.height == bannerFormatHeight + + where: + bannerFormatWeight | bannerFormatHeight + 1 | 1 + PBSUtils.randomNumber | PBSUtils.randomNumber + } + + def "PBS should unsuccessfully pass and throw error due to validation banner{w.h} when banner{w.h} is invalid"() { + given: "Default bid request with banner{w.h}" + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].banner = new Banner(weight: bannerFormatWeight, height: bannerFormatHeight) + } + + when: "Requesting PBS auction" + defaultPbsService.sendAuctionRequest(bidRequest) + + then: "PBs should throw error due to banner{w.h} validation" + def exception = thrown(PrebidServerException) + assert exception.statusCode == 400 + assert exception.responseBody == "Invalid request format: " + + "request.imp[0].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements" + + where: + bannerFormatWeight | bannerFormatHeight + 0 | 0 + 0 | PBSUtils.randomNumber + PBSUtils.randomNumber | 0 + null | null + null | PBSUtils.randomNumber + PBSUtils.randomNumber | null + PBSUtils.randomNegativeNumber | PBSUtils.randomNegativeNumber + PBSUtils.randomNegativeNumber | PBSUtils.randomNumber + PBSUtils.randomNumber | PBSUtils.randomNegativeNumber + } + + def "PBS should emit error and metrics when banner-creative-max-size: warn and bid response W or H is larger that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with banner format" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + banner = new Banner(format: [new Format(weight: RANDOM_NUMBER, height: RANDOM_NUMBER)]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidId = UUID.randomUUID() + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.id = storedBidId + it.weight = responseWeight + it.height = responseHeight + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + and: "Flush metrics" + flushMetrics(pbsService) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert metrics["account.${bidRequest.accountId}.response.validation.size.warn"] == 1 + assert metrics["adapter.generic.response.validation.size.warn"] == 1 + + and: "Response should contain error" + assert bidResponse.ext?.errors[GENERIC]*.code == [5] + assert bidResponse.ext?.errors[GENERIC]*.message[0] + == "BidId `${storedBidId}` validation messages: " + + "Warning: BidResponse validation `warn`: bidder `${GENERIC}` response triggers creative size " + + "validation for bid ${storedBidId}, account=${bidRequest.accountId}, " + + "referrer=${bidRequest.site.page}, max imp size='${RANDOM_NUMBER}x${RANDOM_NUMBER}', " + + "bid response size='${responseWeight}x${responseHeight}'" + + and: "Bid response should contain weight and height from stored response" + def bid = bidResponse.seatbid[0].bid[0] + assert bid.weight == responseWeight + assert bid.height == responseHeight + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize | responseWeight | responseHeight + null | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | WARN.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + WARN | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + WARN | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + WARN | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + } + + def "PBS shouldn't emit error and metrics when banner-creative-max-size: skip and bid response W or H is larger that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with banner format" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + banner = new Banner(format: [new Format(weight: RANDOM_NUMBER, height: RANDOM_NUMBER)]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.weight = responseWeight + it.height = responseHeight + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric shouldn't increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] + assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + + and: "Response should contain error" + assert !bidResponse.ext?.errors + + and: "Bid response should contain weight and height from stored response" + def bid = bidResponse.seatbid[0].bid[0] + assert bid.weight == responseWeight + assert bid.height == responseHeight + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize | responseWeight | responseHeight + null | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | SKIP.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + SKIP | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + SKIP | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + SKIP | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + } + + def "PBS should emit error and metrics and remove bid response from consideration when banner-creative-max-size: enforce and bid response W or H is larger that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with banner format" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + banner = new Banner(format: [new Format(weight: RANDOM_NUMBER, height: RANDOM_NUMBER)]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidId = UUID.randomUUID() + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.id = storedBidId + it.weight = responseWeight + it.height = responseHeight + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 + assert metrics["adapter.generic.response.validation.size.err"] == 1 + + and: "Response should contain error" + assert bidResponse.ext?.errors[GENERIC]*.code == [5] + assert bidResponse.ext?.errors[GENERIC]*.message[0] + == "BidId `${storedBidId}` validation messages: " + + "Error: BidResponse validation `enforce`: bidder `${GENERIC.value}` response triggers creative size " + + "validation for bid ${storedBidId}, account=${bidRequest.accountId}, " + + "referrer=${bidRequest.site.page}, max imp size='${RANDOM_NUMBER}x${RANDOM_NUMBER}', " + + "bid response size='${responseWeight}x${responseHeight}'" + + and: "Pbs should discard seatBid due to validation" + assert !bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize | responseWeight | responseHeight + null | ENFORCE.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | ENFORCE.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | ENFORCE.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + ENFORCE | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + } + + def "PBS shouldn't emit error and metrics when banner-creative-max-size #configCreativeMaxSize and bid response W or H is same that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with banner format" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + banner = new Banner(format: [new Format(weight: RANDOM_NUMBER, height: RANDOM_NUMBER)]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + weight = RANDOM_NUMBER + height = RANDOM_NUMBER + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric shouldn't increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] + assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + + and: "Response should contain error" + assert !bidResponse.ext?.errors + + and: "Bid response should contain weight and height from stored response" + def bid = bidResponse.seatbid[0].bid[0] + assert bid.weight == RANDOM_NUMBER + assert bid.height == RANDOM_NUMBER + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize + null | SKIP.value + SKIP | null + ENFORCE | null + null | ENFORCE.value + WARN | null + null | WARN.value + } + + def "PBS shouldn't emit error and metrics when media type isn't banner and banner-creative-max-size #configCreativeMaxSize and bid response W or H is larger that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with video W and H" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.getDefaultVideoRequest().tap { + imp[0].tap { + video = new Video(weight: RANDOM_NUMBER, height: RANDOM_NUMBER, mimes: [PBSUtils.randomString]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + weight = responseWeight + height = responseHeight + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + assert !metrics["adapter.generic.response.validation.size.err"] + + and: "Response shouldn't contain error" + assert !bidResponse.ext?.errors + + and: "Pbs should contain seatBid.bid" + assert bidResponse.seatbid.bid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize | responseWeight | responseHeight + null | ENFORCE.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | ENFORCE.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | ENFORCE.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + ENFORCE | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + null | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | SKIP.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + SKIP | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + SKIP | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + SKIP | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + null | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + null | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + null | WARN.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + WARN | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + WARN | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + WARN | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + } + + def "PBS should emit error and metrics and remove bid response from consideration and account value should take precedence over host when banner-creative-max-size enforce and bid response W or H is larger that request W or H"() { + given: "PBS with banner creative max size" + def pbsService = pbsServiceFactory.getService(["auction.validations.banner-creative-max-size": configCreativeMaxSize]) + + and: "Default bid request with banner format" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + banner = new Banner(format: [new Format(weight: RANDOM_NUMBER, height: RANDOM_NUMBER)]) + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response with biggest W and H than in bidRequest in DB" + def storedBidId = UUID.randomUUID() + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.id = storedBidId + it.weight = responseWeight + it.height = responseHeight + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + and: "Account in the DB with specified banner max size enforcement" + def account = getAccountWithSpecifiedBannerMax(bidRequest.accountId, accountCretiveMaxSize) + accountDao.save(account) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 + assert metrics["adapter.generic.response.validation.size.err"] == 1 + + and: "Bid response should contain error" + assert bidResponse.ext?.errors[GENERIC]*.code == [5] + assert bidResponse.ext?.errors[GENERIC]*.message[0] + == "BidId `${storedBidId}` validation messages: " + + "Error: BidResponse validation `enforce`: bidder `generic` response triggers creative size " + + "validation for bid ${storedBidId}, account=${bidRequest.accountId}, " + + "referrer=${bidRequest.site.page}, max imp size='${RANDOM_NUMBER}x${RANDOM_NUMBER}', " + + "bid response size='${responseWeight}x${responseHeight}'" + + and: "Pbs should discard seatBid due to validation" + assert !bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + accountCretiveMaxSize | configCreativeMaxSize | responseWeight | responseHeight + ENFORCE | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + ENFORCE | WARN.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + ENFORCE | WARN.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + ENFORCE | null | RANDOM_NUMBER + 1 | RANDOM_NUMBER + ENFORCE | null | RANDOM_NUMBER | RANDOM_NUMBER + 1 + ENFORCE | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + 1 + ENFORCE | SKIP.value | RANDOM_NUMBER + 1 | RANDOM_NUMBER + ENFORCE | SKIP.value | RANDOM_NUMBER | RANDOM_NUMBER + 1 + } + + @PendingFeature(reason = "Waiting for confirmation") + def "PBS shouldn't make a validation for audio media type when secure is #secure and secure markUp is #secureMarkup"() { + given: "PBS with secure-markUp: #secureMarkup" + def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": secureMarkup]) + + and: "Audio bid request" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].secure = secure + imp[0].banner = null + imp[0].video = null + imp[0].audio = Audio.defaultAudio + imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + + and: "Stored bid response in DB" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].adm = new Adm(assets: [Asset.getImgAsset("http://secure-assets.${PBSUtils.randomString}.com")]) + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric shouldn't be increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + + and: "Bid response should contain error" + assert !bidResponse.ext?.errors + + and: "Pbs should contain seatBid" + assert bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + secure | secureMarkup + 1 | SKIP.value + 1 | ENFORCE.value + 1 | WARN.value + 0 | SKIP.value + 0 | ENFORCE.value + 0 | WARN.value + } + + def "PBS should emit metrics and error when imp[0].secure = 1 and config WARN and bid response adm contain #url"() { + given: "PBS with secure-markUp: warn" + def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": WARN.value]) + + and: "Default bid request with secure and banner or video or nativeObj" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].secure = 1 + imp[0].banner = banner + imp[0].video = video + imp[0].nativeObj = nativeObj + imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + + and: "Stored bid response in DB" + def storedBidId = UUID.randomUUID() + def adm = new Adm(assets: [Asset.getImgAsset("${url}://secure-assets.${PBSUtils.randomString}.com")]) + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.id = storedBidId + it.adm = adm + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] == 1 + assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] == 1 + + and: "Bid response should contain error" + assert bidResponse.ext?.errors[GENERIC]*.code == [5] + assert bidResponse.ext?.errors[GENERIC]*.message[0] + == "BidId `${storedBidId}` validation messages: " + + "Warning: BidResponse validation `warn`: bidder `${BidderName.GENERIC.value}` response triggers secure creative " + + "validation for bid ${storedBidId}, account=${bidRequest.accountId}, referrer=${bidRequest.site.page}," + + " adm=${encode(adm)}" + + and: "Pbs should contain seatBid" + assert bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + url | banner | video | nativeObj + "http%3A" | Banner.defaultBanner | null | null + "http" | Banner.defaultBanner | null | null + "http" | null | Video.defaultVideo | null + "http%3A" | null | Video.defaultVideo | null + "http" | null | null | Native.defaultNative + "http%3A" | null | null | Native.defaultNative + } + + def "PBS should emit metrics and error when imp[0].secure = 1, banner and config SKIP and bid response adm contain #url"() { + given: "PBS with secure-markUp: skip" + def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": SKIP.value]) + + and: "Default bid request with secure and banner or video or nativeObj" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].secure = 1 + imp[0].banner = banner + imp[0].video = video + imp[0].nativeObj = nativeObj + imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + + and: "Stored bid response in DB with adm" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].adm = new Adm(assets: [Asset.getImgAsset("${url}://secure-assets.${PBSUtils.randomString}.com")]) + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + + and: "Bid response shouldn't contain error" + assert !bidResponse.ext?.errors + + and: "Pbs should contain seatBid" + assert bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + url | banner | video | nativeObj + "http%3A" | Banner.defaultBanner | null | null + "http" | Banner.defaultBanner | null | null + "http" | null | Video.defaultVideo | null + "http%3A" | null | Video.defaultVideo | null + "http" | null | null | Native.defaultNative + "http%3A" | null | null | Native.defaultNative + } + + def "PBS should emit metrics and error and remove bid response when imp[0].secure = 1, banner and config ENFORCE and bid response adm contain #url"() { + given: "PBS with secure-markUp: enforce" + def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": ENFORCE.value]) + + and: "Default bid request with secure and banner or video or nativeObj" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].secure = 1 + imp[0].banner = banner + imp[0].video = video + imp[0].nativeObj = nativeObj + imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + + and: "Stored bid response in DB" + def storedBidId = UUID.randomUUID() + def adm = new Adm(assets: [Asset.getImgAsset("${url}://secure-assets.${PBSUtils.randomString}.com")]) + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].tap { + it.id = storedBidId + it.adm = adm + } + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric should increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert metrics["account.${bidRequest.accountId}.response.validation.secure.err"] == 1 + assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] == 1 + + and: "Bid response should contain error" + assert bidResponse.ext?.errors[GENERIC]*.code == [5] + assert bidResponse.ext?.errors[GENERIC]*.message[0] + == "BidId `${storedBidId}` validation messages: " + + "Error: BidResponse validation `enforce`: bidder `${BidderName.GENERIC.value}` response triggers secure creative " + + "validation for bid ${storedBidId}, account=${bidRequest.accountId}, referrer=${bidRequest.site.page}," + + " adm=${encode(adm)}" + + and: "Pbs shouldn't contain seatBid" + assert !bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + url | banner | video | nativeObj + "http%3A" | Banner.defaultBanner | null | null + "http" | Banner.defaultBanner | null | null + "http" | null | Video.defaultVideo | null + "http%3A" | null | Video.defaultVideo | null + "http" | null | null | Native.defaultNative + "http%3A" | null | null | Native.defaultNative + } + + def "PBS shouldn't emit errors and metrics when imp[0].secure = #secure and bid response adm contain #url"() { + given: "PBS with secure-markUp" + def pbsService = pbsServiceFactory + .getService(["auction.validations.secure-markup": secureMarkup]) + + and: "Default bid request with secure" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + it.secure = secure + it.ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response in DB with adm" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].adm = new Adm(assets: [Asset.getImgAsset("${url}://secure-assets.${PBSUtils.randomString}.com")]) + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric shouldn't increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + + and: "Bid response shouldn't contain error" + assert !bidResponse.ext?.errors + + and: "Pbs should contain seatBid" + assert bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + url | secure | secureMarkup + "http%3A" | 0 | SKIP.value + "http" | 0 | SKIP.value + "https" | 1 | SKIP.value + "http%3A" | 0 | WARN.value + "http" | 0 | WARN.value + "https" | 1 | WARN.value + "http%3A" | 0 | ENFORCE.value + "http" | 0 | ENFORCE.value + "https" | 1 | ENFORCE.value + } + + def "PBS should ignore specified secureMarkup #secureMarkup validation when secure is 0"() { + given: "PBS with secure-markUp" + def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": secureMarkup]) + + and: "Default bid request with stored bid response and secure" + def storedResponseId = PBSUtils.randomNumber + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].tap { + secure = 0 + ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: BidderName.GENERIC)] + } + } + + and: "Stored bid response in DB with adm" + def adm = new Adm(assets: [Asset.getImgAsset("${url}://secure-assets.${PBSUtils.randomString}.com")]) + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + it.seatbid[0].bid[0].adm = adm + } + def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "Requesting PBS auction" + def bidResponse = pbsService.sendAuctionRequest(bidRequest) + + then: "Corresponding metric shouldn't increments" + def metrics = pbsService.sendCollectedMetricsRequest() + assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] + assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + + and: "Bid response shouldn't contain error" + assert !bidResponse.ext?.errors + + and: "Pbs should contain seatBid" + assert bidResponse.seatbid + + and: "PBs shouldn't perform a bidder request due to stored bid response" + assert !bidder.getBidderRequests(bidRequest.id) + + where: + secureMarkup | url + WARN.value | "http" + WARN.value | "http%3A" + WARN.value | "https" + ENFORCE.value | "http" + ENFORCE.value | "http%3A" + ENFORCE.value | "https" + SKIP.value | "https" + SKIP.value | "http%3A" + SKIP.value | "https" + } + + private static Account getAccountWithSpecifiedBannerMax(String accountId, BidValidationEnforcement bannerMaxSizeEnforcement) { + def accountConfig = new AccountConfig( + auction: new AccountAuctionConfig( + bidValidations: new AccountBidValidationConfig(bannerMaxSizeEnforcement: bannerMaxSizeEnforcement), + debugAllow: true)) + new Account(status: ACTIVE, uuid: accountId, config: accountConfig) + } +} diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy index b0c4a101279..979eac4474b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy @@ -284,8 +284,8 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { def higherWidth = lowerWidth + 1 def higherHigh = lowerHigh + 1 def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].banner.format = [new Format(w: lowerWidth, h: lowerHigh), - new Format(w: higherWidth, h: higherHigh)] + imp[0].banner.format = [new Format(weight: lowerWidth, height: lowerHigh), + new Format(weight: higherWidth, height: higherHigh)] } and: "Account with enabled fetch, fetch.url in the DB" @@ -352,20 +352,20 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { mediaType | impClosure org.prebid.server.functional.model.response.auction.MediaType.BANNER | { int widthVal, int heightVal -> Imp.getDefaultImpression(mediaType).tap { - banner.format = [new Format(w: widthVal, h: heightVal)] + banner.format = [new Format(weight: widthVal, height: heightVal)] } } org.prebid.server.functional.model.response.auction.MediaType.BANNER | { int widthVal, int heightVal -> Imp.getDefaultImpression(mediaType).tap { banner.format = null - banner.w = widthVal - banner.h = heightVal + banner.weight = widthVal + banner.height = heightVal } } org.prebid.server.functional.model.response.auction.MediaType.VIDEO | { int widthVal, int heightVal -> Imp.getDefaultImpression(mediaType).tap { - video.w = widthVal - video.h = heightVal + video.weight = widthVal + video.height = heightVal } } } From 4c7b77b0da6ce0e014bea55258aaf5f4448ae18f Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Wed, 29 May 2024 13:54:26 +0200 Subject: [PATCH 7/9] Core: Add DSA Validations (#3133) --- .../prebid/server/auction/DsaEnforcer.java | 87 +++- .../auction/model/BidRejectionReason.java | 1 + .../requestfactory/Ortb2RequestFactory.java | 6 +- .../bidder/yieldlab/YieldlabBidder.java | 10 +- .../ext/request/DsaPublisherRender.java | 18 + .../openrtb/ext/request/DsaRequired.java | 19 + ...Transparency.java => DsaTransparency.java} | 5 +- .../proto/openrtb/ext/request/ExtRegsDsa.java | 2 +- .../ext/response/DsaAdvertiserRender.java | 17 + .../proto/openrtb/ext/response/ExtBidDsa.java | 36 ++ .../spring/config/ServiceConfiguration.java | 4 +- .../model/request/auction/Dsa.groovy | 4 +- .../model/response/auction/BidExt.groovy | 2 +- .../auction/BidRejectionReason.groovy | 1 + .../{Dsa.groovy => DsaResponse.groovy} | 6 +- .../functional/tests/privacy/DsaSpec.groovy | 151 +++++-- .../server/auction/DsaEnforcerTest.java | 398 +++++++++++++++++- .../Ortb2RequestFactoryTest.java | 56 ++- .../stroeercore/StroeerCoreBidderTest.java | 8 +- .../bidder/yieldlab/YieldlabBidderTest.java | 10 +- 20 files changed, 746 insertions(+), 95 deletions(-) create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaPublisherRender.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaRequired.java rename src/main/java/org/prebid/server/proto/openrtb/ext/request/{ExtRegsDsaTransparency.java => DsaTransparency.java} (68%) create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/response/DsaAdvertiserRender.java create mode 100644 src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtBidDsa.java rename src/test/groovy/org/prebid/server/functional/model/response/auction/{Dsa.groovy => DsaResponse.groovy} (90%) diff --git a/src/main/java/org/prebid/server/auction/DsaEnforcer.java b/src/main/java/org/prebid/server/auction/DsaEnforcer.java index ee992fae6ed..b9b87abd37c 100644 --- a/src/main/java/org/prebid/server/auction/DsaEnforcer.java +++ b/src/main/java/org/prebid/server/auction/DsaEnforcer.java @@ -1,6 +1,6 @@ package org.prebid.server.auction; -import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.JsonNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Regs; import com.iab.openrtb.response.Bid; @@ -12,19 +12,35 @@ import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderSeatBid; +import org.prebid.server.exception.PreBidException; +import org.prebid.server.json.JacksonMapper; +import org.prebid.server.proto.openrtb.ext.request.DsaPublisherRender; +import org.prebid.server.proto.openrtb.ext.request.DsaRequired; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; +import org.prebid.server.proto.openrtb.ext.response.DsaAdvertiserRender; +import org.prebid.server.proto.openrtb.ext.response.ExtBidDsa; import org.prebid.server.util.ObjectUtil; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; public class DsaEnforcer { private static final String DSA_EXT = "dsa"; - private static final Set DSA_REQUIRED = Set.of(2, 3); + private static final Set DSA_REQUIRED = Set.of( + DsaRequired.REQUIRED.getValue(), + DsaRequired.REQUIRED_ONLINE_PLATFORM.getValue()); + private static final int MAX_DSA_FIELD_LENGTH = 100; + + private final JacksonMapper mapper; + + public DsaEnforcer(JacksonMapper mapper) { + this.mapper = Objects.requireNonNull(mapper); + } public AuctionParticipation enforce(BidRequest bidRequest, AuctionParticipation auctionParticipation, @@ -34,7 +50,7 @@ public AuctionParticipation enforce(BidRequest bidRequest, final BidderSeatBid seatBid = ObjectUtil.getIfNotNull(bidderResponse, BidderResponse::getSeatBid); final List bidderBids = ObjectUtil.getIfNotNull(seatBid, BidderSeatBid::getBids); - if (CollectionUtils.isEmpty(bidderBids) || !isDsaValidationRequired(bidRequest)) { + if (CollectionUtils.isEmpty(bidderBids)) { return auctionParticipation; } @@ -44,9 +60,19 @@ public AuctionParticipation enforce(BidRequest bidRequest, for (BidderBid bidderBid : bidderBids) { final Bid bid = bidderBid.getBid(); - if (!isValid(bid)) { - warnings.add(BidderError.invalidBid("Bid \"%s\" missing DSA".formatted(bid.getId()))); - rejectionTracker.reject(bid.getImpid(), BidRejectionReason.GENERAL); + final ExtBidDsa dsaResponse = Optional.ofNullable(bid.getExt()) + .map(ext -> ext.get(DSA_EXT)) + .map(this::getDsaResponse) + .orElse(null); + + try { + validateFieldLength(dsaResponse); + if (isDsaValidationRequired(bidRequest)) { + validateDsa(bidRequest, dsaResponse); + } + } catch (PreBidException e) { + warnings.add(BidderError.invalidBid("Bid \"%s\": %s".formatted(bid.getId(), e.getMessage()))); + rejectionTracker.reject(bid.getImpid(), BidRejectionReason.REJECTED_BY_DSA_PRIVACY); updatedBidderBids.remove(bidderBid); } } @@ -71,9 +97,52 @@ private static boolean isDsaValidationRequired(BidRequest bidRequest) { .orElse(false); } - private boolean isValid(Bid bid) { - final ObjectNode bidExt = bid.getExt(); - return bidExt != null && bidExt.hasNonNull(DSA_EXT) && !bidExt.get(DSA_EXT).isEmpty(); + private static void validateDsa(BidRequest bidRequest, ExtBidDsa dsaResponse) { + if (dsaResponse == null) { + throw new PreBidException("DSA object missing when required"); + } + + final Integer adRender = dsaResponse.getAdRender(); + final Integer pubRender = bidRequest.getRegs().getExt().getDsa().getPubRender(); + + if (pubRender == null) { + return; + } + + if (pubRender == DsaPublisherRender.WILL_RENDER.getValue() + && adRender != null && adRender == DsaAdvertiserRender.WILL_RENDER.getValue()) { + throw new PreBidException("DSA publisher and buyer both signal will render"); + } + + if (pubRender == DsaPublisherRender.NOT_RENDER.getValue() + && (adRender == null || adRender == DsaAdvertiserRender.NOT_RENDER.getValue())) { + throw new PreBidException("DSA publisher and buyer both signal will not render"); + } + } + + private static void validateFieldLength(ExtBidDsa dsaResponse) { + if (dsaResponse == null) { + return; + } + + if (!hasValidLength(dsaResponse.getBehalf())) { + throw new PreBidException("DSA behalf exceeds limit of 100 chars"); + } + if (!hasValidLength(dsaResponse.getPaid())) { + throw new PreBidException("DSA paid exceeds limit of 100 chars"); + } + } + + private static boolean hasValidLength(String value) { + return value == null || value.length() <= MAX_DSA_FIELD_LENGTH; + } + + private ExtBidDsa getDsaResponse(JsonNode dsaExt) { + try { + return mapper.mapper().convertValue(dsaExt, ExtBidDsa.class); + } catch (IllegalArgumentException e) { + return null; + } } } diff --git a/src/main/java/org/prebid/server/auction/model/BidRejectionReason.java b/src/main/java/org/prebid/server/auction/model/BidRejectionReason.java index 4858c80b0c4..de2e89efc31 100644 --- a/src/main/java/org/prebid/server/auction/model/BidRejectionReason.java +++ b/src/main/java/org/prebid/server/auction/model/BidRejectionReason.java @@ -12,6 +12,7 @@ public enum BidRejectionReason { REJECTED_BY_MEDIA_TYPE(204), GENERAL(300), REJECTED_DUE_TO_PRICE_FLOOR(301), + REJECTED_BY_DSA_PRIVACY(305), FAILED_TO_REQUEST_BIDS(100), OTHER_ERROR(100); diff --git a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java index d738477edbf..c677d4b8885 100644 --- a/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java +++ b/src/main/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactory.java @@ -55,7 +55,7 @@ import org.prebid.server.proto.openrtb.ext.request.ExtPublisherPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; -import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsaTransparency; +import org.prebid.server.proto.openrtb.ext.request.DsaTransparency; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestTargeting; @@ -289,9 +289,9 @@ private static Regs enrichRegs(Regs regs, PrivacyContext privacyContext, Account } private static ExtRegs mapRegsExtDsa(DefaultDsa defaultDsa, ExtRegs regsExt) { - final List enrichedDsaTransparencies = defaultDsa.getTransparency() + final List enrichedDsaTransparencies = defaultDsa.getTransparency() .stream() - .map(dsaTransparency -> ExtRegsDsaTransparency.of( + .map(dsaTransparency -> DsaTransparency.of( dsaTransparency.getDomain(), dsaTransparency.getDsaParams())) .toList(); diff --git a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java index f6868ef878f..af1978d5206 100644 --- a/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java +++ b/src/main/java/org/prebid/server/bidder/yieldlab/YieldlabBidder.java @@ -36,7 +36,7 @@ import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; -import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsaTransparency; +import org.prebid.server.proto.openrtb.ext.request.DsaTransparency; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtUser; @@ -271,7 +271,7 @@ private static Map extractDsaRequestParamsFromDsaRegsExtension(f dsaRequestParams.put("dsadatatopub", dsa.getDataToPub().toString()); } - final List dsaTransparency = dsa.getTransparency(); + final List dsaTransparency = dsa.getTransparency(); if (CollectionUtils.isNotEmpty(dsaTransparency)) { final String encodedTransparencies = encodeTransparenciesAsString(dsaTransparency); if (StringUtils.isNotBlank(encodedTransparencies)) { @@ -282,20 +282,20 @@ private static Map extractDsaRequestParamsFromDsaRegsExtension(f return dsaRequestParams; } - private static String encodeTransparenciesAsString(List transparencies) { + private static String encodeTransparenciesAsString(List transparencies) { return transparencies.stream() .filter(YieldlabBidder::isTransparencyValid) .map(YieldlabBidder::encodeTransparency) .collect(Collectors.joining(TRANSPARENCY_TEMPLATE_DELIMITER)); } - private static boolean isTransparencyValid(ExtRegsDsaTransparency transparency) { + private static boolean isTransparencyValid(DsaTransparency transparency) { return StringUtils.isNotBlank(transparency.getDomain()) && transparency.getDsaParams() != null && CollectionUtils.isNotEmpty(transparency.getDsaParams()); } - private static String encodeTransparency(ExtRegsDsaTransparency transparency) { + private static String encodeTransparency(DsaTransparency transparency) { return TRANSPARENCY_TEMPLATE.formatted(transparency.getDomain(), encodeTransparencyParams(transparency.getDsaParams())); } diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaPublisherRender.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaPublisherRender.java new file mode 100644 index 00000000000..e507bd19f67 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaPublisherRender.java @@ -0,0 +1,18 @@ +package org.prebid.server.proto.openrtb.ext.request; + +public enum DsaPublisherRender { + + NOT_RENDER(0), + COULD_RENDER(1), + WILL_RENDER(2); + + private final int value; + + DsaPublisherRender(final int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaRequired.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaRequired.java new file mode 100644 index 00000000000..e2f7a29a652 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaRequired.java @@ -0,0 +1,19 @@ +package org.prebid.server.proto.openrtb.ext.request; + +public enum DsaRequired { + + NOT_REQUIRED(0), + SUPPORTED(1), + REQUIRED(2), + REQUIRED_ONLINE_PLATFORM(3); + + private final int value; + + DsaRequired(final int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsaTransparency.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaTransparency.java similarity index 68% rename from src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsaTransparency.java rename to src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaTransparency.java index 6542326bd5c..6b2e47bc623 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsaTransparency.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/DsaTransparency.java @@ -7,17 +7,20 @@ /** * Defines the contract for bidrequest.regs.ext.dsa.transparency[i] + * and bidresponse.seatbid[i].bid[i].ext.dsa.transparency[i] */ @Value(staticConstructor = "of") -public class ExtRegsDsaTransparency { +public class DsaTransparency { /** * Defines the contract for bidrequest.regs.ext.dsa.transparency[i].domain + * and bidresponse.seatbid[i].bid[i].ext.dsa.transparency[i].domain */ String domain; /** * Defines the contract for bidrequest.regs.ext.dsa.transparency[i].dsaparams[] + * and bidresponse.seatbid[i].bid[i].ext.dsa.transparency[i].dsaparams[] */ @JsonProperty("dsaparams") List dsaParams; diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsa.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsa.java index 3dc3211097f..c976b523e5e 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsa.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/ExtRegsDsa.java @@ -32,6 +32,6 @@ public class ExtRegsDsa { /** * Defines the contract for bidrequest.regs.ext.dsa.transparency[] */ - List transparency; + List transparency; } diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/DsaAdvertiserRender.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/DsaAdvertiserRender.java new file mode 100644 index 00000000000..9b6137ef055 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/response/DsaAdvertiserRender.java @@ -0,0 +1,17 @@ +package org.prebid.server.proto.openrtb.ext.response; + +public enum DsaAdvertiserRender { + + NOT_RENDER(0), + WILL_RENDER(1); + + private final int value; + + DsaAdvertiserRender(final int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtBidDsa.java b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtBidDsa.java new file mode 100644 index 00000000000..aa24e176303 --- /dev/null +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/response/ExtBidDsa.java @@ -0,0 +1,36 @@ +package org.prebid.server.proto.openrtb.ext.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Value; +import org.prebid.server.proto.openrtb.ext.request.DsaTransparency; + +import java.util.List; + +/** + * Defines the contract for bidresponse.seatbid[i].bid[i].ext.dsa + */ +@Value(staticConstructor = "of") +public class ExtBidDsa { + + /** + * Defines the contract for bidresponse.seatbid[i].bid[i].ext.dsa.behalf + */ + String behalf; + + /** + * Defines the contract for bidresponse.seatbid[i].bid[i].ext.dsa.paid + */ + String paid; + + /** + * Defines the contract for bidresponse.seatbid[i].bid[i].ext.dsa.transparency[] + */ + List transparency; + + /** + * Defines the contract for bidresponse.seatbid[i].bid[i].ext.dsa.adrender + */ + @JsonProperty("adrender") + Integer adRender; + +} diff --git a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java index 719f9aee0df..4bc0cb6f600 100644 --- a/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java @@ -1103,8 +1103,8 @@ LoggerControlKnob loggerControlKnob(Vertx vertx) { } @Bean - DsaEnforcer dsaEnforcer() { - return new DsaEnforcer(); + DsaEnforcer dsaEnforcer(JacksonMapper mapper) { + return new DsaEnforcer(mapper); } private static List splitToList(String listAsString) { diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dsa.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dsa.groovy index ed0beafdc31..18169329cf5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Dsa.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Dsa.groovy @@ -6,6 +6,8 @@ import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils +import static org.prebid.server.functional.model.request.auction.DsaPubRender.PUB_MIGHT_RENDER + @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @EqualsAndHashCode @ToString(includeNames = true, ignoreNulls = true) @@ -18,7 +20,7 @@ class Dsa { static Dsa getDefaultDsa(DsaRequired dsaRequired = PBSUtils.getRandomEnum(DsaRequired)) { new Dsa(dsaRequired: dsaRequired, - pubRender: PBSUtils.getRandomEnum(DsaPubRender), + pubRender: PUB_MIGHT_RENDER, dataToPub: PBSUtils.getRandomEnum(DsaDataToPub), transparency: [DsaTransparency.defaultDsaTransparency]) } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidExt.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidExt.groovy index 216b78b3609..61cdd7ad5f0 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidExt.groovy @@ -9,5 +9,5 @@ class BidExt { Prebid prebid BigDecimal origbidcpm Currency origbidcur - Dsa dsa + DsaResponse dsa } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidRejectionReason.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidRejectionReason.groovy index ce517248dca..6cc4fc5605a 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/BidRejectionReason.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/BidRejectionReason.groovy @@ -11,6 +11,7 @@ enum BidRejectionReason { REJECTED_BY_MEDIA_TYPE(204), GENERAL(300), REJECTED_DUE_TO_PRICE_FLOOR(301), + REJECTED_DUE_TO_DSA(305), OTHER_ERROR(100) @JsonValue diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/Dsa.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/DsaResponse.groovy similarity index 90% rename from src/test/groovy/org/prebid/server/functional/model/response/auction/Dsa.groovy rename to src/test/groovy/org/prebid/server/functional/model/response/auction/DsaResponse.groovy index 172955e2e18..30e6fb9accd 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/Dsa.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/DsaResponse.groovy @@ -10,15 +10,15 @@ import org.prebid.server.functional.util.PBSUtils @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @EqualsAndHashCode @ToString(includeNames = true, ignoreNulls = true) -class Dsa { +class DsaResponse { String behalf String paid List transparency DsaAdRender adRender - static Dsa getDefaultDsa() { - new Dsa( + static DsaResponse getDefaultDsa() { + new DsaResponse( behalf: PBSUtils.randomString, paid: PBSUtils.randomString, adRender: PBSUtils.getRandomEnum(DsaAdRender), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/DsaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/DsaSpec.groovy index e7576c23396..ad608a223ab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/DsaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/DsaSpec.groovy @@ -6,14 +6,22 @@ import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Dsa import org.prebid.server.functional.model.request.auction.Dsa as RequestDsa -import org.prebid.server.functional.model.request.auction.DsaRequired import org.prebid.server.functional.model.response.auction.BidExt import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.model.response.auction.Dsa as BidDsa +import org.prebid.server.functional.model.response.auction.DsaResponse +import org.prebid.server.functional.model.response.auction.DsaResponse as BidDsa import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent -import static org.prebid.server.functional.model.response.auction.BidRejectionReason.GENERAL +import static org.prebid.server.functional.model.request.auction.DsaPubRender.PUB_CANT_RENDER +import static org.prebid.server.functional.model.request.auction.DsaPubRender.PUB_WILL_RENDER +import static org.prebid.server.functional.model.request.auction.DsaRequired.NOT_REQUIRED +import static org.prebid.server.functional.model.request.auction.DsaRequired.REQUIRED +import static org.prebid.server.functional.model.request.auction.DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM +import static org.prebid.server.functional.model.request.auction.DsaRequired.SUPPORTED +import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REJECTED_DUE_TO_DSA +import static org.prebid.server.functional.model.response.auction.DsaAdRender.ADVERTISER_WILL_RENDER +import static org.prebid.server.functional.model.response.auction.DsaAdRender.ADVERTISER_WONT_RENDER import static org.prebid.server.functional.model.response.auction.ErrorType.GENERIC import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID import static org.prebid.server.functional.util.privacy.TcfConsent.PurposeId.BASIC_ADS @@ -43,10 +51,10 @@ class DsaSpec extends PrivacyBaseSpec { where: dsa << [null, new RequestDsa(), - RequestDsa.getDefaultDsa(DsaRequired.NOT_REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.SUPPORTED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] + RequestDsa.getDefaultDsa(NOT_REQUIRED), + RequestDsa.getDefaultDsa(SUPPORTED), + RequestDsa.getDefaultDsa(REQUIRED), + RequestDsa.getDefaultDsa(REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] } def "AMP request should always accept bids with DSA"() { @@ -85,10 +93,10 @@ class DsaSpec extends PrivacyBaseSpec { where: dsa << [null, new RequestDsa(), - RequestDsa.getDefaultDsa(DsaRequired.NOT_REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.SUPPORTED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] + RequestDsa.getDefaultDsa(NOT_REQUIRED), + RequestDsa.getDefaultDsa(SUPPORTED), + RequestDsa.getDefaultDsa(REQUIRED), + RequestDsa.getDefaultDsa(REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] } def "AMP request should accept bids without DSA when dsarequired is #dsaRequired"() { @@ -125,8 +133,7 @@ class DsaSpec extends PrivacyBaseSpec { assert !response.ext.errors where: - dsaRequired << [DsaRequired.NOT_REQUIRED, - DsaRequired.SUPPORTED] + dsaRequired << [NOT_REQUIRED, SUPPORTED] } def "AMP request should reject bids without DSA when dsarequired is #dsaRequired"() { @@ -161,11 +168,10 @@ class DsaSpec extends PrivacyBaseSpec { and: "Response should contain an error" def bidId = bidResponse.seatbid[0].bid[0].id assert response.ext?.warnings[GENERIC]*.code == [5] - assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\" missing DSA"] + assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\": DSA object missing when required"] where: - dsaRequired << [DsaRequired.REQUIRED, - DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] + dsaRequired << [REQUIRED, REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] } def "Auction request should always forward DSA to bidders"() { @@ -183,10 +189,10 @@ class DsaSpec extends PrivacyBaseSpec { where: dsa << [null, new RequestDsa(), - RequestDsa.getDefaultDsa(DsaRequired.NOT_REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.SUPPORTED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] + RequestDsa.getDefaultDsa(NOT_REQUIRED), + RequestDsa.getDefaultDsa(SUPPORTED), + RequestDsa.getDefaultDsa(REQUIRED), + RequestDsa.getDefaultDsa(REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] } def "Auction request should always accept bids with DSA"() { @@ -220,10 +226,10 @@ class DsaSpec extends PrivacyBaseSpec { where: dsa << [null, new RequestDsa(), - RequestDsa.getDefaultDsa(DsaRequired.NOT_REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.SUPPORTED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED), - RequestDsa.getDefaultDsa(DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] + RequestDsa.getDefaultDsa(NOT_REQUIRED), + RequestDsa.getDefaultDsa(SUPPORTED), + RequestDsa.getDefaultDsa(REQUIRED), + RequestDsa.getDefaultDsa(REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM)] } def "Auction request should accept bids without DSA when dsarequired is #dsaRequired"() { @@ -251,8 +257,7 @@ class DsaSpec extends PrivacyBaseSpec { assert !response.ext.errors where: - dsaRequired << [DsaRequired.NOT_REQUIRED, - DsaRequired.SUPPORTED] + dsaRequired << [NOT_REQUIRED, SUPPORTED] } def "Auction request should reject bids without DSA when dsarequired is #dsaRequired"() { @@ -278,11 +283,10 @@ class DsaSpec extends PrivacyBaseSpec { and: "Response should contain an error" def bidId = bidResponse.seatbid[0].bid[0].id assert response.ext?.warnings[GENERIC]*.code == [5] - assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\" missing DSA"] + assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\": DSA object missing when required"] where: - dsaRequired << [DsaRequired.REQUIRED, - DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] + dsaRequired << [REQUIRED, REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] } def "Auction request should reject bids without DSA and populate seatNonBid when dsarequired is #dsaRequired"() { @@ -312,16 +316,15 @@ class DsaSpec extends PrivacyBaseSpec { def seatNonBid = response.ext.seatnonbid[0] assert seatNonBid.seat == GENERIC.value assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id - assert seatNonBid.nonBid[0].statusCode == GENERAL + assert seatNonBid.nonBid[0].statusCode == REJECTED_DUE_TO_DSA and: "Response should contain an error" def bidId = bidResponse.seatbid[0].bid[0].id assert response.ext?.warnings[GENERIC]*.code == [5] - assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\" missing DSA"] + assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\": DSA object missing when required"] where: - dsaRequired << [DsaRequired.REQUIRED, - DsaRequired.REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] + dsaRequired << [REQUIRED, REQUIRED_PUBLISHER_IS_ONLINE_PLATFORM] } def "Auction request should set account DSA when BidRequest DSA is null"() { @@ -461,4 +464,86 @@ class DsaSpec extends PrivacyBaseSpec { then: "Bidder request shouldn't contain DSA" assert !bidder.getBidderRequest(bidRequest.id)?.regs?.ext?.dsa } + + def "Auction request should reject bids with DSA when pubRender is #pubRender and adRender is #adRender"() { + given: "Default bid request with DSA pubRender" + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.returnAllBidStatus = true + regs.ext.dsa = RequestDsa.getDefaultDsa(REQUIRED).tap { + it.pubRender = pubRender + } + } + + and: "Default bidder response with incorrect DSA adRender" + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].ext = new BidExt(dsa: new DsaResponse(adRender: adRender)) + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "PBS processes auction request" + def response = privacyPbsService.sendAuctionRequest(bidRequest) + + then: "PBS should reject bid" + assert !response.seatbid + + and: "PBS response should contain seatNonBid for rejected bids" + assert response.ext.seatnonbid.size() == 1 + + def seatNonBid = response.ext.seatnonbid[0] + assert seatNonBid.seat == GENERIC.value + assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id + assert seatNonBid.nonBid[0].statusCode == REJECTED_DUE_TO_DSA + + and: "Response should contain an error" + def bidId = bidResponse.seatbid[0].bid[0].id + assert response.ext?.warnings[GENERIC]*.code == [5] + assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\": ${warningMessage}"] + + where: + warningMessage | pubRender | adRender + "DSA publisher and buyer both signal will render" | PUB_WILL_RENDER | ADVERTISER_WILL_RENDER + "DSA publisher and buyer both signal will not render" | PUB_CANT_RENDER | ADVERTISER_WONT_RENDER + } + + def "Auction request should reject bids with DSA when dsa response have paid or behalf fields longer then 100 characters"() { + given: "Default bid request with DSA pubRender" + def bidRequest = BidRequest.defaultBidRequest.tap { + ext.prebid.returnAllBidStatus = true + regs.ext.dsa = RequestDsa.getDefaultDsa(REQUIRED) + } + + and: "Default bidder response with incorrect DSA" + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].ext = new BidExt(dsa: invalidDsaResponse) + } + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) + + when: "PBS processes auction request" + def response = privacyPbsService.sendAuctionRequest(bidRequest) + + then: "PBS should reject bid" + assert !response.seatbid + + and: "PBS response should contain seatNonBid for rejected bids" + assert response.ext.seatnonbid.size() == 1 + + def seatNonBid = response.ext.seatnonbid[0] + assert seatNonBid.seat == GENERIC.value + assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id + assert seatNonBid.nonBid[0].statusCode == REJECTED_DUE_TO_DSA + + and: "Response should contain an error" + def bidId = bidResponse.seatbid[0].bid[0].id + assert response.ext?.warnings[GENERIC]*.code == [5] + assert response.ext?.warnings[GENERIC]*.message == ["Bid \"$bidId\": ${warningMessage}"] + + where: + warningMessage | invalidDsaResponse + "DSA paid exceeds limit of 100 chars" | new DsaResponse(paid: PBSUtils.getRandomString(101)) + "DSA behalf exceeds limit of 100 chars" | new DsaResponse(behalf: PBSUtils.getRandomString(101)) + } } diff --git a/src/test/java/org/prebid/server/auction/DsaEnforcerTest.java b/src/test/java/org/prebid/server/auction/DsaEnforcerTest.java index 13fb76ef9dc..78580fd5abe 100644 --- a/src/test/java/org/prebid/server/auction/DsaEnforcerTest.java +++ b/src/test/java/org/prebid/server/auction/DsaEnforcerTest.java @@ -4,6 +4,7 @@ import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Regs; import com.iab.openrtb.response.Bid; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; @@ -17,9 +18,13 @@ import org.prebid.server.bidder.model.BidderBid; import org.prebid.server.bidder.model.BidderError; import org.prebid.server.bidder.model.BidderSeatBid; +import org.prebid.server.proto.openrtb.ext.request.DsaPublisherRender; +import org.prebid.server.proto.openrtb.ext.request.DsaRequired; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; import org.prebid.server.proto.openrtb.ext.response.BidType; +import org.prebid.server.proto.openrtb.ext.response.DsaAdvertiserRender; +import org.prebid.server.util.ObjectUtil; import java.util.List; @@ -32,7 +37,8 @@ public class DsaEnforcerTest extends VertxTest { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); - private final DsaEnforcer target = new DsaEnforcer(); + + private final DsaEnforcer target = new DsaEnforcer(jacksonMapper); @Mock private BidRejectionTracker bidRejectionTracker; @@ -53,9 +59,9 @@ public void enforceShouldDoNothingWhenBidsAreEmpty() { } @Test - public void enforceShouldDoNothingWhenDsaIsNotRequired() { + public void enforceShouldDoNothingWhenDsaIsNotRequiredAndDsaResponseIsMissing() { // given - final ExtRegs extRegs = ExtRegs.of(1, "usPrivacy", "1", ExtRegsDsa.of(1, 2, 3, emptyList())); + final ExtRegs extRegs = givenExtRegs(DsaRequired.NOT_REQUIRED, DsaPublisherRender.NOT_RENDER); final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); final BidderBid bid = BidderBid.of(Bid.builder().build(), BidType.banner, "USD"); final AuctionParticipation givenParticipation = AuctionParticipation.builder() @@ -71,14 +77,223 @@ public void enforceShouldDoNothingWhenDsaIsNotRequired() { } @Test - public void enforceDoNothingWhenDsaIsRequiredAndBidHasDsa() { - final ExtRegs extRegs = ExtRegs.of(1, "usPrivacy", "1", ExtRegsDsa.of(2, 2, 3, emptyList())); + public void enforceShouldRejectBidAndAddWarningWhenDsaIsNotRequiredAndDsaResponseHasInvalidBehalfField() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.NOT_REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", RandomStringUtils.randomAlphabetic(101)) + .put("paid", RandomStringUtils.randomAlphabetic(100)) + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\": DSA behalf exceeds limit of 100 chars"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceShouldRejectBidAndAddWarningWhenDsaIsNotRequiredAndDsaResponseHasInvalidPaidField() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.NOT_REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", RandomStringUtils.randomAlphabetic(100)) + .put("paid", RandomStringUtils.randomAlphabetic(101)) + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\": DSA paid exceeds limit of 100 chars"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherNotRenderAndAdvertiserRenders() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.WILL_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherRendersAndAdvertiserNotRender() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.WILL_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherRenderIsAbsentAndAdvertiserNotRender() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, null); final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); final ObjectNode dsaNode = mapper.createObjectNode() .put("behalf", "Advertiser") .put("paid", "Advertiser") - .put("adrender", 1); + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherCouldRenderAndAdvertiserNotRender() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.COULD_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherCouldRenderAndAdvertiserRenders() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.COULD_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.WILL_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherCouldRenderAndAdvertiserIsAbsent() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.COULD_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser"); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + assertThat(actual).isEqualTo(givenParticipation); + verifyNoInteractions(bidRejectionTracker); + } + + @Test + public void enforceDoNothingWhenDsaIsRequiredAndPublisherRendersAndAdvertiserRenderIsAbsent() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.WILL_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser"); final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); final BidderBid bid = BidderBid.of(Bid.builder().ext(ext).build(), BidType.banner, "USD"); final AuctionParticipation givenParticipation = AuctionParticipation.builder() @@ -95,10 +310,11 @@ public void enforceDoNothingWhenDsaIsRequiredAndBidHasDsa() { @Test public void enforceShouldRejectBidAndAddWarningWhenBidExtHasEmptyDsaAndDsaIsRequired() { - final ExtRegs extRegs = ExtRegs.of(1, "usPrivacy", "1", ExtRegsDsa.of(2, 2, 3, emptyList())); + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); - final ObjectNode ext = mapper.createObjectNode().set("dsa", mapper.createObjectNode()); + final ObjectNode ext = mapper.createObjectNode(); final BidderBid bid = BidderBid.of( Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), BidType.banner, @@ -112,22 +328,27 @@ public void enforceShouldRejectBidAndAddWarningWhenBidExtHasEmptyDsaAndDsaIsRequ // then final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() - .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\" missing DSA"))) + .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\": DSA object missing when required"))) .bids(emptyList()) .build(); final AuctionParticipation expectedParticipation = AuctionParticipation.builder() .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) .build(); assertThat(actual).isEqualTo(expectedParticipation); - verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.GENERAL); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); } @Test - public void enforceShouldRejectBidAndAddWarningWhenBidExtIsEmptyDsaAndDsaIsRequired() { - final ExtRegs extRegs = ExtRegs.of(1, "usPrivacy", "1", ExtRegsDsa.of(3, 2, 3, emptyList())); + public void enforceShouldRejectBidAndAddWarningWhenDsaIsRequiredAndDsaResponseHasInvalidPaidField() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); - final ObjectNode ext = mapper.createObjectNode(); + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", RandomStringUtils.randomAlphabetic(100)) + .put("paid", RandomStringUtils.randomAlphabetic(101)) + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); final BidderBid bid = BidderBid.of( Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), BidType.banner, @@ -141,14 +362,161 @@ public void enforceShouldRejectBidAndAddWarningWhenBidExtIsEmptyDsaAndDsaIsRequi // then final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() - .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\" missing DSA"))) + .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\": DSA paid exceeds limit of 100 chars"))) .bids(emptyList()) .build(); final AuctionParticipation expectedParticipation = AuctionParticipation.builder() .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) .build(); assertThat(actual).isEqualTo(expectedParticipation); - verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.GENERAL); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceShouldRejectBidAndAddWarningWhenDsaIsRequiredAndDsaResponseHasInvalidBehalfField() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", RandomStringUtils.randomAlphabetic(101)) + .put("paid", RandomStringUtils.randomAlphabetic(100)) + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of(BidderError.invalidBid("Bid \"bid_id\": DSA behalf exceeds limit of 100 chars"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceShouldRejectBidAndAddWarningWhenDsaIsRequiredAndPublisherAndAdvertiserBothRender() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.WILL_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.WILL_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of( + BidderError.invalidBid("Bid \"bid_id\": DSA publisher and buyer both signal will render"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceShouldRejectBidAndAddWarningWhenDsaIsRequiredAndPublisherAndAdvertiserBothNotRender() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser") + .put("adrender", DsaAdvertiserRender.NOT_RENDER.getValue()); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of( + BidderError.invalidBid("Bid \"bid_id\": DSA publisher and buyer both signal will not render"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + @Test + public void enforceShouldRejectBidAndAddWarningWhenDsaIsRequiredAndPublisherNotRenderAndAdvertiserIsAbsent() { + // given + final ExtRegs extRegs = givenExtRegs(DsaRequired.REQUIRED, DsaPublisherRender.NOT_RENDER); + final BidRequest givenRequest = BidRequest.builder().regs(Regs.builder().ext(extRegs).build()).build(); + + final ObjectNode dsaNode = mapper.createObjectNode() + .put("behalf", "Advertiser") + .put("paid", "Advertiser"); + final ObjectNode ext = mapper.createObjectNode().set("dsa", dsaNode); + final BidderBid bid = BidderBid.of( + Bid.builder().id("bid_id").impid("imp_id").ext(ext).build(), + BidType.banner, + "USD"); + final AuctionParticipation givenParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", BidderSeatBid.of(List.of(bid)), 100)) + .build(); + + // when + final AuctionParticipation actual = target.enforce(givenRequest, givenParticipation, bidRejectionTracker); + + // then + final BidderSeatBid expectedSeatBid = BidderSeatBid.builder() + .warnings(List.of( + BidderError.invalidBid("Bid \"bid_id\": DSA publisher and buyer both signal will not render"))) + .bids(emptyList()) + .build(); + final AuctionParticipation expectedParticipation = AuctionParticipation.builder() + .bidderResponse(BidderResponse.of("bidder", expectedSeatBid, 100)) + .build(); + assertThat(actual).isEqualTo(expectedParticipation); + verify(bidRejectionTracker).reject("imp_id", BidRejectionReason.REJECTED_BY_DSA_PRIVACY); + } + + private static ExtRegs givenExtRegs(DsaRequired dsaRequired, DsaPublisherRender pubRender) { + final ExtRegsDsa dsa = ExtRegsDsa.of( + ObjectUtil.getIfNotNull(dsaRequired, DsaRequired::getValue), + ObjectUtil.getIfNotNull(pubRender, DsaPublisherRender::getValue), + 3, + emptyList()); + return ExtRegs.of(1, "usPrivacy", "1", dsa); } } diff --git a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java index 98f172faee3..d27c15240a8 100644 --- a/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/requestfactory/Ortb2RequestFactoryTest.java @@ -60,7 +60,6 @@ import org.prebid.server.proto.openrtb.ext.request.ExtPublisherPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; -import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsaTransparency; import org.prebid.server.proto.openrtb.ext.request.ExtRequest; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestTargeting; @@ -1368,7 +1367,11 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldSetDsaFromAccountWhen .id(accountId) .privacy(AccountPrivacyConfig.builder() .dsa(AccountDsaConfig.of( - DefaultDsa.of(0, 1, 2, List.of(DsaTransparency.of("", List.of(0)))), null)) + DefaultDsa.of( + 0, + 1, + 2, + List.of(DsaTransparency.of("", List.of(0)))), null)) .build()) .build(); given(applicationSettings.getAccountById(any(), any())).willReturn(Future.succeededFuture(account)); @@ -1392,8 +1395,10 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldSetDsaFromAccountWhen assertThat(dsa.getPubRender()).isEqualTo(1); assertThat(dsa.getDataToPub()).isEqualTo(2); assertThat(dsa.getTransparency()).satisfies(transparencies -> - assertThat(transparencies).isEqualTo(List.of(ExtRegsDsaTransparency.of("", - List.of(0))))); + assertThat(transparencies).isEqualTo( + List.of(org.prebid.server.proto.openrtb.ext.request.DsaTransparency.of( + "", + List.of(0))))); }); } @@ -1459,7 +1464,9 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldNotSetDsaFromAccountW ExtRegsDsa.of(0, 1, 2, - List.of(ExtRegsDsaTransparency.of("", List.of(0)))))) + List.of(org.prebid.server.proto.openrtb.ext.request.DsaTransparency.of( + "", + List.of(0)))))) .build()) ); @@ -1477,7 +1484,14 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldNotSetDsaFromAccountW .id(accountId) .privacy(AccountPrivacyConfig.builder() .dsa(AccountDsaConfig.of( - DefaultDsa.of(3, 4, 5, List.of(DsaTransparency.of("domain", List.of(1)))), null)) + DefaultDsa.of( + 3, + 4, + 5, + List.of(org.prebid.server.settings.model.DsaTransparency.of( + "domain", + List.of(1)))), + null)) .build()) .build(); given(applicationSettings.getAccountById(any(), any())).willReturn(Future.succeededFuture(account)); @@ -1501,8 +1515,10 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldNotSetDsaFromAccountW assertThat(dsa.getPubRender()).isEqualTo(1); assertThat(dsa.getDataToPub()).isEqualTo(2); assertThat(dsa.getTransparency()).satisfies(transparencies -> - assertThat(transparencies).isEqualTo(List.of(ExtRegsDsaTransparency.of("", - List.of(0))))); + assertThat(transparencies).isEqualTo( + List.of(org.prebid.server.proto.openrtb.ext.request.DsaTransparency.of( + "", + List.of(0))))); }); } @@ -1530,7 +1546,14 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldSetDsaFromAccountWhen .id(accountId) .privacy(AccountPrivacyConfig.builder() .dsa(AccountDsaConfig.of( - DefaultDsa.of(0, 1, 2, List.of(DsaTransparency.of("", List.of(0)))), true)) + DefaultDsa.of( + 0, + 1, + 2, + List.of(org.prebid.server.settings.model.DsaTransparency.of( + "", + List.of(0)))), + true)) .build()) .build(); given(applicationSettings.getAccountById(any(), any())).willReturn(Future.succeededFuture(account)); @@ -1554,8 +1577,10 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldSetDsaFromAccountWhen assertThat(dsa.getPubRender()).isEqualTo(1); assertThat(dsa.getDataToPub()).isEqualTo(2); assertThat(dsa.getTransparency()).satisfies(transparencies -> - assertThat(transparencies).isEqualTo(List.of(ExtRegsDsaTransparency.of("", - List.of(0))))); + assertThat(transparencies).isEqualTo( + List.of(org.prebid.server.proto.openrtb.ext.request.DsaTransparency.of( + "", + List.of(0))))); }); } @@ -1585,7 +1610,14 @@ public void enrichBidRequestWithAccountAndPrivacyDataShouldNotSetDsaFromAccountW .id(accountId) .privacy(AccountPrivacyConfig.builder() .dsa(AccountDsaConfig.of( - DefaultDsa.of(0, 1, 2, List.of(DsaTransparency.of("", List.of(0)))), true)) + DefaultDsa.of( + 0, + 1, + 2, + List.of(org.prebid.server.settings.model.DsaTransparency.of( + "", + List.of(0)))), + true)) .build()) .build(); given(applicationSettings.getAccountById(any(), any())).willReturn(Future.succeededFuture(account)); diff --git a/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java b/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java index 60f4197b216..3434f1ef8ea 100644 --- a/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/stroeercore/StroeerCoreBidderTest.java @@ -31,7 +31,7 @@ import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; -import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsaTransparency; +import org.prebid.server.proto.openrtb.ext.request.DsaTransparency; import org.prebid.server.proto.openrtb.ext.request.stroeercore.ExtImpStroeerCore; import org.prebid.server.proto.openrtb.ext.response.BidType; import org.prebid.server.util.HttpUtil; @@ -133,9 +133,9 @@ public void makeHttpRequestsShouldReturnImpsWithExpectedTagIds() { @Test public void makeHttpRequestsShouldReturnDSA() { // given - final List transparencies = Arrays.asList( - ExtRegsDsaTransparency.of("platform-example.com", List.of(1, 2)), - ExtRegsDsaTransparency.of("ssp-example.com", List.of(1)) + final List transparencies = Arrays.asList( + DsaTransparency.of("platform-example.com", List.of(1, 2)), + DsaTransparency.of("ssp-example.com", List.of(1)) ); final ExtRegsDsa dsa = ExtRegsDsa.of(3, 1, 2, transparencies); diff --git a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java index 7ca405b458f..c1d510198fc 100644 --- a/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/yieldlab/YieldlabBidderTest.java @@ -27,7 +27,7 @@ import org.prebid.server.proto.openrtb.ext.ExtPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsa; -import org.prebid.server.proto.openrtb.ext.request.ExtRegsDsaTransparency; +import org.prebid.server.proto.openrtb.ext.request.DsaTransparency; import org.prebid.server.proto.openrtb.ext.request.ExtUser; import org.prebid.server.proto.openrtb.ext.request.yieldlab.ExtImpYieldlab; import org.prebid.server.proto.openrtb.ext.response.BidType; @@ -311,7 +311,7 @@ public void makeBidsShouldReturnCorrectAdm() throws JsonProcessingException { public void makeHttpRequestsShouldAddDsaRequestParamsToRequestWhenDsaIsPresent() { //given final ExtRegsDsa dsa = ExtRegsDsa.of( - 1, 2, 3, List.of(ExtRegsDsaTransparency.of("testDomain", List.of(1, 2, 3))) + 1, 2, 3, List.of(DsaTransparency.of("testDomain", List.of(1, 2, 3))) ); final Regs regs = Regs.builder() .ext(ExtRegs.of(null, null, null, dsa)) @@ -346,8 +346,8 @@ public void makeHttpRequestsEncodesDsaTransparencyCorrectlyWhenBidRequestContain //given final ExtRegsDsa dsa = ExtRegsDsa.of( 1, 2, 3, List.of( - ExtRegsDsaTransparency.of("testDomain", List.of(1, 2, 3)), - ExtRegsDsaTransparency.of("testDomain2", List.of(4, 5, 6)) + DsaTransparency.of("testDomain", List.of(1, 2, 3)), + DsaTransparency.of("testDomain2", List.of(4, 5, 6)) ) ); final Regs regs = Regs.builder() @@ -414,7 +414,7 @@ public void makeHttpRequestsShouldNotSendDsaInfoInBidRequestWhenDsaIsMissing() { public void makeHttpRequestsShouldNotAddDsaTransparencyParamsToBidRequestWhenParamsAreMissing() { //given final ExtRegsDsa dsa = ExtRegsDsa.of( - 2, null, 3, List.of(ExtRegsDsaTransparency.of("domain", null)) + 2, null, 3, List.of(DsaTransparency.of("domain", null)) ); final Regs regs = Regs.builder() .ext(ExtRegs.of(null, null, null, dsa)) From 44d56bad5efc2e12391a11d644eaab35f2243300 Mon Sep 17 00:00:00 2001 From: Anton Babak <76536883+AntoxaAntoxic@users.noreply.github.com> Date: Wed, 29 May 2024 13:55:49 +0200 Subject: [PATCH 8/9] Rubicon: Adapter Eid Enhancement (#3194) --- .../server/bidder/rubicon/RubiconBidder.java | 23 +---- .../bidder/rubicon/RubiconBidderTest.java | 87 ------------------- 2 files changed, 1 insertion(+), 109 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java index 6e0bb270728..144a13918fa 100644 --- a/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java +++ b/src/main/java/org/prebid/server/bidder/rubicon/RubiconBidder.java @@ -139,8 +139,6 @@ public class RubiconBidder implements Bidder { private static final String TK_XINT_QUERY_PARAMETER = "tk_xint"; private static final String PREBID_SERVER_USER_AGENT = "prebid-server/1.0"; - private static final String SOURCE_RUBICON = "rubiconproject.com"; - private static final String FPD_GPID_FIELD = "gpid"; private static final String FPD_SKADN_FIELD = "skadn"; private static final String FPD_SECTIONCAT_FIELD = "sectioncat"; @@ -1123,8 +1121,6 @@ private User makeUser(User user, ExtImpRubicon rubiconImpExt) { final String userId = user != null ? user.getId() : null; final List userEids = user != null ? user.getEids() : null; final String resolvedId = userId == null ? resolveUserId(userEids) : null; - final String userBuyeruid = user != null ? user.getBuyeruid() : null; - final String resolvedBuyeruid = userBuyeruid != null ? userBuyeruid : resolveBuyeruidFromEids(userEids); final ExtUser extUser = user != null ? user.getExt() : null; final boolean hasStypeToRemove = hasStypeToRemove(userEids); final List resolvedUserEids = hasStypeToRemove @@ -1138,9 +1134,7 @@ private User makeUser(User user, ExtImpRubicon rubiconImpExt) { && userExtData == null && resolvedUserEids == null && resolvedId == null - && Objects.equals(userBuyeruid, resolvedBuyeruid) - && !hasStypeToRemove - ) { + && !hasStypeToRemove) { return hasDataToRemove ? user.toBuilder().data(null).build() @@ -1159,7 +1153,6 @@ private User makeUser(User user, ExtImpRubicon rubiconImpExt) { return userBuilder .id(ObjectUtils.defaultIfNull(resolvedId, userId)) - .buyeruid(resolvedBuyeruid) .gender(null) .yob(null) .geo(null) @@ -1260,20 +1253,6 @@ private static Uid cleanExtUserEidUidStype(Uid extUserEidUid) { extUserEidUidExtCopy); } - private static String resolveBuyeruidFromEids(List eids) { - return CollectionUtils.emptyIfNull(eids).stream() - .filter(Objects::nonNull) - .filter(eid -> SOURCE_RUBICON.equals(eid.getSource())) - .map(Eid::getUids) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(Objects::nonNull) - .map(Uid::getId) - .findFirst() - .orElse(null); - - } - private RubiconUserExtRp rubiconUserExtRp(User user, ExtImpRubicon rubiconImpExt) { final JsonNode target = rubiconUserExtRpTarget(rubiconImpExt.getVisitor(), user); diff --git a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java index 599f8fc582a..39d17a580ac 100644 --- a/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/rubicon/RubiconBidderTest.java @@ -1789,93 +1789,6 @@ public void makeHttpRequestsShouldNotCreateUserIfVisitorAndConsentNotPresent() { .containsOnly((User) null); } - @Test - public void makeHttpRequestsShouldUseUserBuyeruidIfPresent() { - // given - final BidRequest bidRequest = givenBidRequest( - builder -> builder.user(User.builder() - .buyeruid("buyeruid") - .ext(ExtUser.builder() - .eids(singletonList(Eid.of( - "rubiconproject.com", - singletonList(Uid.of( - "extUserEidUidId", - null, - mapper.valueToTree(Map.of("stype", "ppuid")) - )), - null))) - .build()) - .build()), - builder -> builder.video(Video.builder().build()), identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .extracting(BidRequest::getUser) - .extracting(User::getBuyeruid) - .containsExactly("buyeruid"); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeHttpRequestsShouldUseUidIdIfUserBuyeruidAbsentAndSpecialEidSourceAndStypeIsPpuid() { - // given - final BidRequest bidRequest = givenBidRequest( - builder -> builder.user(User.builder() - .eids(singletonList(Eid.of( - "rubiconproject.com", - singletonList(Uid.of( - "userEidUidId", - null, - mapper.valueToTree(Map.of("stype", "ppuid")) - )), - null))) - .build()), - builder -> builder.video(Video.builder().build()), identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .extracting(BidRequest::getUser) - .extracting(User::getBuyeruid) - .containsExactly("userEidUidId"); - assertThat(result.getErrors()).isEmpty(); - } - - @Test - public void makeHttpRequestsShouldUseUidIdIfUserBuyeruidAbsentAndSpecialEidSourceAndStypeIsOther() { - // given - final BidRequest bidRequest = givenBidRequest( - builder -> builder.user(User.builder() - .eids(singletonList(Eid.of( - "rubiconproject.com", - singletonList(Uid.of( - "userEidUidId", - null, - mapper.valueToTree(Map.of("stype", "other")) - )), - null))) - .build()), - builder -> builder.video(Video.builder().build()), identity()); - - // when - final Result>> result = target.makeHttpRequests(bidRequest); - - // then - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .extracting(BidRequest::getUser) - .extracting(User::getBuyeruid) - .containsExactly("userEidUidId"); - assertThat(result.getErrors()).isEmpty(); - } - @Test public void makeHttpRequestsShouldUseGivenUserIdIfOtherExtUserFieldsPassed() { // given From 6160015f72de65f743992b1a2a11e6aa9548cc3f Mon Sep 17 00:00:00 2001 From: Alex Maltsev Date: Mon, 3 Jun 2024 13:13:41 +0300 Subject: [PATCH 9/9] Docs: Added strict-app-site-dooh doc. (#3219) --- docs/config-app.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/config-app.md b/docs/config-app.md index f162efff719..3f2c03d5d5a 100644 --- a/docs/config-app.md +++ b/docs/config-app.md @@ -91,6 +91,7 @@ Removes and downloads file again if depending service cant process probably corr - `auction.validations.secure-markup` - enables secure markup validation. Possible values: `skip`, `enforce`, `warn`. Default is `skip`. - `auction.host-schain-node` - defines global schain node that will be appended to `request.source.ext.schain.nodes` passed to bidders - `auction.category-mapping-enabled` - if equals to `true` the category mapping feature will be active while auction. +- `auction.strict-app-site-dooh` - if set to `true`, it will reject requests that contain more than one of app/site/dooh. Defaults to `false`. ## Event - `event.default-timeout-ms` - timeout for event notifications