use of org.xwiki.wiki.properties.WikiPropertyGroupException in project xwiki-platform by xwiki.
the class WikiTemplatePropertyGroupProvider method get.
@Override
public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException {
WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME);
try {
XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId);
// Get the object
BaseObject object = descriptorDocument.getXObject(WikiTemplateClassDocumentInitializer.SERVER_CLASS);
if (object != null) {
group.setTemplate(object.getIntValue(WikiTemplateClassDocumentInitializer.FIELD_ISWIKITEMPLATE, 0) != 0);
}
} catch (WikiManagerException e) {
throw new WikiPropertyGroupException(String.format(ERROR_MESSAGE_NO_DESCRIPTOR_DOCUMENT, wikiId), e);
}
return group;
}
use of org.xwiki.wiki.properties.WikiPropertyGroupException in project xwiki-platform by xwiki.
the class WikiTemplatePropertyGroupProviderTest method getWhenException.
@Test
public void getWhenException() throws Exception {
WikiManagerException exception = new WikiManagerException("error in WikiManager");
when(wikiDescriptorDocumentHelper.getDocumentFromWikiId("wikiId")).thenThrow(exception);
// Test
boolean exceptionCaught = false;
try {
mocker.getComponentUnderTest().get("wikiId");
} catch (WikiPropertyGroupException e) {
exceptionCaught = true;
assertEquals("Unable to load descriptor document for wiki [wikiId].", e.getMessage());
assertEquals(exception, e.getCause());
}
assertTrue(exceptionCaught);
}
Aggregations