diff --git a/src/main/java/org/prebid/server/auction/AmpRequestFactory.java b/src/main/java/org/prebid/server/auction/AmpRequestFactory.java index 4b7a3130c41..ee60140194e 100644 --- a/src/main/java/org/prebid/server/auction/AmpRequestFactory.java +++ b/src/main/java/org/prebid/server/auction/AmpRequestFactory.java @@ -636,7 +636,7 @@ private ExtRequestTargeting createTargetingWithDefaults(ExtRequestPrebid prebid) final Boolean includeFormat = !isTargetingNull ? targeting.getIncludeformat() : null; - return ExtRequestTargeting.builder() + return (isTargetingNull ? ExtRequestTargeting.builder() : targeting.toBuilder()) .pricegranularity(outgoingPriceGranularityNode) .mediatypepricegranularity(mediaTypePriceGranularity) .includewinners(includeWinners) diff --git a/src/test/java/org/prebid/server/auction/AmpRequestFactoryTest.java b/src/test/java/org/prebid/server/auction/AmpRequestFactoryTest.java index 864a85ce91b..dc4e75455ca 100644 --- a/src/test/java/org/prebid/server/auction/AmpRequestFactoryTest.java +++ b/src/test/java/org/prebid/server/auction/AmpRequestFactoryTest.java @@ -26,6 +26,7 @@ import org.prebid.server.auction.model.AuctionContext; import org.prebid.server.exception.InvalidRequestException; import org.prebid.server.metric.MetricName; +import org.prebid.server.proto.openrtb.ext.ExtIncludeBrandCategory; import org.prebid.server.proto.openrtb.ext.request.ExtGranularityRange; import org.prebid.server.proto.openrtb.ext.request.ExtPriceGranularity; import org.prebid.server.proto.openrtb.ext.request.ExtRegs; @@ -398,6 +399,29 @@ public void shouldReturnBidRequestWithDefaultPriceGranularityIfStoredBidRequestE ExtGranularityRange.of(BigDecimal.valueOf(20), BigDecimal.valueOf(0.1))))))); } + @Test + public void shouldReturnBidRequestWithNotChangedExtRequestPrebidTargetingFields() { + // given + givenBidRequest( + builder -> builder + .ext(givenRequestExt(ExtRequestTargeting.builder() + .includebrandcategory(ExtIncludeBrandCategory.of(1, "publisher", true)) + .truncateattrchars(10) + .build())), + Imp.builder().build()); + + // when + final BidRequest request = factory.fromRequest(routingContext, 0L).result().getBidRequest(); + + // then + assertThat(singletonList(request)) + .extracting(BidRequest::getExt).isNotNull() + .extracting(ExtRequest::getPrebid) + .extracting(ExtRequestPrebid::getTargeting) + .extracting(ExtRequestTargeting::getIncludebrandcategory, ExtRequestTargeting::getTruncateattrchars) + .containsOnly(tuple(ExtIncludeBrandCategory.of(1, "publisher", true), 10)); + } + private Answer answerWithFirstArgument() { return invocationOnMock -> invocationOnMock.getArguments()[0]; }