I am using mockito to mock a RestTemplate exchange call. Following is what I've used, but it's not picking up the mocked RestTemplate.
Mocked call.
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class, userId);
The mocked RestTempate as follows.
Mockito.when(restTemplate.exchange(
Matchers.anyString(),
Matchers.any(HttpMethod.class),
Matchers.<HttpEntity<?>> any(),
Matchers.<Class<String>> any(),
Matchers.anyString())).
thenReturn(responseEntity);
Any idea what went wrong here? This runs with @RunWith(PowerMockRunner.class) Since I am mocking a static content.