Search in sources :

Example 26 with WikiManagerException

use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method getByIdError.

@Test
public void getByIdError() throws Exception {
    Exception exception = new WikiManagerException("error in getById");
    when(wikiDescriptorManager.getById("wikiId")).thenThrow(exception);
    WikiDescriptor result = mocker.getComponentUnderTest().getById("wikiId");
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 27 with WikiManagerException

use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method getAllIdsError.

@Test
public void getAllIdsError() throws Exception {
    Exception exception = new WikiManagerException("error in getAllIds");
    when(wikiDescriptorManager.getAllIds()).thenThrow(exception);
    Collection<String> result = mocker.getComponentUnderTest().getAllIds();
    assertTrue(result.isEmpty());
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) Test(org.junit.Test)

Example 28 with WikiManagerException

use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method createWikiError.

@Test
public void createWikiError() throws Exception {
    Exception exception = new WikiManagerException("error on create");
    when(wikiManager.create("newwiki", "alias", true)).thenThrow(exception);
    WikiDescriptor result = mocker.getComponentUnderTest().createWiki("newwiki", "alias", "userA", true);
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 29 with WikiManagerException

use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method idAvailableError.

@Test
public void idAvailableError() throws Exception {
    Exception exception = new WikiManagerException("error in idAvailable");
    when(wikiManager.idAvailable("wikiId")).thenThrow(exception);
    Boolean result = mocker.getComponentUnderTest().idAvailable("wikiId");
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
    assertEquals(exception, mocker.getComponentUnderTest().getLastException());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) Test(org.junit.Test)

Example 30 with WikiManagerException

use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method getMainWikiDescriptorError.

@Test
public void getMainWikiDescriptorError() throws Exception {
    Exception exception = new WikiManagerException("error in getMainWikiDescriptor");
    when(wikiDescriptorManager.getMainWikiDescriptor()).thenThrow(exception);
    WikiDescriptor result = mocker.getComponentUnderTest().getMainWikiDescriptor();
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Aggregations

WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)40 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)17 Test (org.junit.Test)13 XWikiContext (com.xpn.xwiki.XWikiContext)12 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)11 XWiki (com.xpn.xwiki.XWiki)7 XWikiException (com.xpn.xwiki.XWikiException)7 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)6 WikiTemplateManagerException (org.xwiki.wiki.template.WikiTemplateManagerException)6 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)5 WikiPropertyGroupException (org.xwiki.wiki.properties.WikiPropertyGroupException)5 BaseObject (com.xpn.xwiki.objects.BaseObject)4 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)4 WikiTemplatePropertyGroup (org.xwiki.wiki.template.WikiTemplatePropertyGroup)4 ExtensionId (org.xwiki.extension.ExtensionId)3 DocumentReference (org.xwiki.model.reference.DocumentReference)3 WikiReference (org.xwiki.model.reference.WikiReference)3 Query (org.xwiki.query.Query)3 QueryException (org.xwiki.query.QueryException)3 DefaultWikiDescriptor (org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor)3