MembershipProvider extends AuthorizableBaseProvider { boolean isDeclaredMember(@NotNull Tree groupTree, @NotNull Tree authorizableTree) { if (!hasMembers(groupTree)) { return false; } String contentId = getContentID(authorizableTree); MemberReferenceIterator refs = getDeclaredMemberReferenceIterator(groupTree); return Iterators.contains(refs, contentId); } MembershipProvider(@NotNull Root root, @NotNull ConfigurationParameters config);   }
@Test public void testIsDeclaredMemberTransient() throws Exception { Group g = createGroup(); List<String> memberPaths = createMembers(g, NUM_USERS/2); for (String path : memberPaths) { assertTrue(mp.isDeclaredMember(getTree(g), getTree(path))); } }
@Test public void testIsDeclaredMember() throws Exception { Group g = createGroup(); List<String> memberPaths = createMembers(g, NUM_USERS/2); root.commit(); for (String path : memberPaths) { assertTrue(mp.isDeclaredMember(getTree(g), getTree(path))); } }
@Test public void testIsDeclaredMemberMissingMembersProperty() throws Exception { Tree grTree = getTree(createGroup()); Tree memberTree = getTree(createUser()); Tree memberList = TreeUtil.addChild(grTree, REP_MEMBERS_LIST, NT_REP_MEMBER_REFERENCES_LIST); TreeUtil.addChild(memberList, "member1", NT_REP_MEMBER_REFERENCES).setProperty(REP_MEMBERS, Collections.singleton(getContentID(memberTree)), Type.STRINGS); assertTrue(mp.isDeclaredMember(grTree, memberTree)); }
@Test public void testNotIsDeclaredMemberMissingMembersProperty() throws Exception { Tree grTree = getTree(createGroup()); Tree memberTree = getTree(createUser()); Tree memberList = TreeUtil.addChild(grTree, REP_MEMBERS_LIST, NT_REP_MEMBER_REFERENCES_LIST); TreeUtil.addChild(memberList, "member1", NT_REP_MEMBER_REFERENCES).setProperty(REP_MEMBERS, Collections.singleton(getContentID("another")), Type.STRINGS); assertFalse(mp.isDeclaredMember(grTree, memberTree)); }