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