### Question:
MachineDAO extends DefaultDAOBase<Integer, Machine> { public List<Integer> findAllIdsInDatacenters(final Datacenter... datacenters) { Query query = getSession().createQuery(QUERY_ALL_IDS_IN); query.setParameterList("datacenters", datacenters); return query.list(); } MachineDAO();  MachineDAO(final EntityManager entityManager); List<Machine> findMachines(final Datacenter datacenter); List<Machine> findRackMachines(final Rack rack); List<Machine> findRackMachines(final Rack rack, final String filter); List<Machine> findMachinesWithHAInProgress(); List<Machine> findRackEnabledForHAMachines(final Rack rack); List<Machine> findRackEnabledForHAMachinesInUcs(final UcsRack rack); boolean existsAnyWithDatacenterAndName(final Datacenter datacenter, final String name); boolean existsAnyOtherWithDatacenterAndName(final Machine machine, final String name); int deleteRackMachines(final Rack rack); List<Machine> findCandidateMachines(final Integer idRack,
        final Integer idVirtualDatacenter, final Long hdRequiredOnDatastore,
        final Enterprise enterprise); List<Machine> findCandidateMachines(final Integer idRack,
        final Integer idVirtualDatacenter, final Enterprise enterprise, final String datastoreUuid,
        final Integer originalHypervisorId); List<Machine> findReservedMachines(final Enterprise enterprise); Machine findReservedMachine(final Enterprise enterprise, final Integer machineId); void reserveMachine(final Machine machine, final Enterprise enterprise); void releaseMachine(final Machine machine); Machine findByIds(final Integer datacenterId, final Integer rackId,
        final Integer machineId); Machine findByIp(final Datacenter datacenter, final String ip); Set<Integer> findAllIds(); List<Integer> findAllIdsInDatacenters(final Datacenter... datacenters); Long getTotalUsedCores(); Long getTotalUsedCoresExceptMachine(final Machine machine);  }### Answer:
@Test public void testGetIdsInDatacenter() { DatacenterGenerator datacenterGenerator = new DatacenterGenerator(getSeed()); RackGenerator rackGenerator = new RackGenerator(getSeed()); MachineGenerator machineGenerator = new MachineGenerator(getSeed()); Datacenter datacenter1 = datacenterGenerator.createUniqueInstance(); Datacenter datacenter2 = datacenterGenerator.createUniqueInstance(); Rack rack1 = rackGenerator.createInstance(datacenter1); Rack rack2 = rackGenerator.createInstance(datacenter2); final Machine machine11 = machineGenerator.createMachine(datacenter1, rack1); final Machine machine12 = machineGenerator.createMachine(datacenter1, rack1); final Machine machine21 = machineGenerator.createMachine(datacenter2, rack2); final Machine machine22 = machineGenerator.createMachine(datacenter2, rack2); ds().persistAll(datacenter1, datacenter2, rack1, rack2, machine11, machine12, machine21, machine22); Set<Integer> dc1Ids = new HashSet<Integer>() { { add(machine11.getId()); add(machine12.getId()); } }; Set<Integer> dc2Ids = new HashSet<Integer>() { { add(machine21.getId()); add(machine22.getId()); } }; MachineDAO dao = createDaoForRollbackTransaction(); List<Integer> resultDc1 = dao.findAllIdsInDatacenters(datacenter1); assertEquals(resultDc1.size(), 2); for (Integer dc1 : resultDc1) { assertTrue(dc1Ids.contains(dc1)); } List<Integer> resultDc2 = dao.findAllIdsInDatacenters(datacenter2); assertEquals(resultDc2.size(), 2); for (Integer dc2 : resultDc2) { assertTrue(dc2Ids.contains(dc2)); } List<Integer> resultAll = dao.findAllIdsInDatacenters(datacenter1, datacenter2); assertEquals(resultAll.size(), 4); }