use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlUsingStorageDirectoriesNoAutoDiscovery.
@Test
public void testGenerateBusinessObjectDataDdlUsingStorageDirectoriesNoAutoDiscovery() {
// Prepare test data with storage units having no storage files, but only the relative storage directory path values.
// For auto-discovery not to occur, number of partition columns is equal to the number of partition values.
List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns().subList(0, 1 + SUBPARTITION_VALUES.size());
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(FileTypeEntity.TXT_FILE_TYPE, FIRST_PARTITION_COLUMN_NAME, PARTITION_KEY_GROUP, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, UNSORTED_PARTITION_VALUES, SUBPARTITION_VALUES, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), partitionColumns, false, CUSTOM_DDL_NAME, false, ALLOW_DUPLICATE_BUSINESS_OBJECT_DATA);
BusinessObjectDataDdlRequest request;
BusinessObjectDataDdl resultDdl;
// Retrieve business object data ddl.
request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
resultDdl = businessObjectDataService.generateBusinessObjectDataDdl(request);
// Validate the results.
String expectedDdl = businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdl(partitionColumns.size(), FIRST_COLUMN_NAME, FIRST_COLUMN_DATA_TYPE, ROW_FORMAT, Hive13DdlGenerator.TEXT_HIVE_FILE_FORMAT, FileTypeEntity.TXT_FILE_TYPE, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, STORAGE_1_AVAILABLE_PARTITION_VALUES, SUBPARTITION_VALUES, false, true, true);
businessObjectDataServiceTestHelper.validateBusinessObjectDataDdl(request, expectedDdl, resultDdl);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlLatestAfterPartitionValueNoExists.
@Test
public void testGenerateBusinessObjectDataDdlLatestAfterPartitionValueNoExists() {
// Prepare database entities required for testing.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(PARTITION_VALUE);
// Try retrieve business object data ddl using a latest before partition value filter option when the latest partition value does not exist.
try {
businessObjectDataService.generateBusinessObjectDataDdl(new BusinessObjectDataDdlRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, NO_PARTITION_VALUES, NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE_2))), NO_STANDALONE_PARTITION_VALUE_FILTER, DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, TABLE_NAME, NO_CUSTOM_DDL_NAME, INCLUDE_DROP_TABLE_STATEMENT, INCLUDE_IF_NOT_EXISTS_OPTION, NO_INCLUDE_DROP_PARTITIONS, NO_ALLOW_MISSING_DATA, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS, NO_SUPPRESS_SCAN_FOR_UNREGISTERED_SUBPARTITIONS));
fail("Suppose to throw an ObjectNotFoundException when failed to find the latest after partition value.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Failed to find partition value which is the latest after partition value = \"%s\" " + "for partition key = \"%s\" due to no available business object data " + "in \"%s\" storage that satisfies the search criteria. Business object data {namespace: \"%s\", " + "businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d, businessObjectDataVersion: %d}", PARTITION_VALUE_2, FIRST_PARTITION_COLUMN_NAME, STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, DATA_VERSION), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getTestBusinessObjectDataDdlCollectionRequest.
/**
* Creates a generate business object data ddl collection request using hard coded test values.
*
* @return the business object data ddl collection request
*/
public BusinessObjectDataDdlCollectionRequest getTestBusinessObjectDataDdlCollectionRequest() {
// Create a generate business object data ddl collection request.
BusinessObjectDataDdlCollectionRequest businessObjectDataDdlCollectionRequest = new BusinessObjectDataDdlCollectionRequest();
// Create a list of generate business object data ddl requests.
List<BusinessObjectDataDdlRequest> businessObjectDataDdlRequests = new ArrayList<>();
businessObjectDataDdlCollectionRequest.setBusinessObjectDataDdlRequests(businessObjectDataDdlRequests);
// Create a generate business object data ddl request.
BusinessObjectDataDdlRequest businessObjectDataDdlRequest = new BusinessObjectDataDdlRequest(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, AbstractServiceTest.FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(AbstractServiceTest.FIRST_PARTITION_COLUMN_NAME, Arrays.asList(AbstractServiceTest.PARTITION_VALUE), AbstractServiceTest.NO_PARTITION_VALUE_RANGE, AbstractServiceTest.NO_LATEST_BEFORE_PARTITION_VALUE, AbstractServiceTest.NO_LATEST_AFTER_PARTITION_VALUE)), AbstractServiceTest.NO_STANDALONE_PARTITION_VALUE_FILTER, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.NO_STORAGE_NAMES, AbstractServiceTest.STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, AbstractServiceTest.TABLE_NAME, AbstractServiceTest.NO_CUSTOM_DDL_NAME, AbstractServiceTest.INCLUDE_DROP_TABLE_STATEMENT, AbstractServiceTest.INCLUDE_IF_NOT_EXISTS_OPTION, AbstractServiceTest.INCLUDE_DROP_PARTITIONS, AbstractServiceTest.NO_ALLOW_MISSING_DATA, AbstractServiceTest.NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS, AbstractServiceTest.NO_SUPPRESS_SCAN_FOR_UNREGISTERED_SUBPARTITIONS);
// Add two business object ddl requests to the collection request.
businessObjectDataDdlRequests.add(businessObjectDataDdlRequest);
businessObjectDataDdlRequests.add(businessObjectDataDdlRequest);
return businessObjectDataDdlCollectionRequest;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testGenerateBusinessObjectDataDdl.
@Test
public void testGenerateBusinessObjectDataDdl() {
// Create a business object data ddl request.
BusinessObjectDataDdlRequest businessObjectDataDdlRequest = new BusinessObjectDataDdlRequest();
// Create a business object data ddl response.
BusinessObjectDataDdl businessObjectDataDdl = new BusinessObjectDataDdl();
// Mock the external calls.
when(businessObjectDataService.generateBusinessObjectDataDdl(businessObjectDataDdlRequest)).thenReturn(businessObjectDataDdl);
// Call the method under test.
BusinessObjectDataDdl result = businessObjectDataRestController.generateBusinessObjectDataDdl(businessObjectDataDdlRequest);
// Verify the external calls.
verify(businessObjectDataService).generateBusinessObjectDataDdl(businessObjectDataDdlRequest);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(businessObjectDataDdl, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getTestBusinessObjectDataDdlRequest.
/**
* Creates and returns a business object data ddl request using passed parameters along with some hard-coded test values.
*
* @param startPartitionValue the start partition value for the partition value range
* @param endPartitionValue the end partition value for the partition value range
* @param partitionValues the list of partition values
* @param customDdlName the custom DDL name
*
* @return the newly created business object data ddl request
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public BusinessObjectDataDdlRequest getTestBusinessObjectDataDdlRequest(String startPartitionValue, String endPartitionValue, List<String> partitionValues, String customDdlName) {
BusinessObjectDataDdlRequest request = new BusinessObjectDataDdlRequest();
request.setNamespace(AbstractServiceTest.NAMESPACE);
request.setBusinessObjectDefinitionName(AbstractServiceTest.BDEF_NAME);
request.setBusinessObjectFormatUsage(AbstractServiceTest.FORMAT_USAGE_CODE);
request.setBusinessObjectFormatFileType(FileTypeEntity.TXT_FILE_TYPE);
request.setBusinessObjectFormatVersion(AbstractServiceTest.FORMAT_VERSION);
PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
request.setPartitionValueFilters(Arrays.asList(partitionValueFilter));
partitionValueFilter.setPartitionKey(AbstractServiceTest.FIRST_PARTITION_COLUMN_NAME);
if (startPartitionValue != null || endPartitionValue != null) {
PartitionValueRange partitionValueRange = new PartitionValueRange();
partitionValueFilter.setPartitionValueRange(partitionValueRange);
partitionValueRange.setStartPartitionValue(startPartitionValue);
partitionValueRange.setEndPartitionValue(endPartitionValue);
}
if (partitionValues != null) {
partitionValueFilter.setPartitionValues(new ArrayList(partitionValues));
}
request.setBusinessObjectDataVersion(AbstractServiceTest.DATA_VERSION);
request.setStorageName(AbstractServiceTest.STORAGE_NAME);
request.setOutputFormat(BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL);
request.setTableName(AbstractServiceTest.TABLE_NAME);
request.setCustomDdlName(customDdlName);
request.setIncludeDropTableStatement(true);
request.setIncludeIfNotExistsOption(true);
request.setAllowMissingData(true);
request.setIncludeAllRegisteredSubPartitions(AbstractServiceTest.NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
return request;
}
Aggregations