use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method acceptInvitation.
@Test
public void acceptInvitation() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
// Test
Boolean result = mocker.getComponentUnderTest().acceptInvitation(candidacy, "thanks");
// Asserts
assertTrue(result);
assertNull(mocker.getComponentUnderTest().getLastError());
verify(wikiUserManager).acceptInvitation(candidacy, "thanks");
}
use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method getAllInvitations.
@Test
public void getAllInvitations() throws Exception {
ArrayList<MemberCandidacy> candidacies = new ArrayList<MemberCandidacy>();
// the first candidacy concerns the current user
candidacies.add(new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION));
// not the second
candidacies.add(new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.INVITATION));
candidacies.get(0).setAdminPrivateComment("private message");
// We do not have admin rights
when(authorizationManager.hasAccess(eq(Right.ADMIN), eq(userDocRef), eq(new WikiReference("subwiki")))).thenReturn(false);
when(wikiUserManager.getAllInvitations("subwiki")).thenReturn(candidacies);
// Test
Collection<MemberCandidacy> result = mocker.getComponentUnderTest().getAllInvitations("subwiki");
// the result must have been filtered
assertEquals(1, result.size());
assertTrue(result.contains(candidacies.get(0)));
assertFalse(result.contains(candidacies.get(1)));
// The private message from the candidacy must be removed
assertNull(((MemberCandidacy) result.toArray()[0]).getAdminPrivateComment());
}
use of org.xwiki.wiki.user.MemberCandidacy in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method refuseInvitationWhenUserHasNoAdminRight.
@Test
public void refuseInvitationWhenUserHasNoAdminRight() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.INVITATION);
// Mocks
Exception expectedException = currentUserHasNotAdminRight();
// Test
Boolean result = mocker.getComponentUnderTest().refuseInvitation(candidacy, "no thanks");
// Asserts
assertFalse(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 cancelCandidacyWhenUserHasNoAdminRight.
@Test
public void cancelCandidacyWhenUserHasNoAdminRight() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.OtherUser", MemberCandidacy.CandidateType.INVITATION);
// Mocks
Exception expectedException = currentUserHasNotAdminRight();
// Test
Boolean result = mocker.getComponentUnderTest().cancelCandidacy(candidacy);
// Asserts
assertFalse(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 cancelCandidacyWhenUserHasNoAdminRightButConcerned.
@Test
public void cancelCandidacyWhenUserHasNoAdminRightButConcerned() throws Exception {
MemberCandidacy candidacy = new MemberCandidacy("subwiki", "mainWiki:XWiki.User", MemberCandidacy.CandidateType.INVITATION);
// Mocks
currentUserHasNotAdminRight();
// Test
Boolean result = mocker.getComponentUnderTest().cancelCandidacy(candidacy);
// Asserts
assertTrue(result);
assertNull(mocker.getComponentUnderTest().getLastError());
verify(wikiUserManager).cancelCandidacy(candidacy);
}
Aggregations