Search in sources :

Example 81 with BusinessObjectFormatEntity

use of org.finra.herd.model.jpa.BusinessObjectFormatEntity in project herd by FINRAOS.

the class Hive13DdlGeneratorTest method testGenerateReplaceColumnsStatement.

/**
 * Asserts that generateReplaceColumnsStatement() generates the correct DDL statement.
 */
@Test
public void testGenerateReplaceColumnsStatement() {
    BusinessObjectFormatDdlRequest businessObjectFormatDdlRequest = new BusinessObjectFormatDdlRequest();
    businessObjectFormatDdlRequest.setTableName(TABLE_NAME);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    {
        SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
        schemaColumnEntity.setPosition(0);
        schemaColumnEntity.setName("col1");
        schemaColumnEntity.setType("varchar");
        schemaColumnEntity.setSize("255");
        schemaColumnEntity.setDescription("lorem ipsum");
        businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
    }
    {
        SchemaColumnEntity schemaColumnEntity = new SchemaColumnEntity();
        schemaColumnEntity.setPosition(1);
        schemaColumnEntity.setName("col2");
        schemaColumnEntity.setType("date");
        businessObjectFormatEntity.getSchemaColumns().add(schemaColumnEntity);
    }
    String actual = hive13DdlGenerator.generateReplaceColumnsStatement(businessObjectFormatDdlRequest, businessObjectFormatEntity);
    String expected = "ALTER TABLE `" + businessObjectFormatDdlRequest.getTableName() + "` REPLACE COLUMNS (\n" + "    `col1` VARCHAR(255) COMMENT 'lorem ipsum',\n" + "    `col2` DATE);";
    Assert.assertEquals("generated DDL", expected, actual);
}
Also used : SchemaColumnEntity(org.finra.herd.model.jpa.SchemaColumnEntity) BusinessObjectFormatDdlRequest(org.finra.herd.model.api.xml.BusinessObjectFormatDdlRequest) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 82 with BusinessObjectFormatEntity

use of org.finra.herd.model.jpa.BusinessObjectFormatEntity in project herd by FINRAOS.

the class JsonHelperTest method testObjectToJsonValidateNoStackOverflowErrorWithCircularDependency.

@Test
public void testObjectToJsonValidateNoStackOverflowErrorWithCircularDependency() {
    // Create a business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, NO_ATTRIBUTES);
    // Create a business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectDefinitionEntity, FORMAT_USAGE_CODE, fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE, null), FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, null, NO_ATTRIBUTES, SCHEMA_DELIMITER_COMMA, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, NO_COLUMNS, NO_PARTITION_COLUMNS);
    // Introduce circular dependency to the business object format parent/child relationship.
    businessObjectFormatEntity.setBusinessObjectFormatParents(Arrays.asList(businessObjectFormatEntity));
    businessObjectFormatEntity.setBusinessObjectFormatChildren(Arrays.asList(businessObjectFormatEntity));
    businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    // Create a JSON object from the business object definition entity.
    assertNotNull(jsonHelper.objectToJson(businessObjectDefinitionEntity));
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 83 with BusinessObjectFormatEntity

use of org.finra.herd.model.jpa.BusinessObjectFormatEntity in project herd by FINRAOS.

the class BusinessObjectDataDaoTest method testGetBusinessObjectDataByBusinessObjectFormat.

@Test
public void testGetBusinessObjectDataByBusinessObjectFormat() {
    // Create a business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY, PARTITION_KEY_GROUP);
    // Create two business object data entities that belong to the same business object format version.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Retrieve the keys for business object data by specifying business object format and without setting a maximum number of results.
    assertEquals(Arrays.asList(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION)), businessObjectDataDao.getBusinessObjectDataByBusinessObjectFormat(businessObjectFormatEntity, NO_MAX_RESULTS));
    // Retrieve the keys for business object data by specifying business object format and with maximum number of results set to 1.
    assertEquals(Collections.singletonList(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION)), businessObjectDataDao.getBusinessObjectDataByBusinessObjectFormat(businessObjectFormatEntity, MAX_RESULTS_1));
}
Also used : BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 84 with BusinessObjectFormatEntity

use of org.finra.herd.model.jpa.BusinessObjectFormatEntity in project herd by FINRAOS.

the class BusinessObjectDataDaoTest method testGetBusinessObjectDataPartitionValueLatestDataVersionNotInStorage.

/**
 * This unit test validates that we do not rely on the business object data latest version flag when selecting an aggregate on the business object data
 * partition value.
 */
@Test
public void testGetBusinessObjectDataPartitionValueLatestDataVersionNotInStorage() {
    // Create a business object format entity.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectFormatKey, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    // Create two versions of business object data instances with the latest version not located in the test storage.
    List<BusinessObjectDataEntity> businessObjectDataEntities = Arrays.asList(businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, false, BDATA_STATUS), businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, SECOND_DATA_VERSION, true, BDATA_STATUS));
    // Create a storage instance and a storage unit for the initial business object data version only.
    StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
    StorageUnitStatusEntity storageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(STORAGE_UNIT_STATUS);
    storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntities.get(0), storageUnitStatusEntity, NO_STORAGE_DIRECTORY_PATH);
    // Get the maximum available partition value in the test storage without specifying business object data version.
    assertEquals(PARTITION_VALUE, businessObjectDataDao.getBusinessObjectDataMaxPartitionValue(BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, businessObjectFormatKey, null, BDATA_STATUS, Collections.singletonList(STORAGE_NAME), null, null, null, null));
    // Get the minimum available partition value in the test storage without specifying business object data version.
    assertEquals(PARTITION_VALUE, businessObjectDataDao.getBusinessObjectDataMinPartitionValue(BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, businessObjectFormatKey, null, BDATA_STATUS, Collections.singletonList(STORAGE_NAME), null, null));
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Example 85 with BusinessObjectFormatEntity

use of org.finra.herd.model.jpa.BusinessObjectFormatEntity in project herd by FINRAOS.

the class BusinessObjectDataDaoTest method createBusinessObjectEntityForPartitionValueFilterTest.

private BusinessObjectDataEntity createBusinessObjectEntityForPartitionValueFilterTest() {
    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 + "1");
        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);
    }
    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);
    BusinessObjectFormatEntity businessObjectFormatEntity = super.businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectDefinitionEntity, FORMAT_USAGE_CODE, fileTypeEntity, FORMAT_VERSION, null, true, PARTITION_KEY, null, NO_ATTRIBUTES, null, null, null, schemaColumns, schemaColumns);
    BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS, DESCRIPTION, BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
    return businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, businessObjectDataStatusEntity.getCode());
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) 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) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Aggregations

BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)181 Test (org.junit.Test)100 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)72 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)53 ArrayList (java.util.ArrayList)43 StorageEntity (org.finra.herd.model.jpa.StorageEntity)37 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)32 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)32 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)28 Predicate (javax.persistence.criteria.Predicate)25 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)25 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)25 BusinessObjectDefinitionColumnKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey)23 Attribute (org.finra.herd.model.api.xml.Attribute)22 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)22 BusinessObjectDefinitionColumn (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumn)20 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)20 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)19 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)18 BusinessObjectDefinitionColumnEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity)18