Search in sources :

Example 26 with WikiUserManagerException

use of org.xwiki.wiki.user.WikiUserManagerException in project xwiki-platform by xwiki.

the class WikiUserManagerScriptServiceTest method getAllInvitationsError.

@Test
public void getAllInvitationsError() throws Exception {
    // Mocks
    Exception expectedException = new WikiUserManagerException("error in getAllInvitations()");
    when(wikiUserManager.getAllInvitations("subwiki")).thenThrow(expectedException);
    // Test
    Collection<MemberCandidacy> result = mocker.getComponentUnderTest().getAllInvitations("subwiki");
    // Asserts
    assertNull(result);
    assertEquals(expectedException, mocker.getComponentUnderTest().getLastError());
}
Also used : MemberCandidacy(org.xwiki.wiki.user.MemberCandidacy) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Example 27 with WikiUserManagerException

use of org.xwiki.wiki.user.WikiUserManagerException in project xwiki-platform by xwiki.

the class WikiUserManagerScriptServiceTest method hasPendingInvitationWhenError.

@Test
public void hasPendingInvitationWhenError() throws Exception {
    String wikiId = "subwiki";
    // Mocks
    DocumentReference userToTest = new DocumentReference("mainWiki", "XWiki", "User");
    Exception expectedException = new WikiUserManagerException("exception");
    doThrow(expectedException).when(wikiUserManager).hasPendingInvitation(userToTest, wikiId);
    // Test
    Boolean result = mocker.getComponentUnderTest().hasPendingInvitation(userToTest, wikiId);
    // Asserts
    assertNull(result);
    assertEquals(expectedException, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) DocumentReference(org.xwiki.model.reference.DocumentReference) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Aggregations

WikiUserManagerException (org.xwiki.wiki.user.WikiUserManagerException)27 Test (org.junit.Test)14 XWikiContext (com.xpn.xwiki.XWikiContext)9 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)9 XWikiException (com.xpn.xwiki.XWikiException)8 BaseObject (com.xpn.xwiki.objects.BaseObject)6 DocumentReference (org.xwiki.model.reference.DocumentReference)6 MemberCandidacy (org.xwiki.wiki.user.MemberCandidacy)6 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)5 XWiki (com.xpn.xwiki.XWiki)4 MembershipType (org.xwiki.wiki.user.MembershipType)3 UserScope (org.xwiki.wiki.user.UserScope)3 ArrayList (java.util.ArrayList)2 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)2 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)2 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 WikiCreationRequest (org.xwiki.platform.wiki.creationjob.WikiCreationRequest)1 WikiTemplateManagerException (org.xwiki.wiki.template.WikiTemplateManagerException)1 WikiUserConfiguration (org.xwiki.wiki.user.WikiUserConfiguration)1