MultiConfigCommaSplitter implements IParameterSplitter { public List<String> split(String value) { String[] keyValue = value.split("=", 2); if (keyValue.length != 2) { return Collections.singletonList(value); } if (!isMap(keyValue[0])) { return Collections.singletonList(value); } if (hasKey(keyValue[0])) { return Collections.singletonList(value); } return Stream.of(keyValue[1].split(",")) .filter(s -> !s.trim().isEmpty()) .map(s -> { String[] nameProperty = s.trim().split(":", 2); if (nameProperty.length != 2) { throw new ParameterException("Invalid input: " + value); } return keyValue[0] + "." + nameProperty[0] + "=" + nameProperty[1]; }) .distinct() .collect(toList()); }  List<String> split(String value);  }
@Test public void testSplit_1() { List<String> split = splitter.split("offheap-resources.main"); assertEquals(singletonList("offheap-resources.main"), split); }
@Test public void testSplit_2() { List<String> split = splitter.split("offheap-resources"); assertEquals(singletonList("offheap-resources"), split); }
@Test public void testSplit_3() { List<String> split = splitter.split("offheap-resources.main=512MB"); assertEquals(singletonList("offheap-resources.main=512MB"), split); }
@Test public void testSplit_4() { List<String> split = splitter.split("offheap-resources=main:512MB"); assertEquals(singletonList("offheap-resources.main=512MB"), split); }
@Test public void testSplit_5() { List<String> split = splitter.split("offheap-resources=main:512MB,second:1GB"); assertEquals(asList("offheap-resources.main=512MB", "offheap-resources.second=1GB"), split); }
@Test public void testSplit_6() { List<String> split = splitter.split("stripe.1.node.1.tc-properties.something=value"); assertEquals(singletonList("stripe.1.node.1.tc-properties.something=value"), split); }
@Test public void testSplit_7() { List<String> split = splitter.split("client-reconnect-window=10s"); assertEquals(singletonList("client-reconnect-window=10s"), split); }
@Test public void testSplit_8() { List<String> split = splitter.split("failover-priority=consistency:2"); assertEquals(singletonList("failover-priority=consistency:2"), split); }