GroupPrincipals { public static boolean isMember(@NotNull Principal principal, @NotNull Principal member) { if (principal instanceof GroupPrincipal) { return ((GroupPrincipal) principal).isMember(member); } return false; } private  GroupPrincipals(); static boolean isGroup(@NotNull Principal principal); @NotNull static Enumeration<? extends Principal> members(@NotNull Principal principal); static boolean isMember(@NotNull Principal principal, @NotNull Principal member);  }
@Test public void testIsMemberOfNonGroup() { assertFalse(GroupPrincipals.isMember(mock(Principal.class), mock(Principal.class))); }
@Test public void testIsMemberOfGroupPrincipal() { GroupPrincipal gp = mock(GroupPrincipal.class); Principal p = mock(Principal.class); GroupPrincipals.isMember(gp, p); verify(gp, times(1)).isMember(p); }