ExpireRestoredBusinessObjectDataHelperServiceImpl implements ExpireRestoredBusinessObjectDataHelperService { @PublishNotificationMessages @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void completeStorageUnitExpiration(BusinessObjectDataRestoreDto businessObjectDataRestoreDto) { completeStorageUnitExpirationImpl(businessObjectDataRestoreDto); }  @PublishNotificationMessages @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void completeStorageUnitExpiration(BusinessObjectDataRestoreDto businessObjectDataRestoreDto); @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) void executeS3SpecificSteps(BusinessObjectDataRestoreDto businessObjectDataRestoreDto); @PublishNotificationMessages @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataRestoreDto prepareToExpireStorageUnit(BusinessObjectDataStorageUnitKey storageUnitKey);  }
@Test public void testCompleteStorageUnitExpiration() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, Arrays.asList(new StorageFile(S3_KEY, FILE_SIZE, ROW_COUNT)), NO_EXCEPTION, ARCHIVE_RETRIEVAL_OPTION); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); StorageUnitStatusEntity newStorageUnitStatusEntity = new StorageUnitStatusEntity(); newStorageUnitStatusEntity.setCode(StorageUnitStatusEntity.ARCHIVED); StorageUnitStatusEntity oldStorageUnitStatusEntity = new StorageUnitStatusEntity(); oldStorageUnitStatusEntity.setCode(StorageUnitStatusEntity.EXPIRING); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); storageUnitEntity.setStatus(oldStorageUnitStatusEntity); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity)).thenReturn(storageUnitEntity); doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { StorageUnitEntity storageUnitEntity = (StorageUnitEntity) invocation.getArguments()[0]; storageUnitEntity.setStatus(newStorageUnitStatusEntity); return null; } }).when(storageUnitDaoHelper).updateStorageUnitStatus(storageUnitEntity, StorageUnitStatusEntity.ARCHIVED, StorageUnitStatusEntity.ARCHIVED); expireRestoredBusinessObjectDataHelperServiceImpl.completeStorageUnitExpiration(businessObjectDataRestoreDto); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(storageUnitDaoHelper).getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); verify(storageUnitDaoHelper).updateStorageUnitStatus(storageUnitEntity, StorageUnitStatusEntity.ARCHIVED, StorageUnitStatusEntity.ARCHIVED); verifyNoMoreInteractionsHelper(); assertEquals(StorageUnitStatusEntity.ARCHIVED, businessObjectDataRestoreDto.getNewStorageUnitStatus()); assertEquals(StorageUnitStatusEntity.EXPIRING, businessObjectDataRestoreDto.getOldStorageUnitStatus()); }