AccessDeniedExceptionHandler implements BaseExceptionHandler<AccessDeniedException> { @Override @ResponseStatus(value = HttpStatus.FORBIDDEN) @ResponseBody @ExceptionHandler(value = { AccessDeniedException.class }) public MessageResource handle(final AccessDeniedException e) throws Exception { LOG.error("Handling AccessDeniedException", e); MessageResource message = new MessageResource(); message.setMessageType(MessageType.ERROR); message.setMessage(e.getMessage()); return message; }  @Override @ResponseStatus(value = HttpStatus.FORBIDDEN) @ResponseBody @ExceptionHandler(value = { AccessDeniedException.class }) MessageResource handle(final AccessDeniedException e);  }
@Test public void testHandle() throws Exception { AccessDeniedException e = new AccessDeniedException(""); MessageResource expected = new MessageResource(); expected.setMessageType(MessageType.ERROR); expected.setMessage(e.getMessage()); MessageResource actual = unit.handle(e); assertEquals(expected, actual); }