@@ -3479,15 +3479,13 @@ public void isFeatureEnabledReturnsTrueButDoesNotSendWhenUserIsBucketedIntoVaria
3479
3479
* false so feature enabled will return false
3480
3480
*/
3481
3481
@ Test
3482
- public void isFeatureEnabledWithExperimentKeyForcedOfFeatureEnabledFalse () throws Exception {
3482
+ public void isFeatureEnabledWithExperimentKeyForcedOffFeatureEnabledFalse () throws Exception {
3483
3483
assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3484
3484
Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_MULTIVARIATE_EXPERIMENT_KEY );
3485
3485
Variation forcedVariation = activatedExperiment .getVariations ().get (2 );
3486
- EventBuilder mockEventBuilder = mock (EventBuilder .class );
3487
3486
3488
3487
Optimizely optimizely = Optimizely .builder (validDatafile , mockEventHandler )
3489
3488
.withBucketing (mockBucketer )
3490
- .withEventBuilder (mockEventBuilder )
3491
3489
.withConfig (validProjectConfig )
3492
3490
.withErrorHandler (mockErrorHandler )
3493
3491
.build ();
@@ -3506,11 +3504,9 @@ public void isFeatureEnabledWithExperimentKeyForcedWithNoFeatureEnabledSet() thr
3506
3504
assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3507
3505
Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_DOUBLE_FEATURE_EXPERIMENT_KEY );
3508
3506
Variation forcedVariation = activatedExperiment .getVariations ().get (1 );
3509
- EventBuilder mockEventBuilder = mock (EventBuilder .class );
3510
3507
3511
3508
Optimizely optimizely = Optimizely .builder (validDatafile , mockEventHandler )
3512
3509
.withBucketing (mockBucketer )
3513
- .withEventBuilder (mockEventBuilder )
3514
3510
.withConfig (validProjectConfig )
3515
3511
.withErrorHandler (mockErrorHandler )
3516
3512
.build ();
@@ -3584,6 +3580,44 @@ public void isFeatureEnabledFalseWhenFeatureEnabledOfVariationIsFalse() throws E
3584
3580
3585
3581
}
3586
3582
3583
+ /**
3584
+ * Verify {@link Optimizely#isFeatureEnabled(String, String)} calls into
3585
+ * {@link Optimizely#isFeatureEnabled(String, String, Map)} and they both
3586
+ * return False
3587
+ * when the user is bucketed an feature test variation that is turned off.
3588
+ * @throws Exception
3589
+ */
3590
+ @ Test
3591
+ public void isFeatureEnabledReturnsFalseAndDispatchesWhenUserIsBucketedIntoAnExperimentVariationToggleOff () throws Exception {
3592
+ assumeTrue (datafileVersion >= Integer .parseInt (ProjectConfig .Version .V4 .toString ()));
3593
+
3594
+ String validFeatureKey = FEATURE_MULTI_VARIATE_FEATURE_KEY ;
3595
+
3596
+ Optimizely spyOptimizely = spy (Optimizely .builder (validDatafile , mockEventHandler )
3597
+ .withConfig (validProjectConfig )
3598
+ .withDecisionService (mockDecisionService )
3599
+ .build ());
3600
+
3601
+ Experiment activatedExperiment = validProjectConfig .getExperimentKeyMapping ().get (EXPERIMENT_MULTIVARIATE_EXPERIMENT_KEY );
3602
+ Variation variation = new Variation ("2" , "variation_toggled_off" , false , null );
3603
+
3604
+ FeatureDecision featureDecision = new FeatureDecision (activatedExperiment , variation , FeatureDecision .DecisionSource .EXPERIMENT );
3605
+ doReturn (featureDecision ).when (mockDecisionService ).getVariationForFeature (
3606
+ any (FeatureFlag .class ),
3607
+ anyString (),
3608
+ anyMapOf (String .class , String .class )
3609
+ );
3610
+
3611
+ assertFalse (spyOptimizely .isFeatureEnabled (validFeatureKey , genericUserId ));
3612
+
3613
+ logbackVerifier .expectMessage (
3614
+ Level .INFO ,
3615
+ "Feature \" " + validFeatureKey +
3616
+ "\" is not enabled for user \" " + genericUserId + "\" ."
3617
+ );
3618
+ verify (mockEventHandler , times (1 )).dispatchEvent (any (LogEvent .class ));
3619
+ }
3620
+
3587
3621
/** Integration Test
3588
3622
* Verify {@link Optimizely#isFeatureEnabled(String, String, Map)}
3589
3623
* returns True
0 commit comments