title: Mockito RestTemplate Test fails - HttpEntity has both entity and headers
body: <p>I am trying to mock a Rest Client using Mockito which takes in the following:-</p>
  
  <p>MainServiceClass.java</p>
  
  <pre><code>public String serviceCall(String s1){
  
      String data2 = "s1";
  
    try{
        headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.set("headers1", "headers1");
  
        HttpEntity&lt;String&gt; entity = new HttpEntity&lt;String&gt;(data2, headers);
          ResponseEntity&lt;Object&gt; responseEntity = restTemplate.exchange(someurl, HttpMethod.POST, entity, Object.class);
  
        return someString; }
  </code></pre>
  
  <p>ServiceTest.java</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  @SpringBootTest
  public class RestTemplateTests {
  
   @InjectMocks
      @Spy
      private Someservice service;
  
      @Autowired
      private MockMvc mockMvc;
  
  
          @Mock
          RestTemplate restTemplate;
  
          ResponseEntity responseEntity = mock(ResponseEntity.class);
  
  
  
      @Test
      public void myCallToTemplate() throws Exception {
      @Test
      public Mytestforcallingservice() {
        Mockito.when(restTemplate.exchange(
                                      someurl,
                                      HttpMethod.POST,
                                      Mockito.&lt;HttpEntity&lt;String&gt;&gt; any(),
                                      Mockito.&lt;Class&lt;?&gt;&gt; 
                                  any())).thenReturn(responseEntity);
                      String s2 = service.serviceCall(s1);
                      Assert.assertEquals(s2, "hey");
      }
  </code></pre>
  
  <p>Below is my Error:-</p>
  
  <pre><code>.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
          Invalid use of argument matchers!
          4 matchers expected, 2 recorded:
          -&gt; at com.example.MyServiceClass.Mytestforcallingservice(ServiceTest.java:110)
          -&gt; at com.example.ServiceTest.Mytestforcallingservice(ServiceTest.java:110)
  
          This exception may occur if matchers are combined with raw values:
              //incorrect:
              someMethod(anyObject(), "raw String");
          When using matchers, all arguments have to be provided by matchers.
          For example:
              //correct:
              someMethod(anyObject(), eq("String by matcher"));
  </code></pre>
  
  <p>The Test fails at forming HttpEntity which has both data2 and headers.
  How can I form that in the Mockito call ?</p>
  
  <p>Also, how can I verify it.</p>
  
  <p>Thank you.</p>