use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest in project herd by FINRAOS.
the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStorageUnitNoExists.
@Test
public void testRetryStoragePolicyTransitionStorageUnitNoExists() {
// 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, NO_STORAGE_UNIT_STATUS);
// Try to execute a before step for the retry storage policy transition when source storage has no storage unit.
try {
businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Business object data has no storage unit in \"%s\" storage. Business object data: {%s}", STORAGE_NAME, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testRetryStoragePolicyTransition.
@Test
public void testRetryStoragePolicyTransition() {
// 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 business object data retry storage policy transition request.
BusinessObjectDataRetryStoragePolicyTransitionRequest businessObjectDataRetryStoragePolicyTransitionRequest = new BusinessObjectDataRetryStoragePolicyTransitionRequest();
// Create a business object data.
BusinessObjectData businessObjectData = new BusinessObjectData();
// Mock the external calls.
when(businessObjectDataService.retryStoragePolicyTransition(businessObjectDataKey, businessObjectDataRetryStoragePolicyTransitionRequest)).thenReturn(businessObjectData);
// Call the method under test.
BusinessObjectData result = businessObjectDataRestController.retryStoragePolicyTransition(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, getDelimitedFieldValues(SUBPARTITION_VALUES), businessObjectDataRetryStoragePolicyTransitionRequest);
// Verify the external calls.
verify(businessObjectDataService).retryStoragePolicyTransition(businessObjectDataKey, businessObjectDataRetryStoragePolicyTransitionRequest);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(businessObjectData, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceRetryStoragePolicyTransitionTest method testRetryStoragePolicyTransition.
@Test
public void testRetryStoragePolicyTransition() {
// 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, 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 for the business object data.
BusinessObjectData businessObjectData = businessObjectDataService.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest in project herd by FINRAOS.
the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionStorageUnitNotInArchivingState.
@Test
public void testRetryStoragePolicyTransitionStorageUnitNotInArchivingState() {
// 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 unit not in ARCHIVING state.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForRetryStoragePolicyTransitionTesting(businessObjectDataKey, storagePolicyKey, STORAGE_NAME, S3_BUCKET_NAME, STORAGE_UNIT_STATUS);
// Try to execute a before step for the retry storage policy transition when storage unit is not in ARCHIVING state.
try {
businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Business object data is not currently being archived. " + "Storage unit in \"%s\" storage must have \"%s\" status, but it actually has \"%s\" status. Business object data: {%s}", STORAGE_NAME, StorageUnitStatusEntity.ARCHIVING, STORAGE_UNIT_STATUS, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest in project herd by FINRAOS.
the class BusinessObjectDataRetryStoragePolicyTransitionHelperTest method testRetryStoragePolicyTransitionUpperCaseParameters.
@Test
public void testRetryStoragePolicyTransitionUpperCaseParameters() {
// 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 upper case input parameters (except for case-sensitive partition values).
BusinessObjectData businessObjectData = businessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(new BusinessObjectDataKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataRetryStoragePolicyTransitionRequest(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toUpperCase(), STORAGE_POLICY_NAME.toUpperCase())));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS, businessObjectData);
}
Aggregations