Skip to content

Commit 3a8c64c

Browse files
committed
Update after review
1 parent 25a4386 commit 3a8c64c

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ class TargetingSpec extends BaseSpec {
19081908
]
19091909
}
19101910

1911-
def "PBS amp shouldn't emit error for targeting when site is array"() {
1911+
def "PBS amp shouldn't emit error for targeting when site is invalid array"() {
19121912
given: "Create targeting with array of site"
19131913
def anyRandomValue = PBSUtils.randomString
19141914
def targeting = ["site": siteValue, "any": anyRandomValue]
@@ -1939,8 +1939,42 @@ class TargetingSpec extends BaseSpec {
19391939
assert !ampResponse.ext.errors
19401940

19411941
where:
1942-
siteValue << [null, [], [PBSUtils.randomString], [Site.defaultSite], [Site.defaultSite, PBSUtils.randomString],
1943-
[PBSUtils.randomString, Site.defaultSite], [App.defaultApp, Site.defaultSite]]
1942+
siteValue << [null, [], [PBSUtils.randomString], [Site.configFPDSite, PBSUtils.randomString],
1943+
[PBSUtils.randomString, Site.configFPDSite], [App.defaultApp, Site.configFPDSite]]
1944+
}
1945+
1946+
def "PBS amp should pass successfully when targeting site is valid"() {
1947+
given: "Create targeting with array of site"
1948+
def anyRandomValue = PBSUtils.randomString
1949+
def targeting = ["site": siteValue, "any": anyRandomValue]
1950+
1951+
and: "Encode targeting to string"
1952+
def encodeTargeting = URLEncoder.encode(encode(targeting), StandardCharsets.UTF_8)
1953+
1954+
and: "Amp request with targeting"
1955+
def ampRequest = AmpRequest.defaultAmpRequest.tap {
1956+
it.targeting = encodeTargeting
1957+
}
1958+
1959+
and: "Default bid request"
1960+
def ampStoredRequest = BidRequest.defaultBidRequest
1961+
1962+
and: "Create and save stored request into DB"
1963+
def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest)
1964+
storedRequestDao.save(storedRequest)
1965+
1966+
when: "PBS processes amp request"
1967+
def ampResponse = pbsWithDefaultTargetingLength.sendAmpRequest(ampRequest)
1968+
1969+
then: "Amp response should contain value from targeting in imp.ext.data"
1970+
def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id)
1971+
assert bidderRequest.imp[0].ext.data.any == anyRandomValue
1972+
1973+
and: "Amp response shouldn't contain any errors"
1974+
assert !ampResponse.ext.errors
1975+
1976+
where:
1977+
siteValue << [Site.configFPDSite, [Site.configFPDSite], [Site.configFPDSite, Site.configFPDSite]]
19441978
}
19451979

19461980
private static Account createAccountWithPriceGranularity(String accountId, PriceGranularityType priceGranularity) {

0 commit comments

Comments
 (0)