### Question:
NodeVirtualImageStatefulConversionDAO extends
    DefaultDAOBase<Integer, NodeVirtualImageStatefulConversion> { public Collection<NodeVirtualImageStatefulConversion> findByVirtualAppliance( final VirtualAppliance virtualAppliance) { Query query = getSession().createQuery(QUERY_BY_VIRTUAL_APPLIANCE); query.setParameter("idVirtualAppliance", virtualAppliance.getId()); return query.list(); } NodeVirtualImageStatefulConversionDAO();  NodeVirtualImageStatefulConversionDAO(final EntityManager entityManager); static Criterion sameVIConversion(final VirtualImageConversion vic); static Criterion sameVASConversion(final VirtualApplianceStatefulConversion vasc); Collection<NodeVirtualImageStatefulConversion> findByVirtualImageConversion(
        final VirtualImageConversion virtualImageConversion); Collection<NodeVirtualImageStatefulConversion> findByVirtualApplianceStatefulConversion(
        final VirtualApplianceStatefulConversion virtualApplianceStatefulConversion); Collection<NodeVirtualImageStatefulConversion> findByVirtualAppliance(
        final VirtualAppliance virtualAppliance);  }### Answer:
@Test public void test_findNodeVirtualImageStatefulConversionsByVirtualAppliance() { NodeVirtualImageStatefulConversion nvisc = eg().createUniqueInstance(); VirtualApplianceStatefulConversion vasc = nvisc.getVirtualApplianceStatefulConversion(); Enterprise ent = vasc.getVirtualAppliance().getVirtualDatacenter().getEnterprise(); Datacenter dc = vasc.getVirtualAppliance().getVirtualDatacenter().getDatacenter(); VirtualMachineTemplate vi = nvisc.getNodeVirtualImage().getVirtualImage(); VirtualMachine vm = nvisc.getNodeVirtualImage().getVirtualMachine(); vasc.getUser().setEnterprise(ent); vi.setEnterprise(ent); vm.setEnterprise(ent); vasc.getUser().getRole().setEnterprise(ent); nvisc.getTier().setDatacenter(dc); vi.getRepository().setDatacenter(dc); nvisc.getNodeVirtualImage().setVirtualAppliance(vasc.getVirtualAppliance()); vm.setUser(vasc.getUser()); vasc.getUser().getRole().setPrivileges(null); ds().persistAll(dc, ent, vasc.getVirtualAppliance().getVirtualDatacenter(), vasc.getVirtualAppliance(), vasc.getUser().getRole(), vasc.getUser(), vasc, vi.getCategory(), vi.getRepository(), vi, vm, nvisc.getNodeVirtualImage(), nvisc.getTier(), nvisc); NodeVirtualImageStatefulConversionDAO dao = createDaoForRollbackTransaction(); Collection<NodeVirtualImageStatefulConversion> list = dao.findByVirtualAppliance(vasc.getVirtualAppliance()); assertTrue(!list.isEmpty()); assertSize(list, 1); assertEquals(list.iterator().next().getId(), nvisc.getId()); }