Search in sources :

Example 31 with MemberCandidacy

use of org.xwiki.wiki.user.MemberCandidacy 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 32 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method inviteWhenUserHasNoAdminRight.

@Test
public void inviteWhenUserHasNoAdminRight() throws Exception {
    // Mocks
    Exception expectedException = currentUserHasNotAdminRight();
    // Test
    MemberCandidacy result = mocker.getComponentUnderTest().invite("someUser", "subwiki", "someMessage");
    // Asserts
    assertNull(result);
    assertEquals(expectedException, mocker.getComponentUnderTest().getLastError());
    verifyZeroInteractions(wikiUserManager);
}
Also used : MemberCandidacy(org.xwiki.wiki.user.MemberCandidacy) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Example 33 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method acceptInvitationWhenUserHasNoAdminRight.

@Test
public void acceptInvitationWhenUserHasNoAdminRight() throws Exception {
    MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.INVITATION);
    // Mocks
    Exception exception = currentUserHasNotAdminRight();
    // Test
    Boolean result = mocker.getComponentUnderTest().acceptInvitation(candidacy, "thanks");
    // Asserts
    assertFalse(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
    verifyZeroInteractions(wikiUserManager);
}
Also used : MemberCandidacy(org.xwiki.wiki.user.MemberCandidacy) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiUserManagerException(org.xwiki.wiki.user.WikiUserManagerException) Test(org.junit.Test)

Example 34 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method askToJoinWhenUserHasNoRightButConcerned.

@Test
public void askToJoinWhenUserHasNoRightButConcerned() throws Exception {
    // Mocks
    currentUserHasNotAdminRight();
    MemberCandidacy candidacy = new MemberCandidacy();
    when(wikiUserManager.askToJoin("mainWiki:XWiki.User", "subwiki", "please!")).thenReturn(candidacy);
    // Test
    MemberCandidacy result = mocker.getComponentUnderTest().askToJoin("mainWiki:XWiki.User", "subwiki", "please!");
    // Asserts
    assertEquals(candidacy, result);
    assertNull(mocker.getComponentUnderTest().getLastError());
}
Also used : MemberCandidacy(org.xwiki.wiki.user.MemberCandidacy) Test(org.junit.Test)

Aggregations

MemberCandidacy (org.xwiki.wiki.user.MemberCandidacy)34 Test (org.junit.Test)29 WikiUserManagerException (org.xwiki.wiki.user.WikiUserManagerException)15 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)12 WikiReference (org.xwiki.model.reference.WikiReference)4 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)3 BaseObject (com.xpn.xwiki.objects.BaseObject)3 ArrayList (java.util.ArrayList)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 XWikiException (com.xpn.xwiki.XWikiException)2