Search in sources :

Example 11 with AndCondition

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

the class DatafileProjectConfigTest method verifyGetAudienceConditionsFromValidId.

/**
 * Asserts that getAudience returns the respective audience, provided the
 * audience ID parameter is valid.
 */
@Test
public void verifyGetAudienceConditionsFromValidId() throws Exception {
    List<Condition> userAttributes = new ArrayList<Condition>();
    userAttributes.add(new UserAttribute("browser_type", "custom_attribute", null, "firefox"));
    OrCondition orInner = new OrCondition(userAttributes);
    NotCondition notCondition = new NotCondition(orInner);
    List<Condition> outerOrList = new ArrayList<Condition>();
    outerOrList.add(notCondition);
    OrCondition orOuter = new OrCondition(outerOrList);
    List<Condition> andList = new ArrayList<Condition>();
    andList.add(orOuter);
    Condition expectedConditions = new AndCondition(andList);
    Condition actualConditions = projectConfig.getAudience("100").getConditions();
    assertThat(actualConditions, is(expectedConditions));
}
Also used : Condition(com.optimizely.ab.config.audience.Condition) OrCondition(com.optimizely.ab.config.audience.OrCondition) NotCondition(com.optimizely.ab.config.audience.NotCondition) AndCondition(com.optimizely.ab.config.audience.AndCondition) NotCondition(com.optimizely.ab.config.audience.NotCondition) UserAttribute(com.optimizely.ab.config.audience.UserAttribute) OrCondition(com.optimizely.ab.config.audience.OrCondition) AndCondition(com.optimizely.ab.config.audience.AndCondition) Test(org.junit.Test)

Aggregations

AndCondition (com.optimizely.ab.config.audience.AndCondition)11 Condition (com.optimizely.ab.config.audience.Condition)11 NotCondition (com.optimizely.ab.config.audience.NotCondition)11 OrCondition (com.optimizely.ab.config.audience.OrCondition)11 UserAttribute (com.optimizely.ab.config.audience.UserAttribute)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)5 Audience (com.optimizely.ab.config.audience.Audience)4 List (java.util.List)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JsonObject (com.google.gson.JsonObject)1 LinkedTreeMap (com.google.gson.internal.LinkedTreeMap)1 AudienceIdCondition (com.optimizely.ab.config.audience.AudienceIdCondition)1 EmptyCondition (com.optimizely.ab.config.audience.EmptyCondition)1 NullCondition (com.optimizely.ab.config.audience.NullCondition)1 InvalidAudienceCondition (com.optimizely.ab.internal.InvalidAudienceCondition)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 JSONArray (org.json.simple.JSONArray)1