Search in sources :

Example 1 with OptimizelyDecideOption

use of com.optimizely.ab.optimizelydecision.OptimizelyDecideOption in project java-sdk by optimizely.

the class OptimizelyUserContextTest method decideOptions_defaultDecideOptions.

@Test
public void decideOptions_defaultDecideOptions() {
    List<OptimizelyDecideOption> options = Arrays.asList(OptimizelyDecideOption.EXCLUDE_VARIABLES);
    optimizely = Optimizely.builder().withDatafile(datafile).withDefaultDecideOptions(options).build();
    String flagKey = "feature_1";
    OptimizelyUserContext user = optimizely.createUserContext(userId);
    // should be excluded by DefaultDecideOption
    OptimizelyDecision decision = user.decide(flagKey);
    assertTrue(decision.getVariables().toMap().size() == 0);
    decision = user.decide(flagKey, Arrays.asList(OptimizelyDecideOption.INCLUDE_REASONS, OptimizelyDecideOption.EXCLUDE_VARIABLES));
    // other options should work as well
    assertTrue(decision.getReasons().size() > 0);
    // redundant setting ignored
    assertTrue(decision.getVariables().toMap().size() == 0);
}
Also used : OptimizelyDecision(com.optimizely.ab.optimizelydecision.OptimizelyDecision) OptimizelyDecideOption(com.optimizely.ab.optimizelydecision.OptimizelyDecideOption) Test(org.junit.Test)

Aggregations

OptimizelyDecideOption (com.optimizely.ab.optimizelydecision.OptimizelyDecideOption)1 OptimizelyDecision (com.optimizely.ab.optimizelydecision.OptimizelyDecision)1 Test (org.junit.Test)1