AbstractGroupPrincipal extends TreeBasedPrincipal implements GroupPrincipal { abstract boolean isMember(@NotNull Authorizable authorizable) throws RepositoryException; AbstractGroupPrincipal(@NotNull String principalName, @NotNull Tree groupTree, @NotNull NamePathMapper namePathMapper);   AbstractGroupPrincipal(@NotNull String principalName, @NotNull String groupPath, @NotNull NamePathMapper namePathMapper); @Override boolean isMember(@NotNull Principal principal); @NotNull @Override Enumeration<? extends Principal> members();  }
@Test public void testIsMemberOf() throws Exception { final Principal p = getTestUser().getPrincipal(); assertTrue(agp.isMember(p)); assertTrue(agp.isMember(new PrincipalImpl(p.getName()))); assertTrue(agp.isMember(() -> p.getName())); }
@Test public void testIsMemberMissingAuthorizable() { List<Principal> principals = ImmutableList.of( new PrincipalImpl("name"), () -> "name" ); for (Principal p : principals) { assertFalse(agp.isMember(p)); } }
@Test public void testIsMemberOfEveryone() throws Exception { final Principal p = getTestUser().getPrincipal(); assertTrue(everyoneAgp.isMember(p)); assertTrue(everyoneAgp.isMember(new PrincipalImpl(p.getName()))); assertTrue(everyoneAgp.isMember(() -> p.getName())); }
@Test public void testIsMemberOfEveryoneMissingAuthorizable() { List<Principal> principals = ImmutableList.of( new PrincipalImpl("name"), () -> "name" ); for (Principal p : principals) { assertTrue(everyoneAgp.isMember(p)); } }
@Test public void testIsMemberOfInternalError() throws Exception { final Principal p = getTestUser().getPrincipal(); assertFalse(throwing.isMember(p)); }
@Test public void testEveryoneIsMemberOfEveryone() { AbstractGroupPrincipal member = mock(AbstractGroupPrincipal.class); when(member.getName()).thenReturn(EveryonePrincipal.NAME); assertFalse(everyoneAgp.isMember(member)); }