Search in sources :

Example 6 with MemberCandidacy

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

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

the class WikiUserManagerScriptServiceTest method askToJoin.

@Test
public void askToJoin() throws Exception {
    // Mocks
    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)

Example 8 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method askToJoinWhenScriptHasNoRight.

@Test
public void askToJoinWhenScriptHasNoRight() throws Exception {
    // Mocks
    Exception expectedException = currentScriptHasNotAdminRight();
    // Test
    MemberCandidacy result = mocker.getComponentUnderTest().askToJoin("mainWiki:XWiki.User", "subwiki", "please!");
    // 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 9 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method acceptRequestWhenNoAdminRightButConcerned.

@Test
public void acceptRequestWhenNoAdminRightButConcerned() throws Exception {
    MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
    // Mocks
    currentUserHasNotAdminRight();
    // Test
    Boolean result = mocker.getComponentUnderTest().acceptRequest(candidacy, "message", "comment");
    // Asserts
    assertTrue(result);
    assertNull(mocker.getComponentUnderTest().getLastError());
    verify(wikiUserManager).acceptRequest(candidacy, "message", "comment");
}
Also used : MemberCandidacy(org.xwiki.wiki.user.MemberCandidacy) Test(org.junit.Test)

Example 10 with MemberCandidacy

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

the class WikiUserManagerScriptServiceTest method cancelCandidacy.

@Test
public void cancelCandidacy() throws Exception {
    MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
    // Test
    Boolean result = mocker.getComponentUnderTest().cancelCandidacy(candidacy);
    // Asserts
    assertTrue(result);
    assertNull(mocker.getComponentUnderTest().getLastError());
    verify(wikiUserManager).cancelCandidacy(candidacy);
}
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