PrincipalManagerImpl implements PrincipalQueryManager, PrincipalManager { @Override public boolean hasPrincipal(@NotNull String principalName) { return principalProvider.getPrincipal(principalName) != null; } PrincipalManagerImpl(@NotNull PrincipalProvider principalProvider); @Override boolean hasPrincipal(@NotNull String principalName); @Override @Nullable Principal getPrincipal(@NotNull String principalName); @Override @NotNull PrincipalIterator findPrincipals(@Nullable String simpleFilter); @Override @NotNull PrincipalIterator findPrincipals(@Nullable String simpleFilter, int searchType); @Override @NotNull PrincipalIterator getPrincipals(int searchType); @Override @NotNull PrincipalIterator getGroupMembership(@NotNull Principal principal); @Override @NotNull Principal getEveryone(); @NotNull @Override PrincipalIterator findPrincipals(@Nullable String simpleFilter, boolean fullText, int searchType, long offset, long limit);  }
@Test public void testHasPrincipalEveryone() { assertTrue(principalMgr.hasPrincipal(EveryonePrincipal.NAME)); }
@Test public void testHasPrincipal() { for (Principal pcpl : testPrincipals) { assertTrue(principalMgr.hasPrincipal(pcpl.getName())); } }
@Test public void testHasPrincipalUnknown() { assertFalse(principalMgr.hasPrincipal(TestPrincipalProvider.UNKNOWN.getName())); }
@Test public void testAllMembersKnown() { for (Principal p : testPrincipals) { if (isGroup(p)) { Enumeration<? extends Principal> en = ((GroupPrincipal) p).members(); while (en.hasMoreElements()) { Principal memb = en.nextElement(); assertTrue(principalMgr.hasPrincipal(memb.getName())); } } } }