Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Prebid adSlot to Rubicon bidder XAPI #469

Merged
merged 1 commit into from
Nov 5, 2019
Merged
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 @@ -289,6 +289,15 @@ private static JsonNode makeTarget(Imp imp, ExtImpRubicon rubiconImpExt, Site si
final ObjectNode contextDataNode = context != null ? context.getData() : null;
if (contextDataNode != null) {
inventoryNode.setAll(contextDataNode);

// copy OPENRTB.imp[].ext.context.data.adslot to XAPI.imp[].ext.rp.target.dfp_ad_unit_code without
// leading slash
final JsonNode adSlotNode = contextDataNode.get("adslot");
if (adSlotNode != null && adSlotNode.isTextual()) {
final String adSlot = adSlotNode.textValue();
final String adUnitCode = adSlot.indexOf('/') == 0 ? adSlot.substring(1) : adSlot;
inventoryNode.put("dfp_ad_unit_code", adUnitCode);
}
}

// copy OPENRTB.imp[].ext.context.keywords to XAPI.imp[].ext.rp.target.keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,43 @@ public void makeHttpRequestsShouldCreateRequestPerImp() {
}

@Test
public void makeHttpRequestsShouldCopyImpExtContextDataFieldsToRubiconImpExtRpTarget() {
public void makeHttpRequestsShouldCopyAndModifyImpExtContextDataFieldsToRubiconImpExtRpTarget() {
// given
final ObjectNode impExtContextDataNode = mapper.createObjectNode().put("property", "value");
final BidRequest bidRequest = givenBidRequest(
requestBuilder -> requestBuilder.ext(givenExtBidRequestWithRubiconFirstPartyData()),
impBuilder -> impBuilder.video(Video.builder().build()),
identity());

final ObjectNode impExt = bidRequest.getImp().get(0).getExt();
final ObjectNode impExtContextDataNode = mapper.createObjectNode().put("property", "value")
.put("adslot", "/test");
impExt.set("context", mapper.valueToTree(ExtImpContext.of(null, null, impExtContextDataNode)));

// when
final Result<List<HttpRequest<BidRequest>>> result = rubiconBidder.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt)
.extracting(objectNode -> mapper.convertValue(objectNode, RubiconImpExt.class))
.extracting(RubiconImpExt::getRp)
.extracting(RubiconImpExtRp::getTarget)
.containsOnly(impExtContextDataNode.put("dfp_ad_unit_code", "test"));
}

@Test
public void makeHttpRequestsShouldNotCopyAndModifyImpExtContextDataAdslotToRubiconImpExtRpTargetDfpAdUnitCode() {
// given
final BidRequest bidRequest = givenBidRequest(
requestBuilder -> requestBuilder.ext(givenExtBidRequestWithRubiconFirstPartyData()),
impBuilder -> impBuilder.video(Video.builder().build()),
identity());

final ObjectNode impExt = bidRequest.getImp().get(0).getExt();
final ObjectNode impExtContextDataNode = mapper.createObjectNode().put("adslot", 123);
impExt.set("context", mapper.valueToTree(ExtImpContext.of(null, null, impExtContextDataNode)));

// when
Expand Down