I'm trying to mock a RestTemplate exchange() call with the following code:
Test method
given(restTemplate.exchange(any(UriComponents.class), any(HttpMethod.class), any(HttpEntity.class), any(StatusResponse.class)))
.willReturn(new ResponseEntity<>(HttpStatus.BAD_GATEWAY));
The code does not compile because:
- it complains that
cannot resolve method willReturn(new ResponseEntity<>(HttpStatus.BAD_GATEWAY))
- it complains that
cannot resolve method exchange(T, T, T, T)
How should I change the signature to make it work? Thanks.