@Test public void leave() throws Exception { String userId = "mainWiki:XWiki.User"; String wikiId = "wikiId"; boolean result = this.mocker.getComponentUnderTest().leave(userId, wikiId); assertTrue(result); verify(wikiUserManager).leave(userId, wikiId); }
public boolean leave(String userId, String wikiId) { XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call $services.wiki.user.leave()" + " with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.leave(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; }
WikiUserManagerScriptService implements ScriptService { public boolean leave(String userId, String wikiId) { XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call $services.wiki.user.leave()" + " with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.leave(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; } }
WikiUserManagerScriptService implements ScriptService { public boolean leave(String userId, String wikiId) { XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call $services.wiki.user.leave()" + " with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.leave(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; }  }
WikiUserManagerScriptService implements ScriptService { public boolean leave(String userId, String wikiId) { XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call $services.wiki.user.leave()" + " with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.leave(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; }  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 boolean leave(String userId, String wikiId) { XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call $services.wiki.user.leave()" + " with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.leave(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; }  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);  }