@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()); IconSet result = iconSetLoader.loadIconSet(iconSetRef); verifies(result); assertEquals("MyIconTheme", result.getName()); }
@Override public IconSet loadIconSet(DocumentReference iconSetReference) throws IconException { try { DocumentModelBridge doc = documentAccessBridge.getDocumentInstance(iconSetReference); String content = doc.getContent(); DocumentReference iconClassRef = new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), "IconThemesCode", "IconThemeClass"); String name = (String) documentAccessBridge.getProperty(iconSetReference, iconClassRef, "name"); return loadIconSet(new StringReader(content), name); } catch (Exception e) { throw new IconException(String.format(ERROR_MSG, iconSetReference), e); } }
DefaultIconSetLoader implements IconSetLoader { @Override public IconSet loadIconSet(DocumentReference iconSetReference) throws IconException { try { DocumentModelBridge doc = documentAccessBridge.getDocumentInstance(iconSetReference); String content = doc.getContent(); DocumentReference iconClassRef = new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), "IconThemesCode", "IconThemeClass"); String name = (String) documentAccessBridge.getProperty(iconSetReference, iconClassRef, "name"); return loadIconSet(new StringReader(content), name); } catch (Exception e) { throw new IconException(String.format(ERROR_MSG, iconSetReference), e); } } }
DefaultIconSetLoader implements IconSetLoader { @Override public IconSet loadIconSet(DocumentReference iconSetReference) throws IconException { try { DocumentModelBridge doc = documentAccessBridge.getDocumentInstance(iconSetReference); String content = doc.getContent(); DocumentReference iconClassRef = new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), "IconThemesCode", "IconThemeClass"); String name = (String) documentAccessBridge.getProperty(iconSetReference, iconClassRef, "name"); return loadIconSet(new StringReader(content), name); } catch (Exception e) { throw new IconException(String.format(ERROR_MSG, iconSetReference), e); } }  }
DefaultIconSetLoader implements IconSetLoader { @Override public IconSet loadIconSet(DocumentReference iconSetReference) throws IconException { try { DocumentModelBridge doc = documentAccessBridge.getDocumentInstance(iconSetReference); String content = doc.getContent(); DocumentReference iconClassRef = new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), "IconThemesCode", "IconThemeClass"); String name = (String) documentAccessBridge.getProperty(iconSetReference, iconClassRef, "name"); return loadIconSet(new StringReader(content), name); } catch (Exception e) { throw new IconException(String.format(ERROR_MSG, iconSetReference), e); } }  @Override IconSet loadIconSet(DocumentReference iconSetReference); @Override IconSet loadIconSet(Reader input, String name); }
DefaultIconSetLoader implements IconSetLoader { @Override public IconSet loadIconSet(DocumentReference iconSetReference) throws IconException { try { DocumentModelBridge doc = documentAccessBridge.getDocumentInstance(iconSetReference); String content = doc.getContent(); DocumentReference iconClassRef = new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), "IconThemesCode", "IconThemeClass"); String name = (String) documentAccessBridge.getProperty(iconSetReference, iconClassRef, "name"); return loadIconSet(new StringReader(content), name); } catch (Exception e) { throw new IconException(String.format(ERROR_MSG, iconSetReference), e); } }  @Override IconSet loadIconSet(DocumentReference iconSetReference); @Override IconSet loadIconSet(Reader input, String name);  }