diff --git a/core-api/src/main/java/com/optimizely/ab/Optimizely.java b/core-api/src/main/java/com/optimizely/ab/Optimizely.java index ac709abf2..d814c7fd5 100644 --- a/core-api/src/main/java/com/optimizely/ab/Optimizely.java +++ b/core-api/src/main/java/com/optimizely/ab/Optimizely.java @@ -23,8 +23,8 @@ import com.optimizely.ab.config.EventType; import com.optimizely.ab.config.Experiment; import com.optimizely.ab.config.FeatureFlag; -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.LiveVariableUsageInstance; +import com.optimizely.ab.config.FeatureVariable; +import com.optimizely.ab.config.FeatureVariableUsageInstance; import com.optimizely.ab.config.ProjectConfig; import com.optimizely.ab.config.Variation; import com.optimizely.ab.config.parser.ConfigParseException; @@ -203,9 +203,9 @@ public Variation activate(@Nonnull Experiment experiment, @Nullable private Variation activate(@Nonnull ProjectConfig projectConfig, - @Nonnull Experiment experiment, - @Nonnull String userId, - @Nonnull Map attributes) { + @Nonnull Experiment experiment, + @Nonnull String userId, + @Nonnull Map attributes) { if (!isValid) { logger.error("Optimizely instance is not valid, failing activate call."); return null; @@ -310,12 +310,12 @@ public void track(@Nonnull String eventName, // create the conversion event request parameters, then dispatch LogEvent conversionEvent = eventFactory.createConversionEvent( - projectConfig, - userId, - eventType.getId(), - eventType.getKey(), - copiedAttributes, - eventTags); + projectConfig, + userId, + eventType.getId(), + eventType.getKey(), + copiedAttributes, + eventTags); logger.info("Tracking event \"{}\" for user \"{}\".", eventName, userId); @@ -348,7 +348,7 @@ public void track(@Nonnull String eventName, */ @Nonnull public Boolean isFeatureEnabled(@Nonnull String featureKey, - @Nonnull String userId) { + @Nonnull String userId) { return isFeatureEnabled(featureKey, userId, Collections.emptyMap()); } @@ -365,8 +365,8 @@ public Boolean isFeatureEnabled(@Nonnull String featureKey, */ @Nonnull public Boolean isFeatureEnabled(@Nonnull String featureKey, - @Nonnull String userId, - @Nonnull Map attributes) { + @Nonnull String userId, + @Nonnull Map attributes) { if (!isValid) { logger.error("Optimizely instance is not valid, failing isFeatureEnabled call."); return false; @@ -451,7 +451,7 @@ public Boolean getFeatureVariableBoolean(@Nonnull String featureKey, variableKey, userId, attributes, - LiveVariable.VariableType.BOOLEAN + FeatureVariable.VariableType.BOOLEAN ); if (variableValue != null) { return Boolean.parseBoolean(variableValue); @@ -500,7 +500,7 @@ public Double getFeatureVariableDouble(@Nonnull String featureKey, variableKey, userId, attributes, - LiveVariable.VariableType.DOUBLE + FeatureVariable.VariableType.DOUBLE ); if (variableValue != null) { try { @@ -554,7 +554,7 @@ public Integer getFeatureVariableInteger(@Nonnull String featureKey, variableKey, userId, attributes, - LiveVariable.VariableType.INTEGER + FeatureVariable.VariableType.INTEGER ); if (variableValue != null) { try { @@ -608,7 +608,7 @@ public String getFeatureVariableString(@Nonnull String featureKey, variableKey, userId, attributes, - LiveVariable.VariableType.STRING); + FeatureVariable.VariableType.STRING); } @VisibleForTesting @@ -616,7 +616,7 @@ String getFeatureVariableValueForType(@Nonnull String featureKey, @Nonnull String variableKey, @Nonnull String userId, @Nonnull Map attributes, - @Nonnull LiveVariable.VariableType variableType) { + @Nonnull FeatureVariable.VariableType variableType) { if (featureKey == null) { logger.warn("The featureKey parameter must be nonnull."); return null; @@ -633,7 +633,7 @@ String getFeatureVariableValueForType(@Nonnull String featureKey, return null; } - LiveVariable variable = featureFlag.getVariableKeyToLiveVariableMap().get(variableKey); + FeatureVariable variable = featureFlag.getVariableKeyToFeatureVariableMap().get(variableKey); if (variable == null) { logger.info("No feature variable was found for key \"{}\" in feature flag \"{}\".", variableKey, featureKey); @@ -650,10 +650,10 @@ String getFeatureVariableValueForType(@Nonnull String featureKey, Map copiedAttributes = copyAttributes(attributes); FeatureDecision featureDecision = decisionService.getVariationForFeature(featureFlag, userId, copiedAttributes); if (featureDecision.variation != null) { - LiveVariableUsageInstance liveVariableUsageInstance = - featureDecision.variation.getVariableIdToLiveVariableUsageInstanceMap().get(variable.getId()); - if (liveVariableUsageInstance != null) { - variableValue = liveVariableUsageInstance.getValue(); + FeatureVariableUsageInstance featureVariableUsageInstance = + featureDecision.variation.getVariableIdToFeatureVariableUsageInstanceMap().get(variable.getId()); + if (featureVariableUsageInstance != null) { + variableValue = featureVariableUsageInstance.getValue(); } else { variableValue = variable.getDefaultValue(); } diff --git a/core-api/src/main/java/com/optimizely/ab/UnknownLiveVariableException.java b/core-api/src/main/java/com/optimizely/ab/UnknownLiveVariableException.java deleted file mode 100644 index bd8e0989b..000000000 --- a/core-api/src/main/java/com/optimizely/ab/UnknownLiveVariableException.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - * Copyright 2016-2017, Optimizely and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.optimizely.ab; - -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.ProjectConfig; - -/** - * Exception thrown when attempting to use/refer to a {@link LiveVariable} that isn't present in the current - * {@link ProjectConfig}. - */ -public class UnknownLiveVariableException extends OptimizelyRuntimeException { - - public UnknownLiveVariableException(String message) { - super(message); - } - - public UnknownLiveVariableException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/core-api/src/main/java/com/optimizely/ab/config/FeatureFlag.java b/core-api/src/main/java/com/optimizely/ab/config/FeatureFlag.java index 797f19401..2b3bc4939 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/FeatureFlag.java +++ b/core-api/src/main/java/com/optimizely/ab/config/FeatureFlag.java @@ -33,21 +33,21 @@ public class FeatureFlag implements IdKeyMapped { private final String key; private final String rolloutId; private final List experimentIds; - private final List variables; - private final Map variableKeyToLiveVariableMap; + private final List variables; + private final Map variableKeyToFeatureVariableMap; @JsonCreator public FeatureFlag(@JsonProperty("id") String id, @JsonProperty("key") String key, @JsonProperty("rolloutId") String rolloutId, @JsonProperty("experimentIds") List experimentIds, - @JsonProperty("variables") List variables) { + @JsonProperty("variables") List variables) { this.id = id; this.key = key; this.rolloutId = rolloutId; this.experimentIds = experimentIds; this.variables = variables; - this.variableKeyToLiveVariableMap = ProjectConfigUtils.generateNameMapping(variables); + this.variableKeyToFeatureVariableMap = ProjectConfigUtils.generateNameMapping(variables); } public String getId() { @@ -66,12 +66,12 @@ public List getExperimentIds() { return experimentIds; } - public List getVariables() { + public List getVariables() { return variables; } - public Map getVariableKeyToLiveVariableMap() { - return variableKeyToLiveVariableMap; + public Map getVariableKeyToFeatureVariableMap() { + return variableKeyToFeatureVariableMap; } @Override @@ -82,7 +82,7 @@ public String toString() { ", rolloutId='" + rolloutId + '\'' + ", experimentIds=" + experimentIds + ", variables=" + variables + - ", variableKeyToLiveVariableMap=" + variableKeyToLiveVariableMap + + ", variableKeyToFeatureVariableMap=" + variableKeyToFeatureVariableMap + '}'; } @@ -98,7 +98,7 @@ public boolean equals(Object o) { if (!rolloutId.equals(that.rolloutId)) return false; if (!experimentIds.equals(that.experimentIds)) return false; if (!variables.equals(that.variables)) return false; - return variableKeyToLiveVariableMap.equals(that.variableKeyToLiveVariableMap); + return variableKeyToFeatureVariableMap.equals(that.variableKeyToFeatureVariableMap); } @Override @@ -108,7 +108,7 @@ public int hashCode() { result = 31 * result + rolloutId.hashCode(); result = 31 * result + experimentIds.hashCode(); result = 31 * result + variables.hashCode(); - result = 31 * result + variableKeyToLiveVariableMap.hashCode(); + result = 31 * result + variableKeyToFeatureVariableMap.hashCode(); return result; } } diff --git a/core-api/src/main/java/com/optimizely/ab/config/LiveVariable.java b/core-api/src/main/java/com/optimizely/ab/config/FeatureVariable.java similarity index 89% rename from core-api/src/main/java/com/optimizely/ab/config/LiveVariable.java rename to core-api/src/main/java/com/optimizely/ab/config/FeatureVariable.java index ea2adf2b7..35a36cb78 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/LiveVariable.java +++ b/core-api/src/main/java/com/optimizely/ab/config/FeatureVariable.java @@ -25,10 +25,10 @@ import javax.annotation.Nullable; /** - * Represents a live variable definition at the project level + * Represents a feature variable definition at the project level */ @JsonIgnoreProperties(ignoreUnknown = true) -public class LiveVariable implements IdKeyMapped { +public class FeatureVariable implements IdKeyMapped { public enum VariableStatus { @SerializedName("active") @@ -106,11 +106,11 @@ public static VariableType fromString(String variableTypeString) { private final VariableStatus status; @JsonCreator - public LiveVariable(@JsonProperty("id") String id, - @JsonProperty("key") String key, - @JsonProperty("defaultValue") String defaultValue, - @JsonProperty("status") VariableStatus status, - @JsonProperty("type") VariableType type) { + public FeatureVariable(@JsonProperty("id") String id, + @JsonProperty("key") String key, + @JsonProperty("defaultValue") String defaultValue, + @JsonProperty("status") VariableStatus status, + @JsonProperty("type") VariableType type) { this.id = id; this.key = key; this.defaultValue = defaultValue; @@ -141,7 +141,7 @@ public VariableType getType() { @Override public String toString() { - return "LiveVariable{" + + return "FeatureVariable{" + "id='" + id + '\'' + ", key='" + key + '\'' + ", defaultValue='" + defaultValue + '\'' + @@ -155,7 +155,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - LiveVariable variable = (LiveVariable) o; + FeatureVariable variable = (FeatureVariable) o; if (!id.equals(variable.id)) return false; if (!key.equals(variable.key)) return false; diff --git a/core-api/src/main/java/com/optimizely/ab/config/LiveVariableUsageInstance.java b/core-api/src/main/java/com/optimizely/ab/config/FeatureVariableUsageInstance.java similarity index 78% rename from core-api/src/main/java/com/optimizely/ab/config/LiveVariableUsageInstance.java rename to core-api/src/main/java/com/optimizely/ab/config/FeatureVariableUsageInstance.java index 79cf05620..f6d3146d7 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/LiveVariableUsageInstance.java +++ b/core-api/src/main/java/com/optimizely/ab/config/FeatureVariableUsageInstance.java @@ -1,6 +1,6 @@ /** * - * Copyright 2016-2017, Optimizely and contributors + * Copyright 2016-2017, 2019, Optimizely and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,17 +21,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Represents the value of a live variable for a variation + * Represents the value of a feature variable for a variation */ @JsonIgnoreProperties(ignoreUnknown = true) -public class LiveVariableUsageInstance implements IdMapped { +public class FeatureVariableUsageInstance implements IdMapped { private final String id; private final String value; @JsonCreator - public LiveVariableUsageInstance(@JsonProperty("id") String id, - @JsonProperty("value") String value) { + public FeatureVariableUsageInstance(@JsonProperty("id") String id, + @JsonProperty("value") String value) { this.id = id; this.value = value; } @@ -49,7 +49,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - LiveVariableUsageInstance that = (LiveVariableUsageInstance) o; + FeatureVariableUsageInstance that = (FeatureVariableUsageInstance) o; return id.equals(that.id) && value.equals(that.value); } diff --git a/core-api/src/main/java/com/optimizely/ab/config/ProjectConfig.java b/core-api/src/main/java/com/optimizely/ab/config/ProjectConfig.java index c3760accd..eeea91957 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/ProjectConfig.java +++ b/core-api/src/main/java/com/optimizely/ab/config/ProjectConfig.java @@ -84,7 +84,6 @@ public String toString() { private final List experiments; private final List featureFlags; private final List groups; - private final List liveVariables; private final List rollouts; // key to entity mappings @@ -92,7 +91,6 @@ public String toString() { private final Map eventNameMapping; private final Map experimentKeyMapping; private final Map featureKeyMapping; - private final Map liveVariableKeyMapping; // id to entity mappings private final Map audienceIdMapping; @@ -101,8 +99,6 @@ public String toString() { private final Map rolloutIdMapping; // other mappings - private final Map> liveVariableIdToExperimentsMapping; - private final Map> variationToLiveVariableUsageInstanceMapping; private final Map variationIdToExperimentMapping; public final static String RESERVED_ATTRIBUTE_PREFIX = "$opt_"; @@ -119,14 +115,13 @@ public String toString() { public ProjectConfig(String accountId, String projectId, String version, String revision, List groups, List experiments, List attributes, List eventType, List audiences) { - this(accountId, projectId, version, revision, groups, experiments, attributes, eventType, audiences, false, - null); + this(accountId, projectId, version, revision, groups, experiments, attributes, eventType, audiences, false); } // v3 constructor public ProjectConfig(String accountId, String projectId, String version, String revision, List groups, List experiments, List attributes, List eventType, - List audiences, boolean anonymizeIP, List liveVariables) { + List audiences, boolean anonymizeIP) { this( accountId, anonymizeIP, @@ -141,7 +136,6 @@ public ProjectConfig(String accountId, String projectId, String version, String experiments, null, groups, - liveVariables, null ); } @@ -160,7 +154,6 @@ public ProjectConfig(String accountId, List experiments, List featureFlags, List groups, - List liveVariables, List rollouts) { this.accountId = accountId; @@ -223,20 +216,6 @@ public ProjectConfig(String accountId, this.experimentIdMapping = ProjectConfigUtils.generateIdMapping(this.experiments); this.groupIdMapping = ProjectConfigUtils.generateIdMapping(groups); this.rolloutIdMapping = ProjectConfigUtils.generateIdMapping(this.rollouts); - - if (liveVariables == null) { - this.liveVariables = null; - this.liveVariableKeyMapping = Collections.emptyMap(); - this.liveVariableIdToExperimentsMapping = Collections.emptyMap(); - this.variationToLiveVariableUsageInstanceMapping = Collections.emptyMap(); - } else { - this.liveVariables = Collections.unmodifiableList(liveVariables); - this.liveVariableKeyMapping = ProjectConfigUtils.generateNameMapping(this.liveVariables); - this.liveVariableIdToExperimentsMapping = - ProjectConfigUtils.generateLiveVariableIdToExperimentsMapping(this.experiments); - this.variationToLiveVariableUsageInstanceMapping = - ProjectConfigUtils.generateVariationToLiveVariableUsageInstancesMap(this.experiments); - } } /** @@ -408,10 +387,6 @@ public Audience getAudience(String audienceId) { return audienceIdMapping.get(audienceId); } - public List getLiveVariables() { - return liveVariables; - } - public Map getExperimentKeyMapping() { return experimentKeyMapping; } @@ -440,18 +415,6 @@ public Map getRolloutIdMapping() { return rolloutIdMapping; } - public Map getLiveVariableKeyMapping() { - return liveVariableKeyMapping; - } - - public Map> getLiveVariableIdToExperimentsMapping() { - return liveVariableIdToExperimentsMapping; - } - - public Map> getVariationToLiveVariableUsageInstanceMapping() { - return variationToLiveVariableUsageInstanceMapping; - } - public Map getFeatureKeyMapping() { return featureKeyMapping; } @@ -612,19 +575,15 @@ public String toString() { ", experiments=" + experiments + ", featureFlags=" + featureFlags + ", groups=" + groups + - ", liveVariables=" + liveVariables + ", rollouts=" + rollouts + ", attributeKeyMapping=" + attributeKeyMapping + ", eventNameMapping=" + eventNameMapping + ", experimentKeyMapping=" + experimentKeyMapping + ", featureKeyMapping=" + featureKeyMapping + - ", liveVariableKeyMapping=" + liveVariableKeyMapping + ", audienceIdMapping=" + audienceIdMapping + ", experimentIdMapping=" + experimentIdMapping + ", groupIdMapping=" + groupIdMapping + ", rolloutIdMapping=" + rolloutIdMapping + - ", liveVariableIdToExperimentsMapping=" + liveVariableIdToExperimentsMapping + - ", variationToLiveVariableUsageInstanceMapping=" + variationToLiveVariableUsageInstanceMapping + ", forcedVariationMapping=" + forcedVariationMapping + ", variationIdToExperimentMapping=" + variationIdToExperimentMapping + '}'; diff --git a/core-api/src/main/java/com/optimizely/ab/config/ProjectConfigUtils.java b/core-api/src/main/java/com/optimizely/ab/config/ProjectConfigUtils.java index 63a5fd102..0fbb15d76 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/ProjectConfigUtils.java +++ b/core-api/src/main/java/com/optimizely/ab/config/ProjectConfigUtils.java @@ -48,61 +48,4 @@ public static Map generateIdMapping(List name return Collections.unmodifiableMap(nameMapping); } - /** - * Helper method to create a map from a live variable to all the experiments using it - */ - public static Map> generateLiveVariableIdToExperimentsMapping( - List experiments) { - - Map> variableIdToExperiments = - new HashMap>(); - for (Experiment experiment : experiments) { - if (!experiment.getVariations().isEmpty()) { - // if a live variable is used by an experiment, it will have instances in all variations so we can - // short-circuit after getting the live variables for the first variation - Variation variation = experiment.getVariations().get(0); - if (variation.getLiveVariableUsageInstances() != null) { - for (LiveVariableUsageInstance usageInstance : variation.getLiveVariableUsageInstances()) { - List experimentsUsingVariable = variableIdToExperiments.get(usageInstance.getId()); - if (experimentsUsingVariable == null) { - experimentsUsingVariable = new ArrayList(); - } - - experimentsUsingVariable.add(experiment); - variableIdToExperiments.put(usageInstance.getId(), experimentsUsingVariable); - } - } - } - } - - return variableIdToExperiments; - } - - /** - * Helper method to create a map from variation ID to variable ID to {@link LiveVariableUsageInstance} - */ - public static Map> generateVariationToLiveVariableUsageInstancesMap( - List experiments) { - - Map> liveVariableValueMap = - new HashMap>(); - for (Experiment experiment : experiments) { - for (Variation variation : experiment.getVariations()) { - if (variation.getLiveVariableUsageInstances() != null) { - for (LiveVariableUsageInstance usageInstance : variation.getLiveVariableUsageInstances()) { - Map liveVariableIdToValueMap = - liveVariableValueMap.get(variation.getId()); - if (liveVariableIdToValueMap == null) { - liveVariableIdToValueMap = new HashMap(); - } - - liveVariableIdToValueMap.put(usageInstance.getId(), usageInstance); - liveVariableValueMap.put(variation.getId(), liveVariableIdToValueMap); - } - } - } - } - - return liveVariableValueMap; - } } diff --git a/core-api/src/main/java/com/optimizely/ab/config/Variation.java b/core-api/src/main/java/com/optimizely/ab/config/Variation.java index 2074d1604..0bb1765c2 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/Variation.java +++ b/core-api/src/main/java/com/optimizely/ab/config/Variation.java @@ -38,8 +38,8 @@ public class Variation implements IdKeyMapped { private final String id; private final String key; private final Boolean featureEnabled; - private final List liveVariableUsageInstances; - private final Map variableIdToLiveVariableUsageInstanceMap; + private final List featureVariableUsageInstances; + private final Map variableIdToFeatureVariableUsageInstanceMap; public Variation(String id, String key) { this(id, key, null); @@ -47,27 +47,27 @@ public Variation(String id, String key) { public Variation(String id, String key, - List liveVariableUsageInstances) { - this(id, key, false, liveVariableUsageInstances); + List featureVariableUsageInstances) { + this(id, key, false, featureVariableUsageInstances); } @JsonCreator public Variation(@JsonProperty("id") String id, @JsonProperty("key") String key, @JsonProperty("featureEnabled") Boolean featureEnabled, - @JsonProperty("variables") List liveVariableUsageInstances) { + @JsonProperty("variables") List featureVariableUsageInstances) { this.id = id; this.key = key; if (featureEnabled != null) this.featureEnabled = featureEnabled; else this.featureEnabled = false; - if (liveVariableUsageInstances == null) { - this.liveVariableUsageInstances = Collections.emptyList(); + if (featureVariableUsageInstances == null) { + this.featureVariableUsageInstances = Collections.emptyList(); } else { - this.liveVariableUsageInstances = liveVariableUsageInstances; + this.featureVariableUsageInstances = featureVariableUsageInstances; } - this.variableIdToLiveVariableUsageInstanceMap = ProjectConfigUtils.generateIdMapping(this.liveVariableUsageInstances); + this.variableIdToFeatureVariableUsageInstanceMap = ProjectConfigUtils.generateIdMapping(this.featureVariableUsageInstances); } @Nonnull @@ -86,12 +86,12 @@ public Boolean getFeatureEnabled() { } @Nullable - public List getLiveVariableUsageInstances() { - return liveVariableUsageInstances; + public List getFeatureVariableUsageInstances() { + return featureVariableUsageInstances; } - public Map getVariableIdToLiveVariableUsageInstanceMap() { - return variableIdToLiveVariableUsageInstanceMap; + public Map getVariableIdToFeatureVariableUsageInstanceMap() { + return variableIdToFeatureVariableUsageInstanceMap; } public boolean is(String otherKey) { diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/GsonHelpers.java b/core-api/src/main/java/com/optimizely/ab/config/parser/GsonHelpers.java index 764feea0d..1399497b2 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/GsonHelpers.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/GsonHelpers.java @@ -22,21 +22,18 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.google.gson.JsonParser; -import com.google.gson.internal.LinkedTreeMap; import com.google.gson.reflect.TypeToken; import com.optimizely.ab.bucketing.DecisionService; import com.optimizely.ab.config.Experiment; import com.optimizely.ab.config.Experiment.ExperimentStatus; import com.optimizely.ab.config.FeatureFlag; -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.LiveVariableUsageInstance; +import com.optimizely.ab.config.FeatureVariable; +import com.optimizely.ab.config.FeatureVariableUsageInstance; import com.optimizely.ab.config.TrafficAllocation; import com.optimizely.ab.config.Variation; import com.optimizely.ab.config.audience.AudienceIdCondition; import com.optimizely.ab.config.audience.Condition; import com.optimizely.ab.internal.ConditionUtils; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,15 +59,15 @@ private static List parseVariations(JsonArray variationJson, JsonDese featureEnabled = variationObject.get("featureEnabled").getAsBoolean(); } - List variableUsageInstances = null; + List variableUsageInstances = null; // this is an existence check rather than a version check since it's difficult to pass data // across deserializers. if (variationObject.has("variables")) { - Type liveVariableUsageInstancesType = new TypeToken>() { + Type featureVariableUsageInstancesType = new TypeToken>() { }.getType(); variableUsageInstances = context.deserialize(variationObject.getAsJsonArray("variables"), - liveVariableUsageInstancesType); + featureVariableUsageInstancesType); } variations.add(new Variation(id, key, featureEnabled, variableUsageInstances)); @@ -165,12 +162,12 @@ static FeatureFlag parseFeatureFlag(JsonObject featureFlagJson, JsonDeserializat experimentIds.add(experimentIdObj.getAsString()); } - List liveVariables = new ArrayList(); + List FeatureVariables = new ArrayList<>(); try { - Type liveVariableType = new TypeToken>() { + Type FeatureVariableType = new TypeToken>() { }.getType(); - liveVariables = context.deserialize(featureFlagJson.getAsJsonArray("variables"), - liveVariableType); + FeatureVariables = context.deserialize(featureFlagJson.getAsJsonArray("variables"), + FeatureVariableType); } catch (JsonParseException exception) { logger.warn("Unable to parse variables for feature \"" + key + "\". JsonParseException: " + exception); @@ -181,7 +178,7 @@ static FeatureFlag parseFeatureFlag(JsonObject featureFlagJson, JsonDeserializat key, layerId, experimentIds, - liveVariables + FeatureVariables ); } } diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java b/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java index 323db9fb2..0cac06117 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/JsonConfigParser.java @@ -22,10 +22,8 @@ import com.optimizely.ab.config.Experiment.ExperimentStatus; import com.optimizely.ab.config.FeatureFlag; import com.optimizely.ab.config.Group; -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.LiveVariable.VariableStatus; -import com.optimizely.ab.config.LiveVariable.VariableType; -import com.optimizely.ab.config.LiveVariableUsageInstance; +import com.optimizely.ab.config.FeatureVariable; +import com.optimizely.ab.config.FeatureVariableUsageInstance; import com.optimizely.ab.config.ProjectConfig; import com.optimizely.ab.config.Rollout; import com.optimizely.ab.config.TrafficAllocation; @@ -83,10 +81,7 @@ public ProjectConfig parseProjectConfig(@Nonnull String json) throws ConfigParse List groups = parseGroups(rootObject.getJSONArray("groups")); boolean anonymizeIP = false; - List liveVariables = null; if (datafileVersion >= Integer.parseInt(ProjectConfig.Version.V3.toString())) { - liveVariables = parseLiveVariables(rootObject.getJSONArray("variables")); - anonymizeIP = rootObject.getBoolean("anonymizeIP"); } @@ -114,7 +109,6 @@ public ProjectConfig parseProjectConfig(@Nonnull String json) throws ConfigParse experiments, featureFlags, groups, - liveVariables, rollouts ); } catch (Exception e) { @@ -187,7 +181,7 @@ private List parseFeatureFlags(JSONArray featureFlagJson) { List experimentIds = parseExperimentIds(featureFlagObject.getJSONArray("experimentIds")); - List variables = parseLiveVariables(featureFlagObject.getJSONArray("variables")); + List variables = parseFeatureVariables(featureFlagObject.getJSONArray("variables")); featureFlags.add(new FeatureFlag( id, @@ -214,13 +208,13 @@ private List parseVariations(JSONArray variationJson) { featureEnabled = variationObject.getBoolean("featureEnabled"); } - List liveVariableUsageInstances = null; + List featureVariableUsageInstances = null; if (variationObject.has("variables")) { - liveVariableUsageInstances = - parseLiveVariableInstances(variationObject.getJSONArray("variables")); + featureVariableUsageInstances = + parseFeatureVariableInstances(variationObject.getJSONArray("variables")); } - variations.add(new Variation(id, key, featureEnabled, liveVariableUsageInstances)); + variations.add(new Variation(id, key, featureEnabled, featureVariableUsageInstances)); } return variations; @@ -340,38 +334,38 @@ private List parseGroups(JSONArray groupJson) { return groups; } - private List parseLiveVariables(JSONArray liveVariablesJson) { - List liveVariables = new ArrayList(liveVariablesJson.length()); - - for (Object obj : liveVariablesJson) { - JSONObject liveVariableObject = (JSONObject) obj; - String id = liveVariableObject.getString("id"); - String key = liveVariableObject.getString("key"); - String defaultValue = liveVariableObject.getString("defaultValue"); - VariableType type = VariableType.fromString(liveVariableObject.getString("type")); - VariableStatus status = null; - if (liveVariableObject.has("status")) { - status = VariableStatus.fromString(liveVariableObject.getString("status")); + private List parseFeatureVariables(JSONArray FeatureVariablesJson) { + List FeatureVariables = new ArrayList(FeatureVariablesJson.length()); + + for (Object obj : FeatureVariablesJson) { + JSONObject FeatureVariableObject = (JSONObject) obj; + String id = FeatureVariableObject.getString("id"); + String key = FeatureVariableObject.getString("key"); + String defaultValue = FeatureVariableObject.getString("defaultValue"); + FeatureVariable.VariableType type = FeatureVariable.VariableType.fromString(FeatureVariableObject.getString("type")); + FeatureVariable.VariableStatus status = null; + if (FeatureVariableObject.has("status")) { + status = FeatureVariable.VariableStatus.fromString(FeatureVariableObject.getString("status")); } - liveVariables.add(new LiveVariable(id, key, defaultValue, status, type)); + FeatureVariables.add(new FeatureVariable(id, key, defaultValue, status, type)); } - return liveVariables; + return FeatureVariables; } - private List parseLiveVariableInstances(JSONArray liveVariableInstancesJson) { - List liveVariableUsageInstances = new ArrayList(liveVariableInstancesJson.length()); + private List parseFeatureVariableInstances(JSONArray FeatureVariableInstancesJson) { + List featureVariableUsageInstances = new ArrayList(FeatureVariableInstancesJson.length()); - for (Object obj : liveVariableInstancesJson) { - JSONObject liveVariableInstanceObject = (JSONObject) obj; - String id = liveVariableInstanceObject.getString("id"); - String value = liveVariableInstanceObject.getString("value"); + for (Object obj : FeatureVariableInstancesJson) { + JSONObject FeatureVariableInstanceObject = (JSONObject) obj; + String id = FeatureVariableInstanceObject.getString("id"); + String value = FeatureVariableInstanceObject.getString("value"); - liveVariableUsageInstances.add(new LiveVariableUsageInstance(id, value)); + featureVariableUsageInstances.add(new FeatureVariableUsageInstance(id, value)); } - return liveVariableUsageInstances; + return featureVariableUsageInstances; } private List parseRollouts(JSONArray rolloutsJson) { diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/JsonSimpleConfigParser.java b/core-api/src/main/java/com/optimizely/ab/config/parser/JsonSimpleConfigParser.java index 63d4d5ee5..d5c54b86a 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/JsonSimpleConfigParser.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/JsonSimpleConfigParser.java @@ -22,10 +22,10 @@ import com.optimizely.ab.config.Experiment.ExperimentStatus; import com.optimizely.ab.config.FeatureFlag; import com.optimizely.ab.config.Group; -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.LiveVariable.VariableStatus; -import com.optimizely.ab.config.LiveVariable.VariableType; -import com.optimizely.ab.config.LiveVariableUsageInstance; +import com.optimizely.ab.config.FeatureVariable; +import com.optimizely.ab.config.FeatureVariable.VariableStatus; +import com.optimizely.ab.config.FeatureVariable.VariableType; +import com.optimizely.ab.config.FeatureVariableUsageInstance; import com.optimizely.ab.config.ProjectConfig; import com.optimizely.ab.config.Rollout; import com.optimizely.ab.config.TrafficAllocation; @@ -86,10 +86,7 @@ public ProjectConfig parseProjectConfig(@Nonnull String json) throws ConfigParse List groups = parseGroups((JSONArray) rootObject.get("groups")); boolean anonymizeIP = false; - List liveVariables = null; if (datafileVersion >= Integer.parseInt(ProjectConfig.Version.V3.toString())) { - liveVariables = parseLiveVariables((JSONArray) rootObject.get("variables")); - anonymizeIP = (Boolean) rootObject.get("anonymizeIP"); } @@ -117,7 +114,6 @@ public ProjectConfig parseProjectConfig(@Nonnull String json) throws ConfigParse experiments, featureFlags, groups, - liveVariables, rollouts ); } catch (RuntimeException ex) { @@ -199,14 +195,14 @@ private List parseFeatureFlags(JSONArray featureFlagJson) { JSONArray experimentIdsJsonArray = (JSONArray) featureFlagObject.get("experimentIds"); List experimentIds = parseExperimentIds(experimentIdsJsonArray); - List liveVariables = parseLiveVariables((JSONArray) featureFlagObject.get("variables")); + List featureVariable = parseFeatureVariables((JSONArray) featureFlagObject.get("variables")); featureFlags.add(new FeatureFlag( id, key, layerId, experimentIds, - liveVariables + featureVariable )); } @@ -225,12 +221,12 @@ private List parseVariations(JSONArray variationJson) { if (variationObject.containsKey("featureEnabled")) featureEnabled = (Boolean) variationObject.get("featureEnabled"); - List liveVariableUsageInstances = null; + List featureVariableUsageInstances = null; if (variationObject.containsKey("variables")) { - liveVariableUsageInstances = parseLiveVariableInstances((JSONArray) variationObject.get("variables")); + featureVariableUsageInstances = parseFeatureVariableInstances((JSONArray) variationObject.get("variables")); } - variations.add(new Variation(id, key, featureEnabled, liveVariableUsageInstances)); + variations.add(new Variation(id, key, featureEnabled, featureVariableUsageInstances)); } return variations; @@ -341,36 +337,36 @@ private List parseGroups(JSONArray groupJson) { return groups; } - private List parseLiveVariables(JSONArray liveVariablesJson) { - List liveVariables = new ArrayList(liveVariablesJson.size()); + private List parseFeatureVariables(JSONArray featureVariablesJson) { + List featureVariables = new ArrayList(featureVariablesJson.size()); - for (Object obj : liveVariablesJson) { - JSONObject liveVariableObject = (JSONObject) obj; - String id = (String) liveVariableObject.get("id"); - String key = (String) liveVariableObject.get("key"); - String defaultValue = (String) liveVariableObject.get("defaultValue"); - VariableType type = VariableType.fromString((String) liveVariableObject.get("type")); - VariableStatus status = VariableStatus.fromString((String) liveVariableObject.get("status")); + for (Object obj : featureVariablesJson) { + JSONObject featureVariableObject = (JSONObject) obj; + String id = (String) featureVariableObject.get("id"); + String key = (String) featureVariableObject.get("key"); + String defaultValue = (String) featureVariableObject.get("defaultValue"); + VariableType type = VariableType.fromString((String) featureVariableObject.get("type")); + VariableStatus status = VariableStatus.fromString((String) featureVariableObject.get("status")); - liveVariables.add(new LiveVariable(id, key, defaultValue, status, type)); + featureVariables.add(new FeatureVariable(id, key, defaultValue, status, type)); } - return liveVariables; + return featureVariables; } - private List parseLiveVariableInstances(JSONArray liveVariableInstancesJson) { - List liveVariableUsageInstances = - new ArrayList(liveVariableInstancesJson.size()); + private List parseFeatureVariableInstances(JSONArray featureVariableInstancesJson) { + List featureVariableUsageInstances = + new ArrayList(featureVariableInstancesJson.size()); - for (Object obj : liveVariableInstancesJson) { - JSONObject liveVariableInstanceObject = (JSONObject) obj; - String id = (String) liveVariableInstanceObject.get("id"); - String value = (String) liveVariableInstanceObject.get("value"); + for (Object obj : featureVariableInstancesJson) { + JSONObject featureVariableInstanceObject = (JSONObject) obj; + String id = (String) featureVariableInstanceObject.get("id"); + String value = (String) featureVariableInstanceObject.get("value"); - liveVariableUsageInstances.add(new LiveVariableUsageInstance(id, value)); + featureVariableUsageInstances.add(new FeatureVariableUsageInstance(id, value)); } - return liveVariableUsageInstances; + return featureVariableUsageInstances; } private List parseRollouts(JSONArray rolloutsJson) { diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigGsonDeserializer.java b/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigGsonDeserializer.java index 750683c48..6407db79f 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigGsonDeserializer.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigGsonDeserializer.java @@ -27,7 +27,6 @@ import com.optimizely.ab.config.Experiment; import com.optimizely.ab.config.FeatureFlag; import com.optimizely.ab.config.Group; -import com.optimizely.ab.config.LiveVariable; import com.optimizely.ab.config.ProjectConfig; import com.optimizely.ab.config.Rollout; import com.optimizely.ab.config.audience.Audience; @@ -86,13 +85,7 @@ public ProjectConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializa typedAudiences = context.deserialize(jsonObject.get("typedAudiences").getAsJsonArray(), typedAudienceType); } boolean anonymizeIP = false; - // live variables should be null if using V2 - List liveVariables = null; if (datafileVersion >= Integer.parseInt(ProjectConfig.Version.V3.toString())) { - Type liveVariablesType = new TypeToken>() { - }.getType(); - liveVariables = context.deserialize(jsonObject.getAsJsonArray("variables"), liveVariablesType); - anonymizeIP = jsonObject.get("anonymizeIP").getAsBoolean(); } @@ -124,7 +117,6 @@ public ProjectConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializa experiments, featureFlags, groups, - liveVariables, rollouts ); } diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigJacksonDeserializer.java b/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigJacksonDeserializer.java index f25d82ba9..c09f7afaf 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigJacksonDeserializer.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/ProjectConfigJacksonDeserializer.java @@ -59,9 +59,7 @@ public ProjectConfig deserialize(JsonParser parser, DeserializationContext conte } boolean anonymizeIP = false; - List liveVariables = null; if (datafileVersion >= Integer.parseInt(ProjectConfig.Version.V3.toString())) { - liveVariables = JacksonHelpers.arrayNodeToList(node.get("variables"), LiveVariable.class, codec); anonymizeIP = node.get("anonymizeIP").asBoolean(); } @@ -90,7 +88,6 @@ public ProjectConfig deserialize(JsonParser parser, DeserializationContext conte experiments, featureFlags, groups, - liveVariables, rollouts ); } diff --git a/core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java b/core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java index 346e92650..eab7a6e49 100644 --- a/core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java +++ b/core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java @@ -24,8 +24,8 @@ import com.optimizely.ab.config.EventType; import com.optimizely.ab.config.Experiment; import com.optimizely.ab.config.FeatureFlag; -import com.optimizely.ab.config.LiveVariable; -import com.optimizely.ab.config.LiveVariableUsageInstance; +import com.optimizely.ab.config.FeatureVariable; +import com.optimizely.ab.config.FeatureVariableUsageInstance; import com.optimizely.ab.config.ProjectConfig; import com.optimizely.ab.config.TrafficAllocation; import com.optimizely.ab.config.Variation; @@ -2870,8 +2870,7 @@ public void removeNotificationListenerNotificationCenter() throws Exception { verify(activateNotification, never()) .onActivate(activatedExperiment, genericUserId, attributes, actualVariation, logEventToDispatch); - // Check if listener is notified after a live variable is accessed - boolean activateExperiment = true; + // Check if listener is notified after a feature variable is accessed verify(activateNotification, never()) .onActivate(activatedExperiment, genericUserId, attributes, actualVariation, logEventToDispatch); @@ -2954,8 +2953,7 @@ public void clearNotificationListenersNotificationCenter() throws Exception { verify(activateNotification, never()) .onActivate(activatedExperiment, genericUserId, attributes, actualVariation, logEventToDispatch); - // Check if listener is notified after a live variable is accessed - boolean activateExperiment = true; + // Check if listener is notified after a feature variable is accessed verify(activateNotification, never()) .onActivate(activatedExperiment, genericUserId, attributes, actualVariation, logEventToDispatch); @@ -3133,7 +3131,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M //======== Feature Accessor Tests ========// /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null and logs a message * when it is called with a feature key that has no corresponding feature in the datafile. * @@ -3156,7 +3154,7 @@ public void getFeatureVariableValueForTypeReturnsNullWhenFeatureNotFound() throw invalidVariableKey, genericUserId, Collections.emptyMap(), - LiveVariable.VariableType.STRING); + FeatureVariable.VariableType.STRING); assertNull(value); value = optimizely.getFeatureVariableString(invalidFeatureKey, invalidVariableKey, genericUserId, attributes); @@ -3173,7 +3171,7 @@ public void getFeatureVariableValueForTypeReturnsNullWhenFeatureNotFound() throw } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null and logs a message * when the feature key is valid, but no variable could be found for the variable key in the feature. * @@ -3196,7 +3194,7 @@ public void getFeatureVariableValueForTypeReturnsNullWhenVariableNotFoundInValid invalidVariableKey, genericUserId, Collections.emptyMap(), - LiveVariable.VariableType.STRING); + FeatureVariable.VariableType.STRING); assertNull(value); logbackVerifier.expectMessage(Level.INFO, @@ -3211,7 +3209,7 @@ public void getFeatureVariableValueForTypeReturnsNullWhenVariableNotFoundInValid } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null when the variable's type does not match the type with which it was attempted to be accessed. * * @throws ConfigParseException @@ -3233,22 +3231,22 @@ public void getFeatureVariableValueReturnsNullWhenVariableTypeDoesNotMatch() thr validVariableKey, genericUserId, Collections.emptyMap(), - LiveVariable.VariableType.INTEGER + FeatureVariable.VariableType.INTEGER ); assertNull(value); logbackVerifier.expectMessage( Level.INFO, "The feature variable \"" + validVariableKey + - "\" is actually of type \"" + LiveVariable.VariableType.STRING.toString() + - "\" type. You tried to access it as type \"" + LiveVariable.VariableType.INTEGER.toString() + + "\" is actually of type \"" + FeatureVariable.VariableType.STRING.toString() + + "\" type. You tried to access it as type \"" + FeatureVariable.VariableType.INTEGER.toString() + "\". Please use the appropriate feature variable accessor." ); } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} - * returns the String default value of a live variable + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} + * returns the String default value of a feature variable * when the feature is not attached to an experiment or a rollout. * * @throws ConfigParseException @@ -3271,7 +3269,7 @@ public void getFeatureVariableValueForTypeReturnsDefaultValueWhenFeatureIsNotAtt validVariableKey, genericUserId, attributes, - LiveVariable.VariableType.BOOLEAN); + FeatureVariable.VariableType.BOOLEAN); assertEquals(defaultValue, value); logbackVerifier.expectMessage( @@ -3292,8 +3290,8 @@ public void getFeatureVariableValueForTypeReturnsDefaultValueWhenFeatureIsNotAtt } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} - * returns the String default value for a live variable + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} + * returns the String default value for a feature variable * when the feature is attached to an experiment and no rollout, but the user is excluded from the experiment. * * @throws ConfigParseException @@ -3317,7 +3315,7 @@ public void getFeatureVariableValueReturnsDefaultValueWhenFeatureIsAttachedToOne validVariableKey, genericUserId, Collections.singletonMap(ATTRIBUTE_HOUSE_KEY, "Ravenclaw"), - LiveVariable.VariableType.DOUBLE + FeatureVariable.VariableType.DOUBLE ); assertEquals(expectedValue, valueWithImproperAttributes); @@ -3340,7 +3338,7 @@ public void getFeatureVariableValueReturnsDefaultValueWhenFeatureIsAttachedToOne } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns the variable value of the variation the user is bucketed into * if the variation is not null and the variable has a usage within the variation. * @@ -3352,8 +3350,8 @@ public void getFeatureVariableValueReturnsVariationValueWhenUserGetsBucketedToVa String validFeatureKey = FEATURE_MULTI_VARIATE_FEATURE_KEY; String validVariableKey = VARIABLE_FIRST_LETTER_KEY; - LiveVariable variable = FEATURE_FLAG_MULTI_VARIATE_FEATURE.getVariableKeyToLiveVariableMap().get(validVariableKey); - String expectedValue = VARIATION_MULTIVARIATE_EXPERIMENT_GRED.getVariableIdToLiveVariableUsageInstanceMap().get(variable.getId()).getValue(); + FeatureVariable variable = FEATURE_FLAG_MULTI_VARIATE_FEATURE.getVariableKeyToFeatureVariableMap().get(validVariableKey); + String expectedValue = VARIATION_MULTIVARIATE_EXPERIMENT_GRED.getVariableIdToFeatureVariableUsageInstanceMap().get(variable.getId()).getValue(); Experiment multivariateExperiment = validProjectConfig.getExperimentKeyMapping().get(EXPERIMENT_MULTIVARIATE_EXPERIMENT_KEY); Optimizely optimizely = Optimizely.builder(validDatafile, mockEventHandler) @@ -3373,14 +3371,14 @@ public void getFeatureVariableValueReturnsVariationValueWhenUserGetsBucketedToVa validVariableKey, genericUserId, Collections.singletonMap(ATTRIBUTE_HOUSE_KEY, AUDIENCE_GRYFFINDOR_VALUE), - LiveVariable.VariableType.STRING + FeatureVariable.VariableType.STRING ); assertEquals(expectedValue, value); } /** - * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * Verify {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns the default value for the feature variable * when there is no variable usage present for the variation the user is bucketed into. * @@ -3392,7 +3390,7 @@ public void getFeatureVariableValueReturnsDefaultValueWhenNoVariationUsageIsPres String validFeatureKey = FEATURE_SINGLE_VARIABLE_INTEGER_KEY; String validVariableKey = VARIABLE_INTEGER_VARIABLE_KEY; - LiveVariable variable = FEATURE_FLAG_SINGLE_VARIABLE_INTEGER.getVariableKeyToLiveVariableMap().get(validVariableKey); + FeatureVariable variable = FEATURE_FLAG_SINGLE_VARIABLE_INTEGER.getVariableKeyToFeatureVariableMap().get(validVariableKey); String expectedValue = variable.getDefaultValue(); Optimizely optimizely = Optimizely.builder(validDatafile, mockEventHandler) @@ -3404,7 +3402,7 @@ public void getFeatureVariableValueReturnsDefaultValueWhenNoVariationUsageIsPres validVariableKey, genericUserId, Collections.emptyMap(), - LiveVariable.VariableType.INTEGER + FeatureVariable.VariableType.INTEGER ); assertEquals(expectedValue, value); @@ -4011,7 +4009,7 @@ public void getFeatureVariableStringReturnsNullWhenUserIdIsNull() throws ConfigP * Verify {@link Optimizely#getFeatureVariableString(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableString(String, String, String, Map)} * and returns null - * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null * * @throws ConfigParseException @@ -4030,7 +4028,7 @@ public void getFeatureVariableStringReturnsNullFromInternal() throws ConfigParse eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.STRING) + eq(FeatureVariable.VariableType.STRING) ); assertNull(spyOptimizely.getFeatureVariableString( @@ -4051,7 +4049,7 @@ public void getFeatureVariableStringReturnsNullFromInternal() throws ConfigParse * Verify {@link Optimizely#getFeatureVariableString(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableString(String, String, String, Map)} * and both return the value returned from - * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)}. + * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)}. * * @throws ConfigParseException */ @@ -4073,7 +4071,7 @@ public void getFeatureVariableStringReturnsWhatInternalReturns() throws ConfigPa eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.STRING) + eq(FeatureVariable.VariableType.STRING) ); doReturn(valueWithAttributes).when(spyOptimizely).getFeatureVariableValueForType( @@ -4081,7 +4079,7 @@ public void getFeatureVariableStringReturnsWhatInternalReturns() throws ConfigPa eq(variableKey), eq(genericUserId), eq(attributes), - eq(LiveVariable.VariableType.STRING) + eq(FeatureVariable.VariableType.STRING) ); assertEquals(valueNoAttributes, spyOptimizely.getFeatureVariableString( @@ -4216,7 +4214,7 @@ public void getFeatureVariableBooleanReturnsNullWhenUserIdIsNull() throws Config * Verify {@link Optimizely#getFeatureVariableBoolean(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableBoolean(String, String, String, Map)} * and returns null - * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null * * @throws ConfigParseException @@ -4235,7 +4233,7 @@ public void getFeatureVariableBooleanReturnsNullFromInternal() throws ConfigPars eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.BOOLEAN) + eq(FeatureVariable.VariableType.BOOLEAN) ); assertNull(spyOptimizely.getFeatureVariableBoolean( @@ -4256,7 +4254,7 @@ public void getFeatureVariableBooleanReturnsNullFromInternal() throws ConfigPars * Verify {@link Optimizely#getFeatureVariableBoolean(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableBoolean(String, String, String, Map)} * and both return a Boolean representation of the value returned from - * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)}. + * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)}. * * @throws ConfigParseException */ @@ -4278,7 +4276,7 @@ public void getFeatureVariableBooleanReturnsWhatInternalReturns() throws ConfigP eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.BOOLEAN) + eq(FeatureVariable.VariableType.BOOLEAN) ); doReturn(valueWithAttributes.toString()).when(spyOptimizely).getFeatureVariableValueForType( @@ -4286,7 +4284,7 @@ public void getFeatureVariableBooleanReturnsWhatInternalReturns() throws ConfigP eq(variableKey), eq(genericUserId), eq(attributes), - eq(LiveVariable.VariableType.BOOLEAN) + eq(FeatureVariable.VariableType.BOOLEAN) ); assertEquals(valueNoAttributes, spyOptimizely.getFeatureVariableBoolean( @@ -4314,7 +4312,7 @@ public void getFeatureVariableBooleanReturnsWhatInternalReturns() throws ConfigP * Verify {@link Optimizely#getFeatureVariableDouble(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableDouble(String, String, String, Map)} * and returns null - * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null * * @throws ConfigParseException @@ -4333,7 +4331,7 @@ public void getFeatureVariableDoubleReturnsNullFromInternal() throws ConfigParse eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.DOUBLE) + eq(FeatureVariable.VariableType.DOUBLE) ); assertNull(spyOptimizely.getFeatureVariableDouble( @@ -4354,7 +4352,7 @@ public void getFeatureVariableDoubleReturnsNullFromInternal() throws ConfigParse * Verify {@link Optimizely#getFeatureVariableDouble(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableDouble(String, String, String, Map)} * and both return the parsed Double from the value returned from - * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)}. + * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)}. * * @throws ConfigParseException */ @@ -4376,7 +4374,7 @@ public void getFeatureVariableDoubleReturnsWhatInternalReturns() throws ConfigPa eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.DOUBLE) + eq(FeatureVariable.VariableType.DOUBLE) ); doReturn(valueWithAttributes.toString()).when(spyOptimizely).getFeatureVariableValueForType( @@ -4384,7 +4382,7 @@ public void getFeatureVariableDoubleReturnsWhatInternalReturns() throws ConfigPa eq(variableKey), eq(genericUserId), eq(attributes), - eq(LiveVariable.VariableType.DOUBLE) + eq(FeatureVariable.VariableType.DOUBLE) ); assertEquals(valueNoAttributes, spyOptimizely.getFeatureVariableDouble( @@ -4412,7 +4410,7 @@ public void getFeatureVariableDoubleReturnsWhatInternalReturns() throws ConfigPa * Verify {@link Optimizely#getFeatureVariableInteger(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableInteger(String, String, String, Map)} * and returns null - * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)} + * when {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)} * returns null * * @throws ConfigParseException @@ -4431,7 +4429,7 @@ public void getFeatureVariableIntegerReturnsNullFromInternal() throws ConfigPars eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.INTEGER) + eq(FeatureVariable.VariableType.INTEGER) ); assertNull(spyOptimizely.getFeatureVariableInteger( @@ -4576,7 +4574,7 @@ public void getFeatureVariableDoubleCatchesExceptionFromParsing() throws ConfigP anyString(), anyString(), anyMapOf(String.class, String.class), - eq(LiveVariable.VariableType.DOUBLE) + eq(FeatureVariable.VariableType.DOUBLE) ); assertNull(spyOptimizely.getFeatureVariableDouble( @@ -4702,7 +4700,7 @@ public void getFeatureVariableIntegerReturnsNullWhenUserIdIsNull() throws Config * Verify {@link Optimizely#getFeatureVariableInteger(String, String, String)} * calls through to {@link Optimizely#getFeatureVariableInteger(String, String, String, Map)} * and both return the parsed Integer value from the value returned from - * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, LiveVariable.VariableType)}. + * {@link Optimizely#getFeatureVariableValueForType(String, String, String, Map, FeatureVariable.VariableType)}. * * @throws ConfigParseException */ @@ -4724,7 +4722,7 @@ public void getFeatureVariableIntegerReturnsWhatInternalReturns() throws ConfigP eq(variableKey), eq(genericUserId), eq(Collections.emptyMap()), - eq(LiveVariable.VariableType.INTEGER) + eq(FeatureVariable.VariableType.INTEGER) ); doReturn(valueWithAttributes.toString()).when(spyOptimizely).getFeatureVariableValueForType( @@ -4732,7 +4730,7 @@ public void getFeatureVariableIntegerReturnsWhatInternalReturns() throws ConfigP eq(variableKey), eq(genericUserId), eq(attributes), - eq(LiveVariable.VariableType.INTEGER) + eq(FeatureVariable.VariableType.INTEGER) ); assertEquals(valueNoAttributes, spyOptimizely.getFeatureVariableInteger( @@ -4778,7 +4776,7 @@ public void getFeatureVariableIntegerCatchesExceptionFromParsing() throws Config anyString(), anyString(), anyMapOf(String.class, String.class), - eq(LiveVariable.VariableType.INTEGER) + eq(FeatureVariable.VariableType.INTEGER) ); assertNull(spyOptimizely.getFeatureVariableInteger( @@ -4858,7 +4856,7 @@ private Experiment createUnknownExperiment() { Collections.emptyList(), null, Collections.singletonList( - new Variation("8765", "unknown_variation", Collections.emptyList())), + new Variation("8765", "unknown_variation", Collections.emptyList())), Collections.emptyMap(), Collections.singletonList(new TrafficAllocation("8765", 4999))); } diff --git a/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTest.java b/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTest.java index d10ec92c6..b35ba7aba 100644 --- a/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTest.java +++ b/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTest.java @@ -127,70 +127,6 @@ public void verifyGetAudienceFromInvalidId() throws Exception { assertNull(projectConfig.getAudience("invalid_id")); } - /** - * Asserts that getLiveVariableIdToExperimentsMapping returns a correct mapping between live variable IDs and - * corresponding experiments using these live variables. - */ - @Test - public void verifyGetLiveVariableIdToExperimentsMapping() throws Exception { - Experiment ungroupedExpWithVariables = projectConfig.getExperiments().get(0); - Experiment groupedExpWithVariables = projectConfig.getGroups().get(0).getExperiments().get(1); - - Map> expectedLiveVariableIdToExperimentsMapping = - new HashMap>(); - expectedLiveVariableIdToExperimentsMapping.put("6", Collections.singletonList(ungroupedExpWithVariables)); - expectedLiveVariableIdToExperimentsMapping.put("2", Collections.singletonList(ungroupedExpWithVariables)); - expectedLiveVariableIdToExperimentsMapping.put("3", Collections.singletonList(ungroupedExpWithVariables)); - expectedLiveVariableIdToExperimentsMapping.put("4", Collections.singletonList(ungroupedExpWithVariables)); - - expectedLiveVariableIdToExperimentsMapping.put("7", Collections.singletonList(groupedExpWithVariables)); - - assertThat(projectConfig.getLiveVariableIdToExperimentsMapping(), - is(expectedLiveVariableIdToExperimentsMapping)); - } - - /** - * Asserts that getVariationToLiveVariableUsageInstanceMapping returns a correct mapping between variation IDs and - * the values of the live variables for the variation. - */ - @Test - public void verifyGetVariationToLiveVariableUsageInstanceMapping() throws Exception { - Map> expectedVariationToLiveVariableUsageInstanceMapping = - new HashMap>(); - - Map ungroupedVariation276VariableValues = - new HashMap(); - ungroupedVariation276VariableValues.put("6", new LiveVariableUsageInstance("6", "True")); - ungroupedVariation276VariableValues.put("2", new LiveVariableUsageInstance("2", "10")); - ungroupedVariation276VariableValues.put("3", new LiveVariableUsageInstance("3", "string_var_vtag1")); - ungroupedVariation276VariableValues.put("4", new LiveVariableUsageInstance("4", "5.3")); - - - Map ungroupedVariation277VariableValues = - new HashMap(); - ungroupedVariation277VariableValues.put("6", new LiveVariableUsageInstance("6", "False")); - ungroupedVariation277VariableValues.put("2", new LiveVariableUsageInstance("2", "20")); - ungroupedVariation277VariableValues.put("3", new LiveVariableUsageInstance("3", "string_var_vtag2")); - ungroupedVariation277VariableValues.put("4", new LiveVariableUsageInstance("4", "6.3")); - - expectedVariationToLiveVariableUsageInstanceMapping.put("276", ungroupedVariation276VariableValues); - expectedVariationToLiveVariableUsageInstanceMapping.put("277", ungroupedVariation277VariableValues); - - Map groupedVariation280VariableValues = - new HashMap(); - groupedVariation280VariableValues.put("7", new LiveVariableUsageInstance("7", "True")); - - Map groupedVariation281VariableValues = - new HashMap(); - groupedVariation281VariableValues.put("7", new LiveVariableUsageInstance("7", "False")); - - expectedVariationToLiveVariableUsageInstanceMapping.put("280", groupedVariation280VariableValues); - expectedVariationToLiveVariableUsageInstanceMapping.put("281", groupedVariation281VariableValues); - - assertThat(projectConfig.getVariationToLiveVariableUsageInstanceMapping(), - is(expectedVariationToLiveVariableUsageInstanceMapping)); - } - /** * Asserts that anonymizeIP is set to false if not explicitly passed into the constructor (in the case of V2 * projects). diff --git a/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTestUtils.java b/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTestUtils.java index 8f5ac0470..c19f233f8 100644 --- a/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTestUtils.java +++ b/core-api/src/test/java/com/optimizely/ab/config/ProjectConfigTestUtils.java @@ -214,18 +214,18 @@ private static ProjectConfig generateNoAudienceProjectConfigV2() { private static final ProjectConfig VALID_PROJECT_CONFIG_V3 = generateValidProjectConfigV3(); private static ProjectConfig generateValidProjectConfigV3() { - List variationVtag1VariableUsageInstances = asList( - new LiveVariableUsageInstance("6", "True"), - new LiveVariableUsageInstance("2", "10"), - new LiveVariableUsageInstance("3", "string_var_vtag1"), - new LiveVariableUsageInstance("4", "5.3") + List variationVtag1VariableUsageInstances = asList( + new FeatureVariableUsageInstance("6", "True"), + new FeatureVariableUsageInstance("2", "10"), + new FeatureVariableUsageInstance("3", "string_var_vtag1"), + new FeatureVariableUsageInstance("4", "5.3") ); - List variationVtag2VariableUsageInstances = asList( - new LiveVariableUsageInstance("6", "False"), - new LiveVariableUsageInstance("2", "20"), - new LiveVariableUsageInstance("3", "string_var_vtag2"), - new LiveVariableUsageInstance("4", "6.3") + List variationVtag2VariableUsageInstances = asList( + new FeatureVariableUsageInstance("6", "False"), + new FeatureVariableUsageInstance("2", "20"), + new FeatureVariableUsageInstance("3", "string_var_vtag2"), + new FeatureVariableUsageInstance("4", "6.3") ); List experiments = asList( @@ -241,8 +241,8 @@ private static ProjectConfig generateValidProjectConfigV3() { new Experiment("118", "etag2", "Not started", "2", singletonList("100"), null, - asList(new Variation("278", "vtag3", Collections.emptyList()), - new Variation("279", "vtag4", Collections.emptyList())), + asList(new Variation("278", "vtag3", Collections.emptyList()), + new Variation("279", "vtag4", Collections.emptyList())), Collections.singletonMap("testUser3", "vtag3"), asList(new TrafficAllocation("278", 4500), new TrafficAllocation("279", 9000)), @@ -283,8 +283,8 @@ private static ProjectConfig generateValidProjectConfigV3() { new Experiment("301", "group_etag2", "Running", "3", singletonList("100"), null, - asList(new Variation("282", "e2_vtag1", Collections.emptyList()), - new Variation("283", "e2_vtag2", Collections.emptyList())), + asList(new Variation("282", "e2_vtag1", Collections.emptyList()), + new Variation("283", "e2_vtag2", Collections.emptyList())), Collections.emptyMap(), asList(new TrafficAllocation("282", 5000), new TrafficAllocation("283", 10000)), @@ -293,9 +293,9 @@ private static ProjectConfig generateValidProjectConfigV3() { singletonList("100"), null, asList(new Variation("280", "e1_vtag1", - Collections.singletonList(new LiveVariableUsageInstance("7", "True"))), + Collections.singletonList(new FeatureVariableUsageInstance("7", "True"))), new Variation("281", "e1_vtag2", - Collections.singletonList(new LiveVariableUsageInstance("7", "False")))), + Collections.singletonList(new FeatureVariableUsageInstance("7", "False")))), userIdToVariationKeyMap, asList(new TrafficAllocation("280", 3000), new TrafficAllocation("281", 10000)), @@ -306,8 +306,8 @@ private static ProjectConfig generateValidProjectConfigV3() { new Experiment("302", "overlapping_etag1", "Running", "5", singletonList("100"), null, - asList(new Variation("284", "e1_vtag1", Collections.emptyList()), - new Variation("285", "e1_vtag2", Collections.emptyList())), + asList(new Variation("284", "e1_vtag1", Collections.emptyList()), + new Variation("285", "e1_vtag2", Collections.emptyList())), userIdToVariationKeyMap, asList(new TrafficAllocation("284", 1500), new TrafficAllocation("285", 3000)), @@ -324,27 +324,8 @@ private static ProjectConfig generateValidProjectConfigV3() { Collections.emptyList()); List groups = asList(randomPolicyGroup, overlappingPolicyGroup); - List liveVariables = asList( - new LiveVariable("1", "boolean_variable", "False", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.BOOLEAN), - new LiveVariable("2", "integer_variable", "5", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.INTEGER), - new LiveVariable("3", "string_variable", "string_live_variable", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.STRING), - new LiveVariable("4", "double_variable", "13.37", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.DOUBLE), - new LiveVariable("5", "archived_variable", "True", LiveVariable.VariableStatus.ARCHIVED, - LiveVariable.VariableType.BOOLEAN), - new LiveVariable("6", "etag1_variable", "False", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.BOOLEAN), - new LiveVariable("7", "group_etag1_variable", "False", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.BOOLEAN), - new LiveVariable("8", "unused_string_variable", "unused_variable", LiveVariable.VariableStatus.ACTIVE, - LiveVariable.VariableType.STRING) - ); - return new ProjectConfig("789", "1234", "3", "42", groups, experiments, attributes, events, audiences, - true, liveVariables); + true); } private static final ProjectConfig NO_AUDIENCE_PROJECT_CONFIG_V3 = generateNoAudienceProjectConfigV3(); @@ -358,8 +339,8 @@ private static ProjectConfig generateNoAudienceProjectConfigV3() { new Experiment("223", "etag1", "Running", "1", Collections.emptyList(), null, - asList(new Variation("276", "vtag1", Collections.emptyList()), - new Variation("277", "vtag2", Collections.emptyList())), + asList(new Variation("276", "vtag1", Collections.emptyList()), + new Variation("277", "vtag2", Collections.emptyList())), userIdToVariationKeyMap, asList(new TrafficAllocation("276", 3500), new TrafficAllocation("277", 9000)), @@ -367,8 +348,8 @@ private static ProjectConfig generateNoAudienceProjectConfigV3() { new Experiment("118", "etag2", "Not started", "2", Collections.emptyList(), null, - asList(new Variation("278", "vtag3", Collections.emptyList()), - new Variation("279", "vtag4", Collections.emptyList())), + asList(new Variation("278", "vtag3", Collections.emptyList()), + new Variation("279", "vtag4", Collections.emptyList())), Collections.emptyMap(), asList(new TrafficAllocation("278", 4500), new TrafficAllocation("279", 9000)), @@ -397,7 +378,7 @@ private static ProjectConfig generateNoAudienceProjectConfigV3() { ); return new ProjectConfig("789", "1234", "3", "42", Collections.emptyList(), experiments, attributes, - events, Collections.emptyList(), true, Collections.emptyList()); + events, Collections.emptyList(), true); } private static final ProjectConfig VALID_PROJECT_CONFIG_V4 = generateValidProjectConfigV4(); @@ -490,7 +471,6 @@ public static void verifyProjectConfig(@CheckForNull ProjectConfig actual, @Nonn verifyEvents(actual.getEventTypes(), expected.getEventTypes()); verifyExperiments(actual.getExperiments(), expected.getExperiments()); verifyFeatureFlags(actual.getFeatureFlags(), expected.getFeatureFlags()); - verifyLiveVariables(actual.getLiveVariables(), expected.getLiveVariables()); verifyGroups(actual.getGroups(), expected.getGroups()); verifyRollouts(actual.getRollouts(), expected.getRollouts()); } @@ -542,8 +522,8 @@ private static void verifyVariations(List actual, List exp assertThat(actualVariation.getId(), is(expectedVariation.getId())); assertThat(actualVariation.getKey(), is(expectedVariation.getKey())); - verifyLiveVariableInstances(actualVariation.getLiveVariableUsageInstances(), - expectedVariation.getLiveVariableUsageInstances()); + verifyFeatureVariableInstances(actualVariation.getFeatureVariableUsageInstances(), + expectedVariation.getFeatureVariableUsageInstances()); } } @@ -630,29 +610,6 @@ private static void verifyGroups(List actual, List expected) { } } - /** - * Verify that the provided live variable definitions are equivalent. - */ - private static void verifyLiveVariables(List actual, List expected) { - // if using V2, live variables will be null - if (expected == null) { - assertNull(actual); - } else { - assertThat(actual.size(), is(expected.size())); - - for (int i = 0; i < actual.size(); i++) { - LiveVariable actualLiveVariable = actual.get(i); - LiveVariable expectedLiveVariable = expected.get(i); - - assertThat(actualLiveVariable.getId(), is(expectedLiveVariable.getId())); - assertThat(actualLiveVariable.getKey(), is(expectedLiveVariable.getKey())); - assertThat(actualLiveVariable.getDefaultValue(), is(expectedLiveVariable.getDefaultValue())); - assertThat(actualLiveVariable.getType(), is(expectedLiveVariable.getType())); - assertThat(actualLiveVariable.getStatus(), is(expectedLiveVariable.getStatus())); - } - } - } - private static void verifyRollouts(List actual, List expected) { if (expected == null) { assertNull(actual); @@ -670,22 +627,22 @@ private static void verifyRollouts(List actual, List expected) } /** - * Verify that the provided variation-level live variable usage instances are equivalent. + * Verify that the provided variation-level feature variable usage instances are equivalent. */ - private static void verifyLiveVariableInstances(List actual, - List expected) { - // if using V2, live variable instances will be null + private static void verifyFeatureVariableInstances(List actual, + List expected) { + // if using V2, feature variable instances will be null if (expected == null) { assertNull(actual); } else { assertThat(actual.size(), is(expected.size())); for (int i = 0; i < actual.size(); i++) { - LiveVariableUsageInstance actualLiveVariableUsageInstance = actual.get(i); - LiveVariableUsageInstance expectedLiveVariableUsageInstance = expected.get(i); + FeatureVariableUsageInstance actualFeatureVariableUsageInstance = actual.get(i); + FeatureVariableUsageInstance expectedFeatureVariableUsageInstance = expected.get(i); - assertThat(actualLiveVariableUsageInstance.getId(), is(expectedLiveVariableUsageInstance.getId())); - assertThat(actualLiveVariableUsageInstance.getValue(), is(expectedLiveVariableUsageInstance.getValue())); + assertThat(actualFeatureVariableUsageInstance.getId(), is(expectedFeatureVariableUsageInstance.getId())); + assertThat(actualFeatureVariableUsageInstance.getValue(), is(expectedFeatureVariableUsageInstance.getValue())); } } } diff --git a/core-api/src/test/java/com/optimizely/ab/config/ValidProjectConfigV4.java b/core-api/src/test/java/com/optimizely/ab/config/ValidProjectConfigV4.java index bb5785495..7dec888b6 100644 --- a/core-api/src/test/java/com/optimizely/ab/config/ValidProjectConfigV4.java +++ b/core-api/src/test/java/com/optimizely/ab/config/ValidProjectConfigV4.java @@ -235,43 +235,43 @@ public class ValidProjectConfigV4 { FEATURE_BOOLEAN_FEATURE_KEY, "", Collections.emptyList(), - Collections.emptyList() + Collections.emptyList() ); private static final String FEATURE_SINGLE_VARIABLE_DOUBLE_ID = "3926744821"; public static final String FEATURE_SINGLE_VARIABLE_DOUBLE_KEY = "double_single_variable_feature"; private static final String VARIABLE_DOUBLE_VARIABLE_ID = "4111654444"; public static final String VARIABLE_DOUBLE_VARIABLE_KEY = "double_variable"; public static final String VARIABLE_DOUBLE_DEFAULT_VALUE = "14.99"; - private static final LiveVariable VARIABLE_DOUBLE_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_DOUBLE_VARIABLE = new FeatureVariable( VARIABLE_DOUBLE_VARIABLE_ID, VARIABLE_DOUBLE_VARIABLE_KEY, VARIABLE_DOUBLE_DEFAULT_VALUE, null, - LiveVariable.VariableType.DOUBLE + FeatureVariable.VariableType.DOUBLE ); private static final String FEATURE_SINGLE_VARIABLE_INTEGER_ID = "3281420120"; public static final String FEATURE_SINGLE_VARIABLE_INTEGER_KEY = "integer_single_variable_feature"; private static final String VARIABLE_INTEGER_VARIABLE_ID = "593964691"; public static final String VARIABLE_INTEGER_VARIABLE_KEY = "integer_variable"; private static final String VARIABLE_INTEGER_DEFAULT_VALUE = "7"; - private static final LiveVariable VARIABLE_INTEGER_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_INTEGER_VARIABLE = new FeatureVariable( VARIABLE_INTEGER_VARIABLE_ID, VARIABLE_INTEGER_VARIABLE_KEY, VARIABLE_INTEGER_DEFAULT_VALUE, null, - LiveVariable.VariableType.INTEGER + FeatureVariable.VariableType.INTEGER ); private static final String FEATURE_SINGLE_VARIABLE_BOOLEAN_ID = "2591051011"; public static final String FEATURE_SINGLE_VARIABLE_BOOLEAN_KEY = "boolean_single_variable_feature"; private static final String VARIABLE_BOOLEAN_VARIABLE_ID = "3974680341"; public static final String VARIABLE_BOOLEAN_VARIABLE_KEY = "boolean_variable"; public static final String VARIABLE_BOOLEAN_VARIABLE_DEFAULT_VALUE = "true"; - private static final LiveVariable VARIABLE_BOOLEAN_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_BOOLEAN_VARIABLE = new FeatureVariable( VARIABLE_BOOLEAN_VARIABLE_ID, VARIABLE_BOOLEAN_VARIABLE_KEY, VARIABLE_BOOLEAN_VARIABLE_DEFAULT_VALUE, null, - LiveVariable.VariableType.BOOLEAN + FeatureVariable.VariableType.BOOLEAN ); private static final FeatureFlag FEATURE_FLAG_SINGLE_VARIABLE_BOOLEAN = new FeatureFlag( FEATURE_SINGLE_VARIABLE_BOOLEAN_ID, @@ -287,12 +287,12 @@ public class ValidProjectConfigV4 { private static final String VARIABLE_STRING_VARIABLE_ID = "2077511132"; public static final String VARIABLE_STRING_VARIABLE_KEY = "string_variable"; public static final String VARIABLE_STRING_VARIABLE_DEFAULT_VALUE = "wingardium leviosa"; - private static final LiveVariable VARIABLE_STRING_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_STRING_VARIABLE = new FeatureVariable( VARIABLE_STRING_VARIABLE_ID, VARIABLE_STRING_VARIABLE_KEY, VARIABLE_STRING_VARIABLE_DEFAULT_VALUE, null, - LiveVariable.VariableType.STRING + FeatureVariable.VariableType.STRING ); private static final String ROLLOUT_1_ID = "1058508303"; private static final String ROLLOUT_1_EVERYONE_ELSE_EXPERIMENT_ID = "1785077004"; @@ -304,7 +304,7 @@ public class ValidProjectConfigV4 { ROLLOUT_1_EVERYONE_ELSE_RULE_ENABLED_VARIATION_ID, ROLLOUT_1_FEATURE_ENABLED_VALUE, Collections.singletonList( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_STRING_VARIABLE_ID, ROLLOUT_1_EVERYONE_ELSE_RULE_ENABLED_VARIATION_STRING_VALUE ) @@ -351,7 +351,7 @@ public class ValidProjectConfigV4 { ROLLOUT_3_EVERYONE_ELSE_RULE_ENABLED_VARIATION_ID, ROLLOUT_3_EVERYONE_ELSE_RULE_ENABLED_VARIATION_ID, ROLLOUT_3_FEATURE_ENABLED_VALUE, - Collections.emptyList() + Collections.emptyList() ); public static final Experiment ROLLOUT_3_EVERYONE_ELSE_RULE = new Experiment( ROLLOUT_3_EVERYONE_ELSE_EXPERIMENT_ID, @@ -383,34 +383,34 @@ public class ValidProjectConfigV4 { private static final String VARIABLE_FIRST_LETTER_ID = "675244127"; public static final String VARIABLE_FIRST_LETTER_KEY = "first_letter"; public static final String VARIABLE_FIRST_LETTER_DEFAULT_VALUE = "H"; - private static final LiveVariable VARIABLE_FIRST_LETTER_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_FIRST_LETTER_VARIABLE = new FeatureVariable( VARIABLE_FIRST_LETTER_ID, VARIABLE_FIRST_LETTER_KEY, VARIABLE_FIRST_LETTER_DEFAULT_VALUE, null, - LiveVariable.VariableType.STRING + FeatureVariable.VariableType.STRING ); private static final String VARIABLE_REST_OF_NAME_ID = "4052219963"; private static final String VARIABLE_REST_OF_NAME_KEY = "rest_of_name"; private static final String VARIABLE_REST_OF_NAME_DEFAULT_VALUE = "arry"; - private static final LiveVariable VARIABLE_REST_OF_NAME_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_REST_OF_NAME_VARIABLE = new FeatureVariable( VARIABLE_REST_OF_NAME_ID, VARIABLE_REST_OF_NAME_KEY, VARIABLE_REST_OF_NAME_DEFAULT_VALUE, null, - LiveVariable.VariableType.STRING + FeatureVariable.VariableType.STRING ); private static final String FEATURE_MUTEX_GROUP_FEATURE_ID = "3263342226"; public static final String FEATURE_MUTEX_GROUP_FEATURE_KEY = "mutex_group_feature"; private static final String VARIABLE_CORRELATING_VARIATION_NAME_ID = "2059187672"; private static final String VARIABLE_CORRELATING_VARIATION_NAME_KEY = "correlating_variation_name"; private static final String VARIABLE_CORRELATING_VARIATION_NAME_DEFAULT_VALUE = "null"; - private static final LiveVariable VARIABLE_CORRELATING_VARIATION_NAME_VARIABLE = new LiveVariable( + private static final FeatureVariable VARIABLE_CORRELATING_VARIATION_NAME_VARIABLE = new FeatureVariable( VARIABLE_CORRELATING_VARIATION_NAME_ID, VARIABLE_CORRELATING_VARIATION_NAME_KEY, VARIABLE_CORRELATING_VARIATION_NAME_DEFAULT_VALUE, null, - LiveVariable.VariableType.STRING + FeatureVariable.VariableType.STRING ); // group IDs @@ -426,14 +426,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_BASIC_EXPERIMENT_VARIATION_A = new Variation( VARIATION_BASIC_EXPERIMENT_VARIATION_A_ID, VARIATION_BASIC_EXPERIMENT_VARIATION_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_BASIC_EXPERIMENT_VARIATION_B_ID = "3433458314"; private static final String VARIATION_BASIC_EXPERIMENT_VARIATION_B_KEY = "B"; private static final Variation VARIATION_BASIC_EXPERIMENT_VARIATION_B = new Variation( VARIATION_BASIC_EXPERIMENT_VARIATION_B_ID, VARIATION_BASIC_EXPERIMENT_VARIATION_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String BASIC_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_A = "Harry Potter"; private static final String BASIC_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_B = "Tom Riddle"; @@ -477,14 +477,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_A = new Variation( VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_A_ID, VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_B_ID = "3433458315"; private static final String VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_B_KEY = "B"; private static final Variation VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_B = new Variation( VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_B_ID, VARIATION_TYPEDAUDIENCE_EXPERIMENT_VARIATION_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final Experiment EXPERIMENT_TYPEDAUDIENCE_EXPERIMENT = new Experiment( @@ -523,14 +523,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_A = new Variation( VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_A_ID, VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_B_ID = "3433458316"; private static final String VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_B_KEY = "B"; private static final Variation VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_B = new Variation( VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_B_ID, VARIATION_TYPEDAUDIENCE_WITH_AND_EXPERIMENT_VARIATION_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final Experiment EXPERIMENT_TYPEDAUDIENCE_WITH_AND_EXPERIMENT = new Experiment( @@ -568,14 +568,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_A = new Variation( VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_A_ID, VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_B_ID = "3433458317"; private static final String VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_B_KEY = "B"; private static final Variation VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_B = new Variation( VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_B_ID, VARIATION_TYPEDAUDIENCE_LEAF_EXPERIMENT_VARIATION_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final Experiment EXPERIMENT_TYPEDAUDIENCE_LEAF_EXPERIMENT = new Experiment( @@ -609,14 +609,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_FIRST_GROUPED_EXPERIMENT_A = new Variation( VARIATION_FIRST_GROUPED_EXPERIMENT_A_ID, VARIATION_FIRST_GROUPED_EXPERIMENT_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_FIRST_GROUPED_EXPERIMENT_B_ID = "1179171250"; private static final String VARIATION_FIRST_GROUPED_EXPERIMENT_B_KEY = "B"; private static final Variation VARIATION_FIRST_GROUPED_EXPERIMENT_B = new Variation( VARIATION_FIRST_GROUPED_EXPERIMENT_B_ID, VARIATION_FIRST_GROUPED_EXPERIMENT_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String FIRST_GROUPED_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_A = "Harry Potter"; private static final String FIRST_GROUPED_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_B = "Tom Riddle"; @@ -661,14 +661,14 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_SECOND_GROUPED_EXPERIMENT_A = new Variation( VARIATION_SECOND_GROUPED_EXPERIMENT_A_ID, VARIATION_SECOND_GROUPED_EXPERIMENT_A_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String VARIATION_SECOND_GROUPED_EXPERIMENT_B_ID = "2142748370"; private static final String VARIATION_SECOND_GROUPED_EXPERIMENT_B_KEY = "B"; private static final Variation VARIATION_SECOND_GROUPED_EXPERIMENT_B = new Variation( VARIATION_SECOND_GROUPED_EXPERIMENT_B_ID, VARIATION_SECOND_GROUPED_EXPERIMENT_B_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final String SECOND_GROUPED_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_A = "Hermione Granger"; private static final String SECOND_GROUPED_EXPERIMENT_FORCED_VARIATION_USER_ID_VARIATION_B = "Ronald Weasley"; @@ -716,11 +716,11 @@ public class ValidProjectConfigV4 { VARIATION_MULTIVARIATE_EXPERIMENT_FRED_KEY, VARIATION_MULTIVARIATE_FEATURE_ENABLED_VALUE, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_FIRST_LETTER_ID, "F" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_REST_OF_NAME_ID, "red" ) @@ -733,11 +733,11 @@ public class ValidProjectConfigV4 { VARIATION_MULTIVARIATE_EXPERIMENT_FEORGE_KEY, VARIATION_MULTIVARIATE_FEATURE_ENABLED_VALUE, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_FIRST_LETTER_ID, "F" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_REST_OF_NAME_ID, "eorge" ) @@ -751,11 +751,11 @@ public class ValidProjectConfigV4 { VARIATION_MULTIVARIATE_EXPERIMENT_GRED_KEY, VARIATION_MULTIVARIATE_VARIATION_FEATURE_ENABLED_GRED_KEY, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_FIRST_LETTER_ID, "G" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_REST_OF_NAME_ID, "red" ) @@ -768,11 +768,11 @@ public class ValidProjectConfigV4 { VARIATION_MULTIVARIATE_EXPERIMENT_GEORGE_KEY, VARIATION_MULTIVARIATE_FEATURE_ENABLED_VALUE, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_FIRST_LETTER_ID, "G" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_REST_OF_NAME_ID, "eorge" ) @@ -840,7 +840,7 @@ public class ValidProjectConfigV4 { VARIATION_DOUBLE_FEATURE_PI_VARIATION_KEY, VARIATION_DOUBLE_FEATURE_ENABLED_VALUE, Collections.singletonList( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_DOUBLE_VARIABLE_ID, "3.14" ) @@ -852,7 +852,7 @@ public class ValidProjectConfigV4 { VARIATION_DOUBLE_FEATURE_EULER_VARIATION_ID, VARIATION_DOUBLE_FEATURE_EULER_VARIATION_KEY, Collections.singletonList( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_DOUBLE_VARIABLE_ID, "2.718" ) @@ -890,7 +890,7 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_PAUSED_EXPERIMENT_CONTROL = new Variation( VARIATION_PAUSED_EXPERIMENT_CONTROL_ID, VARIATION_PAUSED_EXPERIMENT_CONTROL_KEY, - Collections.emptyList() + Collections.emptyList() ); public static final String PAUSED_EXPERIMENT_FORCED_VARIATION_USER_ID_CONTROL = "Harry Potter"; private static final Experiment EXPERIMENT_PAUSED_EXPERIMENT = new Experiment( @@ -918,7 +918,7 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_LAUNCHED_EXPERIMENT_CONTROL = new Variation( VARIATION_LAUNCHED_EXPERIMENT_CONTROL_ID, VARIATION_LAUNCHED_EXPERIMENT_CONTROL_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final Experiment EXPERIMENT_LAUNCHED_EXPERIMENT = new Experiment( EXPERIMENT_LAUNCHED_EXPERIMENT_ID, @@ -947,7 +947,7 @@ public class ValidProjectConfigV4 { VARIATION_MUTEX_GROUP_EXP_1_VAR_1_KEY, VARIATION_MUTEX_GROUP_EXP_FEATURE_ENABLED_VALUE, Collections.singletonList( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_CORRELATING_VARIATION_NAME_ID, VARIATION_MUTEX_GROUP_EXP_1_VAR_1_KEY ) @@ -981,7 +981,7 @@ public class ValidProjectConfigV4 { VARIATION_MUTEX_GROUP_EXP_2_VAR_1_KEY, VARIATION_MUTEX_GROUP_EXP_2_FEATURE_ENABLED_VALUE, Collections.singletonList( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( VARIABLE_CORRELATING_VARIATION_NAME_ID, VARIATION_MUTEX_GROUP_EXP_2_VAR_1_KEY ) @@ -1013,7 +1013,7 @@ public class ValidProjectConfigV4 { private static final Variation VARIATION_EXPERIMENT_WITH_MALFORMED_AUDIENCE = new Variation( VARIATION_EXPERIMENT_WITH_MALFORMED_AUDIENCE_ID, VARIATION_EXPERIMENT_WITH_MALFORMED_AUDIENCE_KEY, - Collections.emptyList() + Collections.emptyList() ); private static final Experiment EXPERIMENT_WITH_MALFORMED_AUDIENCE = new Experiment( EXPERIMENT_WITH_MALFORMED_AUDIENCE_ID, @@ -1118,11 +1118,11 @@ public class ValidProjectConfigV4 { "521740985", true, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "675244127", "G" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "4052219963", "odric" ) @@ -1150,11 +1150,11 @@ public class ValidProjectConfigV4 { "180042646", true, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "675244127", "S" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "4052219963", "alazar" ) @@ -1182,11 +1182,11 @@ public class ValidProjectConfigV4 { "2346257680", true, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "675244127", "D" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "4052219963", "udley" ) @@ -1214,11 +1214,11 @@ public class ValidProjectConfigV4 { "3137445031", true, ProjectConfigTestUtils.createListOfObjects( - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "675244127", "M" ), - new LiveVariableUsageInstance( + new FeatureVariableUsageInstance( "4052219963", "uggle" ) @@ -1368,7 +1368,6 @@ public static ProjectConfig generateValidProjectConfigV4() { experiments, featureFlags, groups, - Collections.emptyList(), rollouts ); } diff --git a/core-api/src/test/resources/config/no-audience-project-config-v3.json b/core-api/src/test/resources/config/no-audience-project-config-v3.json index 713b84017..c203fa5c9 100644 --- a/core-api/src/test/resources/config/no-audience-project-config-v3.json +++ b/core-api/src/test/resources/config/no-audience-project-config-v3.json @@ -125,6 +125,5 @@ "223" ] } - ], - "variables": [] -} \ No newline at end of file + ] +} diff --git a/core-api/src/test/resources/config/null-featureEnabled-config-v4.json b/core-api/src/test/resources/config/null-featureEnabled-config-v4.json index 85d385a5a..27f664c06 100644 --- a/core-api/src/test/resources/config/null-featureEnabled-config-v4.json +++ b/core-api/src/test/resources/config/null-featureEnabled-config-v4.json @@ -32,7 +32,6 @@ "typedAudiences": [], "anonymizeIP": true, "projectId": "13135560574", - "variables": [], "featureFlags": [ { "experimentIds": [ diff --git a/core-api/src/test/resources/config/valid-project-config-v3.json b/core-api/src/test/resources/config/valid-project-config-v3.json index 03893be76..2ed605d50 100644 --- a/core-api/src/test/resources/config/valid-project-config-v3.json +++ b/core-api/src/test/resources/config/valid-project-config-v3.json @@ -240,63 +240,5 @@ "118" ] } - ], - "variables": [ - { - "id": "1", - "key": "boolean_variable", - "type": "boolean", - "defaultValue": "False", - "status": "active" - }, - { - "id": "2", - "key": "integer_variable", - "type": "integer", - "defaultValue": "5", - "status": "active" - }, - { - "id": "3", - "key": "string_variable", - "type": "string", - "defaultValue": "string_live_variable", - "status": "active" - }, - { - "id": "4", - "key": "double_variable", - "type": "double", - "defaultValue": "13.37", - "status": "active" - }, - { - "id": "5", - "key": "archived_variable", - "type": "boolean", - "defaultValue": "True", - "status": "archived" - }, - { - "id": "6", - "key": "etag1_variable", - "type": "boolean", - "defaultValue": "False", - "status": "active" - }, - { - "id": "7", - "key": "group_etag1_variable", - "type": "boolean", - "defaultValue": "False", - "status": "active" - }, - { - "id": "8", - "key": "unused_string_variable", - "type": "string", - "defaultValue": "unused_variable", - "status": "active" - } ] -} \ No newline at end of file +} diff --git a/core-api/src/test/resources/config/valid-project-config-v4.json b/core-api/src/test/resources/config/valid-project-config-v4.json index 993771652..4f58f4c66 100644 --- a/core-api/src/test/resources/config/valid-project-config-v4.json +++ b/core-api/src/test/resources/config/valid-project-config-v4.json @@ -900,6 +900,5 @@ } ] } - ], - "variables": [] + ] }