From 249d2de2ce5ee599d734b7ff0368fb38c5a01abd Mon Sep 17 00:00:00 2001 From: mark1an Date: Tue, 12 Apr 2022 19:14:11 +0300 Subject: [PATCH 1/5] Colossus bidder add new param --- .../bidder/colossus/ColossusBidder.java | 7 ++- .../ext/request/colossus/ExtImpColossus.java | 9 ++-- .../static/bidder-params/colossus.json | 18 ++++++- .../bidder/colossus/ColossusBidderTest.java | 50 ++++++++++++++----- 4 files changed, 61 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java b/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java index 7b1c4101306..cac4e3e8a6c 100644 --- a/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java +++ b/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java @@ -131,10 +131,13 @@ private static BidderBid makeBidderBid(Bid bid, List imps, String currency, private static BidType resolveBidType(String impId, List imps) { for (Imp imp : imps) { if (Objects.equals(impId, imp.getId())) { - if (imp.getBanner() == null && imp.getVideo() != null) { + if (imp.getBanner() != null) { + return BidType.banner; + } else if (imp.getVideo() != null) { return BidType.video; + } else if (imp.getXNative() != null) { + return BidType.xNative; } - return BidType.banner; } } diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java index ffc19773add..5469c43c982 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java @@ -1,16 +1,13 @@ package org.prebid.server.proto.openrtb.ext.request.colossus; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; import lombok.Value; -/** - * Defines the contract for bidRequest.imp[i].ext.colossus - */ -@AllArgsConstructor(staticName = "of") -@Value +@Value(staticConstructor = "of") public class ExtImpColossus { @JsonProperty("TagID") String tagId; + + String groupId; } diff --git a/src/main/resources/static/bidder-params/colossus.json b/src/main/resources/static/bidder-params/colossus.json index 8d8f3dc0c4f..4755145b830 100644 --- a/src/main/resources/static/bidder-params/colossus.json +++ b/src/main/resources/static/bidder-params/colossus.json @@ -2,13 +2,27 @@ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Colossus Adapter Params", "description": "A schema which validates params accepted by the Colossus adapter", - "type": "object", "properties": { "TagID": { "type": "string", "description": "An ID which identifies the colossus ad tag" + }, + "groupId": { + "type": "string", + "description": "An ID which identifies the colossus group" } }, - "required" : [ "TagID" ] + "oneOf": [ + { + "required": [ + "TagID" + ] + }, + { + "required": [ + "groupId" + ] + } + ] } diff --git a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java index 1635ec93d70..f06f4e02027 100644 --- a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java @@ -4,6 +4,7 @@ import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; +import com.iab.openrtb.request.Native; import com.iab.openrtb.request.Video; import com.iab.openrtb.response.Bid; import com.iab.openrtb.response.BidResponse; @@ -30,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; import static org.prebid.server.proto.openrtb.ext.response.BidType.video; +import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative; public class ColossusBidderTest extends VertxTest { @@ -75,7 +77,7 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidString").build())) + .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidStr").build())) .build(); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) @@ -91,7 +93,8 @@ public void makeHttpRequestsShouldMakeOneRequestPerImp() { requestBuilder -> requestBuilder.imp(Arrays.asList( givenImp(identity()), Imp.builder() - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpColossus.of("otherTagId")))) + .ext(mapper.valueToTree( + ExtPrebid.of(null, ExtImpColossus.of("otherTagId", null)))) .build()))); // when @@ -103,7 +106,7 @@ public void makeHttpRequestsShouldMakeOneRequestPerImp() { .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) .flatExtracting(BidRequest::getImp).hasSize(2) .extracting(Imp::getTagid) - .containsOnly("tagidString", "otherTagId"); + .containsOnly("tagidStr", "otherTagId"); } @Test @@ -149,10 +152,12 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso } @Test - public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingException { + public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder().id("123").build())).build(), + BidRequest.builder().imp(singletonList(Imp.builder().id("123") + .banner(Banner.builder().build()).build())) + .build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when @@ -164,7 +169,24 @@ public void makeBidsShouldReturnBannerBidByDefault() throws JsonProcessingExcept } @Test - public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProcessingException { + public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { + // given + final HttpCall httpCall = givenHttpCall( + BidRequest.builder().imp(singletonList(Imp.builder().id("123") + .xNative(Native.builder().build()).build())) + .build(), + mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + + // when + final Result> result = colossusBidder.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), xNative, "USD")); + } + + @Test + public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( BidRequest.builder() @@ -181,11 +203,11 @@ public void makeBidsShouldReturnVideoBidIfNoBannerAndHasVideo() throws JsonProce } @Test - public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonProcessingException { + public void makeBidsShouldReturnErrorIfDoesHaveAnyBidType() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( BidRequest.builder() - .imp(singletonList(givenImp(identity()))) + .imp(singletonList(Imp.builder().id("123").build())) .build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); @@ -193,15 +215,16 @@ public void makeBidsShouldReturnBannerBidIfHasBothBannerAndVideo() throws JsonPr final Result> result = colossusBidder.makeBids(httpCall, null); // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); + assertThat(result.getValue()).isEmpty(); + assertThat(result.getErrors()) + .containsExactly(BidderError.badServerResponse("Failed to find impression for ID: 123")); } private static BidRequest givenBidRequest( Function impCustomizer, Function requestCustomizer) { return requestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) + .imp(singletonList(givenImp(impCustomizer)))) .build(); } @@ -212,10 +235,11 @@ private static BidRequest givenBidRequest( private static Imp givenImp(Function impCustomizer) { return impCustomizer.apply(Imp.builder() - .id("123")) + .id("123")) .banner(Banner.builder().build()) .video(Video.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpColossus.of("tagidString")))) + .ext(mapper.valueToTree( + ExtPrebid.of(null, ExtImpColossus.of("tagidStr", "groupIdStr")))) .build(); } From 9053e94951f6552d3aa03aa221a3893bff69f6cf Mon Sep 17 00:00:00 2001 From: markiian Date: Tue, 19 Apr 2022 17:56:08 +0300 Subject: [PATCH 2/5] Changes after review --- .../bidder/colossus/ColossusBidderTest.java | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java index f06f4e02027..8a27b40bcca 100644 --- a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java @@ -23,10 +23,10 @@ import java.util.Arrays; import java.util.List; -import java.util.function.Function; +import java.util.function.UnaryOperator; import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; +import static java.util.function.UnaryOperator.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; @@ -77,12 +77,12 @@ public void makeHttpRequestsShouldReturnExpectedBidRequest() { // then final BidRequest expectedRequest = bidRequest.toBuilder() - .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidStr").build())) + .imp(singletonList(bidRequest.getImp().get(0).toBuilder().tagid("tagidString").build())) .build(); assertThat(result.getErrors()).isEmpty(); assertThat(result.getValue()).hasSize(1) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .containsOnly(expectedRequest); + .extracting(HttpRequest::getPayload) + .containsExactly(expectedRequest); } @Test @@ -102,11 +102,11 @@ public void makeHttpRequestsShouldMakeOneRequestPerImp() { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(2) - .extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class)) - .flatExtracting(BidRequest::getImp).hasSize(2) + assertThat(result.getValue()) + .extracting(HttpRequest::getPayload) + .flatExtracting(BidRequest::getImp) .extracting(Imp::getTagid) - .containsOnly("tagidStr", "otherTagId"); + .containsExactly("tagidString", "otherTagId"); } @Test @@ -154,10 +154,7 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso @Test public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { // given - final HttpCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder().id("123") - .banner(Banner.builder().build()).build())) - .build(), + final HttpCall httpCall = givenHttpCall(givenBidRequest(identity()), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when @@ -165,15 +162,18 @@ public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), banner, "USD")); } @Test public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder().id("123") - .xNative(Native.builder().build()).build())) + BidRequest.builder().imp(singletonList(Imp.builder() + .id("123") + .xNative(Native.builder().build()) + .build())) .build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); @@ -182,7 +182,8 @@ public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), xNative, "USD")); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), xNative, "USD")); } @Test @@ -199,7 +200,8 @@ public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { // then assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).containsOnly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); } @Test @@ -220,31 +222,28 @@ public void makeBidsShouldReturnErrorIfDoesHaveAnyBidType() throws JsonProcessin .containsExactly(BidderError.badServerResponse("Failed to find impression for ID: 123")); } - private static BidRequest givenBidRequest( - Function impCustomizer, - Function requestCustomizer) { + private static BidRequest givenBidRequest(UnaryOperator impCustomizer, + UnaryOperator requestCustomizer) { return requestCustomizer.apply(BidRequest.builder() .imp(singletonList(givenImp(impCustomizer)))) .build(); } - private static BidRequest givenBidRequest( - Function impCustomizer) { + private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { return givenBidRequest(impCustomizer, identity()); } - private static Imp givenImp(Function impCustomizer) { + private static Imp givenImp(UnaryOperator impCustomizer) { return impCustomizer.apply(Imp.builder() - .id("123")) + .id("123")) .banner(Banner.builder().build()) .video(Video.builder().build()) .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpColossus.of("tagidStr", "groupIdStr")))) + ExtPrebid.of(null, ExtImpColossus.of("tagidString", "groupIdStr")))) .build(); } - private static BidResponse givenBidResponse( - Function bidCustomizer) { + private static BidResponse givenBidResponse(UnaryOperator bidCustomizer) { return BidResponse.builder() .cur("USD") .seatbid(singletonList(SeatBid.builder() From 9919e758b42a555f3cdfbdffd82e7bd8d134fa5f Mon Sep 17 00:00:00 2001 From: markiian Date: Wed, 20 Apr 2022 17:31:23 +0300 Subject: [PATCH 3/5] Fixes --- .../bidder/colossus/ColossusBidderTest.java | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java index 8a27b40bcca..f4bc0eee780 100644 --- a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java @@ -53,9 +53,8 @@ public void creationShouldFailOnInvalidEndpointUrl() { public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // given final BidRequest bidRequest = BidRequest.builder() - .imp(singletonList(Imp.builder() - .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode()))) - .build())) + .imp(singletonList(givenImp(impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))))) .build(); // when @@ -92,10 +91,8 @@ public void makeHttpRequestsShouldMakeOneRequestPerImp() { identity(), requestBuilder -> requestBuilder.imp(Arrays.asList( givenImp(identity()), - Imp.builder() - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpColossus.of("otherTagId", null)))) - .build()))); + givenImp(impBuilder -> impBuilder.ext(mapper.valueToTree( + ExtPrebid.of(null, ExtImpColossus.of("otherTagId", null)))))))); // when final Result>> result = colossusBidder.makeHttpRequests(bidRequest); @@ -170,10 +167,8 @@ public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(Imp.builder() - .id("123") - .xNative(Native.builder().build()) - .build())) + BidRequest.builder().imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null).video(null) + .xNative(Native.builder().build())))) .build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); @@ -191,8 +186,7 @@ public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( BidRequest.builder() - .imp(singletonList(Imp.builder().video(Video.builder().build()).id("123").build())) - .build(), + .imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null)))).build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when @@ -209,7 +203,7 @@ public void makeBidsShouldReturnErrorIfDoesHaveAnyBidType() throws JsonProcessin // given final HttpCall httpCall = givenHttpCall( BidRequest.builder() - .imp(singletonList(Imp.builder().id("123").build())) + .imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null).video(null)))) .build(), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); @@ -224,9 +218,7 @@ public void makeBidsShouldReturnErrorIfDoesHaveAnyBidType() throws JsonProcessin private static BidRequest givenBidRequest(UnaryOperator impCustomizer, UnaryOperator requestCustomizer) { - return requestCustomizer.apply(BidRequest.builder() - .imp(singletonList(givenImp(impCustomizer)))) - .build(); + return requestCustomizer.apply(BidRequest.builder().imp(singletonList(givenImp(impCustomizer)))).build(); } private static BidRequest givenBidRequest(UnaryOperator impCustomizer) { @@ -234,12 +226,13 @@ private static BidRequest givenBidRequest(UnaryOperator impCusto } private static Imp givenImp(UnaryOperator impCustomizer) { + return impCustomizer.apply(Imp.builder() - .id("123")) - .banner(Banner.builder().build()) - .video(Video.builder().build()) - .ext(mapper.valueToTree( - ExtPrebid.of(null, ExtImpColossus.of("tagidString", "groupIdStr")))) + .id("123") + .banner(Banner.builder().build()) + .video(Video.builder().build()) + .ext(mapper.valueToTree( + ExtPrebid.of(null, ExtImpColossus.of("tagidString", "groupIdStr"))))) .build(); } From 5e2500689dbc7523cf67ed4611b1bc5f6b1506e0 Mon Sep 17 00:00:00 2001 From: markiian Date: Wed, 20 Apr 2022 18:01:51 +0300 Subject: [PATCH 4/5] Small test change --- .../bidder/colossus/ColossusBidderTest.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java index f4bc0eee780..5c024a3d92d 100644 --- a/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/colossus/ColossusBidderTest.java @@ -52,10 +52,8 @@ public void creationShouldFailOnInvalidEndpointUrl() { @Test public void makeHttpRequestsShouldReturnErrorIfImpExtCouldNotBeParsed() { // given - final BidRequest bidRequest = BidRequest.builder() - .imp(singletonList(givenImp(impBuilder -> impBuilder - .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))))) - .build(); + final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder + .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode()))), identity()); // when final Result>> result = colossusBidder.makeHttpRequests(bidRequest); @@ -167,9 +165,7 @@ public void makeBidsShouldReturnBannerBid() throws JsonProcessingException { public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( - BidRequest.builder().imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null).video(null) - .xNative(Native.builder().build())))) - .build(), + givenBidRequest(impBuilder -> impBuilder.banner(null).video(null).xNative(Native.builder().build())), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when @@ -184,9 +180,7 @@ public void makeBidsShouldReturnxNativerBid() throws JsonProcessingException { @Test public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { // given - final HttpCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null)))).build(), + final HttpCall httpCall = givenHttpCall(givenBidRequest(impBuilder -> impBuilder.banner(null)), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when @@ -202,9 +196,7 @@ public void makeBidsShouldReturnVideoBid() throws JsonProcessingException { public void makeBidsShouldReturnErrorIfDoesHaveAnyBidType() throws JsonProcessingException { // given final HttpCall httpCall = givenHttpCall( - BidRequest.builder() - .imp(singletonList(givenImp(impBuilder -> impBuilder.banner(null).video(null)))) - .build(), + givenBidRequest(impBuilder -> impBuilder.banner(null).video(null).id("0")), mapper.writeValueAsString(givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); // when From 85cf29004c3d0a7c5641b70c54b93372a61bb1d1 Mon Sep 17 00:00:00 2001 From: markiian Date: Fri, 29 Apr 2022 17:01:53 +0300 Subject: [PATCH 5/5] Changes after review --- .../bidder/colossus/ColossusBidder.java | 19 +++++++++++++------ .../ext/request/colossus/ExtImpColossus.java | 1 + .../test-auction-colossus-response.json | 1 + .../colossus/test-colossus-bid-response.json | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java b/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java index cac4e3e8a6c..8ba635f06d2 100644 --- a/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java +++ b/src/main/java/org/prebid/server/bidder/colossus/ColossusBidder.java @@ -1,6 +1,8 @@ package org.prebid.server.bidder.colossus; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; import com.iab.openrtb.response.Bid; @@ -100,9 +102,7 @@ public Result> makeBids(HttpCall httpCall, BidReques return Result.of(bids, errors); } - private static List extractBids(BidRequest bidRequest, - BidResponse bidResponse, - List errors) { + private List extractBids(BidRequest bidRequest, BidResponse bidResponse, List errors) { if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { return Collections.emptyList(); @@ -119,16 +119,23 @@ private static List extractBids(BidRequest bidRequest, .collect(Collectors.toList()); } - private static BidderBid makeBidderBid(Bid bid, List imps, String currency, List errors) { + private BidderBid makeBidderBid(Bid bid, List imps, String currency, List errors) { try { - return BidderBid.of(bid, resolveBidType(bid.getImpid(), imps), currency); + return BidderBid.of(bid, resolveBidType(bid.getExt(), bid.getImpid(), imps), currency); } catch (PreBidException e) { errors.add(BidderError.badServerResponse(e.getMessage())); return null; } } - private static BidType resolveBidType(String impId, List imps) { + private BidType resolveBidType(ObjectNode objectNode, String impId, List imps) { + final JsonNode mediaType = objectNode != null ? objectNode.get("mediaType") : null; + final BidType bidType = mediaType != null ? BidType.fromString(mediaType.asText()) : null; + + if (bidType != null) { + return bidType; + } + for (Imp imp : imps) { if (Objects.equals(impId, imp.getId())) { if (imp.getBanner() != null) { diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java index 5469c43c982..e50be5a1ff2 100644 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java +++ b/src/main/java/org/prebid/server/proto/openrtb/ext/request/colossus/ExtImpColossus.java @@ -9,5 +9,6 @@ public class ExtImpColossus { @JsonProperty("TagID") String tagId; + @JsonProperty("groupId") String groupId; } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-auction-colossus-response.json b/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-auction-colossus-response.json index aca95655ab1..c4d521102b5 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-auction-colossus-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-auction-colossus-response.json @@ -15,6 +15,7 @@ "prebid": { "type": "banner" }, + "mediaType" : "banner", "origbidcpm": 1.25 } } diff --git a/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-colossus-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-colossus-bid-response.json index 35a9d7ca47f..40d72eb1a98 100644 --- a/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-colossus-bid-response.json +++ b/src/test/resources/org/prebid/server/it/openrtb2/colossus/test-colossus-bid-response.json @@ -10,10 +10,13 @@ "crid": "crid001", "adm": "adm001", "h": 250, - "w": 300 + "w": 300, + "ext": { + "mediaType" : "banner" + } } ] } ], "bidid": "bid_id" -} \ No newline at end of file +}