diff --git a/client/src/main/java/io/split/client/api/SplitView.java b/client/src/main/java/io/split/client/api/SplitView.java index b9ba3fbc..0043f3ba 100644 --- a/client/src/main/java/io/split/client/api/SplitView.java +++ b/client/src/main/java/io/split/client/api/SplitView.java @@ -26,7 +26,7 @@ public class SplitView { public Map configs; public List sets; public String defaultTreatment; - public boolean trackImpression; + public boolean trackImpressions; public static SplitView fromParsedSplit(ParsedSplit parsedSplit) { SplitView splitView = new SplitView(); @@ -47,7 +47,7 @@ public static SplitView fromParsedSplit(ParsedSplit parsedSplit) { splitView.treatments = new ArrayList(treatments); splitView.configs = parsedSplit.configurations() == null? Collections.emptyMap() : parsedSplit.configurations() ; - splitView.trackImpression = parsedSplit.trackImpression(); + splitView.trackImpressions = parsedSplit.trackImpressions(); return splitView; } diff --git a/client/src/main/java/io/split/client/dtos/Split.java b/client/src/main/java/io/split/client/dtos/Split.java index 0f2147a9..81853a2a 100644 --- a/client/src/main/java/io/split/client/dtos/Split.java +++ b/client/src/main/java/io/split/client/dtos/Split.java @@ -18,7 +18,7 @@ public class Split { public int algo; public Map configurations; public HashSet sets; - public Boolean trackImpression = null; + public Boolean trackImpressions = null; @Override public String toString() { diff --git a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java index 5188b0dc..2cf87ba2 100644 --- a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java +++ b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java @@ -91,7 +91,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu Labels.KILLED, parsedSplit.changeNumber(), config, - parsedSplit.trackImpression()); + parsedSplit.trackImpressions()); } /* @@ -117,7 +117,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null; return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.NOT_IN_SPLIT, - parsedSplit.changeNumber(), config, parsedSplit.trackImpression()); + parsedSplit.changeNumber(), config, parsedSplit.trackImpressions()); } } @@ -132,7 +132,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu parsedCondition.label(), parsedSplit.changeNumber(), config, - parsedSplit.trackImpression()); + parsedSplit.trackImpressions()); } } @@ -142,7 +142,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu Labels.DEFAULT_RULE, parsedSplit.changeNumber(), config, - parsedSplit.trackImpression()); + parsedSplit.trackImpressions()); } catch (Exception e) { throw new ChangeNumberExceptionWrapper(e, parsedSplit.changeNumber()); } diff --git a/client/src/main/java/io/split/engine/experiments/ParsedSplit.java b/client/src/main/java/io/split/engine/experiments/ParsedSplit.java index da45b592..cde5ba45 100644 --- a/client/src/main/java/io/split/engine/experiments/ParsedSplit.java +++ b/client/src/main/java/io/split/engine/experiments/ParsedSplit.java @@ -32,7 +32,7 @@ public class ParsedSplit { private final int _algo; private final Map _configurations; private final HashSet _flagSets; - private final boolean _trackImpression; + private final boolean _trackImpressions; public static ParsedSplit createParsedSplitForTests( String feature, @@ -44,7 +44,7 @@ public static ParsedSplit createParsedSplitForTests( long changeNumber, int algo, HashSet flagSets, - boolean trackImpression + boolean trackImpressions ) { return new ParsedSplit( feature, @@ -59,7 +59,7 @@ public static ParsedSplit createParsedSplitForTests( algo, null, flagSets, - trackImpression + trackImpressions ); } @@ -74,7 +74,7 @@ public static ParsedSplit createParsedSplitForTests( int algo, Map configurations, HashSet flagSets, - boolean trackImpression + boolean trackImpressions ) { return new ParsedSplit( feature, @@ -89,7 +89,7 @@ public static ParsedSplit createParsedSplitForTests( algo, configurations, flagSets, - trackImpression + trackImpressions ); } @@ -106,7 +106,7 @@ public ParsedSplit( int algo, Map configurations, HashSet flagSets, - boolean trackImpression + boolean trackImpressions ) { _split = feature; _seed = seed; @@ -123,7 +123,7 @@ public ParsedSplit( _trafficAllocationSeed = trafficAllocationSeed; _configurations = configurations; _flagSets = flagSets; - _trackImpression = trackImpression; + _trackImpressions = trackImpressions; } public String feature() { @@ -167,8 +167,8 @@ public Map configurations() { return _configurations; } - public boolean trackImpression() { - return _trackImpression; + public boolean trackImpressions() { + return _trackImpressions; } @Override @@ -183,7 +183,7 @@ public int hashCode() { result = 31 * result + (int)(_changeNumber ^ (_changeNumber >>> 32)); result = 31 * result + (_algo ^ (_algo >>> 32)); result = 31 * result + (_configurations == null? 0 : _configurations.hashCode()); - result = 31 * result + (_trackImpression ? 1 : 0); + result = 31 * result + (_trackImpressions ? 1 : 0); return result; } @@ -204,7 +204,7 @@ public boolean equals(Object obj) { && _changeNumber == other._changeNumber && _algo == other._algo && _configurations == null ? other._configurations == null : _configurations.equals(other._configurations) - && _trackImpression == other._trackImpression; + && _trackImpressions == other._trackImpressions; } @Override @@ -228,8 +228,8 @@ public String toString() { bldr.append(_algo); bldr.append(", config:"); bldr.append(_configurations); - bldr.append(", trackImpression:"); - bldr.append(_trackImpression); + bldr.append(", trackImpressions:"); + bldr.append(_trackImpressions); return bldr.toString(); } diff --git a/client/src/main/java/io/split/engine/experiments/SplitParser.java b/client/src/main/java/io/split/engine/experiments/SplitParser.java index 7b70a2e2..c6ca77e1 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitParser.java +++ b/client/src/main/java/io/split/engine/experiments/SplitParser.java @@ -66,9 +66,9 @@ public ParsedSplit parse(Split split) { private ParsedSplit parseWithoutExceptionHandling(Split split) { List parsedConditionList = Lists.newArrayList(); - if (Objects.isNull(split.trackImpression)) { - _log.debug("trackImpression field not detected for Feature flag `" + split.name + "`, setting it to `true`."); - split.trackImpression = true; + if (Objects.isNull(split.trackImpressions)) { + _log.debug("trackImpressions field not detected for Feature flag `" + split.name + "`, setting it to `true`."); + split.trackImpressions = true; } for (Condition condition : split.conditions) { List partitions = condition.partitions; @@ -95,7 +95,7 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) { split.algo, split.configurations, split.sets, - split.trackImpression); + split.trackImpressions); } private boolean checkUnsupportedMatcherExist(List matchers) { diff --git a/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java b/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java index 944fffee..1d999258 100644 --- a/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java +++ b/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java @@ -131,7 +131,7 @@ public void kill(String splitName, String defaultTreatment, long changeNumber) { parsedSplit.algo(), parsedSplit.configurations(), parsedSplit.flagSets(), - parsedSplit.trackImpression() + parsedSplit.trackImpressions() ); _concurrentMap.put(splitName, updatedSplit); diff --git a/client/src/test/java/io/split/client/SplitManagerImplTest.java b/client/src/test/java/io/split/client/SplitManagerImplTest.java index 0eadd45b..65b0929a 100644 --- a/client/src/test/java/io/split/client/SplitManagerImplTest.java +++ b/client/src/test/java/io/split/client/SplitManagerImplTest.java @@ -246,10 +246,10 @@ public void ImpressionToggleParseTest() throws IOException { mock(SDKReadinessGates.class), TELEMETRY_STORAGE); SplitView splitView = splitManager.split("without_impression_toggle"); - assertTrue(splitView.trackImpression); + assertTrue(splitView.trackImpressions); splitView = splitManager.split("impression_toggle_on"); - assertTrue(splitView.trackImpression); + assertTrue(splitView.trackImpressions); splitView = splitManager.split("impression_toggle_off"); - assertFalse(splitView.trackImpression); + assertFalse(splitView.trackImpressions); } } \ No newline at end of file diff --git a/client/src/test/java/io/split/engine/experiments/SplitParserTest.java b/client/src/test/java/io/split/engine/experiments/SplitParserTest.java index 03b3cc2f..95fcb6a3 100644 --- a/client/src/test/java/io/split/engine/experiments/SplitParserTest.java +++ b/client/src/test/java/io/split/engine/experiments/SplitParserTest.java @@ -98,6 +98,8 @@ public void works() { ParsedSplit expected = ParsedSplit.createParsedSplitForTests("first.name", 123, false, Treatments.OFF, listOfMatcherAndSplits, "user", 1, 1, new HashSet<>(), true); Assert.assertEquals(actual, expected); + assertTrue(expected.hashCode() != 0); + assertTrue(expected.equals(expected)); } @Test @@ -650,15 +652,15 @@ public void ImpressionToggleParseTest() throws IOException { for (Split split : change.splits) { ParsedSplit parsedSplit = parser.parse(split); if (split.name.equals("without_impression_toggle")) { - assertTrue(parsedSplit.trackImpression()); + assertTrue(parsedSplit.trackImpressions()); check1 = true; } if (split.name.equals("impression_toggle_on")) { - assertTrue(parsedSplit.trackImpression()); + assertTrue(parsedSplit.trackImpressions()); check2 = true; } if (split.name.equals("impression_toggle_off")) { - assertFalse(parsedSplit.trackImpression()); + assertFalse(parsedSplit.trackImpressions()); check3 = true; } } diff --git a/client/src/test/resources/splits_imp_toggle.json b/client/src/test/resources/splits_imp_toggle.json index 0c940ff8..85b53301 100644 --- a/client/src/test/resources/splits_imp_toggle.json +++ b/client/src/test/resources/splits_imp_toggle.json @@ -97,7 +97,7 @@ "label": "default rule" } ], - "trackImpression": true + "trackImpressions": true }, { "trafficTypeName": "user", @@ -147,7 +147,7 @@ "label": "default rule" } ], - "trackImpression": false + "trackImpressions": false } ], "since": -1,