@@ -91,25 +91,16 @@ public class OptimizelyTest {
9191 public static Collection <Object []> data () throws IOException {
9292 return Arrays .asList (new Object [][]{
9393 {
94- 2 ,
9594 validConfigJsonV2 (),
9695 noAudienceProjectConfigJsonV2 (),
97- validProjectConfigV2 (),
98- noAudienceProjectConfigV2 ()
9996 },
10097 {
101- 3 ,
10298 validConfigJsonV3 (),
103- noAudienceProjectConfigJsonV3 (),
104- validProjectConfigV3 (),
105- noAudienceProjectConfigV3 ()
99+ noAudienceProjectConfigJsonV3 (), // FIX-ME this is not a valid v3 datafile
106100 },
107101 {
108- 4 ,
109102 validConfigJsonV4 (),
110- validConfigJsonV4 (),
111- validProjectConfigV4 (),
112- validProjectConfigV4 ()
103+ validConfigJsonV4 ()
113104 }
114105 });
115106 }
@@ -146,16 +137,17 @@ public static Collection<Object[]> data() throws IOException {
146137 private ProjectConfig validProjectConfig ;
147138 private ProjectConfig noAudienceProjectConfig ;
148139
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 {
155141 this .validDatafile = validDatafile ;
156142 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 ());
159151 }
160152
161153 //======== activate tests ========//
@@ -189,7 +181,6 @@ public void activateEndToEnd() throws Exception {
189181 .withErrorHandler (mockErrorHandler )
190182 .build ();
191183
192-
193184 when (mockEventFactory .createImpressionEvent (validProjectConfig , activatedExperiment , bucketedVariation , testUserId ,
194185 testUserAttributes ))
195186 .thenReturn (logEventToDispatch );
@@ -208,6 +199,9 @@ public void activateEndToEnd() throws Exception {
208199 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
209200 testParams + " and payload \" {}\" " );
210201
202+ // Force variation to null to get expected log output.
203+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
204+
211205 // activate the experiment
212206 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
213207
@@ -267,6 +261,9 @@ public void activateEndToEndWithTypedAudienceInt() throws Exception {
267261 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
268262 testParams + " and payload \" {}\" " );
269263
264+ // Force variation to null to get expected log output.
265+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
266+
270267 // activate the experiment
271268 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
272269
@@ -418,6 +415,9 @@ public void activateEndToEndWithTypedAudienceBool() throws Exception {
418415 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
419416 testParams + " and payload \" {}\" " );
420417
418+ // Force variation to null to get expected log output.
419+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
420+
421421 // activate the experiment
422422 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
423423
@@ -477,6 +477,9 @@ public void activateEndToEndWithTypedAudienceDouble() throws Exception {
477477 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
478478 testParams + " and payload \" {}\" " );
479479
480+ // Force variation to null to get expected log output.
481+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
482+
480483 // activate the experiment
481484 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
482485
@@ -585,6 +588,9 @@ public void activateEndToEndWithTypedAudienceWithAnd() throws Exception {
585588 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
586589 testParams + " and payload \" {}\" " );
587590
591+ // Force variation to null to get expected log output.
592+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
593+
588594 // activate the experiment
589595 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
590596
@@ -1538,6 +1544,9 @@ public void activateLaunchedExperimentDoesNotDispatchEvent() throws Exception {
15381544 when (mockBucketer .bucket (launchedExperiment , testUserId ))
15391545 .thenReturn (launchedExperiment .getVariations ().get (0 ));
15401546
1547+ // Force variation to launched experiment.
1548+ optimizely .setForcedVariation (launchedExperiment .getKey (), testUserId , expectedVariation .getKey ());
1549+
15411550 logbackVerifier .expectMessage (Level .INFO ,
15421551 "Experiment has \" Launched\" status so not dispatching event during activation." );
15431552 Variation variation = optimizely .activate (launchedExperiment .getKey (), testUserId );
0 commit comments