PatchingConversions { public static String flatten(List<String> list) { if (list == null) { throw new IllegalArgumentException("Argument list must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : list) { if (sb.length() > 0) { sb.append(","); } sb.append(p); } return sb.toString(); } private  PatchingConversions(); static String flatten(List<String> list); static String flattenAndEscape(List<String> paths);  }
@Test public void flattenEmptyListTest() { assertEquals("Empty collection should produce empty String", "", PatchingConversions.flatten(Collections.<String>emptyList())); }
@Test public void flattenSingleElementListTest() { String[] singleElementList = new String[]{"sometext"}; assertEquals("Empty collection should produce empty String", "sometext", PatchingConversions.flatten(Arrays.asList(singleElementList))); }
@Test public void flattenSingleElementListWithBackslashesTest() { String[] singleElementList = new String[]{"some\\text"}; assertEquals("Empty collection should produce empty String", "some\\text", PatchingConversions.flatten(Arrays.asList(singleElementList))); }
@Test public void flattenMultipleElementListWithBackslashesTest() { String[] singleElementList = new String[]{"some\\text", "another text"}; assertEquals("Empty collection should produce empty String", "some\\text,another text", PatchingConversions.flatten(Arrays.asList(singleElementList))); }
@Test(expected = IllegalArgumentException.class) public void flattenListAsNull() { PatchingConversions.flatten(null); }
@Test(expected = IllegalArgumentException.class) public void flattenAndEscapeListAsNull() { PatchingConversions.flatten(null); }