Skip to content

Commit d2eefef

Browse files
author
ilya
committed
DATA-22937: PR issues fixed
1 parent d946509 commit d2eefef

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

src/test/java/org/prebid/server/analytics/reporter/liveintent/LiveintentAnalyticsReporterTest.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.prebid.server.analytics.reporter.liveintent;
22

3-
import com.fasterxml.jackson.databind.ObjectMapper;
43
import com.iab.openrtb.request.BidRequest;
54
import com.iab.openrtb.request.Imp;
65
import com.iab.openrtb.response.Bid;
@@ -29,14 +28,13 @@
2928
import org.prebid.server.hooks.execution.model.StageExecutionOutcome;
3029
import org.prebid.server.hooks.execution.v1.analytics.ActivityImpl;
3130
import org.prebid.server.hooks.execution.v1.analytics.TagsImpl;
32-
import org.prebid.server.json.JacksonMapper;
3331
import org.prebid.server.model.Endpoint;
3432
import org.prebid.server.util.ListUtil;
3533
import org.prebid.server.vertx.httpclient.HttpClient;
3634
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;
35+
import com.fasterxml.jackson.core.type.TypeReference;
3736

3837
import java.math.BigDecimal;
39-
import java.util.Arrays;
4038
import java.util.EnumMap;
4139
import java.util.List;
4240

@@ -61,12 +59,12 @@ public class LiveintentAnalyticsReporterTest extends VertxTest {
6159

6260
private LiveIntentAnalyticsProperties properties;
6361

64-
private JacksonMapper jacksonMapper;
62+
private TypeReference<List<PbsjBid>> pbjsCollectionType;
63+
6564

6665
@BeforeEach
6766
public void setUp() {
68-
final ObjectMapper mapper = new ObjectMapper();
69-
jacksonMapper = new JacksonMapper(mapper);
67+
pbjsCollectionType = new TypeReference<>() {};
7068

7169
properties = LiveIntentAnalyticsProperties.builder()
7270
.analyticsEndpoint("https://localhost:8080")
@@ -112,7 +110,7 @@ public void shouldSendAllBidsToLiveIntent() {
112110
eq(properties.getTimeoutMs()));
113111

114112
final String capturedJson = jsonCaptor.getValue();
115-
final List<PbsjBid> pbsjBids = Arrays.stream(jacksonMapper.decodeValue(capturedJson, PbsjBid[].class)).toList();
113+
final List<PbsjBid> pbsjBids = jacksonMapper.decodeValue(capturedJson, pbjsCollectionType);
116114
assertThat(pbsjBids).isEqualTo(List.of(
117115
PbsjBid.builder()
118116
.bidId("bid-id")
@@ -123,8 +121,7 @@ public void shouldSendAllBidsToLiveIntent() {
123121
.treatmentRate(0.5f)
124122
.timestamp(0L)
125123
.partnerId("pbsj")
126-
.build()
127-
));
124+
.build()));
128125
}
129126

130127
@Test
@@ -144,7 +141,7 @@ public void shouldSendAllBidsToLiveIntentNotEnriched() {
144141
eq(properties.getTimeoutMs()));
145142

146143
final String capturedJson = jsonCaptor.getValue();
147-
final List<PbsjBid> pbsjBids = Arrays.stream(jacksonMapper.decodeValue(capturedJson, PbsjBid[].class)).toList();
144+
final List<PbsjBid> pbsjBids = jacksonMapper.decodeValue(capturedJson, pbjsCollectionType);
148145
assertThat(pbsjBids).isEqualTo(List.of(
149146
PbsjBid.builder()
150147
.bidId("bid-id")
@@ -155,8 +152,7 @@ public void shouldSendAllBidsToLiveIntentNotEnriched() {
155152
.treatmentRate(0.5f)
156153
.timestamp(0L)
157154
.partnerId("pbsj")
158-
.build()
159-
));
155+
.build()));
160156
}
161157

162158
@Test
@@ -176,7 +172,7 @@ public void shouldSendAllBidsToLiveIntentNoTreatmentRate() {
176172
eq(properties.getTimeoutMs()));
177173

178174
final String capturedJson = jsonCaptor.getValue();
179-
final List<PbsjBid> pbsjBids = Arrays.stream(jacksonMapper.decodeValue(capturedJson, PbsjBid[].class)).toList();
175+
final List<PbsjBid> pbsjBids = jacksonMapper.decodeValue(capturedJson, pbjsCollectionType);
180176
assertThat(pbsjBids).isEqualTo(List.of(
181177
PbsjBid.builder()
182178
.bidId("bid-id")
@@ -187,8 +183,7 @@ public void shouldSendAllBidsToLiveIntentNoTreatmentRate() {
187183
.timestamp(0L)
188184
.treatmentRate(null)
189185
.partnerId("pbsj")
190-
.build()
191-
));
186+
.build()));
192187
}
193188

194189
private AuctionEvent buildEvent(Boolean isEnriched) {
@@ -212,19 +207,14 @@ private AuctionEvent buildEvent(Boolean isEnriched, Boolean withTags) {
212207
.status(ExecutionStatus.success)
213208
.analyticsTags(TagsImpl.of(
214209
withTags
215-
? ListUtil.union(
216-
List.of(enrichmentRate),
217-
enriched
218-
)
219-
: List.of()
220-
))
210+
? ListUtil.union(List.of(enrichmentRate), enriched)
211+
: List.of()))
221212
.action(null)
222213
.build();
223214

224215
final StageExecutionOutcome stageExecutionOutcome = StageExecutionOutcome.of(
225216
"auction-request",
226-
List.of(GroupExecutionOutcome.of(List.of(hookExecutionOutcome)))
227-
);
217+
List.of(GroupExecutionOutcome.of(List.of(hookExecutionOutcome))));
228218

229219
final EnumMap<Stage, List<StageExecutionOutcome>> stageOutcomes = new EnumMap<>(Stage.class);
230220
stageOutcomes.put(Stage.processed_auction_request, List.of(stageExecutionOutcome));

0 commit comments

Comments
 (0)