Skip to content

Commit

Permalink
Outbrain adapter: overwrite tagid only if it exists (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
And1sS authored and nickluck8 committed Aug 10, 2021
1 parent 5ab95bc commit b3dfa7f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ private ExtImpOutbrain parseImpExt(Imp imp) {
}

private static Imp modifyImp(Imp imp, String tagId) {
return imp.toBuilder()
.tagid(tagId)
.build();
return StringUtils.isNotEmpty(tagId)
? imp.toBuilder().tagid(tagId).build()
: imp;
}

private static BidRequest updateBidRequest(BidRequest bidRequest, List<Imp> imps, ExtImpOutbrain extImpOutbrain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,38 @@ public void makeHttpRequestsShouldCreateOneSingleRequestWithAllImps() {
.hasSize(2);
}

@Test
public void makeHttpRequestsShouldModifyImpTagIdOnlyIfItPresentInExt() {
// given
final Imp firstImp = Imp.builder()
.id("123")
.tagid("123")
.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpOutbrain.of(
ExtImpOutbrainPublisher.of("testId", "testName", "testDomain"),
null, singletonList("testBcat"), singletonList("testBadv")))))
.build();

final Imp thirdImp = Imp.builder()
.id("789")
.tagid("789")
.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpOutbrain.of(
ExtImpOutbrainPublisher.of("testId", "testName", "testDomain"),
"098", singletonList("testBcat"), singletonList("testBadv")))))
.build();

final BidRequest bidRequest = BidRequest.builder().imp(asList(firstImp, thirdImp)).build();

// when
final Result<List<HttpRequest<BidRequest>>> result = outbrainBidder.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.containsExactlyInAnyOrder(firstImp, thirdImp.toBuilder().tagid("098").build());
}

@Test
public void makeHttpRequestsShouldUpdatePresentedAppWithPublisherParamsFromExt() {
// given
Expand Down

0 comments on commit b3dfa7f

Please sign in to comment.