Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanchyk committed May 8, 2020
1 parent 40eae2a commit 87ee7d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/prebid/server/auction/BidResponseCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.prebid.server.auction.model.BidRequestCacheInfo;
import org.prebid.server.auction.model.BidderResponse;
import org.prebid.server.bidder.BidderCatalog;
Expand Down Expand Up @@ -87,16 +88,16 @@ public class BidResponseCreator {
private final BidderCatalog bidderCatalog;
private final EventsService eventsService;
private final StoredRequestProcessor storedRequestProcessor;
private final boolean generateBidId;
private final JacksonMapper mapper;
private final Boolean generateBidId;

private final String cacheHost;
private final String cachePath;
private final String cacheAssetUrlTemplate;

public BidResponseCreator(CacheService cacheService, BidderCatalog bidderCatalog, EventsService eventsService,
StoredRequestProcessor storedRequestProcessor,
JacksonMapper mapper, Boolean generateBidId) {
boolean generateBidId, JacksonMapper mapper) {
this.cacheService = Objects.requireNonNull(cacheService);
this.bidderCatalog = Objects.requireNonNull(bidderCatalog);
this.eventsService = Objects.requireNonNull(eventsService);
Expand Down Expand Up @@ -662,16 +663,15 @@ private Bid toBid(BidderBid bidderBid, String bidder, ExtRequestTargeting target
cache = null;
}

final String extBidPrebidId = BooleanUtils.toBoolean(this.generateBidId) ? UUID.randomUUID().toString() : null;
final String eventId = BooleanUtils.toBoolean(this.generateBidId) ? extBidPrebidId : bid.getId();
final String extBidPrebidId = generateBidId ? UUID.randomUUID().toString() : null;
final String eventId = ObjectUtils.defaultIfNull(extBidPrebidId, bid.getId());
final Video storedVideo = impIdToStoredVideo.get(bid.getImpid());
final Events events = eventsEnabled && eventsAllowedByRequest
? eventsService.createEvent(eventId, bidder, account.getId(), auctionTimestamp)
: null;

final ExtBidPrebid prebidExt = ExtBidPrebid.of(
extBidPrebidId, bidType, targetingKeywords, cache, storedVideo, events, null
);
extBidPrebidId, bidType, targetingKeywords, cache, storedVideo, events, null);

final ExtPrebid<ExtBidPrebid, ObjectNode> bidExt = ExtPrebid.of(prebidExt, bid.getExt());
bid.setExt(mapper.mapper().valueToTree(bidExt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,11 @@ BidResponseCreator bidResponseCreator(
BidderCatalog bidderCatalog,
EventsService eventsService,
StoredRequestProcessor storedRequestProcessor,
JacksonMapper mapper,
@Value("${auction.generate-bid-id}") Boolean generateBidId) {
@Value("${auction.generate-bid-id}") boolean generateBidId,
JacksonMapper mapper) {

return new BidResponseCreator(cacheService, bidderCatalog, eventsService, storedRequestProcessor,
mapper, generateBidId);
generateBidId, mapper);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void setUp() {
.willReturn(Future.succeededFuture(VideoStoredDataResult.empty()));

bidResponseCreator = new BidResponseCreator(cacheService, bidderCatalog, eventsService, storedRequestProcessor,
jacksonMapper, false);
false, jacksonMapper);

timeout = new TimeoutFactory(Clock.fixed(Instant.now(), ZoneId.systemDefault())).create(500);
}
Expand Down Expand Up @@ -430,7 +430,7 @@ public void shouldOverwriteBidderIdToUUID() {
BidderResponse.of("bidder2", givenSeatBid(BidderBid.of(bid, banner, "USD")), 0));

final BidResponseCreator bidResponseCreator = new BidResponseCreator(cacheService, bidderCatalog, eventsService,
storedRequestProcessor, jacksonMapper, true);
storedRequestProcessor, true, jacksonMapper);
// when
final BidResponse bidResponse = bidResponseCreator.create(bidderResponses, bidRequest,
null, CACHE_INFO, ACCOUNT, false, 1000L, false, timeout).result();
Expand Down

0 comments on commit 87ee7d1

Please sign in to comment.