Search in sources :

Example 31 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesS3ManagedS3FileNotFound.

@Test
public void testCreateBusinessObjectDataStorageFilesS3ManagedS3FileNotFound() throws Exception {
    createData(null, true, Arrays.asList(testS3KeyPrefix + "/" + FILE_PATH_1));
    businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, Arrays.asList(FILE_PATH_1));
    // Try to add a storage file that does not exist in S3 managed storage.
    try {
        businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, StorageEntity.MANAGED_STORAGE, Arrays.asList(createFile(testS3KeyPrefix + "/" + FILE_PATH_2, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES));
        fail("Should throw an ObjectNotFoundException when a storage file does not exist in S3 managed storage.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("File not found at s3://%s/%s/%s location.", storageDaoTestHelper.getS3ManagedBucketName(), testS3KeyPrefix, FILE_PATH_2), e.getMessage());
    }
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 32 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesS3ManagedExtraFilesInS3.

@Test
public void testCreateBusinessObjectDataStorageFilesS3ManagedExtraFilesInS3() throws Exception {
    // Create test data.
    createData(null, true, Arrays.asList(testS3KeyPrefix + "/" + FILE_PATH_1));
    // Create and upload to S3 managed storage a set of test files including an extra
    // file not to be listed in the create business object data create request.
    businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, Arrays.asList(FILE_PATH_1, FILE_PATH_2, FILE_PATH_3));
    BusinessObjectDataStorageFilesCreateRequest request = new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, StorageEntity.MANAGED_STORAGE, Arrays.asList(createFile(testS3KeyPrefix + "/" + FILE_PATH_2, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES);
    BusinessObjectDataStorageFilesCreateResponse response = businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(request);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataStorageFilesCreateResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, StorageEntity.MANAGED_STORAGE, request.getStorageFiles(), response);
}
Also used : BusinessObjectDataStorageFilesCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse) BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) Test(org.junit.Test)

Example 33 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesS3ManagedS3FileSizeMismatch.

@Test
public void testCreateBusinessObjectDataStorageFilesS3ManagedS3FileSizeMismatch() throws Exception {
    createData(null, true, Arrays.asList(testS3KeyPrefix + "/" + FILE_PATH_1));
    businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, Arrays.asList(FILE_PATH_1, FILE_PATH_2));
    // Try to add a storage file with file size that does not match to file size reported by S3.
    try {
        businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, StorageEntity.MANAGED_STORAGE, Arrays.asList(createFile(testS3KeyPrefix + "/" + FILE_PATH_2, FILE_SIZE_0_BYTE, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES));
        fail("Should throw an IllegalArgumentException when a storage file size does not match file size reported by S3.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Specified file size of %d bytes for \"%s/%s\" storage file does not match file size of %d bytes reported by S3.", FILE_SIZE_0_BYTE, testS3KeyPrefix, FILE_PATH_2, FILE_SIZE_1_KB), e.getMessage());
    }
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) Test(org.junit.Test)

Example 34 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesUpperCaseParameters.

@Test
public void testCreateBusinessObjectDataStorageFilesUpperCaseParameters() {
    createDataWithSubPartitions();
    // Create business object data storage files using upper case input parameters (except for case-sensitive partition values and storage file paths).
    BusinessObjectDataStorageFilesCreateRequest request = new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUB_PARTITION_VALUES, DATA_VERSION, STORAGE_NAME.toUpperCase(), Arrays.asList(createFile(FILE_PATH_2, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES);
    BusinessObjectDataStorageFilesCreateResponse response = businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(request);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataStorageFilesCreateResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUB_PARTITION_VALUES, DATA_VERSION, STORAGE_NAME, request.getStorageFiles(), response);
}
Also used : BusinessObjectDataStorageFilesCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse) BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) Test(org.junit.Test)

Example 35 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesMissingOptionalParameters.

@Test
public void testCreateBusinessObjectDataStorageFilesMissingOptionalParameters() {
    // Create and persist a business object definition.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    createData(null, false);
    // Create business object data storage files without passing any of the optional parameters.
    BusinessObjectDataStorageFilesCreateRequest request = new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, STORAGE_NAME, Arrays.asList(createFile(FILE_PATH_2, FILE_SIZE_1_KB, null)), NO_DISCOVER_STORAGE_FILES);
    BusinessObjectDataStorageFilesCreateResponse response = businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(request);
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataStorageFilesCreateResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME, request.getStorageFiles(), response);
}
Also used : BusinessObjectDataStorageFilesCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse) BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDataStorageFilesCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest)40 Test (org.junit.Test)37 BusinessObjectDataStorageFilesCreateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse)14 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)5 StorageFileEntity (org.finra.herd.model.jpa.StorageFileEntity)5 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)5 ArrayList (java.util.ArrayList)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 StorageFile (org.finra.herd.model.api.xml.StorageFile)2 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 StringWriter (java.io.StringWriter)1 URI (java.net.URI)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 HttpPost (org.apache.http.client.methods.HttpPost)1