### Question:
ChainingPrincipalResolver implements PrincipalResolver { public boolean supports(final Credential credential) { return this.chain.get(0).supports(credential); }  void setChain(final List<PrincipalResolver> chain); Principal resolve(final Credential credential); boolean supports(final Credential credential);  }### Answer:
@Test public void testSupports() throws Exception { final Credential credential = mock(Credential.class); when(credential.getId()).thenReturn("a"); final PrincipalResolver resolver1 = mock(PrincipalResolver.class); when(resolver1.supports(eq(credential))).thenReturn(true); final PrincipalResolver resolver2 = mock(PrincipalResolver.class); when(resolver2.supports(eq(credential))).thenReturn(false); final ChainingPrincipalResolver resolver = new ChainingPrincipalResolver(); resolver.setChain(Arrays.asList(resolver1, resolver2)); assertTrue(resolver.supports(credential)); }