44
44
import java .nio .file .Files ;
45
45
import java .nio .file .Paths ;
46
46
import java .util .Collections ;
47
- import java .util .HashMap ;
48
47
import java .util .List ;
49
48
import java .util .Map ;
50
49
import java .util .concurrent .TimeUnit ;
@@ -73,7 +72,7 @@ public class GreenbidsRealTimeDataProcessedAuctionRequestHookTest {
73
72
74
73
private static final String THRESHOLDS_CACHE_KEY_PREFIX = "throttlingThresholds_" ;
75
74
76
- private GreenbidsRealTimeDataProcessedAuctionRequestHook hook ;
75
+ private GreenbidsRealTimeDataProcessedAuctionRequestHook target ;
77
76
78
77
private JacksonMapper jacksonMapper ;
79
78
@@ -95,7 +94,7 @@ public void setUp() {
95
94
thresholdsCacheWithExpiration = Caffeine .newBuilder ()
96
95
.expireAfterWrite (CACHE_EXPIRATION_MINUTES , TimeUnit .MINUTES )
97
96
.build ();
98
- hook = new GreenbidsRealTimeDataProcessedAuctionRequestHook (
97
+ target = new GreenbidsRealTimeDataProcessedAuctionRequestHook (
99
98
mapper ,
100
99
modelCacheWithExpiration ,
101
100
thresholdsCacheWithExpiration ,
@@ -120,7 +119,7 @@ public void setUp() {
120
119
}
121
120
122
121
@ Test
123
- public void shouldExitEarlyIfPartnerNotActivatedInBidRequest () throws IOException , OrtException {
122
+ public void shouldExitEarlyWhenPartnerNotActivatedInBidRequest () throws IOException , OrtException {
124
123
// given
125
124
final Banner banner = givenBanner ();
126
125
@@ -142,7 +141,7 @@ public void shouldExitEarlyIfPartnerNotActivatedInBidRequest() throws IOExceptio
142
141
thresholdCache .getCache ().put ("throttlingThresholds_test-pbuid" , givenThrottlingThresholds ());
143
142
144
143
// when
145
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
144
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
146
145
.call (null , invocationContext );
147
146
final InvocationResult <AuctionRequestPayload > result = future .result ();
148
147
final BidRequest resultBidRequest = result
@@ -165,7 +164,7 @@ public void shouldExitEarlyIfPartnerNotActivatedInBidRequest() throws IOExceptio
165
164
}
166
165
167
166
@ Test
168
- public void shouldExitEarlyIfThresholdIsNotAvailable () throws OrtException , IOException {
167
+ public void shouldExitEarlyWhenThresholdIsNotAvailable () throws OrtException , IOException {
169
168
// given
170
169
final Banner banner = givenBanner ();
171
170
@@ -188,7 +187,7 @@ public void shouldExitEarlyIfThresholdIsNotAvailable() throws OrtException, IOEx
188
187
modelCache .getCache ().put ("onnxModelRunner_test-pbuid" , givenOnnxModelRunner ());
189
188
190
189
// when
191
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
190
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
192
191
.call (null , invocationContext );
193
192
final InvocationResult <AuctionRequestPayload > result = future .result ();
194
193
final BidRequest resultBidRequest = result
@@ -211,7 +210,7 @@ public void shouldExitEarlyIfThresholdIsNotAvailable() throws OrtException, IOEx
211
210
}
212
211
213
212
@ Test
214
- public void shouldExitEarlyIfModelIsNotAvailable () throws IOException {
213
+ public void shouldExitEarlyWhenModelIsNotAvailable () throws IOException {
215
214
// given
216
215
final Banner banner = givenBanner ();
217
216
@@ -234,7 +233,7 @@ public void shouldExitEarlyIfModelIsNotAvailable() throws IOException {
234
233
thresholdCache .getCache ().put ("throttlingThresholds_test-pbuid" , givenThrottlingThresholds ());
235
234
236
235
// when
237
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
236
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
238
237
.call (null , invocationContext );
239
238
final InvocationResult <AuctionRequestPayload > result = future .result ();
240
239
final BidRequest resultBidRequest = result
@@ -283,7 +282,7 @@ public void shouldNotFilterBiddersAndReturnAnalyticsTagWhenExploration() throws
283
282
final AnalyticsResult expectedAnalyticsResult = expectedAnalyticsResult (true , true );
284
283
285
284
// when
286
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
285
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
287
286
.call (null , invocationContext );
288
287
final InvocationResult <AuctionRequestPayload > result = future .result ();
289
288
final BidRequest resultBidRequest = result
@@ -314,7 +313,7 @@ public void shouldNotFilterBiddersAndReturnAnalyticsTagWhenExploration() throws
314
313
}
315
314
316
315
@ Test
317
- public void shouldFilterBiddersBasedOnModelIfAnyFeatureNotAvailable () throws OrtException , IOException {
316
+ public void shouldFilterBiddersBasedOnModelWhenAnyFeatureNotAvailable () throws OrtException , IOException {
318
317
// given
319
318
final Banner banner = givenBanner ();
320
319
@@ -341,7 +340,7 @@ public void shouldFilterBiddersBasedOnModelIfAnyFeatureNotAvailable() throws Ort
341
340
final AnalyticsResult expectedAnalyticsResult = expectedAnalyticsResult (false , false );
342
341
343
342
// when
344
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
343
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
345
344
.call (null , invocationContext );
346
345
final InvocationResult <AuctionRequestPayload > result = future .result ();
347
346
final BidRequest resultBidRequest = result
@@ -401,7 +400,7 @@ public void shouldFilterBiddersBasedOnModelResults() throws OrtException, IOExce
401
400
final AnalyticsResult expectedAnalyticsResult = expectedAnalyticsResult (false , false );
402
401
403
402
// when
404
- final Future <InvocationResult <AuctionRequestPayload >> future = hook
403
+ final Future <InvocationResult <AuctionRequestPayload >> future = target
405
404
.call (null , invocationContext );
406
405
final InvocationResult <AuctionRequestPayload > result = future .result ();
407
406
final BidRequest resultBidRequest = result
@@ -606,10 +605,10 @@ private static Ortb2ImpExtResult expectedOrtb2ImpExtResult(Boolean isExploration
606
605
}
607
606
608
607
private static ExplorationResult expectedExplorationResult (Boolean isExploration , Boolean isKeptInAuction ) {
609
- final Map <String , Boolean > keptInAuction = new HashMap <>();
610
- keptInAuction . put ( "appnexus" , isKeptInAuction );
611
- keptInAuction . put ( "pubmatic" , isKeptInAuction );
612
- keptInAuction . put ( "rubicon" , isKeptInAuction );
608
+ final Map <String , Boolean > keptInAuction = Map . of (
609
+ "appnexus" , isKeptInAuction ,
610
+ "pubmatic" , isKeptInAuction ,
611
+ "rubicon" , isKeptInAuction );
613
612
return ExplorationResult .of (null , keptInAuction , isExploration );
614
613
}
615
614
}
0 commit comments