@Test public void getCandidacyAsAdmin() throws Exception { 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); MemberCandidacy result = mocker.getComponentUnderTest().getCandidacy("subwiki", 12); assertEquals(candidacy, result); assertEquals("private message", result.getAdminPrivateComment()); }
public MemberCandidacy getCandidacy(String wikiId, int candidacyId) { MemberCandidacy candidacy = null; try { candidacy = wikiUserManager.getCandidacy(wikiId, candidacyId); if (!canSeeCandidacy(candidacy)) { setLastError(new WikiUserManagerScriptServiceException("You are not allowed to see this candidacy.")); candidacy = null; } } catch (WikiUserManagerException e) { setLastError(e); } return candidacy; }
WikiUserManagerScriptService implements ScriptService { public MemberCandidacy getCandidacy(String wikiId, int candidacyId) { MemberCandidacy candidacy = null; try { candidacy = wikiUserManager.getCandidacy(wikiId, candidacyId); if (!canSeeCandidacy(candidacy)) { setLastError(new WikiUserManagerScriptServiceException("You are not allowed to see this candidacy.")); candidacy = null; } } catch (WikiUserManagerException e) { setLastError(e); } return candidacy; } }
WikiUserManagerScriptService implements ScriptService { public MemberCandidacy getCandidacy(String wikiId, int candidacyId) { MemberCandidacy candidacy = null; try { candidacy = wikiUserManager.getCandidacy(wikiId, candidacyId); if (!canSeeCandidacy(candidacy)) { setLastError(new WikiUserManagerScriptServiceException("You are not allowed to see this candidacy.")); candidacy = null; } } catch (WikiUserManagerException e) { setLastError(e); } return candidacy; }  }
WikiUserManagerScriptService implements ScriptService { public MemberCandidacy getCandidacy(String wikiId, int candidacyId) { MemberCandidacy candidacy = null; try { candidacy = wikiUserManager.getCandidacy(wikiId, candidacyId); if (!canSeeCandidacy(candidacy)) { setLastError(new WikiUserManagerScriptServiceException("You are not allowed to see this candidacy.")); candidacy = null; } } catch (WikiUserManagerException e) { setLastError(e); } return candidacy; }  Exception getLastError(); UserScope getUserScope(); UserScope getUserScope(String wikiId); boolean setUserScope(String wikiId, String scope); MembershipType getMembershipType(); MembershipType getMembershipType(String wikiId); boolean setMembershipType(String wikiId, String type); Collection<String> getMembers(String wikiId); Boolean isMember(String userId, String wikiId); boolean addMember(String userId, String wikiId); boolean addMembers(Collection<String> userIds, String wikiId); boolean removeMember(String userId, String wikiId); MemberCandidacy getCandidacy(String wikiId, int candidacyId); Collection<MemberCandidacy> getAllInvitations(String wikiId); Boolean hasPendingInvitation(DocumentReference user, String wikiId); Boolean hasPendingRequest(DocumentReference user, String wikiId); Collection<MemberCandidacy> getAllRequests(String wikiId); boolean join(String userId, String wikiId); boolean leave(String userId, String wikiId); MemberCandidacy askToJoin(String userId, String wikiId, String message); boolean acceptRequest(MemberCandidacy request, String message, String privateComment); boolean refuseRequest(MemberCandidacy request, String message, String privateComment); boolean cancelCandidacy(MemberCandidacy candidacy); MemberCandidacy invite(String userId, String wikiId, String message); boolean acceptInvitation(MemberCandidacy invitation, String message); boolean refuseInvitation(MemberCandidacy invitation, String message); }
WikiUserManagerScriptService implements ScriptService { public MemberCandidacy getCandidacy(String wikiId, int candidacyId) { MemberCandidacy candidacy = null; try { candidacy = wikiUserManager.getCandidacy(wikiId, candidacyId); if (!canSeeCandidacy(candidacy)) { setLastError(new WikiUserManagerScriptServiceException("You are not allowed to see this candidacy.")); candidacy = null; } } catch (WikiUserManagerException e) { setLastError(e); } return candidacy; }  Exception getLastError(); UserScope getUserScope(); UserScope getUserScope(String wikiId); boolean setUserScope(String wikiId, String scope); MembershipType getMembershipType(); MembershipType getMembershipType(String wikiId); boolean setMembershipType(String wikiId, String type); Collection<String> getMembers(String wikiId); Boolean isMember(String userId, String wikiId); boolean addMember(String userId, String wikiId); boolean addMembers(Collection<String> userIds, String wikiId); boolean removeMember(String userId, String wikiId); MemberCandidacy getCandidacy(String wikiId, int candidacyId); Collection<MemberCandidacy> getAllInvitations(String wikiId); Boolean hasPendingInvitation(DocumentReference user, String wikiId); Boolean hasPendingRequest(DocumentReference user, String wikiId); Collection<MemberCandidacy> getAllRequests(String wikiId); boolean join(String userId, String wikiId); boolean leave(String userId, String wikiId); MemberCandidacy askToJoin(String userId, String wikiId, String message); boolean acceptRequest(MemberCandidacy request, String message, String privateComment); boolean refuseRequest(MemberCandidacy request, String message, String privateComment); boolean cancelCandidacy(MemberCandidacy candidacy); MemberCandidacy invite(String userId, String wikiId, String message); boolean acceptInvitation(MemberCandidacy invitation, String message); boolean refuseInvitation(MemberCandidacy invitation, String message);  }