use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getCurrentIconSet.
@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);
// Test
IconSet result = mocker.getComponentUnderTest().getCurrentIconSet();
// Verify
assertEquals(iconSet, result);
verify(iconSetCache).put(iconThemeRef, iconSet);
verify(iconSetCache).put(currentIconTheme, "currentWikiId", iconSet);
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getIconSetWhenInCache.
@Test
public void getIconSetWhenInCache() throws Exception {
// Mocks
IconSet iconSet = new IconSet("silk");
when(iconSetCache.get("silk", "currentWikiId")).thenReturn(iconSet);
// Test
assertEquals(iconSet, mocker.getComponentUnderTest().getIconSet("silk"));
// Verify
verify(iconSetCache, never()).put(anyString(), any(IconSet.class));
}
use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getIconSetWhenNotInCache.
@Test
public void getIconSetWhenNotInCache() throws Exception {
// Mocks
IconSet iconSet = new IconSet("silk");
Query query = mock(Query.class);
when(queryManager.createQuery("FROM doc.object(IconThemesCode.IconThemeClass) obj WHERE obj.name = :name", Query.XWQL)).thenReturn(query);
List<String> results = new ArrayList<>();
results.add("IconThemes.Silk");
when(query.<String>execute()).thenReturn(results);
DocumentReference documentReference = new DocumentReference("wiki", "IconThemes", "Silk");
when(documentReferenceResolver.resolve("IconThemes.Silk")).thenReturn(documentReference);
when(iconSetLoader.loadIconSet(documentReference)).thenReturn(iconSet);
// Test
assertEquals(iconSet, mocker.getComponentUnderTest().getIconSet("silk"));
// Verify
verify(query).bindValue("name", "silk");
verify(iconSetCache).put(documentReference, iconSet);
verify(iconSetCache).put("silk", "currentWikiId", iconSet);
}
Aggregations