/** * Create and persist database entities required for upload download testing. */ public void createDatabaseEntitiesForUploadDownloadTesting() { createDatabaseEntitiesForUploadDownloadTesting(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, AbstractServiceTest.FORMAT_FILE_TYPE_CODE, AbstractServiceTest.FORMAT_VERSION); createDatabaseEntitiesForUploadDownloadTesting(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME_2, AbstractServiceTest.FORMAT_USAGE_CODE_2, AbstractServiceTest.FORMAT_FILE_TYPE_CODE_2, AbstractServiceTest.FORMAT_VERSION_2); }
@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); }
@Test public void testInitiateUploadSingleUpperCaseParameters() { // Create database entities required for testing. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); // Initiate a file upload using lower case values. UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper .createUploadSingleInitiationRequest(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, NAMESPACE.toLowerCase(), BDEF_NAME_2.toLowerCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toLowerCase(), 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); }
@Test public void testInitiateUploadSingleDuplicateAttributes() { // Create database entities required for testing. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); // Try to initiate a single file upload when duplicate attributes are specified. UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(); request.setBusinessObjectDataAttributes(Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3))); try { uploadDownloadService.initiateUploadSingle(request); fail("Should throw an IllegalArgumentException when duplicate attributes are specified."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage()); } }
@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); }
@Test public void testInitiateUploadSingleRequiredAttributeMissingValue() { // 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); // Try to initiate a single file upload when a required attribute value is not specified. UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(); request.setBusinessObjectDataAttributes(Lists.newArrayList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, BLANK_TEXT))); try { uploadDownloadService.initiateUploadSingle(request); fail("Should throw an IllegalArgumentException when required attribute value is not specified."); } catch (IllegalArgumentException e) { assertEquals(String.format("The business object format has a required attribute \"%s\" which was not specified or has a value which is blank.", ATTRIBUTE_NAME_1_MIXED_CASE), e.getMessage()); } }
@Test public void testExtendUploadSingleCredentials() throws InterruptedException { // Create source and target business object formats database entities which are required to initiate an upload. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); // Initiate a file upload. UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest()); // Sleep a short amount of time to ensure the extended credentials don't return the same expiration as the initial credentials. Thread.sleep(10); // Initiate the download against the uploaded data (i.e. the target business object data). UploadSingleCredentialExtensionResponse uploadSingleCredentialExtensionResponse = extendUploadSingleCredentials(uploadSingleInitiationResponse.getSourceBusinessObjectData()); // Validate the returned object. assertNotNull(uploadSingleCredentialExtensionResponse.getAwsAccessKey()); assertNotNull(uploadSingleCredentialExtensionResponse.getAwsSecretKey()); assertNotNull(uploadSingleCredentialExtensionResponse.getAwsSessionToken()); assertNotNull(uploadSingleCredentialExtensionResponse.getAwsSessionExpirationTime()); assertNotNull(uploadSingleInitiationResponse.getAwsSessionExpirationTime()); // Ensure the extended credentials are greater than the original set of credentials. // We are displaying the values in case there is a problem because this test was acting flaky. if (uploadSingleCredentialExtensionResponse.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis() <= uploadSingleInitiationResponse.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis()) { fail("Initial expiration time \"" + uploadSingleInitiationResponse.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis() + "\" is not > extended expiration time \"" + uploadSingleCredentialExtensionResponse.getAwsSessionExpirationTime().toGregorianCalendar().getTimeInMillis() + "\"."); } }
@Test public void testS3Message() throws Exception { setLogLevel(UploadDownloadHelperServiceImpl.class, LogLevel.OFF); uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest()); String filePath = resultUploadSingleInitiationResponse.getSourceBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath(); S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, 0L, null, null), null); List<S3EventNotificationRecord> records = new ArrayList<>(); records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null)); S3EventNotification s3EventNotification = new S3EventNotification(records); setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF); setLogLevel(HerdJmsMessageListener.class, LogLevel.DEBUG); herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null); }
@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); }
/** * Asserts that error is thrown when target storage's prefix template is not set. */ @Test public void testInitiateUploadSingleAssertTargetStoragePrefixTemplateRequired() { // Create database entities required for testing. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucketName")); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012")); // Initiate a file upload. UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(); uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3); try { uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest); fail(); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); assertEquals("Storage \"" + STORAGE_NAME_3 + "\" has no S3 key prefix velocity template configured.", e.getMessage()); } }
@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); }
@Test public void testS3MessageS3FileNoExists() throws Exception { setLogLevel(UploadDownloadHelperServiceImpl.class, LogLevel.OFF); 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, TARGET_S3_KEY)); String filePath = resultUploadSingleInitiationResponse.getSourceBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath(); S3Entity s3Entity = new S3Entity(null, null, new S3ObjectEntity(filePath, 0L, null, null), null); List<S3EventNotificationRecord> records = new ArrayList<>(); records.add(new S3EventNotificationRecord(null, null, null, null, null, null, null, s3Entity, null)); S3EventNotification s3EventNotification = new S3EventNotification(records); setLogLevel(UploadDownloadServiceImpl.class, LogLevel.OFF); setLogLevel(HerdJmsMessageListener.class, LogLevel.OFF); // Try to process an S3 JMS message, when source S3 file does not exist. herdJmsMessageListener.processMessage(jsonHelper.objectToJson(s3EventNotification), null); }
/** * Asserts that error is thrown when target storage's bucket name is not set. */ @Test public void testInitiateUploadSingleAssertTargetStorageBucketNameRequired() { // Create database entities required for testing. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), "$environment/$namespace/$businessObjectDataPartitionValue")); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012")); // Initiate a file upload. UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(); uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3); try { uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest); fail(); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); assertEquals("Attribute \"" + configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME) + "\" for \"" + STORAGE_NAME_3 + "\" storage must be configured.", e.getMessage()); } }
/** * Asserts that error is thrown when target storage's kms kms id is not set. */ @Test public void testInitiateUploadSingleAssertTargetStorageKmsKeyIdRequired() { // Create database entities required for testing. uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucketName")); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), "$environment/$namespace/$businessObjectDataPartitionValue")); // Initiate a file upload. UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(); uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3); try { uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest); fail(); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); assertEquals("Attribute \"" + configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID) + "\" for \"" + STORAGE_NAME_3 + "\" storage must be configured.", e.getMessage()); } }
@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()); }
/** * Creates the appropriate business object data entries for an upload. * * @param businessObjectDataStatusCode the target business object data status. * * @return the upload single initiation response created during the upload flow. */ public UploadSingleInitiationResponse createUploadedFileData(String businessObjectDataStatusCode) { loggingHelper.setLogLevel(UploadDownloadHelperServiceImpl.class, LogLevel.OFF); // Create source and target business object formats database entities which are required to initiate an upload. createDatabaseEntitiesForUploadDownloadTesting(); // Initiate a file upload. UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(createUploadSingleInitiationRequest()); // Complete the upload. uploadDownloadService.performCompleteUploadSingleMessage( resultUploadSingleInitiationResponse.getSourceBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath()); // Update the target business object data status to valid. Normally this would happen as part of the completion request, but since the status update // happens asynchronously, this will not happen within a unit test context which is why we are setting it explicitly. businessObjectDataDao.getBusinessObjectDataByAltKey( businessObjectDataHelper.getBusinessObjectDataKey(resultUploadSingleInitiationResponse.getTargetBusinessObjectData())) .setStatus(businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(businessObjectDataStatusCode)); resultUploadSingleInitiationResponse.getTargetBusinessObjectData().setStatus(businessObjectDataStatusCode); // Return the initiate upload single response. return resultUploadSingleInitiationResponse; }
@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()); }
@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()); }
@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); }
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting(); StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3); storageEntity.getAttributes().add(storageDaoTestHelper