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 c053c8950..e7c0c8afc 100644 --- a/client/src/main/java/io/split/client/api/SplitView.java +++ b/client/src/main/java/io/split/client/api/SplitView.java @@ -24,6 +24,7 @@ public class SplitView { public List treatments; public long changeNumber; public Map configs; + public List sets = new ArrayList<>(); public static SplitView fromParsedSplit(ParsedSplit parsedSplit) { SplitView splitView = new SplitView(); @@ -31,6 +32,9 @@ public static SplitView fromParsedSplit(ParsedSplit parsedSplit) { splitView.trafficType = parsedSplit.trafficTypeName(); splitView.killed = parsedSplit.killed(); splitView.changeNumber = parsedSplit.changeNumber(); + if (parsedSplit.flagSets() != null) { + splitView.sets = new ArrayList<>(parsedSplit.flagSets()); + } Set treatments = new HashSet(); for (ParsedCondition condition : parsedSplit.parsedConditions()) { diff --git a/client/src/test/java/io/split/client/SplitManagerImplTest.java b/client/src/test/java/io/split/client/SplitManagerImplTest.java index e393ceb27..90cdb868f 100644 --- a/client/src/test/java/io/split/client/SplitManagerImplTest.java +++ b/client/src/test/java/io/split/client/SplitManagerImplTest.java @@ -17,6 +17,7 @@ import org.junit.Test; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -185,6 +186,36 @@ public void block_until_ready_times_when_sdk_is_not_ready() throws TimeoutExcept verify(TELEMETRY_STORAGE, times(1)).recordBURTimeout(); } + @Test + public void splitCallWithExistentSets() { + String existent = "existent"; + SplitCacheConsumer splitCacheConsumer = mock(SplitCacheConsumer.class); + ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", + Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(Arrays.asList("set1", "set2", "set3"))); + when(splitCacheConsumer.get(existent)).thenReturn(response); + + SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer, + mock(SplitClientConfig.class), + mock(SDKReadinessGates.class), TELEMETRY_STORAGE); + SplitView theOne = splitManager.split(existent); + Assert.assertEquals(response.flagSets().size(), theOne.sets.size()); + } + + @Test + public void splitCallWithEmptySets() { + String existent = "existent"; + SplitCacheConsumer splitCacheConsumer = mock(SplitCacheConsumer.class); + ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", + Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, null); + when(splitCacheConsumer.get(existent)).thenReturn(response); + + SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer, + mock(SplitClientConfig.class), + mock(SDKReadinessGates.class), TELEMETRY_STORAGE); + SplitView theOne = splitManager.split(existent); + Assert.assertEquals(0, theOne.sets.size()); + } + private ParsedCondition getTestCondition(String treatment) { return ParsedCondition.createParsedConditionForTests(CombiningMatcher.of(new AllKeysMatcher()), Lists.newArrayList(ConditionsTestUtil.partition(treatment, 10))); }