@Test void handlePaymentAuthorizeException() throws NoSuchFieldException { FieldSetter.setField(service, service.getClass().getDeclaredField("objectMapper"), STATIC_MAPPER); PaymentAuthorizeResponse authorizeResponse = new PaymentAuthorizeResponse(new PaymentTO()); PsuMessage message = new PsuMessage(); message.setCode("400"); message.setText("Msg"); authorizeResponse.setPsuMessages(List.of(message)); ResponseEntity<Map> result = service.handlePaymentAuthorizeException(new PaymentAuthorizeException(ResponseEntity.status(HttpStatus.NOT_FOUND).body(authorizeResponse))); compareBodies(result, ResponseEntity.status(HttpStatus.BAD_REQUEST).body(getExpected(400, "Msg"))); }
@ExceptionHandler(PaymentAuthorizeException.class) public ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e) { PaymentAuthorizeResponse body = e.getError().getBody(); PsuMessage psuMessage = body.getPsuMessages().get(0); Map content = buildContentMap(psuMessage.getCode(), psuMessage.getText()); return new ResponseEntity<>(content, HttpStatus.valueOf(Integer.parseInt(psuMessage.getCode()))); }
GlobalExceptionHandler { @ExceptionHandler(PaymentAuthorizeException.class) public ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e) { PaymentAuthorizeResponse body = e.getError().getBody(); PsuMessage psuMessage = body.getPsuMessages().get(0); Map content = buildContentMap(psuMessage.getCode(), psuMessage.getText()); return new ResponseEntity<>(content, HttpStatus.valueOf(Integer.parseInt(psuMessage.getCode()))); } }
GlobalExceptionHandler { @ExceptionHandler(PaymentAuthorizeException.class) public ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e) { PaymentAuthorizeResponse body = e.getError().getBody(); PsuMessage psuMessage = body.getPsuMessages().get(0); Map content = buildContentMap(psuMessage.getCode(), psuMessage.getText()); return new ResponseEntity<>(content, HttpStatus.valueOf(Integer.parseInt(psuMessage.getCode()))); }  }
GlobalExceptionHandler { @ExceptionHandler(PaymentAuthorizeException.class) public ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e) { PaymentAuthorizeResponse body = e.getError().getBody(); PsuMessage psuMessage = body.getPsuMessages().get(0); Map content = buildContentMap(psuMessage.getCode(), psuMessage.getText()); return new ResponseEntity<>(content, HttpStatus.valueOf(Integer.parseInt(psuMessage.getCode()))); }  @ExceptionHandler(ObaException.class) ResponseEntity<Map> handleAisException(ObaException e); @ExceptionHandler(PaymentAuthorizeException.class) ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e); @ExceptionHandler(AuthorizationException.class) ResponseEntity<Map> handleAuthException(AuthorizationException e); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod); }
GlobalExceptionHandler { @ExceptionHandler(PaymentAuthorizeException.class) public ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e) { PaymentAuthorizeResponse body = e.getError().getBody(); PsuMessage psuMessage = body.getPsuMessages().get(0); Map content = buildContentMap(psuMessage.getCode(), psuMessage.getText()); return new ResponseEntity<>(content, HttpStatus.valueOf(Integer.parseInt(psuMessage.getCode()))); }  @ExceptionHandler(ObaException.class) ResponseEntity<Map> handleAisException(ObaException e); @ExceptionHandler(PaymentAuthorizeException.class) ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e); @ExceptionHandler(AuthorizationException.class) ResponseEntity<Map> handleAuthException(AuthorizationException e); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod);  }