Mockito mocking restTemplate.postForEntity
问题 I am trying to mock restTemplate.postForEntity method, The actual method call is: URI myUri = new URI(myString); HttpEntity<String> myEntity ... String myResponse = restTemplate.postForEntity(myUri, myEntity, String.class); What I have in my test class is: Mockito.when(restTemplate.postForEntity(any(URI.class), any(HttpEntity.class), eq(String.class))).thenReturn(response); This does not work; I have tried several other permutations with no success either. Any suggestions appreciated, thanks.