### Question:
NodeVirtualImageDAO extends DefaultDAOBase<Integer, NodeVirtualImage> { public NodeVirtualImage findByVirtualMachine(final VirtualMachine vmachine) { Criteria criteria = createCriteria(sameVirtualMachine(vmachine)); return (NodeVirtualImage) criteria.uniqueResult(); } NodeVirtualImageDAO();  NodeVirtualImageDAO(final EntityManager entityManager); VirtualAppliance findVirtualAppliance(final VirtualMachine vmachine); NodeVirtualImage findByVirtualMachine(final VirtualMachine vmachine); List<NodeVirtualImage> findByEnterprise(final Enterprise enterprise); List<NodeVirtualImage> findByVirtualImage(final VirtualMachineTemplate virtualImage); List<NodeVirtualImage> findByVirtualAppliance(final VirtualAppliance virtualAppliance); List<Integer> findVirtualMachineIdsByVirtualAppliance(
        final VirtualAppliance virtualAppliance);  }### Answer:
@Test public void testFindByVirtualMachine() { NodeVirtualImage nodeVirtualImage = eg().createInstance(vapp, vmachine, vimage); ds().persistAll(nodeVirtualImage); NodeVirtualImageDAO nodeVirtualImageDAO = createDaoForRollbackTransaction(); NodeVirtualImage result = nodeVirtualImageDAO.findByVirtualMachine(vmachine); assertNotNull(result); assertEquals(result.getId(), nodeVirtualImage.getId()); }
@Test public void testFindByUnexistingVirtualMachine() { NodeVirtualImage nodeVirtualImage = eg().createInstance(vapp, vmachine); ds().persistAll(nodeVirtualImage); NodeVirtualImageDAO nodeVirtualImageDAO = createDaoForRollbackTransaction(); VirtualMachine vmachineUnexisting = virtualMachineGenerator.createUniqueInstance(); NodeVirtualImage result = nodeVirtualImageDAO.findByVirtualMachine(vmachineUnexisting); assertNull(result); }