diff --git a/src/main/java/org/prebid/server/bidder/outbrain/OutbrainBidder.java b/src/main/java/org/prebid/server/bidder/outbrain/OutbrainBidder.java index 40722448117..4643eaef1e1 100644 --- a/src/main/java/org/prebid/server/bidder/outbrain/OutbrainBidder.java +++ b/src/main/java/org/prebid/server/bidder/outbrain/OutbrainBidder.java @@ -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 imps, ExtImpOutbrain extImpOutbrain) { diff --git a/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java b/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java index 6f369c8d651..c6ef4f1fed9 100644 --- a/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/outbrain/OutbrainBidderTest.java @@ -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>> 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