File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import com .iab .openrtb .response .BidResponse ;
99import com .iab .openrtb .response .SeatBid ;
1010import org .apache .commons .collections4 .CollectionUtils ;
11+ import org .apache .commons .lang3 .StringUtils ;
1112import org .prebid .server .exception .InvalidRequestException ;
1213import org .prebid .server .hooks .execution .v1 .auction .AuctionResponsePayloadImpl ;
1314import org .prebid .server .hooks .modules .optable .targeting .model .openrtb .Audience ;
@@ -70,14 +71,15 @@ private ObjectNode targetingToObjectNode(List<Audience> targeting) {
7071
7172 for (Audience audience : targeting ) {
7273 final List <AudienceId > ids = audience .getIds ();
73- if (CollectionUtils .isEmpty (ids )) {
74+ final String keyspace = audience .getKeyspace ();
75+ if (CollectionUtils .isEmpty (ids ) || StringUtils .isEmpty (keyspace )) {
7476 continue ;
7577 }
7678
7779 final String joinedIds = ids .stream ()
7880 .map (AudienceId ::getId )
7981 .collect (Collectors .joining ("," ));
80- node .putIfAbsent (audience . getKeyspace () , TextNode .valueOf (joinedIds ));
82+ node .putIfAbsent (keyspace , TextNode .valueOf (joinedIds ));
8183 }
8284
8385 return node ;
Original file line number Diff line number Diff line change 11package org .prebid .server .hooks .modules .optable .targeting .v1 .core ;
22
33import com .fasterxml .jackson .databind .node .ObjectNode ;
4+ import com .iab .openrtb .response .BidResponse ;
45import org .junit .jupiter .api .Test ;
56import org .prebid .server .hooks .execution .v1 .auction .AuctionResponsePayloadImpl ;
67import org .prebid .server .hooks .modules .optable .targeting .model .openrtb .Audience ;
1011
1112import java .util .List ;
1213
14+ import static java .util .Collections .singletonList ;
1315import static org .assertj .core .api .Assertions .assertThat ;
1416
1517public class BidResponseEnricherTest extends BaseOptableTest {
1618
19+ @ Test
20+ public void shouldSkipEmptyKeyspaceWhileEnrichingBidResponse () {
21+ // given
22+ final BidResponse bidResponse = givenBidResponse ();
23+ final AuctionResponsePayload auctionResponsePayload = AuctionResponsePayloadImpl .of (bidResponse );
24+ final List <Audience > targeting = singletonList (new Audience (
25+ "provider" ,
26+ List .of (new AudienceId ("audienceId" ), new AudienceId ("audienceId2" )),
27+ null ,
28+ 1 ));
29+ final BidResponseEnricher enricher = BidResponseEnricher .of (targeting , mapper , jsonMerger );
30+
31+ // when
32+ final AuctionResponsePayload result = enricher .apply (auctionResponsePayload );
33+
34+ // then
35+ assertThat (result .bidResponse ()).isEqualTo (bidResponse );
36+ }
37+
1738 @ Test
1839 public void shouldEnrichBidResponseByTargetingKeywords () {
1940 // given
You can’t perform that action at this time.
0 commit comments