### Question:
MongoStore implements ToDoStore { @Override public ToDo update(String id, ToDo td) { DBObject query = new BasicDBObject("_id", new ObjectId(id)); DBObject update = convertToDbObject(td); coll.update(query, update); DBCursor cursor = coll.find(query); ToDo newTd = createToDo(cursor.next()); cursor.close(); return newTd; } MongoStore(DBCollection coll); @Override Collection<ToDo> getAll(); @Override ToDo get(String id); @Override ToDo persist(ToDo td); @Override ToDo update(String id, ToDo td); @Override void delete(String id); @Override int count();  }### Answer:
@Test public void testUpdate() { DBCollection coll = createMockCollection(); DBCursor cursor = createMockCursor(); DBObject query = new BasicDBObject("_id", new ObjectId("aaaaaaaaaaaaaaaaaaaaaaa2")); DBObject dbObj = new BasicDBObject(); dbObj.put("_id", new ObjectId("aaaaaaaaaaaaaaaaaaaaaaa2")); dbObj.put("title", "new title"); dbObj.put("completed", true); dbObj.put("order", 0); expect(cursor.next()).andReturn(dbObj); cursor.close(); expectLastCall(); replay(cursor); expect(coll.find(eq(query))).andReturn(cursor); ToDo newTd = new ToDo(); newTd.setId("aaaaaaaaaaaaaaaaaaaaaaa2"); newTd.setCompleted(true); newTd.setTitle("new title"); newTd.setOrder(0); expect(coll.update(eq(query), eq(dbObj))).andReturn(null); replay(coll); MongoStore store = new MongoStore(coll); assertEquals(newTd, store.update("aaaaaaaaaaaaaaaaaaaaaaa2", newTd)); verify(cursor); verify(coll); }