Skip to content

Commit

Permalink
rename property
Browse files Browse the repository at this point in the history
add try/catch clause
  • Loading branch information
nickluck8 committed Jun 4, 2021
1 parent 5b5d95d commit 653da6e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/prebid/server/bidder/grid/GridBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ protected Imp modifyImp(Imp imp, ExtImpGrid impExt) {
throw new PreBidException("uid is empty");
}

final GridExtImp gridExtImp = mapper.mapper().convertValue(imp.getExt(), GridExtImp.class);
final GridExtImpData extImpData = gridExtImp != null ? gridExtImp.getGridExtImpData() : null;
final GridExtImp gridExtImp;
try {
gridExtImp = mapper.mapper().convertValue(imp.getExt(), GridExtImp.class);
} catch (Exception e) {
throw new PreBidException(e.getMessage());
}

final GridExtImpData extImpData = gridExtImp != null ? gridExtImp.getData() : null;
final GridExtImpDataAdServer adServer = extImpData != null ? extImpData.getAdServer() : null;
final String adSlot = adServer != null ? adServer.getAdSlot() : null;
if (StringUtils.isNotEmpty(adSlot)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.prebid.server.bidder.grid.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Builder;
import lombok.Value;
Expand All @@ -14,8 +13,7 @@ public class GridExtImp {

JsonNode bidder;

@JsonProperty("data")
GridExtImpData gridExtImpData;
GridExtImpData data;

String gpid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void makeBidsShouldReturnErrorIfImpIdsFromBidAndRequestWereNotMatchedAndI
public void modifyImpShouldChangeImpExt() {
// given
final GridExtImp gridExtImp = GridExtImp.builder()
.gridExtImpData(GridExtImpData.of(null, GridExtImpDataAdServer.of("name", "adslot")))
.data(GridExtImpData.of(null, GridExtImpDataAdServer.of("name", "adslot")))
.build();

final Imp imp = Imp.builder().ext(mapper.valueToTree(gridExtImp)).build();
Expand All @@ -248,7 +248,7 @@ public void modifyImpShouldChangeImpExt() {

// then
assertThat(mapper.convertValue(modifiedImp.getExt(), GridExtImp.class).getGpid())
.isEqualTo(gridExtImp.getGridExtImpData().getAdServer().getAdSlot());
.isEqualTo(gridExtImp.getData().getAdServer().getAdSlot());
}

private static BidResponse givenBidResponse(UnaryOperator<BidResponse.BidResponseBuilder> bidResponseCustomizer,
Expand Down

0 comments on commit 653da6e

Please sign in to comment.