AssetStudio { @NonNull @VisibleForTesting static Map<String, String> getBasenameToPathMap(@NonNull Generator generator) { ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>(); int dotXmlLength = DOT_XML.length(); for (String category : MATERIAL_DESIGN_ICON_CATEGORIES) { String path = MATERIAL_DESIGN_ICONS_PATH + category + '/'; for (Iterator<String> i = generator.getResourceNames(path); i.hasNext(); ) { String name = i.next(); builder.put(name.substring(0, name.length() - dotXmlLength), path + name); } } return builder.build(); } private  AssetStudio(); @Nullable static String getPathForBasename(@NonNull String basename); static final String MATERIAL_DESIGN_ICONS_PATH; }
@Test public void getBasenameToPathMap() { Object expected = Collections.singletonMap( "ic_search_black_24dp", "images/material_design_icons/action/ic_search_black_24dp.xml"); assertEquals(expected, AssetStudio.getBasenameToPathMap(mGenerator)); }
@Test public void getBasenameToPathMapThrowsIllegalArgumentException() { Mockito.when(mGenerator.getResourceNames("images/material_design_icons/device/")) .thenReturn(Collections.singletonList("ic_search_black_24dp.xml").iterator()); try { AssetStudio.getBasenameToPathMap(mGenerator); fail(); } catch (IllegalArgumentException ignored) { } }