title: Mockito FindIterable<Document>
body: <p>Am trying to write a JUnit test case for below method, am using Mockito framework.</p>
  
  <p>Method:</p>
  
  <pre><code>public EmplInfo getMetaData(String objectId) {
  
          objectId = new StringBuffer(objectId).reverse().toString();
          try{
              BasicDBObject whereClauseCondition = getMetaDataWhereClause(objectId);
              EmplInfo emplinfo= new EmplInfo ();
              emplinfo.set_id(objectId);
              FindIterable&lt;Document&gt; cursorPersonDoc = personDocCollection.find(whereClauseCondition);
              for (Document doc : cursorPersonDoc) {
                  emplinfo.setEmplFirstName(doc.getString("firstname"));
                  emplinfo.setEmplLastName(doc.getString("lastname"));
                  break;
              }
              return emplinfo;
          }catch(Exception e){
           e.printstacktrace();
          }
  </code></pre>
  
  <p>Junit:</p>
  
  <pre><code>@Test
  public void testGetMetaData() throws Exception {
      String docObjectId = "f2da8044b29f2e0a35c0a2b5";
      BasicDBObject dbObj = personDocumentRepo.getMetaDataWhereClause(docObjectId);
      FindIterable&lt;Document&gt; findIterable = null;
      Mockito.when(collection.find(dbObj)).thenReturn(findIterable);
      personDocumentRepo.getMetaData(docObjectId);
  }
  </code></pre>
  
  <p>Am getting null point expection in "personDocumentRepo.getMetaData(docObjectId)", because am "Return" the findIterable which is NULL. Not sure how to assign dummy/test value into findIterable.</p>
  
  <p>Please advise.</p>
  
  <p>Thanks!
  Bharathi</p>