Reputation: 658
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;
Upvotes: 1
Views: 2254
Reputation: 1
Changing any(OrderDocument.class) to eq(OrderDocument.class) worked for me.
Upvotes: 0