use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.
the class StoragePolicyProcessorHelperServiceTest method testInitiateStoragePolicyTransitionStoragePolicyFilterStorageBucketNameNotConfigured.
@Test
public void testInitiateStoragePolicyTransitionStoragePolicyFilterStorageBucketNameNotConfigured() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create and persist a business object data entity.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Create and persist an S3 storage entity without S3 bucket name configured.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_PATH_PREFIX), Boolean.TRUE.toString()));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes);
// Create and persist a storage policy entity with storage policy filter storage has no S3 bucket name attribute configured.
storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Try to initiate a storage policy transition when storage policy filter storage has no S3 bucket name attribute configured.
try {
storagePolicyProcessorHelperService.initiateStoragePolicyTransition(new StoragePolicyTransitionParamsDto(), new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, INITIAL_VERSION));
fail("Should throw an IllegalStateException when storage policy filter storage has no S3 bucket name attribute configured.");
} catch (IllegalStateException e) {
assertEquals(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), STORAGE_NAME), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataEntitiesMatchingStoragePoliciesNoStoragePolicyLatestVersion.
@Test
public void testBusinessObjectDataEntitiesMatchingStoragePoliciesNoStoragePolicyLatestVersion() {
// Create and persist an enabled storage policy entity that has no latest version flag set.
storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, NO_LATEST_VERSION_FLAG_SET);
// Create and persist a storage unit with ENABLED status in the storage policy filter storage.
storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
// Try to retrieve the business object data matching to the storage policy.
Map<BusinessObjectDataEntity, StoragePolicyEntity> result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 0, 0, MAX_RESULT);
// Validate the results.
assertEquals(0, result.size());
}
use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataEntitiesMatchingStoragePoliciesTestingStartPositionAndMaxResult.
@Test
public void testBusinessObjectDataEntitiesMatchingStoragePoliciesTestingStartPositionAndMaxResult() {
// Create and persist a storage policy entity.
StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Create and persist a storage unit with ENABLED status in the storage policy filter storage.
StorageUnitEntity storageUnitEntity1 = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
// Apply the offset in days to business object data "created on" value.
businessObjectDataDaoTestHelper.ageBusinessObjectData(storageUnitEntity1.getBusinessObjectData(), BDATA_AGE_IN_DAYS + 1);
// Create and persist a second storage unit with ENABLED status in the storage policy filter storage.
StorageUnitEntity storageUnitEntity2 = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
// Also apply an offset to business object data "created on" value, but make this business object data older than the first.
businessObjectDataDaoTestHelper.ageBusinessObjectData(storageUnitEntity2.getBusinessObjectData(), BDATA_AGE_IN_DAYS + 2);
// Try to retrieve both business object data instances as matching to the storage policy, but with max result limit set to 1.
Map<BusinessObjectDataEntity, StoragePolicyEntity> result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 0, 0, 1);
// Validate the results. Only the oldest business object data should get selected.
assertEquals(1, result.size());
assertTrue(result.containsKey(storageUnitEntity2.getBusinessObjectData()));
assertEquals(storagePolicyEntity, result.get(storageUnitEntity2.getBusinessObjectData()));
// Try to retrieve the second business object data instance matching to the storage policy
// by specifying the relative start position and max result limit set.
result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 0, 1, 1);
// Validate the results. Now, the second oldest business object data should get selected.
assertEquals(1, result.size());
assertTrue(result.containsKey(storageUnitEntity1.getBusinessObjectData()));
assertEquals(storagePolicyEntity, result.get(storageUnitEntity1.getBusinessObjectData()));
}
use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method testBusinessObjectDataEntitiesMatchingStoragePoliciesWithStoragePolicyTransitionMaxAllowedAttempts.
@Test
public void testBusinessObjectDataEntitiesMatchingStoragePoliciesWithStoragePolicyTransitionMaxAllowedAttempts() {
// Create and persist a storage policy entity.
storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Create and persist a storage unit in the storage policy filter storage.
StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
// Retrieve the business object data matching to the storage policy, when storagePolicyTransitionMaxAllowedAttempts is not specified.
Map<BusinessObjectDataEntity, StoragePolicyEntity> result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 0, 0, MAX_RESULT);
// Validate the results. A single match should get returned.
assertEquals(1, result.size());
assertTrue(result.containsKey(storageUnitEntity.getBusinessObjectData()));
// Retrieve the business object data matching to the storage policy, when storagePolicyTransitionMaxAllowedAttempts is specified,
// storage unit has storagePolicyTransitionFailedAttempts set to NULL.
storageUnitEntity.setStoragePolicyTransitionFailedAttempts(null);
storageUnitDao.saveAndRefresh(storageUnitEntity);
result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 1, 0, MAX_RESULT);
// Validate the results. A single match should get returned.
assertEquals(1, result.size());
assertTrue(result.containsKey(storageUnitEntity.getBusinessObjectData()));
// Retrieve the business object data matching to the storage policy, when storagePolicyTransitionMaxAllowedAttempts is specified,
// storage unit has storagePolicyTransitionFailedAttempts < storagePolicyTransitionMaxAllowedAttempts.
storageUnitEntity.setStoragePolicyTransitionFailedAttempts(0);
storageUnitDao.saveAndRefresh(storageUnitEntity);
result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 1, 0, MAX_RESULT);
// Validate the results. A single match should get returned.
assertEquals(1, result.size());
assertTrue(result.containsKey(storageUnitEntity.getBusinessObjectData()));
// Try to retrieve the business object data matching to the storage policy, when storagePolicyTransitionMaxAllowedAttempts is specified,
// storage unit has storagePolicyTransitionFailedAttempts == storagePolicyTransitionMaxAllowedAttempts.
storageUnitEntity.setStoragePolicyTransitionFailedAttempts(1);
storageUnitDao.saveAndRefresh(storageUnitEntity);
result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 1, 0, MAX_RESULT);
// Validate the results. No matches should get returned.
assertEquals(0, result.size());
// Try to retrieve the business object data matching to the storage policy, when storagePolicyTransitionMaxAllowedAttempts is specified,
// storage unit has storagePolicyTransitionFailedAttempts > storagePolicyTransitionMaxAllowedAttempts.
storageUnitEntity.setStoragePolicyTransitionFailedAttempts(2);
storageUnitDao.saveAndRefresh(storageUnitEntity);
result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(new StoragePolicyPriorityLevel(false, false, false), Collections.singletonList(BDATA_STATUS), 1, 0, MAX_RESULT);
// Validate the results. No matches should get returned.
assertEquals(0, result.size());
}
use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.
the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionMissingOptionalParameters.
@Test
public void testRetryStoragePolicyTransitionMissingOptionalParameters() {
// Create a business object data key without sub-partition values.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Create database entities required for testing.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForRetryStoragePolicyTransitionTesting(businessObjectDataKey, storagePolicyKey);
// Retry a storage policy transition.
BusinessObjectData businessObjectData = businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
}
Aggregations