TableRenderer { public static String renderMultiValueMap(Map<String, List<String>> rows, String... headers) { Table table = createTable(headers); if (rows != null) { for (String key : rows.keySet()) { List<String> values = rows.get(key); if (values != null) { for (String value : values) { table.addRow(key, value); } } } } return format(table); } private  TableRenderer(); static String renderSingleMap(Map<String, String> rows, String... headers); static String renderMultiValueMap(Map<String, List<String>> rows, String... headers); static String renderMapValueMap(Map<String, Map<String, String>> rows, String... headers);  }
@Test public void testRenderMultiValueMap() throws IOException { Map<String, List<String>> map = new LinkedHashMap<>(); map.put("ZOOKEEPER", Collections.singletonList("ZOOKEEPER_SERVER")); map.put("MAPREDUCE2", Collections.singletonList("HISTORYSERVER")); map.put("HDFS", Collections.singletonList("DATANODE")); assertEquals(IOUtils.toString(new FileInputStream(new File("src/test/resources/2columns"))), TableRenderer.renderMultiValueMap(map, "SERVICE", "COMPONENT")); }