Search in sources :

Example 36 with ProjectConfig

use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.

the class JsonConfigParserTest method parseProjectConfigV4.

@Test
public void parseProjectConfigV4() throws Exception {
    JsonConfigParser parser = new JsonConfigParser();
    ProjectConfig actual = parser.parseProjectConfig(validConfigJsonV4());
    ProjectConfig expected = validProjectConfigV4();
    verifyProjectConfig(actual, expected);
}
Also used : ProjectConfig(com.optimizely.ab.config.ProjectConfig) DatafileProjectConfigTestUtils.verifyProjectConfig(com.optimizely.ab.config.DatafileProjectConfigTestUtils.verifyProjectConfig) Test(org.junit.Test)

Example 37 with ProjectConfig

use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.

the class JsonConfigParserTest 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");
}
Also used : ProjectConfig(com.optimizely.ab.config.ProjectConfig) DatafileProjectConfigTestUtils.verifyProjectConfig(com.optimizely.ab.config.DatafileProjectConfigTestUtils.verifyProjectConfig) FeatureFlag(com.optimizely.ab.config.FeatureFlag) FeatureVariable(com.optimizely.ab.config.FeatureVariable) Test(org.junit.Test)

Example 38 with ProjectConfig

use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.

the class BucketerTest method bucketUserNotInOverlappingGroupExperiment.

/**
 * Verify that {@link Bucketer#bucket(Experiment, String, ProjectConfig)} doesn't return a variation when the user doesn't fall
 * into an experiment within an overlapping group.
 */
@Test
public void bucketUserNotInOverlappingGroupExperiment() throws Exception {
    final AtomicInteger bucketValue = new AtomicInteger();
    Bucketer algorithm = testBucketAlgorithm(bucketValue);
    bucketValue.set(3000);
    ProjectConfig projectConfig = validProjectConfigV2();
    List<Experiment> groupExperiments = projectConfig.getGroups().get(1).getExperiments();
    Experiment groupExperiment = groupExperiments.get(0);
    logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is not in any variation of experiment \"overlapping_etag1\".");
    assertNull(algorithm.bucket(groupExperiment, "blah", projectConfig).getResult());
}
Also used : ProjectConfig(com.optimizely.ab.config.ProjectConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Experiment(com.optimizely.ab.config.Experiment) Test(org.junit.Test) ExhaustiveTest(com.optimizely.ab.categories.ExhaustiveTest)

Example 39 with ProjectConfig

use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.

the class BucketerTest method bucketUserToDeletedExperimentSpace.

/**
 * Verify that {@link Bucketer#bucket(Experiment, String, ProjectConfig)} doesn't return a variation when the user is bucketed to
 * the traffic space of a deleted experiment within a random group.
 */
@Test
public void bucketUserToDeletedExperimentSpace() throws Exception {
    final AtomicInteger bucketValue = new AtomicInteger();
    final int bucketIntVal = 9000;
    Bucketer algorithm = testBucketAlgorithm(bucketValue);
    bucketValue.set(bucketIntVal);
    ProjectConfig projectConfig = validProjectConfigV2();
    List<Experiment> groupExperiments = projectConfig.getGroups().get(0).getExperiments();
    Experiment groupExperiment = groupExperiments.get(1);
    logbackVerifier.expectMessage(Level.DEBUG, "Assigned bucket " + bucketIntVal + " to user with bucketingId \"blah\" during experiment bucketing.");
    logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is not in any experiment of group 42.");
    assertNull(algorithm.bucket(groupExperiment, "blah", projectConfig).getResult());
}
Also used : ProjectConfig(com.optimizely.ab.config.ProjectConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Experiment(com.optimizely.ab.config.Experiment) Test(org.junit.Test) ExhaustiveTest(com.optimizely.ab.categories.ExhaustiveTest)

Example 40 with ProjectConfig

use of com.optimizely.ab.config.ProjectConfig in project java-sdk by optimizely.

the class BucketerTest method bucketUserInExperiment.

// ========== Tests for Grouped experiments ==========//
/**
 * Verify that {@link Bucketer#bucket(Experiment, String, ProjectConfig)} returns the proper variation when a user is
 * in the group experiment.
 */
@Test
public void bucketUserInExperiment() 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(0);
    logbackVerifier.expectMessage(Level.DEBUG, "Assigned bucket 3000 to user with bucketingId \"blah\" during experiment bucketing.");
    logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is in experiment \"group_etag2\" of group 42.");
    logbackVerifier.expectMessage(Level.DEBUG, "Assigned bucket 3000 to user with bucketingId \"blah\" when bucketing to a variation.");
    logbackVerifier.expectMessage(Level.INFO, "User with bucketingId \"blah\" is in variation \"e2_vtag1\" of experiment \"group_etag2\".");
    assertThat(algorithm.bucket(groupExperiment, "blah", projectConfig).getResult(), is(groupExperiment.getVariations().get(0)));
}
Also used : ProjectConfig(com.optimizely.ab.config.ProjectConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Experiment(com.optimizely.ab.config.Experiment) Test(org.junit.Test) ExhaustiveTest(com.optimizely.ab.categories.ExhaustiveTest)

Aggregations

ProjectConfig (com.optimizely.ab.config.ProjectConfig)51 Test (org.junit.Test)45 DatafileProjectConfigTestUtils.verifyProjectConfig (com.optimizely.ab.config.DatafileProjectConfigTestUtils.verifyProjectConfig)28 Experiment (com.optimizely.ab.config.Experiment)19 FeatureFlag (com.optimizely.ab.config.FeatureFlag)14 FeatureVariable (com.optimizely.ab.config.FeatureVariable)12 LogEvent (com.optimizely.ab.event.LogEvent)10 Variation (com.optimizely.ab.config.Variation)9 Attribute (com.optimizely.ab.config.Attribute)7 EventBatch (com.optimizely.ab.event.internal.payload.EventBatch)7 ExhaustiveTest (com.optimizely.ab.categories.ExhaustiveTest)6 EventType (com.optimizely.ab.config.EventType)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 HashMap (java.util.HashMap)3 DecisionService (com.optimizely.ab.bucketing.DecisionService)2 Group (com.optimizely.ab.config.Group)2 LiveVariable (com.optimizely.ab.config.LiveVariable)2 Rollout (com.optimizely.ab.config.Rollout)2 Audience (com.optimizely.ab.config.audience.Audience)2 EventBuilder (com.optimizely.ab.event.internal.EventBuilder)2