Search in sources :

Example 6 with UploadSingleInitiationResponse

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

the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageS3FileNoExists.

@Test
public void testPerformCompleteUploadSingleMessageS3FileNoExists() {
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, FILE_NAME));
    String filePath = resultUploadSingleInitiationResponse.getTargetBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath();
    // Try to complete the upload, when source S3 file does not exist.
    UploadDownloadServiceImpl.CompleteUploadSingleMessageResult result = uploadDownloadService.performCompleteUploadSingleMessage(filePath);
    assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getSourceOldBusinessObjectDataStatus());
    assertEquals(BusinessObjectDataStatusEntity.DELETED, result.getSourceNewBusinessObjectDataStatus());
    assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getTargetOldBusinessObjectDataStatus());
    assertEquals(BusinessObjectDataStatusEntity.INVALID, result.getTargetNewBusinessObjectDataStatus());
}
Also used : UploadDownloadServiceImpl(org.finra.herd.service.impl.UploadDownloadServiceImpl) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 7 with UploadSingleInitiationResponse

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

the class UploadDownloadServiceTest method testInitiateUploadSingleRequiredAttribute.

@Test
public void testInitiateUploadSingleRequiredAttribute() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    // Create and persist a business object data attribute definition entity.
    businessObjectFormatDaoTestHelper.createBusinessObjectDataAttributeDefinitionEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Initiate a file upload.
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest());
    // Validate the returned object.
    uploadDownloadServiceTestHelper.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes(), FILE_NAME, FILE_SIZE_1_KB, null, resultUploadSingleInitiationResponse);
}
Also used : UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 8 with UploadSingleInitiationResponse

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

the class UploadDownloadServiceTest method testInitiateDownloadSingle.

@Test
public void testInitiateDownloadSingle() {
    // Create the upload data.
    UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID);
    // Initiate the download against the uploaded data (i.e. the target business object data).
    DownloadSingleInitiationResponse downloadSingleInitiationResponse = initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData());
    // Validate the download initiation response.
    uploadDownloadServiceTestHelper.validateDownloadSingleInitiationResponse(uploadSingleInitiationResponse, downloadSingleInitiationResponse);
}
Also used : DownloadSingleInitiationResponse(org.finra.herd.model.api.xml.DownloadSingleInitiationResponse) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 9 with UploadSingleInitiationResponse

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

the class UploadDownloadServiceTest method testInitiateUploadSingle.

@Test
public void testInitiateUploadSingle() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    // Initiate a file upload.
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest());
    // Validate the returned object.
    uploadDownloadServiceTestHelper.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes(), FILE_NAME, FILE_SIZE_1_KB, null, resultUploadSingleInitiationResponse);
}
Also used : UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 10 with UploadSingleInitiationResponse

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

the class UploadDownloadServiceTest method testInitiateUploadSingleLowerCaseParameters.

@Test
public void testInitiateUploadSingleLowerCaseParameters() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    // Initiate a file upload using upper case values.
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, NAMESPACE.toUpperCase(), BDEF_NAME_2.toUpperCase(), FORMAT_USAGE_CODE_2.toUpperCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase(), FORMAT_VERSION_2));
    // Validate the returned object.
    uploadDownloadServiceTestHelper.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes(), FILE_NAME, FILE_SIZE_1_KB, null, resultUploadSingleInitiationResponse);
}
Also used : UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Aggregations

UploadSingleInitiationResponse (org.finra.herd.model.api.xml.UploadSingleInitiationResponse)23 Test (org.junit.Test)20 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)7 UploadDownloadServiceImpl (org.finra.herd.service.impl.UploadDownloadServiceImpl)4 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 UploadSingleInitiationRequest (org.finra.herd.model.api.xml.UploadSingleInitiationRequest)3 S3EventNotification (com.amazonaws.services.s3.event.S3EventNotification)2 S3Entity (com.amazonaws.services.s3.event.S3EventNotification.S3Entity)2 S3EventNotificationRecord (com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord)2 S3ObjectEntity (com.amazonaws.services.s3.event.S3EventNotification.S3ObjectEntity)2 ArrayList (java.util.ArrayList)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 BusinessObjectDataStatusUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest)2 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)2 StorageEntity (org.finra.herd.model.jpa.StorageEntity)2 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)1 Credentials (com.amazonaws.services.securitytoken.model.Credentials)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1