### Question:
AuditAuthenticator implements IAuthenticator { @Override public AuthenticatedUser legacyAuthenticate(Map<String, String> credentials) throws AuthenticationException { LOG.debug("Setting up SASL negotiation with client peer"); return wrappedAuthenticator.legacyAuthenticate(credentials); } AuditAuthenticator();   AuditAuthenticator(IDecoratedAuthenticator wrappedAuthenticator, AuditAdapter auditAdapter); @Override boolean requireAuthentication(); @Override Set<? extends IResource> protectedResources(); @Override void validateConfiguration(); @Override void setup(); @Override SaslNegotiator newSaslNegotiator(); @Override AuthenticatedUser legacyAuthenticate(Map<String, String> credentials);  }### Answer:
@Test public void testLegacyAuthenticateIsDelegated() { Map<String, String> expectedCredentials = new HashMap<>(); expectedCredentials.put("user", "password"); AuthenticatedUser expectedUser = mock(AuthenticatedUser.class); when(mockAuthenticator.legacyAuthenticate(eq(expectedCredentials))).thenReturn(expectedUser); AuthenticatedUser actualUser = auditAuthenticator.legacyAuthenticate(expectedCredentials); ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); verify(mockAuthenticator, times(1)).legacyAuthenticate(captor.capture()); Map<String, String> actualCredentials = captor.getValue(); assertThat(actualCredentials).isEqualTo(expectedCredentials); assertThat(expectedUser).isEqualTo(actualUser); }