use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getDefaultIconWhenInCache.
@Test
public void getDefaultIconWhenInCache() throws Exception {
IconSet iconSet = new IconSet("default");
when(iconSetCache.get("default")).thenReturn(iconSet);
// Test
IconSet result = mocker.getComponentUnderTest().getDefaultIconSet();
// Verify
assertEquals(iconSet, result);
verify(iconSetLoader, never()).loadIconSet(any(InputStreamReader.class), any());
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getCurrentIconSetWhenInCache.
@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);
// Test
IconSet result = mocker.getComponentUnderTest().getCurrentIconSet();
// Verify
assertEquals(iconSet, result);
verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class));
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getCurrentIconSetWhenItDoesNotExist.
@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);
// Test
IconSet result = mocker.getComponentUnderTest().getCurrentIconSet();
// Verify
assertNull(result);
verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class));
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getDefaultIcon.
@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);
// Test
IconSet result = mocker.getComponentUnderTest().getDefaultIconSet();
// Verify
assertEquals(iconSet, result);
verify(iconSetCache).put("default", iconSet);
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class IconSetTest method simpleTest.
@Test
public void simpleTest() throws Exception {
IconSet iconSet = new IconSet("myIconSet");
assertEquals("myIconSet", iconSet.getName());
iconSet.setName("newName");
assertEquals("newName", iconSet.getName());
}
Aggregations