@Test public void getWhenException() throws Exception { WikiManagerException exception = new WikiManagerException("error in WikiManager"); when(wikiDescriptorDocumentHelper.getDocumentFromWikiId("wikiId")).thenThrow(exception); 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); }
@Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); 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; }
WikiTemplatePropertyGroupProvider implements WikiPropertyGroupProvider { @Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); 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; } }
WikiTemplatePropertyGroupProvider implements WikiPropertyGroupProvider { @Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); 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; }  }
WikiTemplatePropertyGroupProvider implements WikiPropertyGroupProvider { @Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); 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; }  @Override WikiPropertyGroup get(String wikiId); @Override void save(WikiPropertyGroup group, String wikiId); }
WikiTemplatePropertyGroupProvider implements WikiPropertyGroupProvider { @Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); 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; }  @Override WikiPropertyGroup get(String wikiId); @Override void save(WikiPropertyGroup group, String wikiId); static final String GROUP_NAME; }