JSONUtil { public String readListToString(List<?> list) { try { return JsonUtilsV2.listToJson(list); } catch (Exception e) { throw restErrorUtil.createRESTException( "Invalid input data: " + e.getMessage(), MessageEnums.INVALID_INPUT_DATA); } }  File writeJsonToFile(ViewBaseBean viewBean, String fileName); Map<String, String> jsonToMap(String jsonStr); String readMapToString(Map<?, ?> map); String readListToString(List<?> list); String writeObjectAsString(Serializable obj); T writeJsonToJavaObject(String json, Class<T> tClass);  }
@Test public void testReadListToString() { String expectedJsonString = "[\"hdfs\",\"hive\",\"knox\"]"; List<String> testList = new ArrayList<String>(); testList.add("hdfs"); testList.add("hive"); testList.add("knox"); String actualJsonString = jsonUtil.readListToString(testList); Assert.assertEquals(expectedJsonString, actualJsonString); }