### Question:
DefaultIconSetManager implements IconSetManager { @Override public IconSet getDefaultIconSet() throws IconException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); IconSet iconSet = iconSetCache.get(DEFAULT_ICONSET_NAME); if (iconSet == null) { try { iconSet = iconSetLoader.loadIconSet(new InputStreamReader( xwiki.getResourceAsStream("/resources/icons/default.iconset")), DEFAULT_ICONSET_NAME); iconSetCache.put(DEFAULT_ICONSET_NAME, iconSet); } catch (IconException | MalformedURLException e) { throw new IconException("Failed to get the current default icon set.", e); } } return iconSet; }  @Override IconSet getCurrentIconSet(); @Override IconSet getDefaultIconSet(); @Override IconSet getIconSet(String name); @Override List<String> getIconSetNames();  }### Answer:
@Test public void getDefaultIcon() throws Exception { InputStream is = getClass().getResourceAsStream("/test.iconset"); when(xwiki.getResourceAsStream("/resources/icons/default.iconset")).thenReturn(is); IconSet iconSet = new IconSet("default"); when(iconSetLoader.loadIconSet(any(InputStreamReader.class), eq("default"))).thenReturn(iconSet); IconSet result = mocker.getComponentUnderTest().getDefaultIconSet(); assertEquals(iconSet, result); verify(iconSetCache).put("default", iconSet); }
@Test public void getDefaultIconWhenInCache() throws Exception { IconSet iconSet = new IconSet("default"); when(iconSetCache.get("default")).thenReturn(iconSet); IconSet result = mocker.getComponentUnderTest().getDefaultIconSet(); assertEquals(iconSet, result); verify(iconSetLoader, never()).loadIconSet(any(InputStreamReader.class), any()); }
@Test public void getDefaultIconWithException() throws Exception { Exception exception = new MalformedURLException(); when(xwiki.getResourceAsStream(any())).thenThrow(exception); Exception exceptionCaught = null; try { mocker.getComponentUnderTest().getDefaultIconSet(); } catch (IconException e) { exceptionCaught = e; } assertNotNull(exceptionCaught); assertEquals(exception, exceptionCaught.getCause()); assertEquals("Failed to get the current default icon set.", exceptionCaught.getMessage()); }
@Test public void getDefaultIconSet() throws Exception { IconSet iconSet = new IconSet("default"); when(iconSetLoader.loadIconSet(any(Reader.class), eq("default"))).thenReturn(iconSet); InputStream is = getClass().getResourceAsStream("/test.iconset"); when(xwiki.getResourceAsStream("/resources/icons/default.iconset")).thenReturn(is); assertEquals(iconSet, mocker.getComponentUnderTest().getIconSet("default")); verifyZeroInteractions(queryManager); }