### Question:
VolumeManagementDAO extends DefaultDAOBase<Integer, VolumeManagement> { public List<VolumeManagement> getVolumesByVirtualAppliance(final VirtualAppliance vapp) { Query query = getSession().createQuery(VolumeManagement.BY_VAPP); query.setInteger("vappId", vapp.getId()); return query.list(); } VolumeManagementDAO();  VolumeManagementDAO(final EntityManager entityManager); List<VolumeManagement> getVolumesByPool(final StoragePool sp); List<VolumeManagement> getVolumesByVirtualDatacenter(final VirtualDatacenter vdc); VolumeManagement getVolumeByVirtualDatacenter(final VirtualDatacenter vdc,
        final Integer volumeId); List<VolumeManagement> getStatefulCandidates(final VirtualDatacenter vdc); List<VolumeManagement> getVolumesFromEnterprise(final Integer idEnterprise); @SuppressWarnings("unchecked") List<VolumeManagement> getVolumesByPool(final StoragePool sp, final FilterOptions filters); @SuppressWarnings("unchecked") List<VolumeManagement> getVolumesByVirtualDatacenter(final VirtualDatacenter vdc,
        final FilterOptions filters); List<VolumeManagement> getVolumesByEnterprise(final Integer id,
        final FilterOptions filters); @SuppressWarnings("unchecked") List<VolumeManagement> getAvailableVolumes(final VirtualDatacenter vdc,
        final FilterOptions filters); VolumeManagement getVolumeFromImage(final Integer idImage); @Deprecated // use vm.getVolumes List<VolumeManagement> getVolumesByVirtualMachine(final VirtualMachine vm); List<VolumeManagement> getVolumesByVirtualMachine(final VirtualMachine vm,
        final FilterOptions filters); List<VolumeManagement> getAttachedVolumes(final VirtualDatacenter vdc); List<VolumeManagement> getDetachedVolumes(final VirtualDatacenter vdc); List<VolumeManagement> getVolumesByVirtualAppliance(final VirtualAppliance vapp);  }### Answer:
@Test public void testGetSameVirtualAppliance() { VirtualDatacenter vdc = vdcGenerator.createUniqueInstance(); VirtualAppliance vapp = vappGenerator.createInstance(vdc); VirtualAppliance vapp1 = vappGenerator.createInstance(vdc); VolumeManagement volume = eg().createInstance(vdc); VolumeManagement volume1 = eg().createInstance(vdc); VolumeManagement volume2 = eg().createInstance(vdc); volume.setVirtualAppliance(vapp); volume1.setVirtualAppliance(vapp); volume2.setVirtualAppliance(vapp1); List<Object> entitiesToPersist = new ArrayList<Object>(); vdcGenerator.addAuxiliaryEntitiesToPersist(vdc, entitiesToPersist); persistAll(ds(), entitiesToPersist, vdc.getDatacenter(), vdc.getEnterprise(), vdc, volume .getStoragePool().getDevice(), volume.getStoragePool().getTier(), volume.getStoragePool(), volume.getRasd(), volume, volume1.getStoragePool().getDevice(), volume1.getStoragePool().getTier(), volume1.getStoragePool(), volume1.getRasd(), volume1, volume2.getStoragePool() .getDevice(), volume2.getStoragePool().getTier(), volume2.getStoragePool(), volume2.getRasd(), volume2, vapp, vapp1); VolumeManagementDAO dao = createDaoForRollbackTransaction(); List<VolumeManagement> results = dao.getVolumesByVirtualAppliance(vapp); assertEquals(results.size(), 2); }