Skip to content

Commit 0b2813d

Browse files
committed
added tests
1 parent 1ffe622 commit 0b2813d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

client/src/test/java/io/split/engine/experiments/ParsedRuleBasedSegmentTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,37 @@ public void worksWithoutExcluded() {
4646
RuleBasedSegmentsToUpdate toUpdate = processRuleBasedSegmentChanges(parser, change.ruleBasedSegments.d);
4747
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedKeys().isEmpty());
4848
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedSegments().isEmpty());
49+
50+
load = "{\"ff\":{\"s\":-1,\"t\":-1,\"d\":[]},\"rbs\":{\"s\":-1,\"t\":1457726098069,\"d\":[{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\","
51+
+ "\"status\": \"ACTIVE\",\"excluded\":{\"segments\":[\"segment1\"]},\"conditions\": [{\"contitionType\": \"ROLLOUT\","
52+
+ "\"label\": \"some_label\", \"matcherGroup\": { \"matchers\": [{ \"matcherType\": \"ALL_KEYS\", \"negate\": false}],"
53+
+ "\"combiner\": \"AND\"}}]}]}}";
54+
change = Json.fromJson(load, SplitChange.class);
55+
toUpdate = processRuleBasedSegmentChanges(parser, change.ruleBasedSegments.d);
56+
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedKeys().isEmpty());
57+
58+
load = "{\"ff\":{\"s\":-1,\"t\":-1,\"d\":[]},\"rbs\":{\"s\":-1,\"t\":1457726098069,\"d\":[{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\","
59+
+ "\"status\": \"ACTIVE\",\"excluded\":{\"segments\":[\"segment1\"], \"keys\":null},\"conditions\": [{\"contitionType\": \"ROLLOUT\","
60+
+ "\"label\": \"some_label\", \"matcherGroup\": { \"matchers\": [{ \"matcherType\": \"ALL_KEYS\", \"negate\": false}],"
61+
+ "\"combiner\": \"AND\"}}]}]}}";
62+
change = Json.fromJson(load, SplitChange.class);
63+
toUpdate = processRuleBasedSegmentChanges(parser, change.ruleBasedSegments.d);
64+
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedKeys().isEmpty());
65+
66+
load = "{\"ff\":{\"s\":-1,\"t\":-1,\"d\":[]},\"rbs\":{\"s\":-1,\"t\":1457726098069,\"d\":[{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\","
67+
+ "\"status\": \"ACTIVE\",\"excluded\":{\"keys\":[\"key1\"]},\"conditions\": [{\"contitionType\": \"ROLLOUT\","
68+
+ "\"label\": \"some_label\", \"matcherGroup\": { \"matchers\": [{ \"matcherType\": \"ALL_KEYS\", \"negate\": false}],"
69+
+ "\"combiner\": \"AND\"}}]}]}}";
70+
change = Json.fromJson(load, SplitChange.class);
71+
toUpdate = processRuleBasedSegmentChanges(parser, change.ruleBasedSegments.d);
72+
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedSegments().isEmpty());
73+
74+
load = "{\"ff\":{\"s\":-1,\"t\":-1,\"d\":[]},\"rbs\":{\"s\":-1,\"t\":1457726098069,\"d\":[{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\","
75+
+ "\"status\": \"ACTIVE\",\"excluded\":{\"segments\":null, \"keys\":[\"key1\"]},\"conditions\": [{\"contitionType\": \"ROLLOUT\","
76+
+ "\"label\": \"some_label\", \"matcherGroup\": { \"matchers\": [{ \"matcherType\": \"ALL_KEYS\", \"negate\": false}],"
77+
+ "\"combiner\": \"AND\"}}]}]}}";
78+
change = Json.fromJson(load, SplitChange.class);
79+
toUpdate = processRuleBasedSegmentChanges(parser, change.ruleBasedSegments.d);
80+
Assert.assertTrue(toUpdate.getToAdd().get(0).excludedSegments().isEmpty());
4981
}
5082
}

0 commit comments

Comments
 (0)