diff --git a/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt b/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt index 600af47..1c81bd2 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt @@ -383,7 +383,7 @@ fun FeaturevisorInstance.evaluateFlag(featureKey: FeatureKey, context: Context = } // treated as enabled because of matched traffic - if (bucketValue < matchedTraffic.percentage) { + if (bucketValue <= matchedTraffic.percentage) { // @TODO: verify if range check should be inclusive or not evaluation = Evaluation( featureKey = feature.key, diff --git a/src/main/kotlin/com/featurevisor/sdk/Instance+Feature.kt b/src/main/kotlin/com/featurevisor/sdk/Instance+Feature.kt index bc766d0..46cd705 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Instance+Feature.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Instance+Feature.kt @@ -11,6 +11,10 @@ fun FeaturevisorInstance.getFeatureByKey(featureKey: String): Feature? { return datafileReader.getFeature(featureKey) } +fun FeaturevisorInstance.getFeature(featureKey: String): Feature?{ + return datafileReader.getFeature(featureKey) +} + internal fun FeaturevisorInstance.findForceFromFeature( feature: Feature, context: Context, diff --git a/src/main/kotlin/com/featurevisor/types/Types.kt b/src/main/kotlin/com/featurevisor/types/Types.kt index e7e5ca1..870316a 100644 --- a/src/main/kotlin/com/featurevisor/types/Types.kt +++ b/src/main/kotlin/com/featurevisor/types/Types.kt @@ -50,14 +50,14 @@ data class VariableOverride( // one of the below must be present in YAML val conditions: Condition? = null, - val segments: GroupSegment?, + val segments: GroupSegment?=null, ) @Serializable data class Variable( val key: VariableKey, val value: VariableValue, - val overrides: List?, + val overrides: List? = null, ) @Serializable @@ -68,9 +68,9 @@ data class Variation( val value: VariationValue, // 0 to 100 (available from parsed YAML, but not in datafile) - val weight: Double?, + val weight: Double? = null, - val variables: List?, + val variables: List? = null, ) @Serializable @@ -97,7 +97,7 @@ data class Force( data class Slot( // @TODO: allow false? - val feature: FeatureKey?, + val feature: FeatureKey? = null, // 0 to 100 val percentage: Weight, @@ -128,15 +128,15 @@ data class Rule( val segments: GroupSegment, val percentage: Weight, - val enabled: Boolean?, - val variation: VariationValue?, - val variables: VariableValues?, + val enabled: Boolean? = null, + val variation: VariationValue? = null, + val variables: VariableValues? = null, ) data class Environment( - val expose: Boolean?, + val expose: Boolean? = null, val rules: List, - val force: List?, + val force: List? = null, ) typealias Environments = Map diff --git a/src/test/kotlin/com/featurevisor/sdk/serializers/ConditionSerializerTest.kt b/src/test/kotlin/com/featurevisor/sdk/serializers/ConditionSerializerTest.kt index d1124d9..808b969 100644 --- a/src/test/kotlin/com/featurevisor/sdk/serializers/ConditionSerializerTest.kt +++ b/src/test/kotlin/com/featurevisor/sdk/serializers/ConditionSerializerTest.kt @@ -39,7 +39,7 @@ class ConditionSerializerTest { "value": "1.2.3" }, { "attribute": "age", - "operator": "greaterThanOrEqual", + "operator": "greaterThanOrEquals", "value": "18" }] } @@ -70,7 +70,7 @@ class ConditionSerializerTest { "value": "1.2.3" }, { "attribute": "age", - "operator": "greaterThanOrEqual", + "operator": "greaterThanOrEquals", "value": "18" }] }