use of org.finra.herd.model.api.xml.S3KeyPrefixInformation in project herd by FINRAOS.
the class StorageUnitServiceGetS3KeyPrefixTest method testGetS3KeyPrefixNoDataVersionSpecifiedLatestDataVersionExistsCreateNewVersionIsTrue.
@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);
}
use of org.finra.herd.model.api.xml.S3KeyPrefixInformation in project herd by FINRAOS.
the class StorageUnitServiceGetS3KeyPrefixTest method testGetS3KeyPrefixMissingOptionalParametersPassedAsNulls.
@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);
}
use of org.finra.herd.model.api.xml.S3KeyPrefixInformation in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testGetS3KeyPrefix.
@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 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(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, getDelimitedFieldValues(SUBPARTITION_VALUES), DATA_VERSION, STORAGE_NAME, CREATE_NEW_VERSION, servletRequest);
// Verify the external calls.
verify(storageUnitService).getS3KeyPrefix(businessObjectDataKey, PARTITION_KEY, STORAGE_NAME, CREATE_NEW_VERSION);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(s3KeyPrefixInformation, result);
}
use of org.finra.herd.model.api.xml.S3KeyPrefixInformation in project herd by FINRAOS.
the class StorageUnitServiceGetS3KeyPrefixTest method testGetS3KeyPrefixTrimParameters.
@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);
}
use of org.finra.herd.model.api.xml.S3KeyPrefixInformation in project herd by FINRAOS.
the class StorageUnitServiceGetS3KeyPrefixTest method testGetS3KeyPrefixLowerCaseParameters.
@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);
}
Aggregations