@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.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@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) StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential( new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, herdStringHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValues),
@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 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); }
storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); fail("Expected an IllegalStateException, but no exception was thrown");
@Test public void getStorageUnitUploadCredentialAssertOneOfBdataOrCreateNewVersionRequired() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); businessObjectDataKey.setNamespace(NAMESPACE); businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME); businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE); businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE); businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION); businessObjectDataKey.setPartitionValue(PARTITION_VALUE); businessObjectDataKey.setBusinessObjectDataVersion(null); Boolean createNewVersion = null; String storageName = STORAGE_NAME; createBusinessObjectFormatEntity(businessObjectDataKey); // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole")); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); try { storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); fail("Expected an IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); assertEquals("One of businessObjectDataVersion or createNewVersion must be specified.", e.getMessage()); } }
@Test public void getStorageUnitUploadCredentialAssertBDataVersionAndCreateNewVersionExclusive() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); businessObjectDataKey.setNamespace(NAMESPACE); businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME); businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE); businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE); businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION); businessObjectDataKey.setPartitionValue(PARTITION_VALUE); businessObjectDataKey.setBusinessObjectDataVersion(DATA_VERSION); Boolean createNewVersion = true; String storageName = STORAGE_NAME; createBusinessObjectFormatEntity(businessObjectDataKey); // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole")); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); try { storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); fail("Expected an IllegalArgumentException, but no exception was thrown"); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); assertEquals("createNewVersion must be false or unspecified when businessObjectDataVersion is specified.", e.getMessage()); } }
storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName);
@Test public void getStorageUnitUploadCredentialWithBdataVersion() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); businessObjectDataKey.setNamespace(NAMESPACE); businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME); businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE); businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE); businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION); businessObjectDataKey.setPartitionValue(PARTITION_VALUE); businessObjectDataKey.setBusinessObjectDataVersion(DATA_VERSION); Boolean createNewVersion = false; String storageName = STORAGE_NAME; createBusinessObjectFormatEntity(businessObjectDataKey); // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole")); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); attributes.add( new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), S3_KEY_PREFIX_VELOCITY_TEMPLATE)); storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); assertNotNull(storageUnitUploadCredential); assertNotNull(storageUnitUploadCredential.getAwsCredential()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime()); }
@Test public void getStorageUnitUploadCredentialAssertStorageNameTrim() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); businessObjectDataKey.setNamespace(NAMESPACE); businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME); businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE); businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE); businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION); businessObjectDataKey.setPartitionValue(PARTITION_VALUE); Boolean createNewVersion = true; String storageName = STORAGE_NAME; createBusinessObjectFormatEntity(businessObjectDataKey); // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole")); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); attributes.add( new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), S3_KEY_PREFIX_VELOCITY_TEMPLATE)); storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, BLANK_TEXT + storageName + BLANK_TEXT); assertNotNull(storageUnitUploadCredential); assertNotNull(storageUnitUploadCredential.getAwsCredential()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime()); }
storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName);
@Test public void getStorageUnitUploadCredentialWithCreateNewVersion() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(); businessObjectDataKey.setNamespace(NAMESPACE); businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME); businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE); businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE); businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION); businessObjectDataKey.setPartitionValue(PARTITION_VALUE); Boolean createNewVersion = true; String storageName = STORAGE_NAME; createBusinessObjectFormatEntity(businessObjectDataKey); // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole")); attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket")); attributes.add( new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), S3_KEY_PREFIX_VELOCITY_TEMPLATE)); storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName); assertNotNull(storageUnitUploadCredential); assertNotNull(storageUnitUploadCredential.getAwsCredential()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken()); assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime()); }