### Question:
DatastoreDAO extends DefaultDAOBase<Integer, Datastore> { public List<Datastore> findMachineDatastores(final Machine machine) { assert machine != null; assert isManaged2(machine); Criteria criteria = inMachine(machine); criteria.addOrder(Order.asc(Datastore.NAME_PROPERTY)); List<Datastore> result = getResultList(criteria); return result; } DatastoreDAO();  DatastoreDAO(final EntityManager entityManager); List<Datastore> findMachineDatastores(final Machine machine); List<Datastore> findShares(final Datastore datastore); Datastore findDatastore(final String uuid, final Machine machine); boolean existsAnyWithName(final String name); boolean existsAnyOtherWithName(final Datastore entity, final String name); boolean existsAnyWithDirectory(final String directory); boolean existsAnyOtherWithDirectory(final Datastore entity, final String directory);  }### Answer:
@Test public void findMachineDatastores() { DatacenterGenerator datacenterGenerator = new DatacenterGenerator(getSeed()); Datacenter datacenter = datacenterGenerator.createUniqueInstance(); MachineGenerator machineGenerator = new MachineGenerator(getSeed()); Machine machine = machineGenerator.createMachine(datacenter); Datastore entity = eg().createInstance(machine); ds().persistAll(datacenter, machine, entity); EntityManager em = ds().createEntityManagerAndBeginRollbackTransaction(); DatastoreDAO dao = createDao(em); MachineDAO machineDao = new MachineDAO(em); Machine machine_2 = machineDao.findById(machine.getId()); List<Datastore> datastores = dao.findMachineDatastores(machine_2); AssertEx.assertSize(datastores, 1); }