### Question:
DiskStatefulConversionDAO extends DefaultDAOBase<Integer, DiskStatefulConversion> { public DiskStatefulConversion getByVolume(final Integer volumeId) { return findUniqueByCriterions(sameVolume(volumeId)); } DiskStatefulConversionDAO();  DiskStatefulConversionDAO(final EntityManager entityManager); DiskStatefulConversion getByVolume(final Integer volumeId);  }### Answer:
@Test public void testGetByVolume() { VolumeManagement volume = volumeManagementGenerator.createUniqueInstance(); DiskStatefulConversion diskStatefulConversion = eg().createInstance(volume); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(diskStatefulConversion, entitiesToPersist); persistAll(ds(), entitiesToPersist, diskStatefulConversion); DiskStatefulConversionDAO diskStatefulConversionDAO = createDaoForRollbackTransaction(); DiskStatefulConversion result = diskStatefulConversionDAO.getByVolume(volume.getId()); assertNotNull(result); assertAllEntityPropertiesEqual(result, diskStatefulConversion); }
@Test public void testGetByUnexistingVolume() { VolumeManagement volume = volumeManagementGenerator.createUniqueInstance(); DiskStatefulConversion diskStatefulConversion = eg().createInstance(volume); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(diskStatefulConversion, entitiesToPersist); persistAll(ds(), entitiesToPersist, diskStatefulConversion); DiskStatefulConversionDAO diskStatefulConversionDAO = createDaoForRollbackTransaction(); DiskStatefulConversion result = diskStatefulConversionDAO.getByVolume(volume.getId() + 1); assertNull(result); }