TableRenderer { public static String renderMapValueMap(Map<String, Map<String, String>> rows, String... headers) { Table table = createTable(headers); if (rows != null) { for (String key1 : rows.keySet()) { Map<String, String> values = rows.get(key1); if (values != null) { for (String key2 : values.keySet()) { table.addRow(key1, key2, values.get(key2)); } } } } 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 testRenderMapValueMap() throws IOException { Map<String, Map<String, String>> map = new LinkedHashMap<>(); map.put("ZOOKEEPER", Collections.singletonMap("ZOOKEEPER_SERVER", "INSTALLED")); map.put("MAPREDUCE2", Collections.singletonMap("HISTORYSERVER", "STARTED")); map.put("HDFS", Collections.singletonMap("DATANODE", "STARTED")); assertEquals(IOUtils.toString(new FileInputStream(new File("src/test/resources/3columns"))), TableRenderer.renderMapValueMap(map, "SERVICE", "COMPONENT", "STATE")); }