title: Mockito mocking restTemplate.postForEntity
body: <p>I am trying to mock <code>restTemplate.postForEntity</code> method,</p>
  
  <p>The actual method call is:</p>
  
  <pre><code>URI myUri = new URI(myString);
  HttpEntity&lt;String&gt; myEntity ...
  
  
  String myResponse = restTemplate.postForEntity(myUri, myEntity, String.class);
  </code></pre>
  
  <p>What I have in my test class is:</p>
  
  <pre><code>Mockito.when(restTemplate.postForEntity(any(URI.class), any(HttpEntity.class), eq(String.class))).thenReturn(response);
  </code></pre>
  
  <p>This does not work; I have tried several other permutations with no success either. Any suggestions appreciated, thanks.</p>
  
  <p>By this does not work I mean that the actual method is called and not the mocked method (so the desired result is not returned etc.)</p>