Garmaine Staff asked 2 years ago

I am trying to write a JUNIT(version 5 ) for a restemplate call.

My actual Implementation is like below .

ResponseEntity<OrderDocument> responseEntity = restTemplate.exchange(
URL,
HttpMethod.GET,
new HttpEntity<>(headers),
OrderDocument.class, message.getPayload().toString());

My Mock call is

when(restTemplate.exchange(anyString() ,
any(HttpMethod.class)   , 
any(HttpEntity.class) ,
any(OrderDocument.class) ,
any(String.class) )
.thenReturn(responseEntity));

I am getting compiler error Cannot resolve method 'exchange(java.lang.String, T, T, T, T)' I believe my mock call matching with Implementation.Not sure why its not compiling.Please help.

 ResponseEntity<T> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, 
 Class<T> responseType, Object... uriVariables) throws RestClientException;