use of com.optimizely.ab.optimizelydecision.OptimizelyDecision in project java-sdk by optimizely.
the class OptimizelyUserContextTest method decide_nullVariation.
@Test
public void decide_nullVariation() {
optimizely = new Optimizely.Builder().withDatafile(datafile).withEventProcessor(new ForwardingEventProcessor(eventHandler, null)).build();
String flagKey = "feature_3";
OptimizelyJSON variablesExpected = new OptimizelyJSON(Collections.emptyMap());
OptimizelyUserContext user = optimizely.createUserContext(userId);
OptimizelyDecision decision = user.decide(flagKey);
assertEquals(decision.getVariationKey(), null);
assertFalse(decision.getEnabled());
assertEquals(decision.getVariables().toMap(), variablesExpected.toMap());
assertEquals(decision.getRuleKey(), null);
assertEquals(decision.getFlagKey(), flagKey);
assertEquals(decision.getUserContext(), user);
assertTrue(decision.getReasons().isEmpty());
DecisionMetadata metadata = new DecisionMetadata.Builder().setFlagKey(flagKey).setRuleKey("").setRuleType(FeatureDecision.DecisionSource.ROLLOUT.toString()).setVariationKey("").setEnabled(false).build();
eventHandler.expectImpression(null, "", userId, Collections.emptyMap(), metadata);
}
use of com.optimizely.ab.optimizelydecision.OptimizelyDecision in project java-sdk by optimizely.
the class OptimizelyUserContextTest method decideReasons_experimentNotRunning.
// reasons (infos with includeReasons)
@Test
public void decideReasons_experimentNotRunning() {
String flagKey = "feature_1";
Experiment experiment = getSpyExperiment(flagKey);
when(experiment.isActive()).thenReturn(false);
addSpyExperiment(experiment);
OptimizelyDecision decision = callDecideWithIncludeReasons(flagKey);
assertTrue(decision.getReasons().contains(String.format("Experiment \"exp_with_audience\" is not running.")));
}
Aggregations