### Question:
MongoTopologyDao extends MongoDao<Topology, String> implements TopologyDao { @Override public Topology findById(String id, String userId) { return query().field("_id").equal(id).field("userId").equal(userId).get(); } @Inject  MongoTopologyDao(Datastore datastore); @Override boolean exists(String id, String userId); @Override List<Topology> findAll(String userId); @Override Topology findById(String id, String userId); @Override Topology findByName(String name, String userId); @Override Topology save(Topology topology, String userId); @Override Topology update(Topology topology, String userId); @Override void delete(Topology topology, String userId); @Override void deleteById(String id, String userId);  }### Answer:
@Test public void findTopologyByIdForUser() { Topology validTopology = topologyDao.findById("first", "user1"); assertNotNull("The returned topology should not be null with valid query values", validTopology); Topology invalidTopology = topologyDao.findById("second", "user1"); assertNull("The returned topology should be null with invalid query values", invalidTopology); }
@Test public void findTopologyByIdForAnonymous() { Topology validTopology = topologyDao.findById("fourth", null); assertNotNull("The returned topology should not be null with valid query values", validTopology); Topology invalidTopology = topologyDao.findById("second", null); assertNull("The returned topology should be null with invalid query values", invalidTopology); }