Search in sources :

Example 21 with BusinessObjectDataDdl

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);
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) Test(org.junit.Test)

Example 22 with BusinessObjectDataDdl

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;
}
Also used : BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) ArrayList(java.util.ArrayList) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 23 with BusinessObjectDataDdl

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);
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) Test(org.junit.Test)

Example 24 with BusinessObjectDataDdl

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;
}
Also used : BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl)

Example 25 with BusinessObjectDataDdl

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;
}
Also used : BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl)

Aggregations

BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)50 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)47 Test (org.junit.Test)45 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)16 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)16 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)8 ArrayList (java.util.ArrayList)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)4 StorageEntity (org.finra.herd.model.jpa.StorageEntity)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)3 HashMap (java.util.HashMap)2 BusinessObjectDataDdlCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse)2 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)2 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)2 List (java.util.List)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)1 CustomDdlKey (org.finra.herd.model.api.xml.CustomDdlKey)1 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)1