use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest 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);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testBusinessObjectDataServiceMethodsNewTx.
/**
* This method is to get the coverage for the business object format service method that starts the new transaction.
*/
@Test
public void testBusinessObjectDataServiceMethodsNewTx() throws Exception {
try {
BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey();
businessObjectFormatServiceImpl.getBusinessObjectFormat(businessObjectFormatKey);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
BusinessObjectFormatDdlRequest businessObjectFormatDdlRequest = new BusinessObjectFormatDdlRequest();
businessObjectFormatServiceImpl.generateBusinessObjectFormatDdl(businessObjectFormatDdlRequest);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
BusinessObjectFormatDdlCollectionRequest businessObjectFormatDdlCollectionRequest = new BusinessObjectFormatDdlCollectionRequest();
businessObjectFormatServiceImpl.generateBusinessObjectFormatDdlCollection(businessObjectFormatDdlCollectionRequest);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("At least one business object format DDL request must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest 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);");
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest 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);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest 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);
}
Aggregations