### Question:
TextUtils { public static String joinJSON(Iterable<?> elements) { try { return MAPPER.writeValueAsString(elements); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); } } private  TextUtils(); static String[] parseDelimited(String delimited, char delimiter); static String[] parsePMMLDelimited(String delimited); static String joinDelimited(Iterable<?> elements, char delimiter); static String joinPMMLDelimited(Iterable<?> elements); static String joinPMMLDelimitedNumbers(Iterable<? extends Number> elements); static String[] parseJSONArray(String json); static String joinJSON(Iterable<?> elements); static T readJSON(String json, Class<T> clazz); static T convertViaJSON(Object value, Class<T> clazz);  }### Answer:
@Test public void testJoinJSON() { assertEquals("[\"1\",\"2\",\"3\"]", TextUtils.joinJSON(Arrays.asList("1", "2", "3"))); assertEquals("[\"1 \",\"2 \",\"3\"]", TextUtils.joinJSON(Arrays.asList("1 ", "2 ", "3"))); assertEquals("[]", TextUtils.joinJSON(Collections.emptyList())); }
@Test public void testJSONList() { List<Object> list = new ArrayList<>(); list.add("foo"); list.add(2); assertEquals("[\"A\",[\"foo\",2],\"B\"]", TextUtils.joinJSON(Arrays.asList("A", list, "B"))); }
@Test public void testJSONMap() { Map<Object,Object> map = new HashMap<>(); map.put(1, "bar"); map.put("foo", 2); assertEquals("[\"A\",{\"1\":\"bar\",\"foo\":2},\"B\"]", TextUtils.joinJSON(Arrays.asList("A", map, "B"))); }