Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ private ExtImpMobkoi parseExtImp(Imp imp) {
}

private Imp modifyImp(Imp firstImp, ExtImpMobkoi extImpMobkoi) {
if (StringUtils.isNotBlank(firstImp.getTagid())) {
return firstImp;
}

if (StringUtils.isNotBlank(extImpMobkoi.getPlacementId())) {
return firstImp.toBuilder().tagid(extImpMobkoi.getPlacementId()).build();
}

if (StringUtils.isNotBlank(firstImp.getTagid())) {
return firstImp;
}

throw new PreBidException("invalid because it comes with neither request.imp[0].tagId nor "
+ "req.imp[0].ext.Bidder.placementId");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,38 @@ public void makeHttpRequestsShouldAddPlacementIdOnlyInFirstImpressionTagId() {
.containsExactly("pid", null);
}

@Test
public void makeHttpRequestsShouldOverrideExistingTagIdWithPlacementId() {
final ObjectNode mobkoiExt = impExt("placement-id-from-ext");
final Imp givenImp1 = givenImp(impBuilder -> impBuilder.tagid("existing-tag-id").ext(mobkoiExt));
final Imp givenImp2 = givenImp(identity());
final BidRequest bidRequest = BidRequest.builder().imp(asList(givenImp1, givenImp2)).build();
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

assertThat(result.getValue())
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(imp -> imp.getTagid())
.containsExactly("placement-id-from-ext", null);
assertThat(result.getErrors()).isEmpty();
}

@Test
public void makeHttpRequestsShouldKeepExistingTagIdWhenPlacementIdIsMissing() {
final ObjectNode mobkoiExt = impExt(null);
final Imp givenImp1 = givenImp(impBuilder -> impBuilder.tagid("existing-tag-id").ext(mobkoiExt));
final Imp givenImp2 = givenImp(identity());
final BidRequest bidRequest = BidRequest.builder().imp(asList(givenImp1, givenImp2)).build();
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

assertThat(result.getValue())
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(imp -> imp.getTagid())
.containsExactly("existing-tag-id", null);
assertThat(result.getErrors()).isEmpty();
}

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