### Question:
RestExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler ResponseEntity handle(ErrorResponseException exception) { logError(exception); HttpHeaders responseHeaders = addErrorOriginationHeader( headersMapper.toHttpHeaders(exception.getResponseHeaders()), ErrorOrigination.BANK ); HttpStatus status = HttpStatus.valueOf(exception.getStatusCode()); return exception.getErrorResponse() .map(response -> { String originalResponse = exception.getMessage(); if (response.getTppMessages() == null && response.getLinks() == null && originalResponse != null && !originalResponse.isEmpty()) { return new ResponseEntity<>(originalResponse, responseHeaders, status); } return new ResponseEntity<>(response, responseHeaders, status); }) .orElseGet(() -> new ResponseEntity<>(responseHeaders, status)); } RestExceptionHandler(HeadersMapper headersMapper);   }### Answer:
@Test void handleErrorResponseExceptionReturnsOriginalMessageWhenXs2aErrorResponseFieldsAreAbsent() { ErrorResponseException ex = new ErrorResponseException(400, emptyResponseHeaders(), new ErrorResponse(), OAUTH_ERROR_RESPONSE); RestExceptionHandler exceptionHandler = this.exceptionHandler; ResponseEntity responseEntity = exceptionHandler.handle(ex); assertThat(responseEntity.getBody()).isEqualTo(OAUTH_ERROR_RESPONSE); }
@Test void requestValidationException() { RequestValidationException requestValidationException = new RequestValidationException(singletonList(new ValidationError(ValidationError.Code.REQUIRED, RequestHeaders.TPP_REDIRECT_URI, "..."))); ResponseEntity<ErrorResponse> responseEntity = exceptionHandler.handle(requestValidationException); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); assertThat(responseEntity.getHeaders().get("X-GTW-Error-Origination")).isEqualTo(singletonList("ADAPTER")); assertThat(responseEntity.getBody().getTppMessages()).hasSize(1); TppMessage tppMessage = responseEntity.getBody().getTppMessages().get(0); assertThat(tppMessage.getCategory()).isEqualTo(TppMessageCategory.ERROR); assertThat(tppMessage.getCode()).isEqualTo(MessageCode.FORMAT_ERROR); assertThat(tppMessage.getPath()).isEqualTo(requestValidationException.getValidationErrors().get(0).getPath()); assertThat(tppMessage.getText()).isEqualTo(requestValidationException.getValidationErrors().get(0).getMessage()); }