Search in sources :

Example 11 with WikiUserManagerException

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

the class WikiUserManagerScriptServiceTest method getAllRequestError.

@Test
public void getAllRequestError() throws Exception {
    // Mocks
    Exception expectedException = new WikiUserManagerException("error in getAllRequests()");
    when(wikiUserManager.getAllRequests("subwiki")).thenThrow(expectedException);
    // Test
    Collection<MemberCandidacy> result = mocker.getComponentUnderTest().getAllRequests("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 12 with WikiUserManagerException

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

the class WikiUserManagerScriptServiceTest method getCandidacyWhenError.

@Test
public void getCandidacyWhenError() throws Exception {
    // Mocks
    Exception exception = new WikiUserManagerException("error in getCandidacy");
    when(wikiUserManager.getCandidacy("subwiki", 42)).thenThrow(exception);
    // Test
    MemberCandidacy result = mocker.getComponentUnderTest().getCandidacy("subwiki", 42);
    // Asserts
    assertNull(result);
    assertEquals(exception, 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 13 with WikiUserManagerException

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

the class WikiUserManagerScriptServiceTest method joinWhenError.

@Test
public void joinWhenError() throws Exception {
    String userId = "mainWiki:XWiki.User";
    String wikiId = "wikiId";
    // Mocks
    WikiUserManagerException expectedException = new WikiUserManagerException("error in wikiUserManager#join()");
    doThrow(expectedException).when(wikiUserManager).join(userId, wikiId);
    // Test
    boolean result = this.mocker.getComponentUnderTest().join(userId, wikiId);
    // Asserts
    assertFalse(result);
    assertEquals(expectedException, this.mocker.getComponentUnderTest().getLastError());
}
Also used : WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Example 14 with WikiUserManagerException

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

the class WikiUserManagerScriptServiceTest method isMemberError.

@Test
public void isMemberError() throws Exception {
    // Mocks
    Exception expectedException = new WikiUserManagerException("error in isMember");
    when(wikiUserManager.isMember("mainWiki:XWiki.User", "subwiki")).thenThrow(expectedException);
    // Test
    Boolean result = mocker.getComponentUnderTest().isMember("mainWiki:XWiki.User", "subwiki");
    // Asserts
    assertNull(result);
    assertEquals(expectedException, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Example 15 with WikiUserManagerException

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

the class WikiUserManagerScriptServiceTest method hasPendingRequestWhenError.

@Test
public void hasPendingRequestWhenError() throws Exception {
    String wikiId = "subwiki";
    DocumentReference userToTest = new DocumentReference("mainWiki", "XWiki", "User");
    // Mocks
    Exception expectedException = new WikiUserManagerException("exception");
    doThrow(expectedException).when(wikiUserManager).hasPendingRequest(userToTest, wikiId);
    // Test
    Boolean result = mocker.getComponentUnderTest().hasPendingRequest(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