use of org.finra.herd.model.api.xml.UploadSingleInitiationResponse in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleMissingOptionalParameters.
@Test
public void testInitiateUploadSingleMissingOptionalParameters() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
// Initiate a file upload without specifying any of the optional parameters.
UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
request.setBusinessObjectDataAttributes(null);
request.getFile().setFileSizeBytes(null);
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(request);
// 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, NO_ATTRIBUTES, FILE_NAME, null, null, resultUploadSingleInitiationResponse);
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationResponse in project herd by FINRAOS.
the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageSourceBusinessObjectDataStatusNotUploading.
@Test
public void testPerformCompleteUploadSingleMessageSourceBusinessObjectDataStatusNotUploading() {
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();
// Create a business object data status.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Update the status of the source business object data so it would not be "UPLOADING".
businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataHelper.getBusinessObjectDataKey(resultUploadSingleInitiationResponse.getSourceBusinessObjectData()), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
// Try to complete the upload, when source business object data status is not "UPLOADING".
UploadDownloadServiceImpl.CompleteUploadSingleMessageResult result = uploadDownloadService.performCompleteUploadSingleMessage(filePath);
assertEquals(BDATA_STATUS, result.getSourceOldBusinessObjectDataStatus());
assertNull(result.getSourceNewBusinessObjectDataStatus());
assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getTargetOldBusinessObjectDataStatus());
assertNull(result.getTargetNewBusinessObjectDataStatus());
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationResponse in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleTrimParameters.
@Test
public void testInitiateUploadSingleTrimParameters() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
// Initiate a file upload using input parameters with leading and trailing empty spaces.
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME_2), addWhitespace(FORMAT_USAGE_CODE_2), addWhitespace(FORMAT_FILE_TYPE_CODE_2), 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);
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationResponse in project herd by FINRAOS.
the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageTargetBusinessObjectDataStatusNotUploading.
@Test
public void testPerformCompleteUploadSingleMessageTargetBusinessObjectDataStatusNotUploading() {
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();
// Create a business object data status.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Update the status of the target business object data so it would not be "UPLOADING".
businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataHelper.getBusinessObjectDataKey(resultUploadSingleInitiationResponse.getTargetBusinessObjectData()), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
// Try to complete the upload, when target business object data status is not "UPLOADING".
UploadDownloadServiceImpl.CompleteUploadSingleMessageResult result = uploadDownloadService.performCompleteUploadSingleMessage(filePath);
assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getSourceOldBusinessObjectDataStatus());
assertNull(result.getSourceNewBusinessObjectDataStatus());
assertEquals(BDATA_STATUS, result.getTargetOldBusinessObjectDataStatus());
assertNull(result.getTargetNewBusinessObjectDataStatus());
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationResponse in project herd by FINRAOS.
the class UploadDownloadServiceTest method testExtendUploadSingleCredentialsBusinessObjectDataStatusNotValid.
@Test
public void testExtendUploadSingleCredentialsBusinessObjectDataStatusNotValid() {
// Create the upload data. This internally calls "complete" which sets the source business object data's status to "DELETED".
// This is a status where credentials can't be extended (i.e. only UPLOADING statuses).
UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID);
// Try to extend the upload credentials of a source business object data with an invalid status of "DELETED".
try {
extendUploadSingleCredentials(uploadSingleInitiationResponse.getSourceBusinessObjectData());
fail("Suppose to throw an IllegalArgumentException when business object data is not in VALID status.");
} catch (IllegalArgumentException e) {
BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getSourceBusinessObjectData();
assertEquals(String.format("Business object data {%s} has a status of \"%s\" and must be \"%s\" to extend credentials.", businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), businessObjectData.getPartitionValue(), NO_SUBPARTITION_VALUES, businessObjectData.getVersion()), BusinessObjectDataStatusEntity.DELETED, BusinessObjectDataStatusEntity.UPLOADING), e.getMessage());
}
}
Aggregations