Search in sources :

Example 16 with BusinessObjectDataCreateRequest

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataS3ManagedBucketDirectoryPathAlreadyRegistered.

@Test
public void testCreateBusinessObjectDataS3ManagedBucketDirectoryPathAlreadyRegistered() {
    // Create relative database entities including a storage unit for the business object data with PARTITION_VALUE_2 partition value,
    // but with a directory path that would actually match with a test business object data with PARTITION_VALUE partition value.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE_2, INITIAL_DATA_VERSION, true, BDATA_STATUS);
    storageUnitDaoTestHelper.createStorageUnitEntity(storageDao.getStorageByName(StorageEntity.MANAGED_STORAGE), businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, testS3KeyPrefix);
    // Build a new business object data create request containing the already registered storage directory path.
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, StorageEntity.MANAGED_STORAGE, testS3KeyPrefix, businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, Arrays.asList(LOCAL_FILE)));
    try {
        // Try to create a business object data instance.
        businessObjectDataService.createBusinessObjectData(request);
        fail("Should throw an AlreadyExistsException when directory path in S3 managed " + "storage matches the location of an already registered business object data.");
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Storage directory \"%s\" in \"%s\" storage is already registered by the business object data {%s}.", testS3KeyPrefix, StorageEntity.MANAGED_STORAGE, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE_2, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION)), e.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 17 with BusinessObjectDataCreateRequest

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataMissingOptionalParameters.

@Test
public void testCreateBusinessObjectDataMissingOptionalParameters() {
    // Create relative database entities.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
    // Create an initial version of business object data without specifying any of the optional parameters except for namespace.
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, null);
    assertNull(request.getSubPartitionValues());
    request.setStatus(BLANK_TEXT);
    assertNull(request.getAttributes());
    assertNull(request.getStorageUnits().get(0).getStorageFiles());
    request.setCreateNewVersion(null);
    assertNull(request.getBusinessObjectDataParents());
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
    // Verify the results.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(request, INITIAL_DATA_VERSION, true, resultBusinessObjectData);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 18 with BusinessObjectDataCreateRequest

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataValidateFileExistenceNoValidatePrefix.

@Test
public void testCreateBusinessObjectDataValidateFileExistenceNoValidatePrefix() throws Exception {
    // Create an S3 storage entity.
    List<Attribute> attributes = new ArrayList<>();
    attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME));
    attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes);
    // Create relative database entities.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    // Build a list of storage files.
    List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, LOCAL_FILES);
    // Create and upload to S3 managed storage a set of test files.
    businessObjectDataServiceTestHelper.prepareTestS3Files(S3_BUCKET_NAME, testS3KeyPrefix, localTempPath, LOCAL_FILES, new ArrayList<String>());
    // Build a new business object data create request.
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles);
    // Try to create a business object data instance. It should go through without any errors.
    businessObjectDataService.createBusinessObjectData(request);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) StorageFile(org.finra.herd.model.api.xml.StorageFile) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 19 with BusinessObjectDataCreateRequest

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataNoStorageFiles.

@Test
public void testCreateBusinessObjectDataNoStorageFiles() {
    // Create the initial version of the business object data without specifying storage files.
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
    request.getStorageUnits().get(0).setStorageFiles(null);
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
    // Verify the results.
    businessObjectDataServiceTestHelper.validateBusinessObjectData(request, INITIAL_DATA_VERSION, true, resultBusinessObjectData);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 20 with BusinessObjectDataCreateRequest

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataValidateFlagIgnoredForNonS3Storage.

@Test
public void testCreateBusinessObjectDataValidateFlagIgnoredForNonS3Storage() throws Exception {
    // Create an S3 storage entity.
    List<Attribute> attributes = new ArrayList<>();
    attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME));
    attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME, "NON_S3_STORAGE", attributes);
    // Create relative database entities.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    // Build a list of storage files.
    List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, LOCAL_FILES);
    // Build a new business object data create request.
    BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles);
    // Try to create a business object data instance. This should succeed since the bucket is not of type "S3", even though there are no files in S3.
    businessObjectDataService.createBusinessObjectData(request);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) StorageFile(org.finra.herd.model.api.xml.StorageFile) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)56 Test (org.junit.Test)50 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)18 ArrayList (java.util.ArrayList)16 StorageUnitCreateRequest (org.finra.herd.model.api.xml.StorageUnitCreateRequest)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)11 StorageFile (org.finra.herd.model.api.xml.StorageFile)11 Attribute (org.finra.herd.model.api.xml.Attribute)10 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)3 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 Storage (org.finra.herd.model.api.xml.Storage)2