use of com.optimizely.ab.optimizelyjson.OptimizelyJSON 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);
}
Aggregations