CpmStar: Adapter Update bidder implementation to allow imp.ext passth… by przemkaczmarek · Pull Request #4228 · prebid/prebid-server-java

"USD"
],
"source" :
{"tid" : "${json-unit.any-string}"},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format

Comment on lines +84 to +91

final Map<String, Object> extMap = mapper.mapper().convertValue(imp.getExt(), new TypeReference<>() {
});
final Map<String, Object> bidderMap = (Map<String, Object>) extMap.remove("bidder");
if (bidderMap != null) {
extMap.putAll(bidderMap);
}
final ObjectNode newExt = mapper.mapper().valueToTree(extMap);
return imp.toBuilder().ext(newExt).build();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably use the following approach:

        final ObjectNode impExt = imp.getExt().deepCopy();
        final JsonNode bidderNode = impExt.remove("bidder");
        bidderNode.fields().forEachRemaining(field -> impExt.set(field.getKey(), field.getValue()));
        return imp.toBuilder().ext(impExt).build();

Comment on lines +84 to +91

final Map<String, Object> extMap = mapper.mapper().convertValue(imp.getExt(), new TypeReference<>() {
});
final Map<String, Object> bidderMap = (Map<String, Object>) extMap.remove("bidder");
if (bidderMap != null) {
extMap.putAll(bidderMap);
}
final ObjectNode newExt = mapper.mapper().valueToTree(extMap);
return imp.toBuilder().ext(newExt).build();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please cover the changes with the unit test (the existing fields like gpid should be preserved - an additional case)