Skip to content
Open
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 @@ -106,10 +106,6 @@ private BidderBid toBidderBid(StroeerCoreBid stroeercoreBid, List<BidderError> e
return null;
}

final ObjectNode bidExt = stroeercoreBid.getDsa() != null
? mapper.mapper().createObjectNode().set("dsa", stroeercoreBid.getDsa())
: null;

return BidderBid.of(
Bid.builder()
.id(stroeercoreBid.getId())
Expand All @@ -121,12 +117,24 @@ private BidderBid toBidderBid(StroeerCoreBid stroeercoreBid, List<BidderError> e
.crid(stroeercoreBid.getCreativeId())
.adomain(stroeercoreBid.getAdomain())
.mtype(bidType.ordinal() + 1)
.ext(bidExt)
.ext(getBidExt(stroeercoreBid))
.build(),
bidType,
BIDDER_CURRENCY);
}

private ObjectNode getBidExt(StroeerCoreBid stroeercoreBid) {
final ObjectNode dsa = stroeercoreBid.getDsa();
ObjectNode ext = stroeercoreBid.getExt();
if (dsa == null) {
return ext;
}
if (ext == null) {
ext = mapper.mapper().createObjectNode();
}
return ext.set("dsa", dsa);
}

private static BidType getBidType(String mtype) {
return switch (mtype) {
case "banner" -> BidType.banner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ public class StroeerCoreBid {
@JsonProperty("crid")
String creativeId;

/**
* @deprecated The dsa will move to the bid's ext.
*/
@Deprecated(forRemoval = true)
ObjectNode dsa;

String mtype;

List<String> adomain;

ObjectNode ext;
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() {
@Test
public void makeBidsShouldReturnExpectedBannerBid() throws JsonProcessingException {
// given
final ObjectNode dsaResponse = createDsaResponse();
final ObjectNode bidExt = mapper.createObjectNode();
bidExt.put("something", "else");
bidExt.set("dsa", createDsaResponse());

final StroeerCoreBid bannerBid = StroeerCoreBid.builder()
.id("1")
Expand All @@ -163,7 +165,7 @@ public void makeBidsShouldReturnExpectedBannerBid() throws JsonProcessingExcepti
.width(300)
.height(600)
.mtype("banner")
.dsa(dsaResponse.deepCopy())
.ext(bidExt.deepCopy())
.adomain(List.of("domain1.com", "domain2.com"))
.build();

Expand All @@ -184,13 +186,73 @@ public void makeBidsShouldReturnExpectedBannerBid() throws JsonProcessingExcepti
.h(600)
.adomain(List.of("domain1.com", "domain2.com"))
.mtype(1)
.ext(mapper.createObjectNode().set("dsa", dsaResponse))
.ext(bidExt)
.build();

assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).containsOnly(BidderBid.of(expectedBannerBid, BidType.banner, "EUR"));
}

@Test
public void makeBidsShouldSupportDeprecatedDsaPath() throws JsonProcessingException {
// given
final ObjectNode dsa = createDsaResponse();

final StroeerCoreBid.StroeerCoreBidBuilder stroeerBidBuilder = StroeerCoreBid.builder()
.id("1")
.bidId("banner-imp-id")
.adMarkup("<div></div>")
.cpm(BigDecimal.valueOf(0.3))
.creativeId("foo")
.width(300)
.height(600)
.mtype("banner")
.adomain(List.of("domain1.com", "domain2.com"))
.dsa(dsa.deepCopy());

final StroeerCoreBid bannerBidWithoutExt = stroeerBidBuilder
.ext(null)
.build();

final StroeerCoreBid bannerBidWithExt = stroeerBidBuilder
.ext(mapper.createObjectNode().put("xyz", true))
.build();

final StroeerCoreBidResponse response = StroeerCoreBidResponse.of(
List.of(bannerBidWithoutExt, bannerBidWithExt)
);
final BidderCall<BidRequest> httpCall = createHttpCall(response);

// when
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);

// then
final Bid.BidBuilder expectedBannerBidBuilder = Bid.builder()
.id("1")
.impid("banner-imp-id")
.adm("<div></div>")
.price(BigDecimal.valueOf(0.3))
.crid("foo")
.w(300)
.h(600)
.adomain(List.of("domain1.com", "domain2.com"))
.mtype(1);

final Bid expectedBid1 = expectedBannerBidBuilder
.ext(mapper.createObjectNode().set("dsa", dsa))
.build();

final Bid expectedBid2 = expectedBannerBidBuilder
.ext(mapper.createObjectNode().put("xyz", true).set("dsa", dsa))
.build();

assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).containsOnly(
BidderBid.of(expectedBid1, BidType.banner, "EUR"),
BidderBid.of(expectedBid2, BidType.banner, "EUR")
);
}

@Test
public void makeBidsShouldReturnExpectedBidderBids() throws JsonProcessingException {
// given
Expand Down
Loading