@@ -91,25 +91,16 @@ public class OptimizelyTest {
91
91
public static Collection <Object []> data () throws IOException {
92
92
return Arrays .asList (new Object [][]{
93
93
{
94
- 2 ,
95
94
validConfigJsonV2 (),
96
95
noAudienceProjectConfigJsonV2 (),
97
- validProjectConfigV2 (),
98
- noAudienceProjectConfigV2 ()
99
96
},
100
97
{
101
- 3 ,
102
98
validConfigJsonV3 (),
103
- noAudienceProjectConfigJsonV3 (),
104
- validProjectConfigV3 (),
105
- noAudienceProjectConfigV3 ()
99
+ noAudienceProjectConfigJsonV3 (), // FIX-ME this is not a valid v3 datafile
106
100
},
107
101
{
108
- 4 ,
109
102
validConfigJsonV4 (),
110
- validConfigJsonV4 (),
111
- validProjectConfigV4 (),
112
- validProjectConfigV4 ()
103
+ validConfigJsonV4 ()
113
104
}
114
105
});
115
106
}
@@ -146,16 +137,17 @@ public static Collection<Object[]> data() throws IOException {
146
137
private ProjectConfig validProjectConfig ;
147
138
private ProjectConfig noAudienceProjectConfig ;
148
139
149
- public OptimizelyTest (int datafileVersion ,
150
- String validDatafile ,
151
- String noAudienceDatafile ,
152
- ProjectConfig validProjectConfig ,
153
- ProjectConfig noAudienceProjectConfig ) {
154
- this .datafileVersion = datafileVersion ;
140
+ public OptimizelyTest (String validDatafile , String noAudienceDatafile ) throws ConfigParseException {
155
141
this .validDatafile = validDatafile ;
156
142
this .noAudienceDatafile = noAudienceDatafile ;
157
- this .validProjectConfig = validProjectConfig ;
158
- this .noAudienceProjectConfig = noAudienceProjectConfig ;
143
+
144
+ this .validProjectConfig = new ProjectConfig .Builder ().withDatafile (validDatafile ).build ();
145
+ this .noAudienceProjectConfig = new ProjectConfig .Builder ().withDatafile (noAudienceDatafile ).build ();
146
+
147
+ // FIX-ME
148
+ //assertEquals(validProjectConfig.getVersion(), noAudienceProjectConfig.getVersion());
149
+
150
+ this .datafileVersion = Integer .parseInt (validProjectConfig .getVersion ());
159
151
}
160
152
161
153
//======== activate tests ========//
@@ -189,7 +181,6 @@ public void activateEndToEnd() throws Exception {
189
181
.withErrorHandler (mockErrorHandler )
190
182
.build ();
191
183
192
-
193
184
when (mockEventFactory .createImpressionEvent (validProjectConfig , activatedExperiment , bucketedVariation , testUserId ,
194
185
testUserAttributes ))
195
186
.thenReturn (logEventToDispatch );
@@ -208,6 +199,9 @@ public void activateEndToEnd() throws Exception {
208
199
logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
209
200
testParams + " and payload \" {}\" " );
210
201
202
+ // Force variation to null to get expected log output.
203
+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
204
+
211
205
// activate the experiment
212
206
Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
213
207
@@ -267,6 +261,9 @@ public void activateEndToEndWithTypedAudienceInt() throws Exception {
267
261
logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
268
262
testParams + " and payload \" {}\" " );
269
263
264
+ // Force variation to null to get expected log output.
265
+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
266
+
270
267
// activate the experiment
271
268
Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
272
269
@@ -418,6 +415,9 @@ public void activateEndToEndWithTypedAudienceBool() throws Exception {
418
415
logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
419
416
testParams + " and payload \" {}\" " );
420
417
418
+ // Force variation to null to get expected log output.
419
+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
420
+
421
421
// activate the experiment
422
422
Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
423
423
@@ -477,6 +477,9 @@ public void activateEndToEndWithTypedAudienceDouble() throws Exception {
477
477
logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
478
478
testParams + " and payload \" {}\" " );
479
479
480
+ // Force variation to null to get expected log output.
481
+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
482
+
480
483
// activate the experiment
481
484
Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
482
485
@@ -585,6 +588,9 @@ public void activateEndToEndWithTypedAudienceWithAnd() throws Exception {
585
588
logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
586
589
testParams + " and payload \" {}\" " );
587
590
591
+ // Force variation to null to get expected log output.
592
+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
593
+
588
594
// activate the experiment
589
595
Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
590
596
@@ -1538,6 +1544,9 @@ public void activateLaunchedExperimentDoesNotDispatchEvent() throws Exception {
1538
1544
when (mockBucketer .bucket (launchedExperiment , testUserId ))
1539
1545
.thenReturn (launchedExperiment .getVariations ().get (0 ));
1540
1546
1547
+ // Force variation to launched experiment.
1548
+ optimizely .setForcedVariation (launchedExperiment .getKey (), testUserId , expectedVariation .getKey ());
1549
+
1541
1550
logbackVerifier .expectMessage (Level .INFO ,
1542
1551
"Experiment has \" Launched\" status so not dispatching event during activation." );
1543
1552
Variation variation = optimizely .activate (launchedExperiment .getKey (), testUserId );
0 commit comments