UsernamePasswordCredentialToPrincipalResolver implements CredentialToPrincipalResolver { @Override public boolean supports(Credential credential) { return credential != null && (this.classToSupport.equals(credential.getClass()) || (this.classToSupport .isAssignableFrom(credential.getClass())) && this.supportSubClasses); }  void setSupportSubClasses(boolean supportSubClasses); @Override Principal resolvePrincipal(Credential credential); @Override boolean supports(Credential credential);  }
@Test public void testSupports(){ Assert.assertFalse(resolver.supports(null)); Credential credential = Mockito.mock(Credential.class); Assert.assertFalse(resolver.supports(credential)); credential = new UsernamePasswordCredential(); Assert.assertTrue(resolver.supports(credential)); credential = new SubUsernamePasswordCredential(); Assert.assertTrue(resolver.supports(credential)); }