I have the following code:
@Component
public class ProductServiceClient {
    private final RestTemplate template;
    public ProductServiceClient(RestTemplate template) {
        this.template = template;
    }
    public HttpStatus retrieveProducts() {
        HttpStatus response = null;
        try {
            response = template.getForEntity("/products", ProductContainer.class);
        } catch (RestClientResponseException exception) {
            responseStatus = getAllStat(exception);
        }
        return response;
    }
    private HttpStatus getAllStat (RestClientResponseException exception) {
        HttpStatus responseStatus = null;
        var getResponse = objectMapper.readValue(exception.getResponseBodyAsByteArray(), ProductContainer.class);
        responseStatus = getResponse.getCode();
        return responseStatus;
    }
}
I am having trouble with testing private method getAllstat (it can't be tested directly, only through retrieveProducts() method). I need to cover exactly that method with test. Here what I have by now:
@Test
class GetStatusOfProducts {
RestTemplate template = new RestTemplate();
when(restTemplate.postForEntity("/products", ProductContainer.class).thenThrow(
            RestClientResponseException.class);
}
