0
@Retryable(value = {UnknownHostException.class, ResourceAccessException.class, HttpClientErrorException.class},
            maxAttemptsExpression = "#{${labelling.service.retry.maxAttempts}}",
            backoff = @Backoff(delayExpression = "#{${labelling.service.retry.delay}}",
                    multiplierExpression = "#{${labelling.service.retry.multiplier}}",
                    maxDelayExpression = "#{${labelling.service.retry.maxDelay}}"))
    public ResponseEntity<String> fetchLabellingServiceData(String packageId){

/// Details of the method omitted intentionally  
}


@Recover
    public ResponseEntity<String> handle(HttpClientErrorException e){
        return ResponseEntity
                .status(e.getRawStatusCode())
                .body(e.getMessage()+" "+e.getResponseBodyAsString());
    }

During Junit Test If I mock and throw HttpClientErrorException then the @Recover method is not called . How Can I call that while writing mock ?

Santanu Guha
  • 71
  • 1
  • 8

0 Answers0