### Question:
UnauthorizedHandler implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws ServletException { log.debug("Unauthorized access to '{}' endpoint", request.getRequestURI()); handler.handleException(request, response, authException); }  @Override void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException);  }### Answer:
@Test public void testCommence() throws IOException, ServletException { UnauthorizedHandler unauthorizedHandler = new UnauthorizedHandler(new AuthExceptionHandler(messageService, objectMapper)); MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); httpServletRequest.setRequestURI("URI"); MockHttpServletResponse httpServletResponse = new MockHttpServletResponse(); unauthorizedHandler.commence(httpServletRequest, httpServletResponse, new TokenExpireException("ERROR")); assertEquals(HttpStatus.UNAUTHORIZED.value(), httpServletResponse.getStatus()); Message message = messageService.createMessage( ErrorType.TOKEN_EXPIRED.getErrorMessageKey(), httpServletRequest.getRequestURI()); verify(objectMapper).writeValue(httpServletResponse.getWriter(), message.mapToView()); }