Search in sources :

Example 21 with BusinessObjectFormatDdl

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdl in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlNoCustomDdlSingleLevelPartitioning.

@Test
public void testGenerateBusinessObjectFormatDdlNoCustomDdlSingleLevelPartitioning() {
    // Prepare test data without custom ddl.
    List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns().subList(0, 1);
    String partitionKey = partitionColumns.get(0).getName();
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlTesting(FileTypeEntity.TXT_FILE_TYPE, partitionKey, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), partitionColumns, null);
    // Retrieve business object format ddl without specifying custom ddl name.
    BusinessObjectFormatDdlRequest request = businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlRequest(null);
    BusinessObjectFormatDdl resultDdl = businessObjectFormatService.generateBusinessObjectFormatDdl(request);
    // Validate the results.
    String expectedDdl = businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatDdl(partitionColumns.size(), FIRST_COLUMN_NAME, FIRST_COLUMN_DATA_TYPE, ROW_FORMAT, Hive13DdlGenerator.TEXT_HIVE_FILE_FORMAT, FileTypeEntity.TXT_FILE_TYPE, true, true);
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormatDdl(null, expectedDdl, resultDdl);
}
Also used : BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest) Test(org.junit.Test)

Example 22 with BusinessObjectFormatDdl

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdl in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlWhenReplaceColumns.

/**
 * Asserts that when replace columns is TRUE.
 */
@Test
public void testGenerateBusinessObjectFormatDdlWhenReplaceColumns() {
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlTesting();
    BusinessObjectFormatDdlRequest businessObjectFormatDdlRequest = businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlRequest(BLANK_TEXT);
    businessObjectFormatDdlRequest.setReplaceColumns(true);
    businessObjectFormatDdlRequest.setIncludeDropTableStatement(false);
    businessObjectFormatDdlRequest.setIncludeIfNotExistsOption(false);
    BusinessObjectFormatDdl result = businessObjectFormatService.generateBusinessObjectFormatDdl(businessObjectFormatDdlRequest);
    Assert.assertEquals("result DDL", result.getDdl(), "ALTER TABLE `" + businessObjectFormatDdlRequest.getTableName() + "` REPLACE COLUMNS (\n" + "    `COLUMN001` TINYINT,\n" + "    `COLUMN002` SMALLINT COMMENT 'This is \\'COLUMN002\\' column. Here are \\'single\\' and \"double\" quotes along with a backslash \\.',\n" + "    `COLUMN003` INT,\n" + "    `COLUMN004` BIGINT,\n" + "    `COLUMN005` FLOAT,\n" + "    `COLUMN006` DOUBLE,\n" + "    `COLUMN007` DECIMAL,\n" + "    `COLUMN008` DECIMAL(p,s),\n" + "    `COLUMN009` DECIMAL,\n" + "    `COLUMN010` DECIMAL(p),\n" + "    `COLUMN011` DECIMAL(p,s),\n" + "    `COLUMN012` TIMESTAMP,\n" + "    `COLUMN013` DATE,\n" + "    `COLUMN014` STRING,\n" + "    `COLUMN015` VARCHAR(n),\n" + "    `COLUMN016` VARCHAR(n),\n" + "    `COLUMN017` CHAR(n),\n" + "    `COLUMN018` BOOLEAN,\n" + "    `COLUMN019` BINARY);");
}
Also used : BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest) Test(org.junit.Test)

Example 23 with BusinessObjectFormatDdl

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdl in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlUpperCaseParameters.

@Test
public void testGenerateBusinessObjectFormatDdlUpperCaseParameters() {
    // Prepare test data.
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlTesting();
    // Retrieve business object format ddl request with all string values in upper case.
    BusinessObjectFormatDdlRequest request = businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlRequest(CUSTOM_DDL_NAME);
    request.setNamespace(request.getNamespace().toUpperCase());
    request.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName().toUpperCase());
    request.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage().toUpperCase());
    request.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType().toUpperCase());
    request.setCustomDdlName(request.getCustomDdlName().toUpperCase());
    BusinessObjectFormatDdl resultDdl = businessObjectFormatService.generateBusinessObjectFormatDdl(request);
    // Validate the results.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormatDdl(CUSTOM_DDL_NAME, businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatDdl(AbstractServiceTest.PARTITION_COLUMNS.length, AbstractServiceTest.FIRST_COLUMN_NAME, AbstractServiceTest.FIRST_COLUMN_DATA_TYPE, AbstractServiceTest.ROW_FORMAT, Hive13DdlGenerator.TEXT_HIVE_FILE_FORMAT, FileTypeEntity.TXT_FILE_TYPE, true, true), resultDdl);
}
Also used : BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest) Test(org.junit.Test)

Example 24 with BusinessObjectFormatDdl

use of org.finra.herd.model.api.xml.BusinessObjectFormatDdl in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlNoCustomDdlMissingSchemaDelimiterCharacter.

@Test
public void testGenerateBusinessObjectFormatDdlNoCustomDdlMissingSchemaDelimiterCharacter() {
    // Prepare test data.
    List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns();
    String partitionKey = partitionColumns.get(0).getName();
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlTesting(FileTypeEntity.TXT_FILE_TYPE, partitionKey, null, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), partitionColumns, null);
    // Retrieve business object format ddl.
    BusinessObjectFormatDdlRequest request = businessObjectFormatServiceTestHelper.getTestBusinessObjectFormatDdlRequest(null);
    BusinessObjectFormatDdl resultDdl = businessObjectFormatService.generateBusinessObjectFormatDdl(request);
    // Validate the results.
    String expectedRowFormat = "ROW FORMAT DELIMITED NULL DEFINED AS '\\N'";
    String expectedDdl = businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatDdl(PARTITION_COLUMNS.length, FIRST_COLUMN_NAME, FIRST_COLUMN_DATA_TYPE, expectedRowFormat, Hive13DdlGenerator.TEXT_HIVE_FILE_FORMAT, FileTypeEntity.TXT_FILE_TYPE, true, true);
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormatDdl(null, expectedDdl, resultDdl);
}
Also used : BusinessObjectFormatDdl(org.finra.herd.model.api.xml.BusinessObjectFormatDdl) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest) Test(org.junit.Test)

Aggregations

BusinessObjectFormatDdl (org.finra.herd.model.api.xml.BusinessObjectFormatDdl)24 BusinessObjectFormatDdlRequest (org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest)21 Test (org.junit.Test)20 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)9 ArrayList (java.util.ArrayList)2 BusinessObjectFormatDdlCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectFormatDdlCollectionResponse)2 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)2 HashMap (java.util.HashMap)1 BusinessObjectDataDdlOutputFormatEnum (org.finra.herd.model.api.xml.BusinessObjectDataDdlOutputFormatEnum)1 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)1 CustomDdlKey (org.finra.herd.model.api.xml.CustomDdlKey)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1 DdlGenerator (org.finra.herd.service.helper.DdlGenerator)1