@@ -93,25 +93,16 @@ public class OptimizelyTest {
9393 public static Collection <Object []> data () throws IOException {
9494 return Arrays .asList (new Object [][]{
9595 {
96- 2 ,
9796 validConfigJsonV2 (),
9897 noAudienceProjectConfigJsonV2 (),
99- validProjectConfigV2 (),
100- noAudienceProjectConfigV2 ()
10198 },
10299 {
103- 3 ,
104100 validConfigJsonV3 (),
105- noAudienceProjectConfigJsonV3 (),
106- validProjectConfigV3 (),
107- noAudienceProjectConfigV3 ()
101+ noAudienceProjectConfigJsonV3 (), // FIX-ME this is not a valid v3 datafile
108102 },
109103 {
110- 4 ,
111104 validConfigJsonV4 (),
112- validConfigJsonV4 (),
113- validProjectConfigV4 (),
114- validProjectConfigV4 ()
105+ validConfigJsonV4 ()
115106 }
116107 });
117108 }
@@ -148,16 +139,17 @@ public static Collection<Object[]> data() throws IOException {
148139 private ProjectConfig validProjectConfig ;
149140 private ProjectConfig noAudienceProjectConfig ;
150141
151- public OptimizelyTest (int datafileVersion ,
152- String validDatafile ,
153- String noAudienceDatafile ,
154- ProjectConfig validProjectConfig ,
155- ProjectConfig noAudienceProjectConfig ) {
156- this .datafileVersion = datafileVersion ;
142+ public OptimizelyTest (String validDatafile , String noAudienceDatafile ) throws ConfigParseException {
157143 this .validDatafile = validDatafile ;
158144 this .noAudienceDatafile = noAudienceDatafile ;
159- this .validProjectConfig = validProjectConfig ;
160- this .noAudienceProjectConfig = noAudienceProjectConfig ;
145+
146+ this .validProjectConfig = new ProjectConfig .Builder ().withDatafile (validDatafile ).build ();
147+ this .noAudienceProjectConfig = new ProjectConfig .Builder ().withDatafile (noAudienceDatafile ).build ();
148+
149+ // FIX-ME
150+ //assertEquals(validProjectConfig.getVersion(), noAudienceProjectConfig.getVersion());
151+
152+ this .datafileVersion = Integer .parseInt (validProjectConfig .getVersion ());
161153 }
162154
163155 //======== activate tests ========//
@@ -191,7 +183,6 @@ public void activateEndToEnd() throws Exception {
191183 .withErrorHandler (mockErrorHandler )
192184 .build ();
193185
194-
195186 when (mockEventFactory .createImpressionEvent (validProjectConfig , activatedExperiment , bucketedVariation , testUserId ,
196187 testUserAttributes ))
197188 .thenReturn (logEventToDispatch );
@@ -210,6 +201,9 @@ public void activateEndToEnd() throws Exception {
210201 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
211202 testParams + " and payload \" {}\" " );
212203
204+ // Force variation to null to get expected log output.
205+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
206+
213207 // activate the experiment
214208 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
215209
@@ -269,6 +263,9 @@ public void activateEndToEndWithTypedAudienceInt() throws Exception {
269263 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
270264 testParams + " and payload \" {}\" " );
271265
266+ // Force variation to null to get expected log output.
267+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
268+
272269 // activate the experiment
273270 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
274271
@@ -420,6 +417,9 @@ public void activateEndToEndWithTypedAudienceBool() throws Exception {
420417 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
421418 testParams + " and payload \" {}\" " );
422419
420+ // Force variation to null to get expected log output.
421+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
422+
423423 // activate the experiment
424424 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
425425
@@ -479,6 +479,9 @@ public void activateEndToEndWithTypedAudienceDouble() throws Exception {
479479 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
480480 testParams + " and payload \" {}\" " );
481481
482+ // Force variation to null to get expected log output.
483+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
484+
482485 // activate the experiment
483486 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
484487
@@ -587,6 +590,9 @@ public void activateEndToEndWithTypedAudienceWithAnd() throws Exception {
587590 logbackVerifier .expectMessage (Level .DEBUG , "Dispatching impression event to URL test_url with params " +
588591 testParams + " and payload \" {}\" " );
589592
593+ // Force variation to null to get expected log output.
594+ optimizely .setForcedVariation (activatedExperiment .getKey (), testUserId , null );
595+
590596 // activate the experiment
591597 Variation actualVariation = optimizely .activate (activatedExperiment .getKey (), userId , testUserAttributes );
592598
@@ -1540,6 +1546,9 @@ public void activateLaunchedExperimentDoesNotDispatchEvent() throws Exception {
15401546 when (mockBucketer .bucket (launchedExperiment , testUserId ))
15411547 .thenReturn (launchedExperiment .getVariations ().get (0 ));
15421548
1549+ // Force variation to launched experiment.
1550+ optimizely .setForcedVariation (launchedExperiment .getKey (), testUserId , expectedVariation .getKey ());
1551+
15431552 logbackVerifier .expectMessage (Level .INFO ,
15441553 "Experiment has \" Launched\" status so not dispatching event during activation." );
15451554 Variation variation = optimizely .activate (launchedExperiment .getKey (), testUserId );
0 commit comments