From 698385ff982bc8a74a42414c4d18db77e770be97 Mon Sep 17 00:00:00 2001 From: pkaczmarek Date: Wed, 11 Dec 2024 15:40:36 +0100 Subject: [PATCH 1/2] Conversant: Enable audio requests #3605 --- .../server/bidder/epsilon/EpsilonBidder.java | 13 ++++++------ src/main/resources/bidder-config/epsilon.yaml | 2 ++ .../bidder/epsilon/EpsilonBidderTest.java | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java index 25578dafb75..49bfbd32dab 100644 --- a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java +++ b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java @@ -260,11 +260,12 @@ private Bid updateBidWithId(Bid bid) { } private static BidType getType(String impId, List imps) { - for (Imp imp : imps) { - if (imp.getId().equals(impId)) { - return imp.getVideo() != null ? BidType.video : BidType.banner; - } - } - return BidType.banner; + return imps.stream() + .filter(imp -> impId.equals(imp.getId())) + .findFirst() + .map(imp -> imp.getAudio() != null ? BidType.audio + : (imp.getVideo() != null ? BidType.video + : BidType.banner)) + .orElse(BidType.banner); } } diff --git a/src/main/resources/bidder-config/epsilon.yaml b/src/main/resources/bidder-config/epsilon.yaml index 27d1ed14343..ba7472331d7 100644 --- a/src/main/resources/bidder-config/epsilon.yaml +++ b/src/main/resources/bidder-config/epsilon.yaml @@ -11,9 +11,11 @@ adapters: app-media-types: - banner - video + - audio site-media-types: - banner - video + - audio supported-vendors: vendor-id: 24 usersync: diff --git a/src/test/java/org/prebid/server/bidder/epsilon/EpsilonBidderTest.java b/src/test/java/org/prebid/server/bidder/epsilon/EpsilonBidderTest.java index 91f0ab88d8c..872a04c0a96 100644 --- a/src/test/java/org/prebid/server/bidder/epsilon/EpsilonBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/epsilon/EpsilonBidderTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.iab.openrtb.request.App; +import com.iab.openrtb.request.Audio; import com.iab.openrtb.request.Banner; import com.iab.openrtb.request.BidRequest; import com.iab.openrtb.request.Imp; @@ -41,6 +42,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.prebid.server.proto.openrtb.ext.response.BidType.audio; import static org.prebid.server.proto.openrtb.ext.response.BidType.banner; import static org.prebid.server.proto.openrtb.ext.response.BidType.video; @@ -610,6 +612,25 @@ public void makeBidsShouldReturnVideoBidIfRequestImpHasVideo() throws JsonProces .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD")); } + @Test + public void makeBidsShouldReturnAudioBidIfRequestImpHasAudio() throws JsonProcessingException { + // given + final BidderCall httpCall = givenHttpCall( + givenBidRequest(builder -> builder.id("123") + .audio(Audio.builder().build()) + .banner(Banner.builder().build())), + mapper.writeValueAsString( + givenBidResponse(bidBuilder -> bidBuilder.impid("123")))); + + // when + final Result> result = target.makeBids(httpCall, null); + + // then + assertThat(result.getErrors()).isEmpty(); + assertThat(result.getValue()) + .containsExactly(BidderBid.of(Bid.builder().impid("123").build(), audio, "USD")); + } + @Test public void makeBidsShouldUpdateBidWithUUIDIfGenerateBidIdIsTrue() throws JsonProcessingException { // given From 9d090f461f9b92aa8e0363663cf761ca290e34d3 Mon Sep 17 00:00:00 2001 From: pkaczmarek Date: Thu, 12 Dec 2024 12:44:06 +0100 Subject: [PATCH 2/2] fix comment --- .../server/bidder/epsilon/EpsilonBidder.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java index 49bfbd32dab..77ec518e216 100644 --- a/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java +++ b/src/main/java/org/prebid/server/bidder/epsilon/EpsilonBidder.java @@ -260,12 +260,17 @@ private Bid updateBidWithId(Bid bid) { } private static BidType getType(String impId, List imps) { - return imps.stream() - .filter(imp -> impId.equals(imp.getId())) - .findFirst() - .map(imp -> imp.getAudio() != null ? BidType.audio - : (imp.getVideo() != null ? BidType.video - : BidType.banner)) - .orElse(BidType.banner); + for (Imp imp : imps) { + if (imp.getId().equals(impId)) { + if (imp.getVideo() != null) { + return BidType.video; + } else if (imp.getAudio() != null) { + return BidType.audio; + } else { + return BidType.banner; + } + } + } + return BidType.banner; } }