title: Mockito: Stub method with complex object as a parameter
body: <p>Maybe this is a newbie question, but can't find the answer.</p>
  
  <p>I need to stub a method with Mockito. If the method has "simple" arguments, then I can do it. For example, a find method with two parameters, car color and number of doors:</p>
  
  <pre class="lang-java prettyprint-override"><code> when(carFinderMock.find(eq(Color.RED),anyInt())).thenReturn(Car1);
   when(carFinderMock.find(eq(Color.BLUE),anyInt())).thenReturn(Car2);
   when(carFinderMock.find(eq(Color.GREEN), eq(5))).thenReturn(Car3);
  </code></pre>
  
  <p>The problem is that the find argument is a complex object.</p>
  
  <pre class="lang-java prettyprint-override"><code> mappingFilter = new MappingFilter();
   mappingFilter.setColor(eq(Color.RED));
   mappingFilter.setDoorNumber(anyInt());
   when(carFinderMock.find(mappingFilter)).thenReturn(Car1);
  </code></pre>
  
  <p>This code does not work. The error is "Invalid use of argument matchers! 1 matchers expected, 2 recorded". </p>
  
  <p>Can't modify the "find" method, it needs to be a MappingFilter parameter.</p>
  
  <p>I suppose that I have to do "something" to indicate Mockito that when the mappingFilter.getColor is RED, and mappingFilter.getDoorNumber is any, then it has to return Car1 (and the same for the other two sentences). 
  But how?</p>