### Question:
DefaultIconSetManager implements IconSetManager { @Override public IconSet getCurrentIconSet() throws IconException { IconSet iconSet = this.iconSetContext.getIconSet(); if (iconSet != null) { return iconSet; } String iconTheme = this.configurationSource.getProperty("iconTheme"); DocumentReference iconThemeDocRef = documentReferenceResolver.resolve(iconTheme); if (!StringUtils.isBlank(iconTheme) && documentAccessBridge.exists(iconThemeDocRef)) { iconSet = iconSetCache.get(iconThemeDocRef); if (iconSet == null) { iconSet = iconSetLoader.loadIconSet(iconThemeDocRef); iconSetCache.put(iconThemeDocRef, iconSet); iconSetCache.put(iconSet.getName(), wikiDescriptorManager.getCurrentWikiId(), iconSet); } } return iconSet; }  @Override IconSet getCurrentIconSet(); @Override IconSet getDefaultIconSet(); @Override IconSet getIconSet(String name); @Override List<String> getIconSetNames();  }### Answer:
@Test public void getCurrentIconSet() throws Exception { String currentIconTheme = "IconThemes.SilkTheme"; when(configurationSource.getProperty("iconTheme")).thenReturn(currentIconTheme); DocumentReference iconThemeRef = new DocumentReference("xwiki", "IconThemes", "SilkTheme"); when(documentReferenceResolver.resolve(currentIconTheme)).thenReturn(iconThemeRef); when(documentAccessBridge.exists(iconThemeRef)).thenReturn(true); IconSet iconSet = new IconSet(currentIconTheme); when(iconSetLoader.loadIconSet(iconThemeRef)).thenReturn(iconSet); IconSet result = mocker.getComponentUnderTest().getCurrentIconSet(); assertEquals(iconSet, result); verify(iconSetCache).put(iconThemeRef, iconSet); verify(iconSetCache).put(currentIconTheme, "currentWikiId", iconSet); }
@Test public void getCurrentIconSetWhenInCache() throws Exception { String currentIconTheme = "IconThemes.SilkTheme"; when(configurationSource.getProperty("iconTheme")).thenReturn(currentIconTheme); DocumentReference iconThemeRef = new DocumentReference("xwiki", "IconThemes", "SilkTheme"); when(documentReferenceResolver.resolve(currentIconTheme)).thenReturn(iconThemeRef); when(documentAccessBridge.exists(iconThemeRef)).thenReturn(true); IconSet iconSet = new IconSet(currentIconTheme); when(iconSetCache.get(iconThemeRef)).thenReturn(iconSet); IconSet result = mocker.getComponentUnderTest().getCurrentIconSet(); assertEquals(iconSet, result); verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class)); }
@Test public void getCurrentIconSetWhenItDoesNotExist() throws Exception { String currentIconTheme = "xwiki:IconThemes.SilkTheme"; when(configurationSource.getProperty("iconTheme")).thenReturn(currentIconTheme); DocumentReference iconThemeRef = new DocumentReference("xwiki", "IconThemes", "SilkTheme"); when(documentReferenceResolver.resolve(currentIconTheme)).thenReturn(iconThemeRef); when(documentAccessBridge.exists(iconThemeRef)).thenReturn(false); when(iconSetCache.get(iconThemeRef)).thenReturn(null); IconSet result = mocker.getComponentUnderTest().getCurrentIconSet(); assertNull(result); verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class)); }