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());
}
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());
}
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);
}
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");
}
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);
}
Aggregations