|
1 | 1 | package io.split.engine.experiments; |
2 | 2 |
|
3 | 3 | import com.google.common.collect.Lists; |
| 4 | +import io.split.client.utils.Json; |
4 | 5 | import io.split.storages.SegmentCache; |
5 | 6 | import io.split.storages.memory.SegmentCacheInMemoryImpl; |
6 | 7 | import io.split.client.dtos.*; |
| 8 | +import io.split.engine.evaluator.Labels; |
7 | 9 | import io.split.engine.ConditionsTestUtil; |
8 | 10 | import io.split.engine.SDKReadinessGates; |
9 | 11 | import io.split.engine.matchers.AttributeMatcher; |
|
39 | 41 | import static org.hamcrest.Matchers.equalTo; |
40 | 42 | import static org.hamcrest.Matchers.is; |
41 | 43 | import static org.junit.Assert.assertThat; |
| 44 | +import static org.junit.Assert.assertTrue; |
42 | 45 |
|
43 | 46 | /** |
44 | 47 | * Tests for ExperimentParser |
@@ -529,6 +532,29 @@ public void contains_string() { |
529 | 532 | set_matcher_test(c, m); |
530 | 533 | } |
531 | 534 |
|
| 535 | + @Test |
| 536 | + public void unsupportedMatcher() { |
| 537 | + SplitParser parser = new SplitParser(); |
| 538 | + String splitWithUndefinedMatcher = "{\"since\":-1,\"till\": 1457726098069,\"splits\": [{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\"," |
| 539 | + + "\"trafficAllocation\": 100, \"trafficAllocationSeed\": 123456, \"seed\": 321654, \"status\": \"ACTIVE\"," |
| 540 | + + "\"killed\": false, \"defaultTreatment\": \"off\", \"algo\": 2,\"conditions\": [{ \"partitions\": [" |
| 541 | + + "{\"treatment\": \"on\", \"size\": 50}, {\"treatment\": \"off\", \"size\": 50}], \"contitionType\": \"ROLLOUT\"," |
| 542 | + + "\"label\": \"some_label\", \"matcherGroup\": { \"matchers\": [{ \"matcherType\": \"UNKNOWN\", \"negate\": false}]," |
| 543 | + + "\"combiner\": \"AND\"}}], \"sets\": [\"set1\"]}]}"; |
| 544 | + SplitChange change = Json.fromJson(splitWithUndefinedMatcher, SplitChange.class); |
| 545 | + for (Split split : change.splits) { |
| 546 | + // should not cause exception |
| 547 | + ParsedSplit parsedSplit = parser.parse(split); |
| 548 | + for (ParsedCondition parsedCondition : parsedSplit.parsedConditions()) { |
| 549 | + assertTrue(parsedCondition.label() == Labels.UNSUPPORTED_MATCHER); |
| 550 | + for (AttributeMatcher matcher : parsedCondition.matcher().attributeMatchers()) { |
| 551 | + // Check the matcher is ALL_KEYS |
| 552 | + assertTrue(matcher.matcher().toString().equals(" in segment all")); |
| 553 | + } |
| 554 | + } |
| 555 | + } |
| 556 | + } |
| 557 | + |
532 | 558 | public void set_matcher_test(Condition c, io.split.engine.matchers.Matcher m) { |
533 | 559 |
|
534 | 560 | // SegmentSynchronizationTask segmentFetcher = new SegmentSynchronizationTaskImp(fetcherMap); |
|
0 commit comments