Search in sources :

Example 11 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetCacheTest method putByDocRef.

@Test
public void putByDocRef() throws Exception {
    IconSet iconSet = new IconSet("key");
    DocumentReference docRef = new DocumentReference("a", "b", "c");
    when(entityReferenceSerializer.serialize(docRef)).thenReturn("a:b.c");
    mocker.getComponentUnderTest().put(docRef, iconSet);
    verify(cache).set("DOC:a:b.c", iconSet);
}
Also used : DocumentReference(org.xwiki.model.reference.DocumentReference) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 12 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetCacheTest method getByNameAndWiki.

@Test
public void getByNameAndWiki() throws Exception {
    IconSet iconSet = new IconSet("key");
    when(cache.get("NAMED:6wikiId_key")).thenReturn(iconSet);
    IconSet result = mocker.getComponentUnderTest().get("key", "wikiId");
    assertTrue(iconSet == result);
}
Also used : IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 13 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetLoaderTest method loadIconSetFromWikiDocument.

@Test
public void loadIconSetFromWikiDocument() throws Exception {
    DocumentReference iconSetRef = new DocumentReference("xwiki", "IconThemes", "Default");
    DocumentReference iconClassRef = new DocumentReference("wikiId", "IconThemesCode", "IconThemeClass");
    when(documentAccessBridge.getProperty(eq(iconSetRef), eq(iconClassRef), eq("name"))).thenReturn("MyIconTheme");
    DocumentModelBridge doc = mock(DocumentModelBridge.class);
    when(documentAccessBridge.getDocumentInstance(iconSetRef)).thenReturn(doc);
    StringWriter content = new StringWriter();
    IOUtils.copyLarge(new InputStreamReader(getClass().getResourceAsStream("/test.iconset")), content);
    when(doc.getContent()).thenReturn(content.toString());
    // Test
    IconSet result = mocker.getComponentUnderTest().loadIconSet(iconSetRef);
    // Verify
    verifies(result);
    assertEquals("MyIconTheme", result.getName());
}
Also used : DocumentModelBridge(org.xwiki.bridge.DocumentModelBridge) StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) DocumentReference(org.xwiki.model.reference.DocumentReference) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 14 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetLoaderTest method loadIconSet.

@Test
public void loadIconSet() throws Exception {
    Reader content = new InputStreamReader(getClass().getResourceAsStream("/test.iconset"));
    // Test
    IconSet result = mocker.getComponentUnderTest().loadIconSet(content, "FontAwesome");
    // Verify
    verifies(result);
    assertEquals("FontAwesome", result.getName());
}
Also used : InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 15 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetManagerTest method getDefaultIconSet.

@Test
public void getDefaultIconSet() throws Exception {
    // Mock
    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);
    // Test
    assertEquals(iconSet, mocker.getComponentUnderTest().getIconSet("default"));
    // Verify
    verifyZeroInteractions(queryManager);
}
Also used : InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Aggregations

IconSet (org.xwiki.icon.IconSet)38 Test (org.junit.Test)33 Icon (org.xwiki.icon.Icon)14 DocumentReference (org.xwiki.model.reference.DocumentReference)9 InputStreamReader (java.io.InputStreamReader)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 IconException (org.xwiki.icon.IconException)4 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 Query (org.xwiki.query.Query)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)1