use of com.optimizely.ab.bucketing.FeatureDecision in project java-sdk by optimizely.
the class OptimizelyTest method isFeatureEnabledReturnsFalseWhenUserIsNotBucketedIntoAnyVariation.
/**
* Verify {@link Optimizely#isFeatureEnabled(String, String)} calls into
* {@link Optimizely#isFeatureEnabled(String, String, Map)} and they both
* return False
* when the user is not bucketed into any variation for the feature.
*/
@Test
public void isFeatureEnabledReturnsFalseWhenUserIsNotBucketedIntoAnyVariation() throws Exception {
assumeTrue(datafileVersion >= Integer.parseInt(ProjectConfig.Version.V4.toString()));
String validFeatureKey = FEATURE_MULTI_VARIATE_FEATURE_KEY;
Optimizely optimizely = optimizelyBuilder.withDecisionService(mockDecisionService).build();
FeatureDecision featureDecision = new FeatureDecision(null, null, null);
doReturn(DecisionResponse.responseNoReasons(featureDecision)).when(mockDecisionService).getVariationForFeature(any(FeatureFlag.class), any(OptimizelyUserContext.class), any(ProjectConfig.class));
assertFalse(optimizely.isFeatureEnabled(validFeatureKey, genericUserId));
logbackVerifier.expectMessage(Level.INFO, "Feature \"" + validFeatureKey + "\" is enabled for user \"" + genericUserId + "\"? false");
eventHandler.expectImpression(null, "", genericUserId);
verify(mockDecisionService).getVariationForFeature(eq(FEATURE_FLAG_MULTI_VARIATE_FEATURE), eq(optimizely.createUserContext(genericUserId, Collections.emptyMap())), eq(validProjectConfig));
}
Aggregations