### Question:
VolumeManagementDAO extends DefaultDAOBase<Integer, VolumeManagement> { public VolumeManagement getVolumeByVirtualDatacenter(final VirtualDatacenter vdc, final Integer volumeId) { Criteria criteria = createCriteria(sameId(volumeId), sameVirtualDatacenter(vdc)); return getSingleResultOrNull(criteria); } 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 testGetVolumeByVirtualDatacenter() { VolumeManagement volume = eg().createUniqueInstance(); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(volume, entitiesToPersist); persistAll(ds(), entitiesToPersist, volume); VolumeManagementDAO dao = createDaoForRollbackTransaction(); VolumeManagement result = dao.getVolumeByVirtualDatacenter(volume.getVirtualDatacenter(), volume.getId()); eg().assertAllPropertiesEqual(result, volume); }