use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method refuseInvitation.
@Test
public void refuseInvitation() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
// Test
Boolean result = mocker.getComponentUnderTest().refuseInvitation(candidacy, "no thanks");
// Asserts
assertTrue(result);
assertNull(mocker.getComponentUnderTest().getLastError());
verify(wikiUserManager).refuseInvitation(candidacy, "no thanks");
}
use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method askToJoinWhenUsertHasNoRight.
@Test
public void askToJoinWhenUsertHasNoRight() throws Exception {
// Mocks
Exception expectedException = currentUserHasNotAdminRight();
// Test
MemberCandidacy result = mocker.getComponentUnderTest().askToJoin("mainWiki:XWiki.OtherUser", "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 refuseInvitationWhenUserHasNoAdminRightButConcerned.
@Test
public void refuseInvitationWhenUserHasNoAdminRightButConcerned() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
// Mocks
currentUserHasNotAdminRight();
// Test
Boolean result = mocker.getComponentUnderTest().refuseInvitation(candidacy, "no thanks");
// Asserts
assertTrue(result);
assertNull(mocker.getComponentUnderTest().getLastError());
verify(wikiUserManager).refuseInvitation(candidacy, "no thanks");
}
use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method getCandidacyAsAdmin.
@Test
public void getCandidacyAsAdmin() throws Exception {
// Mocks
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.REQUEST);
candidacy.setId(12);
candidacy.setAdminPrivateComment("private message");
when(wikiUserManager.getCandidacy("subwiki", candidacy.getId())).thenReturn(candidacy);
when(authorizationManager.hasAccess(eq(Right.ADMIN), eq(userDocRef), eq(new WikiReference("subwiki")))).thenReturn(true);
// Test
MemberCandidacy result = mocker.getComponentUnderTest().getCandidacy("subwiki", 12);
// Asserts
assertEquals(candidacy, result);
assertEquals("private message", result.getAdminPrivateComment());
}
use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method getCandidacyWhenNoRight.
@Test
public void getCandidacyWhenNoRight() throws Exception {
// Mocks
// The current user is not the candidate
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.REQUEST);
candidacy.setId(12);
when(wikiUserManager.getCandidacy("subwiki", candidacy.getId())).thenReturn(candidacy);
// The current user does not have ADMIN right
when(authorizationManager.hasAccess(eq(Right.ADMIN), eq(userDocRef), eq(new WikiReference("subwiki")))).thenReturn(false);
// Test
MemberCandidacy result = mocker.getComponentUnderTest().getCandidacy("subwiki", 12);
// Asserts
assertNull(result);
Exception exception = mocker.getComponentUnderTest().getLastError();
assertTrue(exception instanceof WikiUserManagerScriptServiceException);
assertEquals("You are not allowed to see this candidacy.", exception.getMessage());
}
Aggregations