Search in sources :

Example 56 with SchemaColumn

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

the class BusinessObjectFormatServiceTest method testGenerateBusinessObjectFormatDdlNoCustomDdlMissingSchemaEscapeCharacter.

@Test
public void testGenerateBusinessObjectFormatDdlNoCustomDdlMissingSchemaEscapeCharacter() {
    // Prepare test data without custom ddl.
    List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns();
    String partitionKey = partitionColumns.get(0).getName();
    businessObjectFormatServiceTestHelper.createDatabaseEntitiesForBusinessObjectFormatDdlTesting(FileTypeEntity.TXT_FILE_TYPE, partitionKey, SCHEMA_DELIMITER_PIPE, null, 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 FIELDS TERMINATED BY '|' 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)

Example 57 with SchemaColumn

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoSchemaColumnType.

@Test
public void testCreateBusinessObjectFormatNoSchemaColumnType() {
    // Create a business object format create request.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    // Try to create a business object format with an empty column data type.
    SchemaColumn schemaColumn = new SchemaColumn();
    request.getSchema().getColumns().add(schemaColumn);
    schemaColumn.setName("COLUMN_NAME");
    schemaColumn.setType(BLANK_TEXT);
    try {
        businessObjectFormatService.createBusinessObjectFormat(request);
        fail("Should throw an IllegalArgumentException when schema has an empty column data type.");
    } catch (IllegalArgumentException e) {
        assertEquals("A schema column data type must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) Test(org.junit.Test)

Example 58 with SchemaColumn

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoSchemaPartitionColumnType.

@Test
public void testCreateBusinessObjectFormatNoSchemaPartitionColumnType() {
    // Create a business object format create request.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    // Try to create a business object format with an empty column data type.
    SchemaColumn partitionColumn = new SchemaColumn();
    request.getSchema().getPartitions().add(partitionColumn);
    partitionColumn.setName("COLUMN_NAME");
    partitionColumn.setType(BLANK_TEXT);
    try {
        businessObjectFormatService.createBusinessObjectFormat(request);
        fail("Should throw an IllegalArgumentException when schema has an empty partition column data type.");
    } catch (IllegalArgumentException e) {
        assertEquals("A schema column data type must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) Test(org.junit.Test)

Example 59 with SchemaColumn

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

the class BusinessObjectDataStorageFileServiceTest method createDataWithSubPartitions.

private void createDataWithSubPartitions() {
    NamespaceEntity namespaceEntity = super.namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    DataProviderEntity dataProviderEntity = super.dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = super.businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(namespaceEntity, BDEF_NAME, dataProviderEntity, NO_BDEF_DESCRIPTION, NO_BDEF_DISPLAY_NAME, NO_ATTRIBUTES, NO_SAMPLE_DATA_FILES);
    FileTypeEntity fileTypeEntity = super.fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE, FORMAT_DESCRIPTION);
    List<SchemaColumn> schemaColumns = new ArrayList<>();
    {
        SchemaColumn schemaColumn = new SchemaColumn();
        schemaColumn.setName(PARTITION_KEY);
        schemaColumn.setType("STRING");
        schemaColumns.add(schemaColumn);
    }
    {
        SchemaColumn schemaColumn = new SchemaColumn();
        schemaColumn.setName(PARTITION_KEY_2);
        schemaColumn.setType("STRING");
        schemaColumns.add(schemaColumn);
    }
    {
        SchemaColumn schemaColumn = new SchemaColumn();
        schemaColumn.setName(PARTITION_KEY_3);
        schemaColumn.setType("STRING");
        schemaColumns.add(schemaColumn);
    }
    {
        SchemaColumn schemaColumn = new SchemaColumn();
        schemaColumn.setName(PARTITION_KEY_4);
        schemaColumn.setType("STRING");
        schemaColumns.add(schemaColumn);
    }
    {
        SchemaColumn schemaColumn = new SchemaColumn();
        schemaColumn.setName(PARTITION_KEY_5);
        schemaColumn.setType("STRING");
        schemaColumns.add(schemaColumn);
    }
    BusinessObjectFormatEntity businessObjectFormatEntity = super.businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectDefinitionEntity, FORMAT_USAGE_CODE, fileTypeEntity, FORMAT_VERSION, null, true, PARTITION_KEY, null, NO_ATTRIBUTES, null, null, null, schemaColumns, null);
    BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS, DESCRIPTION, BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUB_PARTITION_VALUES, DATA_VERSION, true, businessObjectDataStatusEntity.getCode());
    StorageEntity storageEntity = super.storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
    StorageUnitEntity storageUnitEntity = super.storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    super.storageFileDaoTestHelper.createStorageFileEntity(storageUnitEntity, FILE_PATH_1, FILE_SIZE_1_KB, null);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Example 60 with SchemaColumn

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

the class BusinessObjectDataServiceTestHelper method createDatabaseEntitiesForGetS3KeyPrefixTesting.

/**
 * Create and persist database entities required for testing.
 *
 * @param createBusinessObjectDataEntity specifies if a business object data instance should be created or not
 */
public void createDatabaseEntitiesForGetS3KeyPrefixTesting(boolean createBusinessObjectDataEntity) {
    // Get a list of test schema partition columns and use the first column name as the partition key.
    List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns();
    String partitionKey = partitionColumns.get(0).getName();
    // Create and persist a business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, AbstractServiceTest.FORMAT_FILE_TYPE_CODE, AbstractServiceTest.FORMAT_VERSION, AbstractServiceTest.FORMAT_DESCRIPTION, AbstractServiceTest.LATEST_VERSION_FLAG_SET, partitionKey, AbstractServiceTest.NO_PARTITION_KEY_GROUP, AbstractServiceTest.NO_ATTRIBUTES, AbstractServiceTest.SCHEMA_DELIMITER_PIPE, AbstractServiceTest.SCHEMA_ESCAPE_CHARACTER_BACKSLASH, AbstractServiceTest.SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), partitionColumns);
    // Create and persist an S3 storage with the S3 key prefix velocity template attribute.
    storageDaoTestHelper.createStorageEntity(AbstractServiceTest.STORAGE_NAME, StoragePlatformEntity.S3, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), AbstractServiceTest.S3_KEY_PREFIX_VELOCITY_TEMPLATE);
    // If requested, create and persist a business object data entity.
    if (createBusinessObjectDataEntity) {
        businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, AbstractServiceTest.PARTITION_VALUE, AbstractServiceTest.SUBPARTITION_VALUES, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET, AbstractServiceTest.BDATA_STATUS);
    }
}
Also used : SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Aggregations

SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)98 Test (org.junit.Test)68 ArrayList (java.util.ArrayList)23 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)22 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)18 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)17 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)16 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)15 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)14 Attribute (org.finra.herd.model.api.xml.Attribute)12 StorageEntity (org.finra.herd.model.jpa.StorageEntity)12 BusinessObjectFormatDdlRequest (org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest)11 BusinessObjectFormatDdl (org.finra.herd.model.api.xml.BusinessObjectFormatDdl)9 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)9 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)8 Schema (org.finra.herd.model.api.xml.Schema)8 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)7 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)5 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3