@Test public void deleteTheMainWiki() throws Exception { boolean exceptionCaught = false; try { this.mocker.getComponentUnderTest().delete("xwiki"); } catch (WikiManagerException e) { exceptionCaught = true; } assertTrue(exceptionCaught); }
@Override public void delete(String wikiId) throws WikiManagerException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) { throw new WikiManagerException("It's not allowed to delete the main wiki!"); } try { XWikiDocument descriptorDocument = descriptorDocumentHelper.getDocumentFromWikiId(wikiId); xwiki.deleteDocument(descriptorDocument, context); } catch (XWikiException e) { throw new WikiManagerException( String.format("Error deleting the Wiki Descriptor Document for database [%s]", wikiId), e); } try { xwiki.getStore().deleteWiki(wikiId, context); } catch (XWikiException e) { throw new WikiManagerException(String.format("Error deleting the database [%s]", wikiId), e); } }
DefaultWikiDeleter implements WikiDeleter { @Override public void delete(String wikiId) throws WikiManagerException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) { throw new WikiManagerException("It's not allowed to delete the main wiki!"); } try { XWikiDocument descriptorDocument = descriptorDocumentHelper.getDocumentFromWikiId(wikiId); xwiki.deleteDocument(descriptorDocument, context); } catch (XWikiException e) { throw new WikiManagerException( String.format("Error deleting the Wiki Descriptor Document for database [%s]", wikiId), e); } try { xwiki.getStore().deleteWiki(wikiId, context); } catch (XWikiException e) { throw new WikiManagerException(String.format("Error deleting the database [%s]", wikiId), e); } } }
DefaultWikiDeleter implements WikiDeleter { @Override public void delete(String wikiId) throws WikiManagerException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) { throw new WikiManagerException("It's not allowed to delete the main wiki!"); } try { XWikiDocument descriptorDocument = descriptorDocumentHelper.getDocumentFromWikiId(wikiId); xwiki.deleteDocument(descriptorDocument, context); } catch (XWikiException e) { throw new WikiManagerException( String.format("Error deleting the Wiki Descriptor Document for database [%s]", wikiId), e); } try { xwiki.getStore().deleteWiki(wikiId, context); } catch (XWikiException e) { throw new WikiManagerException(String.format("Error deleting the database [%s]", wikiId), e); } }  }
DefaultWikiDeleter implements WikiDeleter { @Override public void delete(String wikiId) throws WikiManagerException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) { throw new WikiManagerException("It's not allowed to delete the main wiki!"); } try { XWikiDocument descriptorDocument = descriptorDocumentHelper.getDocumentFromWikiId(wikiId); xwiki.deleteDocument(descriptorDocument, context); } catch (XWikiException e) { throw new WikiManagerException( String.format("Error deleting the Wiki Descriptor Document for database [%s]", wikiId), e); } try { xwiki.getStore().deleteWiki(wikiId, context); } catch (XWikiException e) { throw new WikiManagerException(String.format("Error deleting the database [%s]", wikiId), e); } }  @Override void delete(String wikiId); }
DefaultWikiDeleter implements WikiDeleter { @Override public void delete(String wikiId) throws WikiManagerException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) { throw new WikiManagerException("It's not allowed to delete the main wiki!"); } try { XWikiDocument descriptorDocument = descriptorDocumentHelper.getDocumentFromWikiId(wikiId); xwiki.deleteDocument(descriptorDocument, context); } catch (XWikiException e) { throw new WikiManagerException( String.format("Error deleting the Wiki Descriptor Document for database [%s]", wikiId), e); } try { xwiki.getStore().deleteWiki(wikiId, context); } catch (XWikiException e) { throw new WikiManagerException(String.format("Error deleting the database [%s]", wikiId), e); } }  @Override void delete(String wikiId);  }