@Test void canAddGroupAsMember() throws Exception { when(this.groupManager.getMembers(CANDIDATE_GROUP, true)).thenReturn(emptyList()); when(this.groupManager.getMembers(TARGET_GROUP, true)).thenReturn(emptyList()); boolean actual = this.groupScriptService.canAddGroupAsMember(CANDIDATE_GROUP, TARGET_GROUP); assertTrue(actual); assertEquals(0, this.logCapture.size()); }
@Unstable public boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target) { boolean ret; if (target == null || candidate == null || candidate.equals(target)) { ret = false; } else { try { if (getMembers(target, false).contains(candidate)) { ret = false; } else { try { ret = !getMembers(candidate, true).contains(target); } catch (GroupException e) { this.logger.warn("Failed to access the members of the candidate group [{}]", candidate, e); ret = false; } } } catch (GroupException e) { this.logger.warn("Failed to access the members of the target group [{}]", target, e); ret = false; } } return ret; }
GroupScriptService implements ScriptService { @Unstable public boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target) { boolean ret; if (target == null || candidate == null || candidate.equals(target)) { ret = false; } else { try { if (getMembers(target, false).contains(candidate)) { ret = false; } else { try { ret = !getMembers(candidate, true).contains(target); } catch (GroupException e) { this.logger.warn("Failed to access the members of the candidate group [{}]", candidate, e); ret = false; } } } catch (GroupException e) { this.logger.warn("Failed to access the members of the target group [{}]", target, e); ret = false; } } return ret; } }
GroupScriptService implements ScriptService { @Unstable public boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target) { boolean ret; if (target == null || candidate == null || candidate.equals(target)) { ret = false; } else { try { if (getMembers(target, false).contains(candidate)) { ret = false; } else { try { ret = !getMembers(candidate, true).contains(target); } catch (GroupException e) { this.logger.warn("Failed to access the members of the candidate group [{}]", candidate, e); ret = false; } } } catch (GroupException e) { this.logger.warn("Failed to access the members of the target group [{}]", target, e); ret = false; } } return ret; }  }
GroupScriptService implements ScriptService { @Unstable public boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target) { boolean ret; if (target == null || candidate == null || candidate.equals(target)) { ret = false; } else { try { if (getMembers(target, false).contains(candidate)) { ret = false; } else { try { ret = !getMembers(candidate, true).contains(target); } catch (GroupException e) { this.logger.warn("Failed to access the members of the candidate group [{}]", candidate, e); ret = false; } } } catch (GroupException e) { this.logger.warn("Failed to access the members of the target group [{}]", target, e); ret = false; } } return ret; }  Collection<DocumentReference> getGroups(DocumentReference member, Object wikiTarget, boolean recurse); Collection<DocumentReference> getGroupsFromAllWikis(DocumentReference member); Collection<DocumentReference> getGroupsFromMemberWiki(DocumentReference member); Collection<DocumentReference> getGroupsFromMemberAndCurrentWiki(DocumentReference member); Collection<DocumentReference> getMembers(DocumentReference group, boolean recurse); Collection<DocumentReference> getMembers(DocumentReference group); @Unstable boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target); }
GroupScriptService implements ScriptService { @Unstable public boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target) { boolean ret; if (target == null || candidate == null || candidate.equals(target)) { ret = false; } else { try { if (getMembers(target, false).contains(candidate)) { ret = false; } else { try { ret = !getMembers(candidate, true).contains(target); } catch (GroupException e) { this.logger.warn("Failed to access the members of the candidate group [{}]", candidate, e); ret = false; } } } catch (GroupException e) { this.logger.warn("Failed to access the members of the target group [{}]", target, e); ret = false; } } return ret; }  Collection<DocumentReference> getGroups(DocumentReference member, Object wikiTarget, boolean recurse); Collection<DocumentReference> getGroupsFromAllWikis(DocumentReference member); Collection<DocumentReference> getGroupsFromMemberWiki(DocumentReference member); Collection<DocumentReference> getGroupsFromMemberAndCurrentWiki(DocumentReference member); Collection<DocumentReference> getMembers(DocumentReference group, boolean recurse); Collection<DocumentReference> getMembers(DocumentReference group); @Unstable boolean canAddGroupAsMember(DocumentReference candidate, DocumentReference target); static final String ROLEHINT; }