'Mockito: Verify if restTemplate.exchange() is called
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)
Solution 1:[1]
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |