Search in sources :

Example 1 with BusinessObjectDataRetryStoragePolicyTransitionRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest 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);
}
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 2 with BusinessObjectDataRetryStoragePolicyTransitionRequest

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

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStorageUnitHasNoStorageFiles.

@Test
public void testRetryStoragePolicyTransitionStorageUnitHasNoStorageFiles() {
    // 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, STORAGE_NAME, S3_BUCKET_NAME, StorageUnitStatusEntity.ARCHIVING);
    // Get the storage unit entity.
    StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity);
    // Remove storage files from the storage unit.
    storageUnitEntity.getStorageFiles().clear();
    // Try to execute a before step for the retry storage policy transition when storage unit has no storage files.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Business object data has no storage files registered in \"%s\" storage. Business object data: {%s}", STORAGE_NAME, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage());
    }
}
Also used : StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) 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 3 with BusinessObjectDataRetryStoragePolicyTransitionRequest

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

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionMissingRequiredParameters.

@Test
public void testRetryStoragePolicyTransitionMissingRequiredParameters() {
    // 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 without specifying business object definition name.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying business object format usage.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying business object format file type.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying business object format version.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying primary partition value.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying 1st subpartition value.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(BLANK_TEXT, SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A subpartition value must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying 2nd subpartition value.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), BLANK_TEXT, SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A subpartition value must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying 3rd subpartition value.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), BLANK_TEXT, SUBPARTITION_VALUES.get(3)), DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A subpartition value must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying 4th subpartition value.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), BLANK_TEXT), DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A subpartition value must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying business object data version.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, NO_DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data version must be specified.", e.getMessage());
    }
    // without specifying a business object data retry storage policy transition request.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, null);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data retry storage policy transition request must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying a storage policy key.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(null));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A storage policy key must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying storage policy namespace.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(new StoragePolicyKey(BLANK_TEXT, STORAGE_POLICY_NAME)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to execute a before step for the retry storage policy transition without specifying storage policy name.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, BLANK_TEXT)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A storage policy name must be specified.", e.getMessage());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) 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 4 with BusinessObjectDataRetryStoragePolicyTransitionRequest

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

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionTrimParameters.

@Test
public void testRetryStoragePolicyTransitionTrimParameters() {
    // 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 input parameters with leading and trailing empty spaces.
    BusinessObjectData businessObjectData = businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(addWhitespace(BDEF_NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(new StoragePolicyKey(addWhitespace(STORAGE_POLICY_NAMESPACE_CD), addWhitespace(STORAGE_POLICY_NAME))));
    // 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 5 with BusinessObjectDataRetryStoragePolicyTransitionRequest

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

the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStorageHasNoBucketName.

@Test
public void testRetryStoragePolicyTransitionStorageHasNoBucketName() {
    // 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 with a storage not having S3 bucket name configured.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForRetryStoragePolicyTransitionTesting(businessObjectDataKey, storagePolicyKey, STORAGE_NAME, NO_S3_BUCKET_NAME, StorageUnitStatusEntity.ARCHIVING);
    // Try to execute a before step for the retry storage policy transition when the storage does not have an S3 bucket name configured.
    try {
        businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
        fail();
    } 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());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) 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

BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)19 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)19 Test (org.junit.Test)19 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)17 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)9 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)8 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 BusinessObjectDataAvailabilityCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest)1 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)1 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)1 BusinessObjectDataDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest)1 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)1 BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)1 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)1