title: Mockito Matchers: matching a Class type in parameter list
body: <p>I am working with Java, Spring's RestTemplate, and Mockito, using Eclipse.  I am trying to mock Spring's rest template, and the last parameter for the method I am mocking is a Class type.  Below is the signature for the function:</p>
  
  <pre><code>public &lt;T&gt; ResponseEntity&lt;T&gt; exchange(URI url,
                                    HttpMethod method,
                                    HttpEntity&lt;?&gt; requestEntity,
                                    Class&lt;T&gt; responseType)
                         throws RestClientException
  </code></pre>
  
  <p>The initial attempt I made to mock this method is as follows:</p>
  
  <pre><code>//given restTemplate returns exception
  when(restTemplate.exchange(isA(URI.class), eq(HttpMethod.POST), isA(HttpEntity.class), eq(Long.class))).thenThrow(new RestClientException(EXCEPTION_MESSAGE));
  </code></pre>
  
  <p>However, this line of code produces the following error from eclipse:</p>
  
  <pre><code>The method exchange(URI, HttpMethod, HttpEntity&lt;?&gt;, Class&lt;T&gt;) in the type RestTemplate is not applicable for the arguments (URI, HttpMethod, HttpEntity, Class&lt;Long&gt;)
  </code></pre>
  
  <p>Eclipse then suggests I cast the last parameter with a 'Class' cast, but does not seem to work if I cast it to a 'Class', or other type.</p>
  
  <p>I've been looking online for help on this, but seem to stumped on the fact that the parameter requested is a class type.  </p>
  
  <p>The answers I've looked at so far have been mainly related to generic collections.  Any help here would be greatly appreciated.</p>