Skip to content
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 @@ -34,7 +34,6 @@ public class MobilefuseBidder implements Bidder<BidRequest> {
private static final TypeReference<ExtPrebid<?, ExtImpMobilefuse>> MOBILEFUSE_EXT_TYPE_REFERENCE =
new TypeReference<>() {
};
private static final String SKADN_PROPERTY_NAME = "skadn";

private final String endpointUrl;
private final JacksonMapper mapper;
Expand Down Expand Up @@ -86,22 +85,12 @@ private ExtImpMobilefuse parseImpExt(Imp imp) {
}
}

private Imp modifyImp(Imp imp, ExtImpMobilefuse extImp) {
final ObjectNode skadn = parseSkadn(imp.getExt());
private static Imp modifyImp(Imp imp, ExtImpMobilefuse extImp) {
return imp.toBuilder()
.tagid(Objects.toString(extImp.getPlacementId(), "0"))
.ext(skadn != null ? mapper.mapper().createObjectNode().set(SKADN_PROPERTY_NAME, skadn) : null)
.build();
}

private ObjectNode parseSkadn(ObjectNode impExt) {
try {
return mapper.mapper().convertValue(impExt.get(SKADN_PROPERTY_NAME), ObjectNode.class);
} catch (IllegalArgumentException e) {
throw new PreBidException(e.getMessage());
}
}

@Override
public final Result<List<BidderBid>> makeBids(BidderCall<BidRequest> httpCall, BidRequest bidRequest) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,30 @@ public void makeHttpRequestsShouldModifyImpTagId() {
assertThat(result.getValue()).hasSize(1)
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt, Imp::getTagid)
.containsExactly(tuple(null, "1"));
.extracting(Imp::getTagid)
.containsExactly("1");
}

@Test
public void makeHttpRequestsShouldModifyImpWithAddingSkadnWhenSkadnIsPresent() {
public void makeHttpRequestsShouldPassImpExtThrough() {
// given
final ObjectNode skadn = mapper.createObjectNode().put("something", "something");
final ObjectNode impExt = mapper.createObjectNode();
impExt.set("bidder", mapper.valueToTree(ExtImpMobilefuse.of(1)));
impExt.set("skadn", skadn);
impExt.set("skadn", mapper.createObjectNode().put("something", "something"));
impExt.put("gpid", "/1234/home#div-banner");
final BidRequest bidRequest = givenBidRequest(
impBuilder -> impBuilder.banner(Banner.builder().build()).ext(impExt));

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

// then
final ObjectNode expectedImpExt = mapper.createObjectNode().set("skadn", skadn);
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt, Imp::getTagid)
.containsExactly(tuple(expectedImpExt, "1"));
.containsExactly(tuple(impExt, "1"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"w": 300,
"h": 250
},
"tagid": "999999"
"tagid": "999999",
"ext": {
"tid": "${json-unit.any-string}",
"bidder": {
"placement_id": 999999
}
}
}
],
"source": {
Expand Down
Loading