use of org.finra.herd.model.api.xml.StorageDirectory in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesStorageFilesSpecified.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesStorageFilesSpecified() {
// Try to create an initial version of the business object data when discovery of storage files is enabled and storage files are specified.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), Arrays.asList(new StorageFile(LOCAL_FILE, FILE_SIZE_1_KB, ROW_COUNT_1000)), DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when discovery of storage files is enabled and storage files are specified.");
} catch (IllegalArgumentException e) {
assertEquals("Storage files cannot be specified when discovery of storage files is enabled.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageDirectory in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesInvalidStoragePlatform.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesInvalidStoragePlatform() {
// Create a business object format entity.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
// Create a business object data status entity.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Create a non-S3 storage entity with a bucket name attribute.
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, STORAGE_PLATFORM_CODE, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME);
// Try to create an initial version of the business object data when storage platform is not supported for discovery of storage files.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BDATA_STATUS, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(testS3KeyPrefix), NO_STORAGE_FILES, DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when storage platform is not supported for discovery of storage files.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Cannot discover storage files at \"%s\" storage platform.", STORAGE_PLATFORM_CODE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageDirectory in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesNoS3FilesExist.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesNoS3FilesExist() {
// Create a business object format entity.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
// Create a business object data status entity.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Try to create an initial version of the business object data when there are no files in S3 to discover.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BDATA_STATUS, Arrays.asList(new StorageUnitCreateRequest(StorageEntity.MANAGED_STORAGE, new StorageDirectory(testS3KeyPrefix), NO_STORAGE_FILES, DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an ObjectNotFoundException when there are no files in S3 to discover.");
} catch (ObjectNotFoundException e) {
assertTrue(e.getMessage().startsWith(String.format("Found no files at \"s3://%s", storageDaoTestHelper.getS3ManagedBucketName())));
}
}
use of org.finra.herd.model.api.xml.StorageDirectory in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getNewBusinessObjectDataCreateRequest.
/**
* Gets a newly created business object data create request.
*
* @param includeAttributes If true, attribute definitions and attributes will be included. Otherwise, not.
*
* @return the business object create request.
*/
public BusinessObjectDataCreateRequest getNewBusinessObjectDataCreateRequest(boolean includeAttributes) {
// Crete a test business object format (and associated data).
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(includeAttributes);
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity();
// Create a request to create business object data.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
businessObjectDataCreateRequest.setNamespace(businessObjectFormatEntity.getBusinessObjectDefinition().getNamespace().getCode());
businessObjectDataCreateRequest.setBusinessObjectDefinitionName(businessObjectFormatEntity.getBusinessObjectDefinition().getName());
businessObjectDataCreateRequest.setBusinessObjectFormatUsage(businessObjectFormatEntity.getUsage());
businessObjectDataCreateRequest.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode());
businessObjectDataCreateRequest.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion());
businessObjectDataCreateRequest.setPartitionKey(businessObjectFormatEntity.getPartitionKey());
businessObjectDataCreateRequest.setPartitionValue(AbstractServiceTest.PARTITION_VALUE);
businessObjectDataCreateRequest.setSubPartitionValues(AbstractServiceTest.SUBPARTITION_VALUES);
List<StorageUnitCreateRequest> storageUnits = new ArrayList<>();
businessObjectDataCreateRequest.setStorageUnits(storageUnits);
StorageUnitCreateRequest storageUnit = new StorageUnitCreateRequest();
storageUnits.add(storageUnit);
storageUnit.setStorageName(storageEntity.getName());
StorageDirectory storageDirectory = new StorageDirectory();
storageUnit.setStorageDirectory(storageDirectory);
storageDirectory.setDirectoryPath("Folder");
List<StorageFile> storageFiles = new ArrayList<>();
storageUnit.setStorageFiles(storageFiles);
StorageFile storageFile1 = new StorageFile();
storageFiles.add(storageFile1);
storageFile1.setFilePath("Folder/file1.gz");
storageFile1.setFileSizeBytes(0L);
storageFile1.setRowCount(0L);
StorageFile storageFile2 = new StorageFile();
storageFiles.add(storageFile2);
storageFile2.setFilePath("Folder/file2.gz");
storageFile2.setFileSizeBytes(2999L);
storageFile2.setRowCount(1000L);
StorageFile storageFile3 = new StorageFile();
storageFiles.add(storageFile3);
storageFile3.setFilePath("Folder/file3.gz");
storageFile3.setFileSizeBytes(Long.MAX_VALUE);
storageFile3.setRowCount(Long.MAX_VALUE);
if (includeAttributes) {
businessObjectDataCreateRequest.setAttributes(businessObjectDefinitionServiceTestHelper.getNewAttributes());
}
List<BusinessObjectDataKey> businessObjectDataParents = new ArrayList<>();
businessObjectDataCreateRequest.setBusinessObjectDataParents(businessObjectDataParents);
// Create 2 parents.
for (int i = 0; i < 2; i++) {
BusinessObjectDataEntity parentBusinessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity();
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getNamespace().getCode());
businessObjectDataKey.setBusinessObjectDefinitionName(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getName());
businessObjectDataKey.setBusinessObjectFormatUsage(parentBusinessObjectDataEntity.getBusinessObjectFormat().getUsage());
businessObjectDataKey.setBusinessObjectFormatFileType(parentBusinessObjectDataEntity.getBusinessObjectFormat().getFileType().getCode());
businessObjectDataKey.setBusinessObjectFormatVersion(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectFormatVersion());
businessObjectDataKey.setPartitionValue(parentBusinessObjectDataEntity.getPartitionValue());
businessObjectDataKey.setBusinessObjectDataVersion(parentBusinessObjectDataEntity.getVersion());
businessObjectDataKey.setSubPartitionValues(businessObjectDataHelper.getSubPartitionValues(parentBusinessObjectDataEntity));
businessObjectDataParents.add(businessObjectDataKey);
}
return businessObjectDataCreateRequest;
}
use of org.finra.herd.model.api.xml.StorageDirectory in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method createBusinessObjectDataCreateRequest.
/**
* Returns a newly created business object data create request.
*
* @param namespaceCode the namespace code
* @param businessObjectDefinitionName the business object definition name
* @param businessObjectFormatUsage the business object format usage
* @param businessObjectFormatFileType the business object format file type
* @param businessObjectFormatVersion the business object format version
* @param partitionKey the partition key
* @param partitionValue the partition value
* @param storageName the storage name
* @param storageDirectoryPath the storage directory path
* @param storageFiles the list of storage files
*
* @return the business object create request
*/
public BusinessObjectDataCreateRequest createBusinessObjectDataCreateRequest(String namespaceCode, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String partitionKey, String partitionValue, String businessObjectDataStatusCode, String storageName, String storageDirectoryPath, List<StorageFile> storageFiles) {
// Create a business object data create request.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
businessObjectDataCreateRequest.setNamespace(namespaceCode);
businessObjectDataCreateRequest.setBusinessObjectDefinitionName(businessObjectDefinitionName);
businessObjectDataCreateRequest.setBusinessObjectFormatUsage(businessObjectFormatUsage);
businessObjectDataCreateRequest.setBusinessObjectFormatFileType(businessObjectFormatFileType);
businessObjectDataCreateRequest.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectDataCreateRequest.setPartitionKey(partitionKey);
businessObjectDataCreateRequest.setPartitionValue(partitionValue);
businessObjectDataCreateRequest.setStatus(businessObjectDataStatusCode);
List<StorageUnitCreateRequest> storageUnits = new ArrayList<>();
businessObjectDataCreateRequest.setStorageUnits(storageUnits);
StorageUnitCreateRequest storageUnit = new StorageUnitCreateRequest();
storageUnits.add(storageUnit);
storageUnit.setStorageName(storageName);
if (storageDirectoryPath != null) {
StorageDirectory storageDirectory = new StorageDirectory();
storageUnit.setStorageDirectory(storageDirectory);
storageDirectory.setDirectoryPath(storageDirectoryPath);
}
storageUnit.setStorageFiles(storageFiles);
return businessObjectDataCreateRequest;
}
Aggregations