@RequestParam(value = "createNewVersion", required = false, defaultValue = "false") Boolean createNewVersion, ServletRequest servletRequest) return storageUnitService.getS3KeyPrefix( validateRequestAndCreateBusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, subPartitionValues, businessObjectDataVersion, servletRequest), partitionKey, storageName,
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) return storageUnitService.getStorageUnitDownloadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) return storageUnitService.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@RequestParam(value = "createNewVersion", required = false, defaultValue = "false") Boolean createNewVersion, ServletRequest servletRequest) return storageUnitService.getS3KeyPrefix( validateRequestAndCreateBusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, subPartitionValues, businessObjectDataVersion, servletRequest), partitionKey, storageName,
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) return storageUnitService.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) return storageUnitService.getStorageUnitDownloadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@Test public void testGetS3KeyPrefixUpperCaseParameters() { // Create database entities required for testing. Please note that we are not passing the flag to create a business object data entity. businessObjectDataServiceTestHelper.createDatabaseEntitiesForGetS3KeyPrefixTesting(false); // Get the test partition columns. List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns(); String testPartitionKey = testPartitionColumns.get(0).getName(); List<SchemaColumn> testSubPartitionColumns = testPartitionColumns.subList(1, SUBPARTITION_VALUES.size() + 1); // Get an S3 key prefix using upper case input parameters (except for case-sensitive partition values). S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), testPartitionKey.toUpperCase(), STORAGE_NAME.toUpperCase(), false); // Get the expected S3 key prefix value using the business object data version. String expectedS3KeyPrefix = getExpectedS3KeyPrefix(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testPartitionKey, PARTITION_VALUE, testSubPartitionColumns.toArray(new SchemaColumn[testSubPartitionColumns.size()]), SUBPARTITION_VALUES.toArray(new String[SUBPARTITION_VALUES.size()]), DATA_VERSION); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); }
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) StorageUnitDownloadCredential storageUnitDownloadCredential = storageUnitService.getStorageUnitDownloadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@Test public void testGetS3KeyPrefixLowerCaseParameters() { // Create database entities required for testing. Please note that we are not passing the flag to create a business object data entity. businessObjectDataServiceTestHelper.createDatabaseEntitiesForGetS3KeyPrefixTesting(false); // Get the test partition columns. List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns(); String testPartitionKey = testPartitionColumns.get(0).getName(); List<SchemaColumn> testSubPartitionColumns = testPartitionColumns.subList(1, SUBPARTITION_VALUES.size() + 1); // Get an S3 key prefix using lower case input parameters (except for case-sensitive partition values). S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), testPartitionKey.toLowerCase(), STORAGE_NAME.toLowerCase(), false); // Get the expected S3 key prefix value using the business object data version. String expectedS3KeyPrefix = getExpectedS3KeyPrefix(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testPartitionKey, PARTITION_VALUE, testSubPartitionColumns.toArray(new SchemaColumn[testSubPartitionColumns.size()]), SUBPARTITION_VALUES.toArray(new String[SUBPARTITION_VALUES.size()]), DATA_VERSION); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); }
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@RequestParam(value = "subPartitionValues", required = false) String subPartitionValues) StorageUnitDownloadCredential storageUnitDownloadCredential = storageUnitService.getStorageUnitDownloadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@Test public void testGetS3KeyPrefix() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create an S3 key prefix information. S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); // Mock a servlet request. ServletRequest servletRequest = mock(ServletRequest.class); when(servletRequest.getParameterMap()).thenReturn(new HashMap<>()); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getS3KeyPrefix(businessObjectDataKey, PARTITION_KEY, STORAGE_NAME, CREATE_NEW_VERSION)).thenReturn(s3KeyPrefixInformation); // Call the method under test. S3KeyPrefixInformation result = businessObjectDataRestController .getS3KeyPrefix(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, delimitedSubPartitionValues, DATA_VERSION, STORAGE_NAME, CREATE_NEW_VERSION, servletRequest); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getS3KeyPrefix(businessObjectDataKey, PARTITION_KEY, STORAGE_NAME, CREATE_NEW_VERSION); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(s3KeyPrefixInformation, result); }
@Test public void testGetBusinessObjectDataUploadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create an AWS credential. AwsCredential awsCredential = new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME); // Create a storage unit download credential. StorageUnitUploadCredential storageUnitUploadCredential = new StorageUnitUploadCredential(awsCredential, AWS_KMS_KEY_ID); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, CREATE_NEW_VERSION, STORAGE_NAME)) .thenReturn(storageUnitUploadCredential); // Call the method under test. BusinessObjectDataUploadCredential result = businessObjectDataRestController .getBusinessObjectDataUploadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, CREATE_NEW_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitUploadCredential(businessObjectDataKey, CREATE_NEW_VERSION, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(new BusinessObjectDataUploadCredential(awsCredential, AWS_KMS_KEY_ID), result); }
@Test public void testGetBusinessObjectDataDownloadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create an AWS credential. AwsCredential awsCredential = new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME); // Create a storage unit download credential. StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential(awsCredential); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME)).thenReturn(storageUnitDownloadCredential); // Call the method under test. BusinessObjectDataDownloadCredential result = businessObjectDataRestController .getBusinessObjectDataDownloadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(new BusinessObjectDataDownloadCredential(awsCredential), result); }
@Test public void testGetS3KeyPrefixNoDataVersionSpecifiedLatestDataVersionExistsCreateNewVersionIsTrue() { // Create database entities required for testing. Please note that we are passing the flag to create a business object data entity. businessObjectDataServiceTestHelper.createDatabaseEntitiesForGetS3KeyPrefixTesting(true); // Get the test partition columns. List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns(); String testPartitionKey = testPartitionColumns.get(0).getName(); List<SchemaColumn> testSubPartitionColumns = testPartitionColumns.subList(1, SUBPARTITION_VALUES.size() + 1); // Get an S3 key prefix for the next business object data by not passing the business object data version and passing the create new version flag. S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, null), testPartitionKey, STORAGE_NAME, true); // Get the expected S3 key prefix value using the next business object data version. String expectedS3KeyPrefix = getExpectedS3KeyPrefix(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testPartitionKey, PARTITION_VALUE, testSubPartitionColumns.toArray(new SchemaColumn[testSubPartitionColumns.size()]), SUBPARTITION_VALUES.toArray(new String[SUBPARTITION_VALUES.size()]), DATA_VERSION + 1); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); }
@Test public void getStorageUnitUploadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create a storage unit upload credential. StorageUnitUploadCredential storageUnitUploadCredential = new StorageUnitUploadCredential( new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME), AWS_KMS_KEY_ID); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, null, STORAGE_NAME)).thenReturn(storageUnitUploadCredential); // Call the method under test. StorageUnitUploadCredential result = storageUnitRestController .getStorageUnitUploadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitUploadCredential(businessObjectDataKey, null, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(storageUnitUploadCredential, result); }
@Test public void getStorageUnitDownloadCredential() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); // Create a delimited list of sub-partition values. String delimitedSubPartitionValues = String.join("|", SUBPARTITION_VALUES); // Create a storage unit download credential. StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential( new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME)); // Mock the external calls. when(herdStringHelper.splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues)).thenReturn(SUBPARTITION_VALUES); when(storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME)).thenReturn(storageUnitDownloadCredential); // Call the method under test. StorageUnitDownloadCredential result = storageUnitRestController .getStorageUnitDownloadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, delimitedSubPartitionValues); // Verify the external calls. verify(herdStringHelper).splitStringWithDefaultDelimiterEscaped(delimitedSubPartitionValues); verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(storageUnitDownloadCredential, result); }
@Test public void testGetS3KeyPrefix() { // Create database entities required for testing. Please note that we are not passing the flag to create a business object data entity. businessObjectDataServiceTestHelper.createDatabaseEntitiesForGetS3KeyPrefixTesting(false); // Get the test partition columns. List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns(); String testPartitionKey = testPartitionColumns.get(0).getName(); List<SchemaColumn> testSubPartitionColumns = testPartitionColumns.subList(1, SUBPARTITION_VALUES.size() + 1); // Get an S3 key prefix by passing all parameters including partition key, business object data version, // and "create new version" flag (has no effect when data version is specified). S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), testPartitionKey, STORAGE_NAME, false); // Get the expected S3 key prefix value using the business object data version. String expectedS3KeyPrefix = getExpectedS3KeyPrefix(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testPartitionKey, PARTITION_VALUE, testSubPartitionColumns.toArray(new SchemaColumn[testSubPartitionColumns.size()]), SUBPARTITION_VALUES.toArray(new String[SUBPARTITION_VALUES.size()]), DATA_VERSION); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); }
storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); fail("Expected an IllegalStateException, but no exception was thrown");