DefaultExceptionHandler implements BaseExceptionHandler<Exception> { @Override @ResponseBody @ResponseStatus(value = HttpStatus.BAD_REQUEST) @ExceptionHandler(value = { IllegalArgumentException.class, UnsupportedOperationException.class }) public MessageResource handle(final Exception e) { LOGGER.error("Handling general exception exception", e); MessageResource message = new MessageResource(); message.setMessageType(MessageType.ERROR); message.setMessage(e.getMessage()); return message; }  @Override @ResponseBody @ResponseStatus(value = HttpStatus.BAD_REQUEST) @ExceptionHandler(value = { IllegalArgumentException.class, UnsupportedOperationException.class }) MessageResource handle(final Exception e);  }
@Test public void testHandle() throws Exception { String msg = "No entity found"; IllegalArgumentException e = new IllegalArgumentException(msg); MessageResource expected = new MessageResource(); expected.setMessageType(MessageType.ERROR); expected.setMessage(e.getMessage()); MessageResource actual = unit.handle(e); assertEquals(expected, actual); }