@@ -3436,15 +3436,13 @@ public void isFeatureEnabledReturnsTrueButDoesNotSendWhenUserIsBucketedIntoVaria
3436
3436
* false so feature enabled will return false
3437
3437
*/
3438
3438
@ Test
3439
- public void isFeatureEnabledWithExperimentKeyForcedOfFeatureEnabledFalse () throws Exception {
3439
+ public void isFeatureEnabledWithExperimentKeyForcedOffFeatureEnabledFalse () throws Exception {
3440
3440
assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3441
3441
Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_MULTIVARIATE_EXPERIMENT_KEY );
3442
3442
Variation forcedVariation = activatedExperiment .getVariations ().get (2 );
3443
- EventBuilder mockEventBuilder = mock (EventBuilder .class );
3444
3443
3445
3444
Optimizely optimizely = Optimizely .builder (validDatafile , mockEventHandler )
3446
3445
.withBucketing (mockBucketer )
3447
- .withEventBuilder (mockEventBuilder )
3448
3446
.withConfig (validProjectConfig )
3449
3447
.withErrorHandler (mockErrorHandler )
3450
3448
.build ();
@@ -3463,11 +3461,9 @@ public void isFeatureEnabledWithExperimentKeyForcedWithNoFeatureEnabledSet() thr
3463
3461
assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3464
3462
Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_DOUBLE_FEATURE_EXPERIMENT_KEY );
3465
3463
Variation forcedVariation = activatedExperiment .getVariations ().get (1 );
3466
- EventBuilder mockEventBuilder = mock (EventBuilder .class );
3467
3464
3468
3465
Optimizely optimizely = Optimizely .builder (validDatafile , mockEventHandler )
3469
3466
.withBucketing (mockBucketer )
3470
- .withEventBuilder (mockEventBuilder )
3471
3467
.withConfig (validProjectConfig )
3472
3468
.withErrorHandler (mockErrorHandler )
3473
3469
.build ();
@@ -3541,6 +3537,44 @@ public void isFeatureEnabledFalseWhenFeatureEnabledOfVariationIsFalse() throws E
3541
3537
3542
3538
}
3543
3539
3540
+ /**
3541
+ * Verify {@link Optimizely#isFeatureEnabled(String, String)} calls into
3542
+ * {@link Optimizely#isFeatureEnabled(String, String, Map)} and they both
3543
+ * return False
3544
+ * when the user is bucketed an feature test variation that is turned off.
3545
+ * @throws Exception
3546
+ */
3547
+ @ Test
3548
+ public void isFeatureEnabledReturnsFalseAndDispatchesWhenUserIsBucketedIntoAnExperimentVariationToggleOff () throws Exception {
3549
+ assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3550
+
3551
+ String validFeatureKey = FEATURE_MULTI_VARIATE_FEATURE_KEY ;
3552
+
3553
+ Optimizely spyOptimizely = spy (Optimizely .builder (validDatafile , mockEventHandler )
3554
+ .withConfig (validProjectConfig )
3555
+ .withDecisionService (mockDecisionService )
3556
+ .build ());
3557
+
3558
+ Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_MULTIVARIATE_EXPERIMENT_KEY );
3559
+ Variation variation = new Variation ("2" , "variation_toggled_off" , false , null );
3560
+
3561
+ FeatureDecision featureDecision = new FeatureDecision (activatedExperiment , variation , FeatureDecision .DecisionSource .EXPERIMENT );
3562
+ doReturn (featureDecision ).when (mockDecisionService ).getVariationForFeature (
3563
+ any (FeatureFlag .class ),
3564
+ anyString (),
3565
+ anyMapOf (String .class , String .class )
3566
+ );
3567
+
3568
+ assertFalse (spyOptimizely .isFeatureEnabled (validFeatureKey , genericUserId ));
3569
+
3570
+ logbackVerifier .expectMessage (
3571
+ Level .INFO ,
3572
+ "Feature \" " + validFeatureKey +
3573
+ "\" is not enabled for user \" " + genericUserId + "\" ."
3574
+ );
3575
+ verify (mockEventHandler , times (1 )).dispatchEvent (any (LogEvent .class ));
3576
+ }
3577
+
3544
3578
/** Integration Test
3545
3579
* Verify {@link Optimizely#isFeatureEnabled(String, String, Map)}
3546
3580
* returns True
0 commit comments