Skip to content

Commit

Permalink
Config v6 (#43)
Browse files Browse the repository at this point in the history
* SDKKey validation update to handle proxy and new format

* Comparators rework

Added Comparator enum

Removed:IS ONE OF, IS NOT ONE OF
Changed: CONTAINS, DOES_NOT_CONTAIN
Added: DATE_BEFORE, DATE_AFTER, HASHED_EQUALS, HASHED_NOT_EQUALS, HASHED_STARTS_WITH, HASHED_ENDS_WITH, HASHED_ARRAY_CONTAINS, HASHED_ARRAY_NOT_CONTAINS

* Fix logMatch for date comparator

* Fix comparators names

* Updated const to config_v6

* Small fixes in comparators name

* v6 model added, evaluation and tests updated

* Implement evaluatePrerequisiteFlagCondition and added v6 tests

* Fix comparator and other errors

* Added segments impl and test

* Rename ComparisonCondition to UserCondition

* Add logs

* Evaluation logs and test added

* Small fixes

* Remove TODOs

* Code Format

* EvaluationLogger run based on loglevel

* V5 and v6 sdk keys updated

* EvaluationLoggerTurnOffTest update with LogLevel checks

* User attributeValueFrom helper methods added with test.

* Add some javadoc

* Fix test error after merge

* Fix list truncation

* Bug and code smell fixes

* Add text comparators and update test. Update config model.

* Segment tests and evaluation update.

* Unicode test and fix

* Remove unnecessary byte array copy

* Code format

* Code smell fixes

* Add ConditionAccessor interface to make evaluateConditions method more readable.

* Update circular dependency check to throw error.
Add target rule and percentage test.
Update User to handle Object custom values.

* Reformat Code

* Update proguard

* Small fix and add missing test

* Rename Comparator to UserComparator
Fix User toString and attribute override
Fix NaN skip and added missing test (byte, short) to UserAttributeConverterTest

* evaluateConditions default result set to true.
Add validateReturnType.
Fix getKeyAndValueFromSettingMap method to handel targetingRule's percentageOptions as well

* Update 1103 error message

* Update evaluateHashedStartOrEndsWith

* Fix circularDependency missing remove

* Trim and UserCondition evaluator method updated based on reviews.

* Added specialCharacters test.
Added returnType tests.
Added trim tests.

* Set ConditionAccessor.java to package-private.
Rename ServedValue to SimpleValue.
Update JavaDoc.

* Reformat Code

* Update ci java version to 17.

* Update version to 10.0.0

* Fixes based on code review.

* Fix prerequisiteFlagOverrideTest test cases.

* Fix typo in test name.
  • Loading branch information
novalisdenahi authored Jan 29, 2024
1 parent 300ec89 commit 12723e8
Show file tree
Hide file tree
Showing 135 changed files with 6,404 additions and 858 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: zulu

- name: Cache SonarCloud packages
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ dependencies {
api 'de.skuzzle:semantic-version:2.1.1'
testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version:"5.8.0"
testImplementation group: "org.junit.jupiter", name: "junit-jupiter-params", version:"5.8.0"
testImplementation group: "org.slf4j", name: "slf4j-simple", version:"1.7.25"
testImplementation 'ch.qos.logback:logback-classic:1.3.11'
testImplementation 'ch.qos.logback:logback-core:1.3.11'
testImplementation group: "com.squareup.okhttp3", name: "mockwebserver", version:"4.11.0"
testImplementation 'org.mockito:mockito-core:4.8.0'
testImplementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.4'
Expand Down
12 changes: 10 additions & 2 deletions configcat-proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
-keep class com.configcat.Config { *; }
-keep class com.configcat.Preferences { *; }
-keep class com.configcat.Setting { *; }
-keep class com.configcat.RolloutRule { *; }
-keep class com.configcat.PercentageRule { *; }
-keep class com.configcat.SettingType { *; }
-keep class com.configcat.EvaluationDetails { *; }
-keep class com.configcat.TargetingRule { *; }
-keep class com.configcat.SettingType { *; }
-keep class com.configcat.SettingsValue { *; }
-keep class com.configcat.Segment { *; }
-keep class com.configcat.Condition { *; }
-keep class com.configcat.SimpleValue { *; }
-keep class com.configcat.Condition { *; }
-keep class com.configcat.UserCondition { *; }
-keep class com.configcat.SegmentCondition { *; }
-keep class com.configcat.PrerequisiteFlagCondition { *; }
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=9.1.1
version=10.0.0

org.gradle.jvmargs=-Xmx2g
31 changes: 31 additions & 0 deletions src/main/java/com/configcat/Condition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.configcat;

import com.google.gson.annotations.SerializedName;

/**
* Represents a condition.
*/
public class Condition implements ConditionAccessor {

@SerializedName(value = "u")
private UserCondition userCondition;
@SerializedName(value = "s")
private SegmentCondition segmentCondition;
@SerializedName(value = "p")
private PrerequisiteFlagCondition prerequisiteFlagCondition;

@Override
public UserCondition getUserCondition() {
return userCondition;
}

@Override
public SegmentCondition getSegmentCondition() {
return segmentCondition;
}

@Override
public PrerequisiteFlagCondition getPrerequisiteFlagCondition() {
return prerequisiteFlagCondition;
}
}
9 changes: 9 additions & 0 deletions src/main/java/com/configcat/ConditionAccessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.configcat;

interface ConditionAccessor {
UserCondition getUserCondition();

SegmentCondition getSegmentCondition();

PrerequisiteFlagCondition getPrerequisiteFlagCondition();
}
46 changes: 46 additions & 0 deletions src/main/java/com/configcat/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.configcat;

import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.Map;

/**
* Details of a ConfigCat config.
*/
public class Config {

@SerializedName(value = "p")
private Preferences preferences;
@SerializedName(value = "f")
private final Map<String, Setting> entries = new HashMap<>();
@SerializedName(value = "s")
private Segment[] segments;

/**
* The config preferences.
*/
public Preferences getPreferences() {
return preferences;
}

/**
* The list of segments.
*/
public Segment[] getSegments() {
return segments;
}

/**
* The map of settings.
*/
public Map<String, Setting> getEntries() {
return entries;
}

boolean isEmpty() {
return EMPTY.equals(this);
}

public static final Config EMPTY = new Config();
}
Loading

0 comments on commit 12723e8

Please sign in to comment.