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);
}
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));
}
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));
}
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));
}
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());
}
Aggregations