### Question:
FailedAuthenticationHandler implements AuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws ServletException { log.debug("Unauthorized access to '{}' endpoint", request.getRequestURI()); handler.handleException(request, response, exception); }  @Override void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception);  }### Answer:
@Test public void testOnAuthenticationFailure() throws ServletException { AuthExceptionHandler authExceptionHandler = mock(AuthExceptionHandler.class); MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); MockHttpServletResponse httpServletResponse = new MockHttpServletResponse(); FailedAuthenticationHandler failedAuthenticationHandler = new FailedAuthenticationHandler(authExceptionHandler); BadCredentialsException badCredentialsException = new BadCredentialsException("ERROR"); failedAuthenticationHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, badCredentialsException); verify(authExceptionHandler).handleException( httpServletRequest, httpServletResponse, badCredentialsException ); }