Search in sources :

Example 66 with StoragePolicyKey

use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionLowerCaseParameters.

@Test
public void testRetryStoragePolicyTransitionLowerCaseParameters() {
    // 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 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 using lower case input parameters (except for case-sensitive partition values).
    BusinessObjectData businessObjectData = businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toLowerCase(), STORAGE_POLICY_NAME.toLowerCase())));
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataRetryStoragePolicyTransitionRequest(org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 67 with StoragePolicyKey

use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionBusinessObjectDataNoExists.

@Test
public void testRetryStoragePolicyTransitionBusinessObjectDataNoExists() {
    // 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 a storage policy key.
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    // Try to execute a before step for the retry storage policy transition for a non-existing business object data.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectDataKey, NO_BDATA_STATUS), e.getMessage());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataRetryStoragePolicyTransitionRequest(org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 68 with StoragePolicyKey

use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStoragePolicyNoExists.

@Test
public void testRetryStoragePolicyTransitionStoragePolicyNoExists() {
    // 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 a storage policy key.
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    // Create a business object data entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Try to execute a before step for the retry storage policy transition for a non-existing storage policy.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(storagePolicyServiceTestHelper.getExpectedStoragePolicyNotFoundErrorMessage(storagePolicyKey), e.getMessage());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataRetryStoragePolicyTransitionRequest(org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 69 with StoragePolicyKey

use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStoragePolicyFilterDoesNotMatchBusinessObjectData.

@Test
public void testRetryStoragePolicyTransitionStoragePolicyFilterDoesNotMatchBusinessObjectData() {
    // 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 a storage policy key.
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    // Create four more storage policy keys.
    List<StoragePolicyKey> storagePolicyKeys = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        storagePolicyKeys.add(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME + "_" + i));
    }
    // Create database entities required for testing.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForRetryStoragePolicyTransitionTesting(businessObjectDataKey, storagePolicyKey);
    // Create four more storage policies having on of the filter fields not matching the business object data.
    storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKeys.get(0), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, AbstractServiceTest.BDATA_AGE_IN_DAYS, BDEF_NAMESPACE_2, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME, StoragePolicyStatusEntity.ENABLED, AbstractServiceTest.INITIAL_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET);
    storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKeys.get(1), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, AbstractServiceTest.BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME, StoragePolicyStatusEntity.ENABLED, AbstractServiceTest.INITIAL_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET);
    storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKeys.get(2), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, AbstractServiceTest.BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME, StoragePolicyStatusEntity.ENABLED, AbstractServiceTest.INITIAL_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET);
    storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKeys.get(3), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, AbstractServiceTest.BDATA_AGE_IN_DAYS, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE_2, STORAGE_NAME, STORAGE_NAME, StoragePolicyStatusEntity.ENABLED, AbstractServiceTest.INITIAL_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET);
    // Try to execute a before step for the retry storage policy transition when storage policy filter does not match business object data.
    for (int i = 0; i < 4; i++) {
        try {
            businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKeys.get(i)));
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals(String.format("Business object data does not match storage policy filter. Storage policy: {%s}, business object data: {%s}", storagePolicyServiceTestHelper.getExpectedStoragePolicyKeyAndVersionAsString(storagePolicyKeys.get(i), INITIAL_VERSION), businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage());
        }
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataRetryStoragePolicyTransitionRequest(org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 70 with StoragePolicyKey

use of org.finra.herd.model.api.xml.StoragePolicyKey in project herd by FINRAOS.

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStoragePolicyFilterNoOptionalFields.

@Test
public void testRetryStoragePolicyTransitionStoragePolicyFilterNoOptionalFields() {
    // 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 two storage policy keys.
    List<StoragePolicyKey> storagePolicyKeys = Arrays.asList(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME_2));
    // Create database entities required for testing.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForRetryStoragePolicyTransitionTesting(businessObjectDataKey, storagePolicyKeys.get(0));
    // Create another storage policy with storage policy filter with missing optional fields.
    storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKeys.get(1), StoragePolicyRuleTypeEntity.DAYS_SINCE_BDATA_REGISTERED, AbstractServiceTest.BDATA_AGE_IN_DAYS, NO_BDEF_NAMESPACE, NO_BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME, StoragePolicyStatusEntity.ENABLED, AbstractServiceTest.INITIAL_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET);
    // Retry a storage policy transition with storage policy filter missing all optional fields.
    BusinessObjectData businessObjectData = businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKeys.get(1)));
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataRetryStoragePolicyTransitionRequest(org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)101 Test (org.junit.Test)97 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)50 StoragePolicySelection (org.finra.herd.model.dto.StoragePolicySelection)32 StoragePolicyEntity (org.finra.herd.model.jpa.StoragePolicyEntity)24 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)24 StoragePolicyFilter (org.finra.herd.model.api.xml.StoragePolicyFilter)21 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)21 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)21 StoragePolicy (org.finra.herd.model.api.xml.StoragePolicy)20 StoragePolicyRule (org.finra.herd.model.api.xml.StoragePolicyRule)20 StoragePolicyTransition (org.finra.herd.model.api.xml.StoragePolicyTransition)20 HashMap (java.util.HashMap)18 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)17 StoragePolicyTransitionParamsDto (org.finra.herd.model.dto.StoragePolicyTransitionParamsDto)17 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)10 StoragePolicyPriorityLevel (org.finra.herd.model.dto.StoragePolicyPriorityLevel)9 ArrayList (java.util.ArrayList)8 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)7 StorageFile (org.finra.herd.model.api.xml.StorageFile)7