MaterialDesignIcons { @NotNull @VisibleForTesting static Map<String, String> getBasenameToPathMap(@NotNull Function<String, List<String>> generator) { ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>(); int dotXmlLength = DOT_XML.length(); for (String category : getCategories()) { String path = PATH + category + '/'; for (String name : generator.apply(path)) { builder.put(name.substring(0, name.length() - dotXmlLength), path + name); } } return builder.build(); } private  MaterialDesignIcons(); @Nullable static String getPathForBasename(@NotNull String basename); @NotNull static Collection<String> getCategories(); @NotNull static List<String> getIconNames(@NotNull String categoryName); @NotNull static URL getIcon(@NotNull String iconName, @NotNull String categoryName); @NotNull static URL getDefaultIcon();  }
@Test public void getBasenameToPathMap() { Object expected = Collections.singletonMap( "ic_search_black_24dp", "images/material_design_icons/action/ic_search_black_24dp.xml"); assertEquals(expected, MaterialDesignIcons.getBasenameToPathMap(mockGenerator())); }
@Test public void getBasenameToPathMapThrowsIllegalArgumentException() { Function<String, List<String>> generator = mockGenerator(); Mockito.when(generator.apply("images/material_design_icons/device/")) .thenReturn(Collections.singletonList("ic_search_black_24dp.xml")); try { MaterialDesignIcons.getBasenameToPathMap(generator); fail(); } catch (IllegalArgumentException ignored) { } }