@Test public void idAvailable() throws Exception { when(xwiki.Param("xwiki.virtual.reserved_wikis")).thenReturn("forbidden,wikiid3,toto"); when(store.isWikiNameAvailable(any(String.class), any(XWikiContext.class))).thenReturn(true); when(wikiDescriptorManager.exists("wikiid1")).thenReturn(true); assertFalse(this.mocker.getComponentUnderTest().idAvailable("wikiid1")); when(wikiDescriptorManager.exists("wikiid2")).thenReturn(false); assertTrue(this.mocker.getComponentUnderTest().idAvailable("wikiid2")); when(wikiDescriptorManager.exists("wikiid3")).thenReturn(false); assertFalse(this.mocker.getComponentUnderTest().idAvailable("wikiid3")); }
@Override public boolean idAvailable(String wikiId) throws WikiManagerException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis"); try { return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext); } catch (XWikiException e) { throw new WikiManagerException("Fail to look at the databases."); } }
DefaultWikiManager implements WikiManager { @Override public boolean idAvailable(String wikiId) throws WikiManagerException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis"); try { return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext); } catch (XWikiException e) { throw new WikiManagerException("Fail to look at the databases."); } } }
DefaultWikiManager implements WikiManager { @Override public boolean idAvailable(String wikiId) throws WikiManagerException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis"); try { return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext); } catch (XWikiException e) { throw new WikiManagerException("Fail to look at the databases."); } }  }
DefaultWikiManager implements WikiManager { @Override public boolean idAvailable(String wikiId) throws WikiManagerException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis"); try { return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext); } catch (XWikiException e) { throw new WikiManagerException("Fail to look at the databases."); } }  @Override WikiDescriptor create(String wikiId, String wikiAlias, boolean failOnExist); @Override WikiDescriptor create(String wikiId, String wikiAlias, String ownerId, boolean failOnExist); @Override WikiDescriptor copy(String fromWikiId, String newWikiId, String newWikiAlias, boolean copyHistory,
        boolean copyRecycleBin, boolean failOnExist); @Override WikiDescriptor rename(String wikiId, String newWikiId); @Override void delete(String wikiId); @Override boolean idAvailable(String wikiId); }
DefaultWikiManager implements WikiManager { @Override public boolean idAvailable(String wikiId) throws WikiManagerException { XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis"); try { return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext); } catch (XWikiException e) { throw new WikiManagerException("Fail to look at the databases."); } }  @Override WikiDescriptor create(String wikiId, String wikiAlias, boolean failOnExist); @Override WikiDescriptor create(String wikiId, String wikiAlias, String ownerId, boolean failOnExist); @Override WikiDescriptor copy(String fromWikiId, String newWikiId, String newWikiAlias, boolean copyHistory,
        boolean copyRecycleBin, boolean failOnExist); @Override WikiDescriptor rename(String wikiId, String newWikiId); @Override void delete(String wikiId); @Override boolean idAvailable(String wikiId);  }