title: Mockito mock overloaded methods
body: <p>I am trying to mock an overloaded method of the following schema</p>
  
  <pre><code>JestClient {
  
      DocumentResult execute(Index x) {...}
  
      BulkResult execute(Bulk y ) {...}
  }
  </code></pre>
  
  <p>I used the following code to create the mocks. </p>
  
  <pre><code>JestClient client = Mockito.mock(JestClient.class);
  
      DocumentResult setResult = Mockito.mock(DocumentResult.class);
      when(setResult.isSucceeded()).thenReturn(true);
  
      BulkResult bulkResult = Mockito.mock(BulkResult.class);
      when(bulkResult.isSucceeded()).thenReturn(true);
  
      // when(client.execute(Mockito.any(Index.class))).thenReturn(setResult);
      // when(client.execute(Mockito.any(Bulk.class))).thenReturn(bulkResult);
  
      doReturn(setResult).when(client).execute(Mockito.any(Index.class));
      doReturn(bulkResult).when(client).execute(Mockito.any(Bulk.class));
  
      JestClientFactory factory = Mockito.mock(JestClientFactory.class);
      when(factory.getObject()).thenReturn(client);
  </code></pre>
  
  <p>The resultant mock always returns the second mock and ignores the first irrespective of the object type passed as parameter.</p>