ClusterViewDocument { private static String setToCsv(Set<Integer> ids) { if (ids == null || ids.size() == 0) { return null; } StringBuffer sb = new StringBuffer(); for (Integer id : ids) { if (sb.length() != 0) { sb.append(","); } sb.append(id); } return sb.toString(); } @SuppressWarnings("unchecked")  ClusterViewDocument(Document doc); @Override String toString();  }
@Test public void testSetToCsv() throws Throwable { assertNull(callSetToCsv(null)); assertNull(callSetToCsv(new HashSet<Integer>())); Set<Integer> input = new TreeSet<Integer>(); StringBuffer sb = new StringBuffer(); for (int i = 100; i < 199; i++) { input.add(i); if (sb.length() != 0) { sb.append(","); } sb.append(String.valueOf(i)); assertEquals(sb.toString(), callSetToCsv(input)); } }