### Question:
MachineLoadRuleDAO extends DefaultDAOBase<Integer, MachineLoadRule> { public List<MachineLoadRule> findByRack(final Rack rack) { return findByRack(rack, false); } MachineLoadRuleDAO();  MachineLoadRuleDAO(final EntityManager entityManager); @SuppressWarnings("unchecked") List<MachineLoadRule> findCandidateMachineLoadRules(
        final Collection<Machine> firstPassCandidateMachines); List<MachineLoadRule> getRulesForDatacenter(final Integer idDatacenter); @SuppressWarnings("unchecked") List<MachineLoadRule> findByMachine(final Integer idMachine); List<MachineLoadRule> findByRack(final Rack rack); @SuppressWarnings("unchecked") List<MachineLoadRule> findByRack(final Rack rack, final boolean includeMachineRules);  }### Answer:
@Test public void test_findMachineLoadRulesByRack() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Datacenter datacenter = datacenterGenerator.createUniqueInstance(); Rack rack = datacenter.createRack("bRack_1", 2, 4094, 2, 10); Machine machine = machineGenerator.createMachine(datacenter, rack); MachineLoadRule mclr1 = eg().createInstance(rack); MachineLoadRule mclr2 = eg().createInstance(machine); ds().persistAll(datacenter, rack, machine, mclr1, mclr2); MachineLoadRuleDAO dao = createDaoForRollbackTransaction(); Assert.assertEquals(dao.findByRack(rack).size(), 1); }
@Test public void test_findMachineLoadRulesByRackIncludingMachineRules() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Datacenter datacenter = datacenterGenerator.createUniqueInstance(); Rack rack = datacenter.createRack("bRack_1", 2, 4094, 2, 10); Machine machine = machineGenerator.createMachine(datacenter, rack); MachineLoadRule mclr1 = eg().createInstance(rack); MachineLoadRule mclr2 = eg().createInstance(machine); ds().persistAll(datacenter, rack, machine, mclr1, mclr2); MachineLoadRuleDAO dao = createDaoForRollbackTransaction(); Assert.assertEquals(dao.findByRack(rack, true).size(), 2); }