@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); }
@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()); } }
@Test public void testInitiateDownloadSingleBusinessObjectDataStatusNotValid() { // Create the upload data, but leave the target business object data in a "RE-ENCRYPTING" status. UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.RE_ENCRYPTING); // Try to initiate a single file download when the business object data is not set to "VALID" which is invalid. try { // Initiate the download against the uploaded data (i.e. the target business object data). initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData()); fail("Suppose to throw an IllegalArgumentException when business object data is not in VALID status."); } catch (IllegalArgumentException e) { BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getTargetBusinessObjectData(); assertEquals(String.format("Business object data status \"%s\" does not match the expected status \"%s\" for the business object data {%s}.", uploadSingleInitiationResponse.getTargetBusinessObjectData().getStatus(), BusinessObjectDataStatusEntity.VALID, businessObjectDataServiceTestHelper .getExpectedBusinessObjectDataKeyAsString(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), businessObjectData.getPartitionValue(), businessObjectData.getSubPartitionValues(), businessObjectData.getVersion())), e.getMessage()); } }
@Test public void testInitiateDownloadSingleMultipleStorageFilesExist() { // Create the upload data. UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID); // Get the target business object data entity. BusinessObjectDataEntity targetBusinessObjectDataEntity = businessObjectDataDao .getBusinessObjectDataByAltKey(businessObjectDataHelper.getBusinessObjectDataKey(uploadSingleInitiationResponse.getTargetBusinessObjectData())); // Get the target bushiness object data storage unit. StorageUnitEntity targetStorageUnitEntity = IterableUtils.get(targetBusinessObjectDataEntity.getStorageUnits(), 0); // Add a second storage file to the target business object data storage unit. storageFileDaoTestHelper.createStorageFileEntity(targetStorageUnitEntity, FILE_NAME_2, FILE_SIZE_1_KB, ROW_COUNT_1000); // Try to initiate a single file download when business object data has more than one storage file. try { // Initiate the download against the uploaded data (i.e. the target business object data). initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData()); fail("Suppose to throw an IllegalArgumentException when business object has more than one storage file."); } catch (IllegalArgumentException e) { BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getTargetBusinessObjectData(); assertEquals(String.format("Found 2 registered storage files when expecting one in \"%s\" storage for the business object data {%s}.", targetStorageUnitEntity.getStorage().getName(), businessObjectDataServiceTestHelper .getExpectedBusinessObjectDataKeyAsString(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectData))), e.getMessage()); } }
@Test public void testExtendUploadSingleCredentialsBusinessObjectDataNoExists() { String INVALID_PARTITION_VALUE = "DOES_NOT_EXIST"; // Create the upload data. UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID); // Change the source business object data partition value to something invalid. uploadSingleInitiationResponse.getSourceBusinessObjectData().setPartitionValue(INVALID_PARTITION_VALUE); // Try to initiate a single file download when business object data does not exist (i.e. the partition value doesn't match). try { extendUploadSingleCredentials(uploadSingleInitiationResponse.getSourceBusinessObjectData()); fail("Suppose to throw an ObjectNotFoundException when business object data does not exist."); } catch (ObjectNotFoundException e) { BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getSourceBusinessObjectData(); assertEquals(businessObjectDataServiceTestHelper .getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), INVALID_PARTITION_VALUE, NO_SUBPARTITION_VALUES, businessObjectData.getVersion(), null), e.getMessage()); } }
@Test public void testInitiateDownloadSingleBusinessObjectDataNoExists() { String INVALID_PARTITION_VALUE = "DOES_NOT_EXIST"; // Create the upload data. UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID); // Change the target business object data partition value to something invalid. uploadSingleInitiationResponse.getTargetBusinessObjectData().setPartitionValue(INVALID_PARTITION_VALUE); // Try to initiate a single file download when business object data does not exist (i.e. the partition value doesn't match). try { // Initiate the download against the uploaded data (i.e. the target business object data). initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData()); fail("Suppose to throw an ObjectNotFoundException when business object data does not exist."); } catch (ObjectNotFoundException e) { BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getTargetBusinessObjectData(); assertEquals(businessObjectDataServiceTestHelper .getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), INVALID_PARTITION_VALUE, NO_SUBPARTITION_VALUES, businessObjectData.getVersion(), null), e.getMessage()); } }