/** * Create an instance of {@link S3KeyPrefixInformation } * */ public S3KeyPrefixInformation createS3KeyPrefixInformation() { return new S3KeyPrefixInformation(); }
/** * Create an instance of {@link S3KeyPrefixInformation } * */ public S3KeyPrefixInformation createS3KeyPrefixInformation() { return new S3KeyPrefixInformation(); }
/** * Create an instance of {@link S3KeyPrefixInformation } * */ public S3KeyPrefixInformation createS3KeyPrefixInformation() { return new S3KeyPrefixInformation(); }
public Object createNewInstance() { return new S3KeyPrefixInformation(); }
public Object createNewInstance() { return new S3KeyPrefixInformation(); }
public Object createNewInstance() { return new S3KeyPrefixInformation(); }
@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); }
@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); }
if (matcher.find()) S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); String namespace = getGroup(matcher, "namespace"); namespace = namespace == null ? "testNamespace" : namespace;
@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 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); }
@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); }
assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation);
@Test public void testGetS3KeyPrefixMissingOptionalParameters() { // Create a business object definition. businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); // 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); // Test if we can get an S3 key prefix without specifying optional parameters // including passing all allowed number of subpartition values (from 0 to MAX_SUBPARTITIONS). for (int i = 0; i <= BusinessObjectDataEntity.MAX_SUBPARTITIONS; i++) { // Build a list of subpartition values. List<String> subPartitionValues = SUBPARTITION_VALUES.subList(0, i); // Get the test partition columns. List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns(); String testPartitionKey = testPartitionColumns.get(0).getName(); List<SchemaColumn> testSubPartitionColumns = testPartitionColumns.subList(1, subPartitionValues.size() + 1); // Get an S3 key prefix without passing any of the optional parameters. S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, null), BLANK_TEXT, BLANK_TEXT, null); // Get the expected S3 key prefix value using the initial 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()]), INITIAL_DATA_VERSION); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); } }
@Test public void testGetS3KeyPrefixTrimParameters() { // 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 using input parameters with leading and trailing empty spaces. S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), DATA_VERSION), addWhitespace(testPartitionKey), addWhitespace(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); }
S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); s3KeyPrefixInformation.setS3KeyPrefix(s3KeyPrefix); return s3KeyPrefixInformation;
S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); s3KeyPrefixInformation.setS3KeyPrefix(s3KeyPrefix); return s3KeyPrefixInformation;
BusinessObjectData businessObjectData = new BusinessObjectData(); StorageUnit storageUnit = new StorageUnit(new Storage(storageName, null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); s3KeyPrefixInformation.setS3KeyPrefix(s3KeyPrefix);
BusinessObjectData businessObjectData = new BusinessObjectData(); StorageUnit storageUnit = new StorageUnit(new Storage(storageName, null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation(); s3KeyPrefixInformation.setS3KeyPrefix(s3KeyPrefix);
@Test public void testGetS3KeyPrefixMissingOptionalParametersPassedAsNulls() { // Create a business object definition. businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION); // 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(); // Get an S3 key prefix by passing null values for the namespace and partition key. S3KeyPrefixInformation resultS3KeyPrefixInformation = storageUnitService.getS3KeyPrefix( new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION), null, null, 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, null, null, DATA_VERSION); // Validate the results. assertEquals(new S3KeyPrefixInformation(expectedS3KeyPrefix), resultS3KeyPrefixInformation); }