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

Fix passing ext.prebid.targeting.* fields for AMP #1108

Merged
merged 1 commit into from
Jan 20, 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 @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/org/prebid/server/auction/AmpRequestFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Object> answerWithFirstArgument() {
return invocationOnMock -> invocationOnMock.getArguments()[0];
}
Expand Down