@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)); }
@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; }
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; } }
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; }  }
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(); }
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();  }