### Question:
MongoDao implements GenericDao<T, ID> { @Override public T update(T entity) { Key<T> key = datastore.merge(entity); return datastore.getByKey(persistentClass, key); } @Inject  MongoDao(Datastore datastore, Class<T> persistentClass); @Override boolean exists(ID id); @Override List<T> findAll(); @Override T findById(ID id); @Override T save(T entity); @Override T update(T entity); @Override void delete(T entity); @Override void deleteById(ID id); Query<T> query();  }### Answer:
@Test public void updateEntity() { TestEntity requestEntity = mockedEntity; requestEntity.setIntField(1000); requestEntity.setBooleanField(false); requestEntity.setDoubleField(Math.PI); requestEntity.setFloatField(7.18f); requestEntity.setLongField(5000); requestEntity.setStringField("Testing 1...2...3"); TestEntity responseEntity = mongoDao.update(requestEntity); assertNotNull("The updated entity should be returned after saving", responseEntity); assertEquals("The response and request entities should be equal", requestEntity, responseEntity); assertEquals("The datastore should still have one entity", 1, fongoRule.getDB("streamflow").getCollection("test").count()); }