title: Mockito.when calling with real object return null, must use any()
body: <p>When I unit test with a mock <code>@Service</code>, I notice that in the <code>Mockito.when()</code> statement, when I save the real object, I get <code>null</code> as return; and I have to use <code>any()</code>. </p>
  
  <p>So, instead of using:</p>
  
  <pre><code>@Mock
  private BinInfoService service;
  ...  
  @Test
  public void testSave() {
      SomeBean bean = new SomeBean();
      Mockito.when(service.saveBinInfo(bean).thenReturn(bean);
  }
  </code></pre>
  
  <p>I have to use:</p>
  
  <pre><code>Mockito.when(service.saveBinInfo(Mockito.any(SomeBean.class))).thenReturn(bean);
  </code></pre>
  
  <p>The first form returns <code>null</code>. While the second form returns the saved entity.</p>
  
  <p>Why?</p>
  
  <p>EDIT:</p>
  
  <p>Sorry actually I am not instantiate the object like above. I used two other ways. See my answer.</p>