use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataAttributeServiceTest method testGetBusinessObjectDataAttributesUpperCaseParameters.
@Test
public void testGetBusinessObjectDataAttributesUpperCaseParameters() {
// List of test business object data attribute names.
List<String> testBusinessObjectDataAttributeNames = Arrays.asList(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_NAME_2_MIXED_CASE);
// Create and persist a business object data attribute entities using lower case values.
for (String businessObjectDataAttributeName : testBusinessObjectDataAttributeNames) {
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION, businessObjectDataAttributeName.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase());
}
// Retrieve a list of business object data attribute keys using upper case input parameters (except for case-sensitive partition values).
BusinessObjectDataAttributeKeys resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataAttributeKeys);
assertEquals(testBusinessObjectDataAttributeNames.size(), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().size());
for (int i = 0; i < testBusinessObjectDataAttributeNames.size(); i++) {
businessObjectDataAttributeServiceTestHelper.validateBusinessObjectDataAttributeKey(NAMESPACE, BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE.toLowerCase(), convertListToLowerCase(SUBPARTITION_VALUES), DATA_VERSION, testBusinessObjectDataAttributeNames.get(i).toLowerCase(), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().get(i));
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataAttributeServiceTest method testGetBusinessObjectDataAttributesTrimParameters.
@Test
public void testGetBusinessObjectDataAttributesTrimParameters() {
// List of test business object data attribute names.
List<String> testBusinessObjectDataAttributeNames = Arrays.asList(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_NAME_2_MIXED_CASE);
// Create and persist a business object data attribute entities.
for (String businessObjectDataAttributeName : testBusinessObjectDataAttributeNames) {
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, businessObjectDataAttributeName, ATTRIBUTE_VALUE_1);
}
// Retrieve a list of business object data attribute keys using input parameters with leading and trailing empty spaces.
BusinessObjectDataAttributeKeys resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), DATA_VERSION));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataAttributeKeys);
assertEquals(testBusinessObjectDataAttributeNames.size(), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().size());
for (int i = 0; i < testBusinessObjectDataAttributeNames.size(); i++) {
businessObjectDataAttributeServiceTestHelper.validateBusinessObjectDataAttributeKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, testBusinessObjectDataAttributeNames.get(i), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().get(i));
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataAttributeServiceTest method testGetBusinessObjectDataAttributesMissingOptionalParameters.
@Test
public void testGetBusinessObjectDataAttributesMissingOptionalParameters() {
// List of test business object data attribute names.
List<String> testBusinessObjectDataAttributeNames = Arrays.asList(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_NAME_2_MIXED_CASE);
// with any allowed number of subpartition values (from 0 to MAX_SUBPARTITIONS).
for (int i = 0; i <= BusinessObjectDataEntity.MAX_SUBPARTITIONS; i++) {
// Build a list of subpartition values.
List<String> subPartitionValues = SUBPARTITION_VALUES.subList(0, i);
// Create and persist business object data attribute entities with the relative number of subpartition values.
for (String businessObjectDataAttributeName : testBusinessObjectDataAttributeNames) {
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION, businessObjectDataAttributeName, ATTRIBUTE_VALUE_1);
}
// Retrieve the list of attribute keys for the business object data using the relative endpoint.
BusinessObjectDataAttributeKeys resultBusinessObjectDataAttributeKeys = null;
switch(i) {
case 0:
resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION));
break;
case 1:
resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0)), DATA_VERSION));
break;
case 2:
resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1)), DATA_VERSION));
break;
case 3:
resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(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)), DATA_VERSION));
break;
case 4:
resultBusinessObjectDataAttributeKeys = businessObjectDataAttributeService.getBusinessObjectDataAttributes(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION));
break;
}
// Validate the returned object.
assertNotNull(resultBusinessObjectDataAttributeKeys);
assertEquals(testBusinessObjectDataAttributeNames.size(), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().size());
for (int j = 0; j < testBusinessObjectDataAttributeNames.size(); j++) {
businessObjectDataAttributeServiceTestHelper.validateBusinessObjectDataAttributeKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION, testBusinessObjectDataAttributeNames.get(j), resultBusinessObjectDataAttributeKeys.getBusinessObjectDataAttributeKeys().get(j));
}
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataFinalizeRestoreHelperServiceTest method testExecuteS3SpecificStepsGlacierS3FileStillRestoring.
@Test
public void testExecuteS3SpecificStepsGlacierS3FileStillRestoring() throws Exception {
// Create S3FileTransferRequestParamsDto to access the S3 bucket.
// Since test S3 key prefix represents a directory, we add a trailing '/' character to it.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = S3FileTransferRequestParamsDto.builder().withS3BucketName(S3_BUCKET_NAME).withS3KeyPrefix(TEST_S3_KEY_PREFIX + "/").build();
// 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 restore DTO.
BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, NO_S3_ENDPOINT, S3_BUCKET_NAME, TEST_S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, Arrays.asList(new StorageFile(TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE, FILE_SIZE_1_KB, NO_ROW_COUNT)), NO_EXCEPTION);
try {
// Put a "still restoring" Glacier storage class S3 file in the Glacier S3 bucket.
ObjectMetadata metadata = new ObjectMetadata();
metadata.setHeader(Headers.STORAGE_CLASS, StorageClass.Glacier);
metadata.setOngoingRestore(true);
s3Operations.putObject(new PutObjectRequest(S3_BUCKET_NAME, String.format("%s/%s", TEST_S3_KEY_PREFIX, LOCAL_FILE), new ByteArrayInputStream(new byte[(int) FILE_SIZE_1_KB]), metadata), NO_S3_CLIENT);
// Try to execute S3 specific steps to finalize a restore for the storage unit when Glacier S3 file is still restoring.
try {
businessObjectDataFinalizeRestoreHelperService.executeS3SpecificSteps(businessObjectDataRestoreDto);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Archived Glacier S3 file \"%s/%s\" is not restored. " + "StorageClass {GLACIER}, OngoingRestore flag {true}, S3 bucket name {%s}", TEST_S3_KEY_PREFIX, LOCAL_FILE, S3_BUCKET_NAME), e.getMessage());
}
// Validate that we have a Glacier S3 file at the expected S3 location.
assertEquals(1, s3Dao.listDirectory(s3FileTransferRequestParamsDto).size());
} finally {
// Delete test files from S3 storage.
if (!s3Dao.listDirectory(s3FileTransferRequestParamsDto).isEmpty()) {
s3Dao.deleteDirectory(s3FileTransferRequestParamsDto);
}
s3Operations.rollback();
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataFinalizeRestoreHelperServiceTest method testPrepareToFinalizeRestoreMissingOptionalParameters.
@Test
public void testPrepareToFinalizeRestoreMissingOptionalParameters() throws Exception {
// 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 database entities required for testing.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForFinalizeRestoreTesting(businessObjectDataKey);
// Get the storage unit entity.
StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity);
// Create a storage unit key.
BusinessObjectDataStorageUnitKey storageUnitKey = storageUnitHelper.createStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
// Prepare to finalize a restore for business object data without sub-partition values.
BusinessObjectDataRestoreDto result = businessObjectDataFinalizeRestoreHelperService.prepareToFinalizeRestore(storageUnitKey);
// Validate the returned object.
assertEquals(new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, NO_S3_ENDPOINT, S3_BUCKET_NAME, result.getS3KeyPrefix(), NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, storageFileHelper.createStorageFilesFromEntities(storageUnitEntity.getStorageFiles()), NO_EXCEPTION), result);
}
Aggregations