How do I write the following Mockito Matchers so that the call is not ambiguous?
The actual function call I'm trying to make fun of in my code:
Below is a snippet from my Unit Test case. It contains the following simulated call, emulating the above call, but, unfortunately, the compiler considers it ambiguous and does not compile.
The error I am getting is as follows:
The method exchange(String, HttpMethod, HttpEntity<?>, Class<DdsOAuthToken>, Object[]) is ambiguous for the type RestTemplate
This is the Spring RestTemplate api call. In particular, two api calls that it finds ambiguous, the following two calls:
1. exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) 2. exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Object... uriVariables)
I'm trying to make fun of # 1 above. But the Java compiler cannot determine if I am trying to call No. 1 or No. 2. Exactly how should I write Mockito layouts so that it knows that I want # 1 higher and not # 2?