use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.
the class JsonConfigParserTest method parseFeatureVariablesWithJsonPatched.
@Test
public void parseFeatureVariablesWithJsonPatched() throws Exception {
JsonSimpleConfigParser parser = new JsonSimpleConfigParser();
ProjectConfig actual = parser.parseProjectConfig(validConfigJsonV4());
// "string" type + "json" subType
FeatureFlag featureFlag = actual.getFeatureKeyMapping().get("multi_variate_feature");
FeatureVariable variable = featureFlag.getVariableKeyToFeatureVariableMap().get("json_patched");
assertEquals(variable.getType(), "json");
}
use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.
the class BucketerTest method bucketUserNotInExperiment.
/**
* Verify that {@link Bucketer#bucket(Experiment, String, ProjectConfig)} doesn't return a variation when a user isn't bucketed
* into the group experiment.
*/
@Test
public void bucketUserNotInExperiment() throws Exception {
final AtomicInteger bucketValue = new AtomicInteger();
Bucketer algorithm = testBucketAlgorithm(bucketValue);
bucketValue.set(3000);
ProjectConfig projectConfig = validProjectConfigV2();
List<Experiment> groupExperiments = projectConfig.getGroups().get(0).getExperiments();
Experiment groupExperiment = groupExperiments.get(1);
// the user should be bucketed to a different experiment than the one provided, resulting in no variation being
// returned.
logbackVerifier.expectMessage(Level.DEBUG, "Assigned bucket 3000 to user with bucketingId \"blah\" during experiment bucketing.");
logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is not in experiment \"group_etag1\" of group 42");
assertNull(algorithm.bucket(groupExperiment, "blah", projectConfig).getResult());
}
use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.
the class BucketerTest method bucketUserToVariationInOverlappingGroupExperiment.
/**
* Verify that {@link Bucketer#bucket(Experiment, String, ProjectConfig)} returns a variation when the user falls into an
* experiment within an overlapping group.
*/
@Test
public void bucketUserToVariationInOverlappingGroupExperiment() throws Exception {
final AtomicInteger bucketValue = new AtomicInteger();
Bucketer algorithm = testBucketAlgorithm(bucketValue);
bucketValue.set(0);
ProjectConfig projectConfig = validProjectConfigV2();
List<Experiment> groupExperiments = projectConfig.getGroups().get(1).getExperiments();
Experiment groupExperiment = groupExperiments.get(0);
Variation expectedVariation = groupExperiment.getVariations().get(0);
logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is in variation \"e1_vtag1\" of experiment \"overlapping_etag1\".");
assertThat(algorithm.bucket(groupExperiment, "blah", projectConfig).getResult(), is(expectedVariation));
}
use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.
the class GsonConfigParserTest method parseProjectConfigV2.
@Test
public void parseProjectConfigV2() throws Exception {
GsonConfigParser parser = new GsonConfigParser();
ProjectConfig actual = parser.parseProjectConfig(validConfigJsonV2());
ProjectConfig expected = validProjectConfigV2();
verifyProjectConfig(actual, expected);
}
use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.
the class JsonSimpleConfigParserTest method parseFeatureVariablesWithJsonNative.
@Test
public void parseFeatureVariablesWithJsonNative() throws Exception {
JsonSimpleConfigParser parser = new JsonSimpleConfigParser();
ProjectConfig actual = parser.parseProjectConfig(validConfigJsonV4());
// native "json" type
FeatureFlag featureFlag = actual.getFeatureKeyMapping().get("multi_variate_future_feature");
FeatureVariable variable = featureFlag.getVariableKeyToFeatureVariableMap().get("json_native");
assertEquals(variable.getType(), "json");
}
Aggregations