ClusterViewDocument { static String arrayToCsv(Integer[] arr) { if (arr == null || arr.length == 0) { return null; } StringBuffer sb = new StringBuffer(); for (Integer a : arr) { if (sb.length() != 0) { sb.append(","); } sb.append(a); } return sb.toString(); } @SuppressWarnings("unchecked")  ClusterViewDocument(Document doc); @Override String toString();  }
@Test public void testArrayToCsv() throws Throwable { assertNull(callArrayToCsv(null)); assertNull(callArrayToCsv(new Integer[0])); assertEquals("101", callArrayToCsv(new Integer[] { 101 })); assertEquals("101,102", callArrayToCsv(new Integer[] { 101, 102 })); assertEquals("101,102,103", callArrayToCsv(new Integer[] { 101, 102, 103 })); assertEquals("101,102,103,104", callArrayToCsv(new Integer[] { 101, 102, 103, 104 })); }