@Test void willMapAggregateNotFoundExceptions() { var exception = new AggregateNotFoundException("aggregate-id", "not found here"); var expectedResponse = ApiErrorResponse.builder() .status(NOT_FOUND) .message("not found here") .timeStamp(Instant.now(clock)) .build(); assertEquals(new ResponseEntity<>(expectedResponse, new HttpHeaders(), NOT_FOUND), controllerAdvice.handleNotFoundException(exception)); }
@ExceptionHandler(AggregateNotFoundException.class) public ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception) { return new ResponseEntity<>(createResponseBody(exception.getMessage(), NOT_FOUND), new HttpHeaders(), NOT_FOUND); }
ExceptionHandlingControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler(AggregateNotFoundException.class) public ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception) { return new ResponseEntity<>(createResponseBody(exception.getMessage(), NOT_FOUND), new HttpHeaders(), NOT_FOUND); } }
ExceptionHandlingControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler(AggregateNotFoundException.class) public ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception) { return new ResponseEntity<>(createResponseBody(exception.getMessage(), NOT_FOUND), new HttpHeaders(), NOT_FOUND); } ExceptionHandlingControllerAdvice(Clock clock); }
ExceptionHandlingControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler(AggregateNotFoundException.class) public ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception) { return new ResponseEntity<>(createResponseBody(exception.getMessage(), NOT_FOUND), new HttpHeaders(), NOT_FOUND); } ExceptionHandlingControllerAdvice(Clock clock); @ExceptionHandler(AggregateNotFoundException.class) ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception); @ExceptionHandler(RuntimeException.class) ResponseEntity<Object> handleRuntimeException(RuntimeException exception); @ExceptionHandler(ExecutionException.class) ResponseEntity<Object> handleExecutionException(ExecutionException exception); @ExceptionHandler(RemoteCommandExecutionException.class) ResponseEntity<Object> handleRemoteCommandExecutionException(RemoteCommandExecutionException exception); }
ExceptionHandlingControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler(AggregateNotFoundException.class) public ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception) { return new ResponseEntity<>(createResponseBody(exception.getMessage(), NOT_FOUND), new HttpHeaders(), NOT_FOUND); } ExceptionHandlingControllerAdvice(Clock clock); @ExceptionHandler(AggregateNotFoundException.class) ResponseEntity<Object> handleNotFoundException(AggregateNotFoundException exception); @ExceptionHandler(RuntimeException.class) ResponseEntity<Object> handleRuntimeException(RuntimeException exception); @ExceptionHandler(ExecutionException.class) ResponseEntity<Object> handleExecutionException(ExecutionException exception); @ExceptionHandler(RemoteCommandExecutionException.class) ResponseEntity<Object> handleRemoteCommandExecutionException(RemoteCommandExecutionException exception);  }