i try to test my SpringBoot application with Mockito. Is it possible to check if a restTemplate.exchange() method is called n times?
For example:
verify(restTemplate, times(1))
.exchange(myURL, method, requestEntity, responseType)
i try to test my SpringBoot application with Mockito. Is it possible to check if a restTemplate.exchange() method is called n times?
For example:
verify(restTemplate, times(1))
.exchange(myURL, method, requestEntity, responseType)
Try this:
verify(restTemplate, times(1))
.exchange(
ArgumentMatchers.anyString(),
ArgumentMatchers.any(HttpMethod.class),
ArgumentMatchers.any(HttpEntity.class),
ArgumentMatchers.<Class<Object>>any()
);
More on this topic: How do I mock a REST template exchange?