title: mongodb+mockito doesn't work together?
body: <p>I'm trying to setup mocks for mongodb in my java code, and I'm getting the following exception:</p>
  
  <pre><code>org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
  DBCursor$$EnhancerByMockitoWithCGLIB$$fc4f0e22 cannot be returned by getOptions()
  getOptions() should return int
  </code></pre>
  
  <p>The line of code that generates this is:</p>
  
  <pre><code>when(col.find(query)).thenReturn(cursor);
  </code></pre>
  
  <p>Where col is a mocked DBCollection, query is a mocked DBObject, and cursor is a mocked DBCursor.</p>
  
  <p>I've found the following very vague but probably relevant problem description:</p>
  
  <p><a href="http://osdir.com/ml/mongodb-user/2010-08/msg02102.html" rel="nofollow">http://osdir.com/ml/mongodb-user/2010-08/msg02102.html</a></p>