Search in sources :

Example 1 with StoragePolicyPriorityLevel

use of org.finra.herd.model.dto.StoragePolicyPriorityLevel 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());
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyEntity(org.finra.herd.model.jpa.StoragePolicyEntity) StoragePolicyPriorityLevel(org.finra.herd.model.dto.StoragePolicyPriorityLevel) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 2 with StoragePolicyPriorityLevel

use of org.finra.herd.model.dto.StoragePolicyPriorityLevel 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()));
}
Also used : StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyEntity(org.finra.herd.model.jpa.StoragePolicyEntity) StoragePolicyPriorityLevel(org.finra.herd.model.dto.StoragePolicyPriorityLevel) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 3 with StoragePolicyPriorityLevel

use of org.finra.herd.model.dto.StoragePolicyPriorityLevel 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());
}
Also used : StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyEntity(org.finra.herd.model.jpa.StoragePolicyEntity) StoragePolicyPriorityLevel(org.finra.herd.model.dto.StoragePolicyPriorityLevel) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 4 with StoragePolicyPriorityLevel

use of org.finra.herd.model.dto.StoragePolicyPriorityLevel in project herd by FINRAOS.

the class BusinessObjectDataDaoTest method testBusinessObjectDataEntitiesMatchingStoragePolicies.

@Test
public void testBusinessObjectDataEntitiesMatchingStoragePolicies() {
    // Create and persist a storage unit with ENABLED status 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);
    // For all possible storage policy priority levels, create and persist a storage policy entity matching to the business object data.
    Map<StoragePolicyPriorityLevel, StoragePolicyEntity> input = new LinkedHashMap<>();
    // Storage policy filter has business object definition, usage, and file type specified.
    input.put(new StoragePolicyPriorityLevel(false, false, false), 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));
    // Storage policy filter has only business object definition specified.
    input.put(new StoragePolicyPriorityLevel(false, true, true), storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME_2), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET));
    // Storage policy filter has only usage and file type specified.
    input.put(new StoragePolicyPriorityLevel(true, false, false), storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD_2, STORAGE_POLICY_NAME), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, NO_BDEF_NAMESPACE, NO_BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET));
    // Storage policy filter has no fields specified.
    input.put(new StoragePolicyPriorityLevel(true, true, true), storagePolicyDaoTestHelper.createStoragePolicyEntity(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD_2, STORAGE_POLICY_NAME_2), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, BDATA_AGE_IN_DAYS, NO_BDEF_NAMESPACE, NO_BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET));
    // For each storage policy priority level, retrieve business object data matching to the relative storage policy.
    for (Map.Entry<StoragePolicyPriorityLevel, StoragePolicyEntity> entry : input.entrySet()) {
        StoragePolicyPriorityLevel storagePolicyPriorityLevel = entry.getKey();
        StoragePolicyEntity storagePolicyEntity = entry.getValue();
        // Retrieve the match.
        Map<BusinessObjectDataEntity, StoragePolicyEntity> result = businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(storagePolicyPriorityLevel, Collections.singletonList(BDATA_STATUS), 0, 0, MAX_RESULT);
        // Validate the results.
        assertEquals(1, result.size());
        assertTrue(result.containsKey(storageUnitEntity.getBusinessObjectData()));
        assertEquals(storagePolicyEntity, result.get(storageUnitEntity.getBusinessObjectData()));
    }
}
Also used : StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyPriorityLevel(org.finra.herd.model.dto.StoragePolicyPriorityLevel) StoragePolicyEntity(org.finra.herd.model.jpa.StoragePolicyEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 5 with StoragePolicyPriorityLevel

use of org.finra.herd.model.dto.StoragePolicyPriorityLevel in project herd by FINRAOS.

the class BusinessObjectDataDaoTest method testBusinessObjectDataEntitiesMatchingStoragePoliciesInvalidBusinessObjectDataStatus.

@Test
public void testBusinessObjectDataEntitiesMatchingStoragePoliciesInvalidBusinessObjectDataStatus() {
    // 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, but having "not supported" business object data status.
    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_2, 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());
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyEntity(org.finra.herd.model.jpa.StoragePolicyEntity) StoragePolicyPriorityLevel(org.finra.herd.model.dto.StoragePolicyPriorityLevel) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Aggregations

StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)9 StoragePolicyPriorityLevel (org.finra.herd.model.dto.StoragePolicyPriorityLevel)9 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)9 StoragePolicyEntity (org.finra.herd.model.jpa.StoragePolicyEntity)9 Test (org.junit.Test)8 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)4 Map (java.util.Map)2 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)1 StoragePolicySelection (org.finra.herd.model.dto.StoragePolicySelection)1