Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmxDigital: Return bids without modifying #1560

Merged
merged 2 commits into from
Nov 5, 2021
Merged
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 @@ -9,7 +9,6 @@
import com.iab.openrtb.request.Imp;
import com.iab.openrtb.request.Site;
import com.iab.openrtb.request.Video;
import com.iab.openrtb.response.Bid;
import com.iab.openrtb.response.BidResponse;
import com.iab.openrtb.response.SeatBid;
import io.vertx.core.MultiMap;
Expand Down Expand Up @@ -265,16 +264,12 @@ private static List<BidderBid> bidsFromResponse(BidResponse bidResponse) {
.map(SeatBid::getBid)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.map(bid -> BidderBid.of(modifyBid(bid), getBidType(bid.getAdm()), bidResponse.getCur()))
.map(bid -> BidderBid.of(bid, getBidType(bid.getAdm()), bidResponse.getCur()))
.collect(Collectors.toList());
}

private static BidType getBidType(String bidAdm) {
return StringUtils.containsAny(bidAdm, "<?xml", "<vast")
? BidType.video : BidType.banner;
}

private static Bid modifyBid(Bid bid) {
return bid.toBuilder().impid(bid.getId()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void makeHttpRequestsShouldModifyImpWhenExtImpEmaDigitalContainsRequiredV
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.containsOnly(expectedImp);
.containsExactly(expectedImp);
}

@Test
Expand Down Expand Up @@ -274,7 +274,7 @@ public void makeHttpRequestsShouldRemoveVast40ProtocolFromVideo() {
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.containsOnly(expectedImp);
.containsExactly(expectedImp);
}

@Test
Expand All @@ -294,7 +294,7 @@ public void shouldThrowExceptionIfVideoDoNotHaveAtLeastOneSizeParameter() {

// then
assertThat(result.getErrors()).hasSize(1)
.containsOnly(BidderError.badInput("Video: Need at least one size to build request"));
.containsExactly(BidderError.badInput("Video: Need at least one size to build request"));
}

@Test
Expand All @@ -314,7 +314,7 @@ public void shouldThrowExceptionIfVideoDoNotHaveAnyMimeParameter() {

// then
assertThat(result.getErrors()).hasSize(1)
.containsOnly(BidderError.badInput("Video: missing required field mimes"));
.containsExactly(BidderError.badInput("Video: missing required field mimes"));
}

@Test
Expand All @@ -338,7 +338,7 @@ public void requestSecureShouldBeOneIfPageStartsWithHttps() {
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.extracting(request -> request.getImp().get(0).getSecure())
.containsOnly(1);
.containsExactly(1);
}

@Test
Expand All @@ -363,7 +363,7 @@ public void requestSecureShouldBeOneIfUrlStartsWithHttps() {
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getSecure)
.containsOnly(1);
.containsExactly(1);
}

@Test
Expand All @@ -388,7 +388,7 @@ public void requestSecureShouldBe1IfStoreUrlStartsWithHttps() {
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getSecure)
.containsOnly(1);
.containsExactly(1);
}

@Test
Expand All @@ -413,7 +413,7 @@ public void requestSecureShouldBe0IfPageDoNotStartsWithHttps() {
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getSecure)
.containsOnly(0);
.containsExactly(0);
}

@Test
Expand Down Expand Up @@ -450,7 +450,7 @@ public void makeHttpRequestsShouldModifyBannerFormatAndWidthAndHeightWhenRequest
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.flatExtracting(BidRequest::getImp).hasSize(1)
.containsOnly(expectedImp);
.containsExactly(expectedImp);
}

@Test
Expand Down Expand Up @@ -486,7 +486,7 @@ public void makeHttpRequestsShouldSendRequestToModifiedUrlWithHeaders() {
assertThat(result.getValue()).hasSize(1)
.flatExtracting(r -> r.getHeaders().entries())
.extracting(Map.Entry::getKey, Map.Entry::getValue)
.containsOnly(
.containsExactlyInAnyOrder(
tuple("Content-Type", "application/json;charset=utf-8"),
tuple("Accept", "application/json"),
tuple("User-Agent", "Agent"),
Expand Down Expand Up @@ -544,7 +544,7 @@ public void makeBidsShouldReturnEmptyListWhenBidResponseSeatBidIsNull()
}

@Test
public void makeBidsShouldReturnBannerBidWithChangedBidImpId() throws JsonProcessingException {
public void makeBidsShouldReturnBannerBidWithCorrectImpId() throws JsonProcessingException {
// given
final HttpCall<BidRequest> httpCall = givenHttpCall(
BidRequest.builder()
Expand All @@ -559,7 +559,7 @@ public void makeBidsShouldReturnBannerBidWithChangedBidImpId() throws JsonProces
// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.containsOnly(BidderBid.of(Bid.builder().id("321").impid("321").build(), banner, "USD"));
.containsExactly(BidderBid.of(Bid.builder().id("321").impid("123").build(), banner, "USD"));
}

@Test
Expand All @@ -578,7 +578,7 @@ public void makeBidsShouldReturnVideoBidIfAdmContainsVastPrefix() throws JsonPro
// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.containsOnly(BidderBid.of(Bid.builder().id("321").adm("<vast data=test").impid("321").build(),
.containsExactly(BidderBid.of(Bid.builder().id("321").adm("<vast data=test").impid("123").build(),
video, "USD"));
}

Expand All @@ -598,7 +598,7 @@ public void makeBidsShouldReturnVideoBidIfAdmContainsXmlPrefix() throws JsonProc
// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.containsOnly(BidderBid.of(Bid.builder().id("321").adm("<?xml data=test").impid("321").build(),
.containsExactly(BidderBid.of(Bid.builder().id("321").adm("<?xml data=test").impid("123").build(),
video, "USD"));
}

Expand Down