-
Notifications
You must be signed in to change notification settings - Fork 224
OpenX Adapter: Set buyer exts fields in bid.ext.prebid.meta
#4171
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
Changes from 8 commits
8b335a7
d85bf2f
61206a5
c164516
62fd676
252d4db
93906c0
36d996c
1cf8c18
227cbb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.prebid.server.bidder.openx.proto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
CTMBNara marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public class OpenxBidExt { | ||
|
|
||
| @JsonProperty("dsp_id") | ||
| String dspId; | ||
| @JsonProperty("buyer_id") | ||
| String buyerId; | ||
| @JsonProperty("brand_id") | ||
| String brandId; | ||
CTMBNara marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |
| import com.iab.openrtb.response.BidResponse; | ||
| import com.iab.openrtb.response.SeatBid; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import org.prebid.server.VertxTest; | ||
| import org.prebid.server.bidder.model.BidderBid; | ||
| import org.prebid.server.bidder.model.BidderCall; | ||
|
|
@@ -23,6 +26,7 @@ | |
| import org.prebid.server.bidder.model.HttpRequest; | ||
| import org.prebid.server.bidder.model.HttpResponse; | ||
| import org.prebid.server.bidder.model.Result; | ||
| import org.prebid.server.bidder.openx.proto.OpenxBidExt; | ||
| import org.prebid.server.bidder.openx.proto.OpenxBidResponse; | ||
| import org.prebid.server.bidder.openx.proto.OpenxBidResponseExt; | ||
| import org.prebid.server.bidder.openx.proto.OpenxRequestExt; | ||
|
|
@@ -42,6 +46,7 @@ | |
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static java.util.Arrays.asList; | ||
| import static java.util.Collections.emptyList; | ||
|
|
@@ -990,4 +995,99 @@ private static Map<String, JsonNode> givenCustomParams(String key, Object values | |
| private static BidderCall<BidRequest> givenHttpCall(String body) { | ||
| return BidderCall.succeededHttp(null, HttpResponse.of(200, null, body), null); | ||
| } | ||
|
|
||
| private static Stream<Arguments> bidWithExtTestCases() throws JsonProcessingException { | ||
| final ObjectNode allBuyerExt = mapper.valueToTree(OpenxBidExt.builder() | ||
| .dspId("1") | ||
| .buyerId("2") | ||
| .brandId("3") | ||
| .build()); | ||
| final ObjectNode onlyBrandExt = mapper.valueToTree(OpenxBidExt.builder() | ||
| .brandId("4") | ||
| .build()); | ||
| final ObjectNode badExt = mapper.valueToTree(OpenxBidExt.builder() | ||
| .dspId("abc") | ||
| .brandId("cba") | ||
| .build()); | ||
|
|
||
| final ObjectNode allBuyerExpectedExt = (ObjectNode) mapper.readTree(""" | ||
| { | ||
| "dsp_id": "1", | ||
| "buyer_id": "2", | ||
| "brand_id": "3", | ||
| "prebid": { | ||
| "meta": { | ||
| "advertiserId":2, | ||
| "brandId":3, | ||
| "networkId":1 | ||
| } | ||
| } | ||
| } | ||
| """); | ||
CTMBNara marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| final ObjectNode onlyBrandExpectedExt = (ObjectNode) mapper.readTree(""" | ||
| { | ||
| "brand_id": "4", | ||
| "prebid": { | ||
| "meta": { | ||
| "brandId":4 | ||
| } | ||
| } | ||
| } | ||
| """); | ||
| final ObjectNode badExpectedExt = (ObjectNode) mapper.readTree(""" | ||
| { | ||
| "dsp_id": "abc", | ||
| "brand_id": "cba" | ||
| } | ||
| """); | ||
|
|
||
| return Stream.of( | ||
| Arguments.of(allBuyerExt, allBuyerExpectedExt), | ||
| Arguments.of(onlyBrandExt, onlyBrandExpectedExt), | ||
| Arguments.of(badExt, badExpectedExt), | ||
| Arguments.of(null, null) | ||
| ); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("bidWithExtTestCases") | ||
|
||
| public void makeBidsShouldReturnBidWithExt( | ||
| ObjectNode bidExt, | ||
| ObjectNode expectedExtWithBidMeta) throws JsonProcessingException { | ||
| // given | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(mapper.writeValueAsString( | ||
| BidResponse.builder() | ||
| .seatbid(singletonList(SeatBid.builder() | ||
| .bid(List.of( | ||
| Bid.builder() | ||
| .w(200) | ||
| .h(150) | ||
| .price(BigDecimal.ONE) | ||
| .impid("impId1") | ||
| .dealid("dealid") | ||
| .adm("<div>This is an Ad</div>") | ||
| .ext(bidExt) | ||
| .build())) | ||
| .build())) | ||
| .build())); | ||
|
|
||
| final BidRequest bidRequest = BidRequest.builder() | ||
| .id("bidRequestId") | ||
| .imp(List.of( | ||
| Imp.builder() | ||
| .id("impId1") | ||
| .banner(Banner.builder().build()) | ||
| .build())) | ||
| .build(); | ||
|
|
||
| // when | ||
| final CompositeBidderResponse result = target.makeBidderResponse(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getBids()).hasSize(1) | ||
| .extracting(BidderBid::getBid) | ||
| .extracting(Bid::getExt) | ||
| .containsExactly(expectedExtWithBidMeta); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.