Skip to content

Commit

Permalink
Remove overriding of fields for BidResponseCreator (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGarbar authored May 18, 2021
1 parent 408646d commit db9595c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ private String updateBidAdm(Bid bid,
}

private ObjectNode updateBidExt(Bid bid, String generatedBidId) {
final ObjectNode bidExt = bid.getExt();
if (generatedBidId == null) {
return bid.getExt();
return bidExt;
}

final ExtPrebid<ExtBidPrebid, ObjectNode> extPrebid = getExtPrebid(bid.getExt());
final ExtPrebid<ExtBidPrebid, ObjectNode> extPrebid = getExtPrebid(bidExt);
final ExtBidPrebid extBidPrebid = extPrebid != null ? extPrebid.getPrebid() : null;
final ExtBidPrebid.ExtBidPrebidBuilder extBidPrebidBuilder = extBidPrebid != null
? extBidPrebid.toBuilder()
Expand All @@ -276,8 +277,8 @@ private ObjectNode updateBidExt(Bid bid, String generatedBidId) {
.bidid(generatedBidId)
.build();

final ObjectNode extPrebidBidder = extPrebid != null ? extPrebid.getBidder() : null;
return mapper.mapper().valueToTree(ExtPrebid.of(modifiedExtBidPrebid, extPrebidBidder));
final ObjectNode existingBidExt = bidExt != null ? bidExt : mapper.mapper().createObjectNode();
return existingBidExt.set(PREBID_EXT, mapper.mapper().valueToTree(modifiedExtBidPrebid));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,20 @@ public void setUp() {
}

@Test
public void shouldPassBidWithGeneratedIdWhenIdGeneratorTypeUuid() {
public void shouldPassBidWithGeneratedIdAndNotOverrideExtFieldsWhenIdGeneratorTypeUuid() {
// given
final Imp imp = givenImp();
final AuctionContext auctionContext = givenAuctionContext(givenBidRequest(imp));
final String generatedId = "generatedId";
given(idGenerator.getType()).willReturn(IdGeneratorType.uuid);
given(idGenerator.generateId()).willReturn(generatedId);

final ObjectNode recievedBidExt = mapper.createObjectNode().put("origbidcur", "test");
final Bid bid = Bid.builder()
.id("bidId1")
.impid(IMP_ID)
.price(BigDecimal.valueOf(5.67))
.ext(recievedBidExt)
.build();
final String bidder = "bidder1";
final List<BidderResponse> bidderResponses = singletonList(
Expand All @@ -204,7 +206,7 @@ public void shouldPassBidWithGeneratedIdWhenIdGeneratorTypeUuid() {
.bidid(generatedId)
.build();
final Bid expectedBid = bid.toBuilder()
.ext(mapper.createObjectNode().set("prebid", mapper.valueToTree(extBidPrebid)))
.ext(recievedBidExt.set("prebid", mapper.valueToTree(extBidPrebid)))
.build();
final TargetingInfo targetingInfo = toTargetingInfo(bidder, true);
final BidInfo bidInfo = toBidInfo(expectedBid, imp, bidder, banner, targetingInfo);
Expand Down

0 comments on commit db9595c

Please sign in to comment.