use of org.finra.herd.model.api.xml.BusinessObjectDataDdl 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.BusinessObjectDataDdl in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getExpectedBusinessObjectDataDdlCollectionResponse.
/**
* Creates an expected generate business object data ddl collection response using hard coded test values.
*
* @return the business object data ddl collection response
*/
public BusinessObjectDataDdlCollectionResponse getExpectedBusinessObjectDataDdlCollectionResponse() {
// Prepare a generate business object data collection response using hard coded test values.
BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = new BusinessObjectDataDdlCollectionResponse();
// Create a list of business object data ddl responses.
List<BusinessObjectDataDdl> businessObjectDataDdlResponses = new ArrayList<>();
businessObjectDataDdlCollectionResponse.setBusinessObjectDataDdlResponses(businessObjectDataDdlResponses);
// Get the actual HIVE DDL expected to be generated.
String expectedDdl = getExpectedBusinessObjectDataDdl(AbstractServiceTest.PARTITION_VALUE);
// Create a business object data ddl response.
BusinessObjectDataDdl expectedBusinessObjectDataDdl = new BusinessObjectDataDdl(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, expectedDdl);
// Add two business object ddl responses to the collection response.
businessObjectDataDdlResponses.add(expectedBusinessObjectDataDdl);
businessObjectDataDdlResponses.add(expectedBusinessObjectDataDdl);
// Set the expected DDL collection value.
businessObjectDataDdlCollectionResponse.setDdlCollection(String.format("%s\n\n%s", expectedDdl, expectedDdl));
return businessObjectDataDdlCollectionResponse;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdl 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.BusinessObjectDataDdl in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method generateBusinessObjectDataDdlCollectionImpl.
/**
* Retrieves the DDL to initialize the specified type of the database system to perform queries for a collection of business object data in the specified
* storages.
*
* @param businessObjectDataDdlCollectionRequest the business object data DDL collection request
*
* @return the business object data DDL information
*/
protected BusinessObjectDataDdlCollectionResponse generateBusinessObjectDataDdlCollectionImpl(BusinessObjectDataDdlCollectionRequest businessObjectDataDdlCollectionRequest) {
// Perform the validation of the entire request, before we start processing the individual requests that requires the database access.
validateBusinessObjectDataDdlCollectionRequest(businessObjectDataDdlCollectionRequest);
// Process the individual requests and build the response.
BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = new BusinessObjectDataDdlCollectionResponse();
List<BusinessObjectDataDdl> businessObjectDataDdlResponses = new ArrayList<>();
businessObjectDataDdlCollectionResponse.setBusinessObjectDataDdlResponses(businessObjectDataDdlResponses);
List<String> ddls = new ArrayList<>();
for (BusinessObjectDataDdlRequest request : businessObjectDataDdlCollectionRequest.getBusinessObjectDataDdlRequests()) {
// Please note that when calling to process individual ddl requests, we ask to skip the request validation and trimming step.
BusinessObjectDataDdl businessObjectDataDdl = generateBusinessObjectDataDdlImpl(request, true);
businessObjectDataDdlResponses.add(businessObjectDataDdl);
ddls.add(businessObjectDataDdl.getDdl());
}
businessObjectDataDdlCollectionResponse.setDdlCollection(StringUtils.join(ddls, "\n\n"));
return businessObjectDataDdlCollectionResponse;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdl in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method createBusinessObjectDataDdl.
/**
* Creates business object data ddl object instance and initialise it with the business object data ddl request field values.
*
* @param request the business object data ddl request
*
* @return the newly created BusinessObjectDataDdl object instance
*/
private BusinessObjectDataDdl createBusinessObjectDataDdl(BusinessObjectDataDdlRequest request) {
BusinessObjectDataDdl businessObjectDataDdl = new BusinessObjectDataDdl();
businessObjectDataDdl.setNamespace(request.getNamespace());
businessObjectDataDdl.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName());
businessObjectDataDdl.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage());
businessObjectDataDdl.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType());
businessObjectDataDdl.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion());
businessObjectDataDdl.setPartitionValueFilters(request.getPartitionValueFilters());
businessObjectDataDdl.setPartitionValueFilter(request.getPartitionValueFilter());
businessObjectDataDdl.setBusinessObjectDataVersion(request.getBusinessObjectDataVersion());
businessObjectDataDdl.setStorageNames(request.getStorageNames());
businessObjectDataDdl.setStorageName(request.getStorageName());
businessObjectDataDdl.setOutputFormat(request.getOutputFormat());
businessObjectDataDdl.setTableName(request.getTableName());
businessObjectDataDdl.setCustomDdlName(request.getCustomDdlName());
return businessObjectDataDdl;
}
Aggregations