StoragePolicyProcessorHelperServiceImpl implements StoragePolicyProcessorHelperService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void updateStoragePolicyTransitionFailedAttemptsIgnoreException(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto) { updateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImpl(storagePolicyTransitionParamsDto); }  @PublishNotificationMessages @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void initiateStoragePolicyTransition(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto,
        StoragePolicySelection storagePolicySelection); @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) void executeStoragePolicyTransition(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto); @PublishNotificationMessages @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void completeStoragePolicyTransition(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void updateStoragePolicyTransitionFailedAttemptsIgnoreException(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto);  }
@Test public void testUpdateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImplFirstFailure() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(); storagePolicyTransitionParamsDto.setBusinessObjectDataKey(businessObjectDataKey); storagePolicyTransitionParamsDto.setStorageName(STORAGE_NAME); when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey); when(storageUnitDaoHelper.getStorageUnitEntityByKey(businessObjectDataStorageUnitKey)).thenReturn(storageUnitEntity); storagePolicyProcessorHelperServiceImpl.updateStoragePolicyTransitionFailedAttemptsIgnoreException(storagePolicyTransitionParamsDto); verify(jsonHelper).objectToJson(storagePolicyTransitionParamsDto); verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME); verify(storageUnitDaoHelper).getStorageUnitEntityByKey(businessObjectDataStorageUnitKey); verify(storageUnitDao).saveAndRefresh(storageUnitEntity); verify(jsonHelper).objectToJson(businessObjectDataStorageUnitKey); verifyNoMoreInteractionsHelper(); assertEquals(Integer.valueOf(1), storageUnitEntity.getStoragePolicyTransitionFailedAttempts()); }
@Test public void testUpdateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImplNoBusinessObjectDataKey() { StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(); storagePolicyTransitionParamsDto.setStorageName(STORAGE_NAME); storagePolicyProcessorHelperServiceImpl.updateStoragePolicyTransitionFailedAttemptsIgnoreException(storagePolicyTransitionParamsDto); verify(jsonHelper).objectToJson(storagePolicyTransitionParamsDto); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImplNoStorageName() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(); storagePolicyTransitionParamsDto.setBusinessObjectDataKey(businessObjectDataKey); storagePolicyProcessorHelperServiceImpl.updateStoragePolicyTransitionFailedAttemptsIgnoreException(storagePolicyTransitionParamsDto); verify(jsonHelper).objectToJson(storagePolicyTransitionParamsDto); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateStoragePolicyTransitionFailedAttemptsIgnoreExceptionImplSecondFailure() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); storageUnitEntity.setStoragePolicyTransitionFailedAttempts(1); BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(); storagePolicyTransitionParamsDto.setBusinessObjectDataKey(businessObjectDataKey); storagePolicyTransitionParamsDto.setStorageName(STORAGE_NAME); when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey); when(storageUnitDaoHelper.getStorageUnitEntityByKey(businessObjectDataStorageUnitKey)).thenReturn(storageUnitEntity); storagePolicyProcessorHelperServiceImpl.updateStoragePolicyTransitionFailedAttemptsIgnoreException(storagePolicyTransitionParamsDto); verify(jsonHelper).objectToJson(storagePolicyTransitionParamsDto); verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME); verify(storageUnitDaoHelper).getStorageUnitEntityByKey(businessObjectDataStorageUnitKey); verify(storageUnitDao).saveAndRefresh(storageUnitEntity); verify(jsonHelper).objectToJson(businessObjectDataStorageUnitKey); verifyNoMoreInteractionsHelper(); assertEquals(Integer.valueOf(2), storageUnitEntity.getStoragePolicyTransitionFailedAttempts()); }