ClassWrapperRenderer implements TableCellRenderer { protected SortedMap<String, String> toMap(String configuration) { Properties p = new Properties(); SortedMap<String, String> result = new TreeMap<>(stringLengthComparator); try { p.load(new StringReader(StringUtils.defaultString(configuration))); for (Object o : p.keySet()) { final String key = o.toString(); final String value = p.getProperty(key); result.put(key, value); } } catch (IOException e) { e.printStackTrace(); } return result; } ClassWrapperRenderer(); @Override Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column); String abbreviatePackagesToSingleLetter(String abbreviatePackage, int availableWidth, FontMetrics fm); void reloadConfiguration(String propertyConfiguration);  }
@Test public void testToMap() throws Exception { final SortedMap<String, String> treeMap = underTest.toMap("a.b.c.d={D}\na.b.c.e={E}\na.b.c={C}\na.b={B}"); assertEquals(treeMap.size(), 4, Joiner.on(", ").withKeyValueSeparator("=").join(treeMap)); assertEquals(treeMap.get("a.b.c.d"), "{D}"); assertEquals(treeMap.get("a.b.c.e"), "{E}"); assertEquals(treeMap.get("a.b.c"), "{C}"); assertEquals(treeMap.get("a.b"), "{B}"); }
@Test public void testToMapIfConfIsNull() throws Exception { final Map<String, String> treeMap = underTest.toMap(null); assertEquals(treeMap.size(), 0); }