Search in sources :

Example 6 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesBusinessObjectDefinitionAlreadyExists.

@Test
public void testGetRelationalStorageAttributesBusinessObjectDefinitionAlreadyExists() {
    // Create a namespace.
    namespaceDaoTestHelper.createNamespaceEntity(BDEF_NAMESPACE);
    // Create a business object definition.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    // Try to a get relational storage attributes when specified business object definition already exists.
    try {
        relationalTableRegistrationHelperService.getRelationalStorageAttributes(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
        fail();
    } catch (AlreadyExistsException ex) {
        Assert.assertEquals(String.format("Business object definition with name \"%s\" already exists for namespace \"%s\".", BDEF_NAME, BDEF_NAMESPACE), ex.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) Test(org.junit.Test)

Example 7 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationServiceTest method testCreateRelationalTableRegistration.

@Test
public void testCreateRelationalTableRegistration() {
    // Create database entities required for relational table registration testing.
    relationalTableRegistrationServiceTestHelper.createDatabaseEntitiesForRelationalTableRegistrationTesting(BDEF_NAMESPACE, DATA_PROVIDER_NAME, STORAGE_NAME);
    // Pick one of the in-memory database tables to be registered as a relational table.
    String relationalSchemaName = "PUBLIC";
    String relationalTableName = BusinessObjectDefinitionEntity.TABLE_NAME.toUpperCase();
    // Create a relational table registration create request for a table that is part of the in-memory database setup as part of DAO mocks.
    RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest = new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, relationalSchemaName, relationalTableName, STORAGE_NAME);
    // Create a relational table registration.
    BusinessObjectData businessObjectData = relationalTableRegistrationService.createRelationalTableRegistration(relationalTableRegistrationCreateRequest, APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
    // Create an expected storage unit.
    StorageUnit expectedStorageUnit = new StorageUnit();
    expectedStorageUnit.setStorage(new Storage(STORAGE_NAME, StoragePlatformEntity.RELATIONAL, relationalTableRegistrationServiceTestHelper.getStorageAttributes()));
    expectedStorageUnit.setStorageUnitStatus(StorageUnitStatusEntity.ENABLED);
    // Create an expected business object data.
    BusinessObjectData expectedBusinessObjectData = new BusinessObjectData();
    expectedBusinessObjectData.setId(businessObjectData.getId());
    expectedBusinessObjectData.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectData.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectData.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    expectedBusinessObjectData.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    expectedBusinessObjectData.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    expectedBusinessObjectData.setPartitionValue(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_VALUE);
    expectedBusinessObjectData.setSubPartitionValues(new ArrayList<>());
    expectedBusinessObjectData.setVersion(INITIAL_DATA_VERSION);
    expectedBusinessObjectData.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    expectedBusinessObjectData.setLatestVersion(LATEST_VERSION_FLAG_SET);
    expectedBusinessObjectData.setStatus(BusinessObjectDataStatusEntity.VALID);
    expectedBusinessObjectData.setStorageUnits(Collections.singletonList(expectedStorageUnit));
    expectedBusinessObjectData.setAttributes(new ArrayList<>());
    expectedBusinessObjectData.setBusinessObjectDataParents(new ArrayList<>());
    expectedBusinessObjectData.setBusinessObjectDataChildren(new ArrayList<>());
    // Validate the response.
    assertEquals(expectedBusinessObjectData, businessObjectData);
    // Create a business object format key.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, INITIAL_FORMAT_VERSION);
    // Retrieve business object format that was created as part of the relational table registration.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey);
    // Create an expected schema.
    Schema expectedSchema = new Schema();
    expectedSchema.setColumns(relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns());
    expectedSchema.setNullValue(EMPTY_STRING);
    // Build an expected business object format.
    BusinessObjectFormat expectedBusinessObjectFormat = new BusinessObjectFormat();
    expectedBusinessObjectFormat.setId(businessObjectFormat.getId());
    expectedBusinessObjectFormat.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectFormat.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectFormat.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    expectedBusinessObjectFormat.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    expectedBusinessObjectFormat.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    expectedBusinessObjectFormat.setLatestVersion(LATEST_VERSION_FLAG_SET);
    expectedBusinessObjectFormat.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    expectedBusinessObjectFormat.setBusinessObjectFormatParents(new ArrayList<>());
    expectedBusinessObjectFormat.setBusinessObjectFormatChildren(new ArrayList<>());
    expectedBusinessObjectFormat.setAttributeDefinitions(new ArrayList<>());
    expectedBusinessObjectFormat.setAttributes(Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_SCHEMA_NAME), relationalSchemaName), new Attribute(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_FORMAT_ATTRIBUTE_NAME_RELATIONAL_TABLE_NAME), relationalTableName)));
    expectedBusinessObjectFormat.setSchema(expectedSchema);
    // Validate the newly created business object format.
    assertEquals(expectedBusinessObjectFormat, businessObjectFormat);
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
    // Retrieve business object definition that was created as part of the relational table registration.
    BusinessObjectDefinition businessObjectDefinition = businessObjectDefinitionService.getBusinessObjectDefinition(businessObjectDefinitionKey, true);
    // Create an expected business object definition.
    BusinessObjectDefinition expectedBusinessObjectDefinition = new BusinessObjectDefinition();
    expectedBusinessObjectDefinition.setId(businessObjectDefinition.getId());
    expectedBusinessObjectDefinition.setNamespace(BDEF_NAMESPACE);
    expectedBusinessObjectDefinition.setBusinessObjectDefinitionName(BDEF_NAME);
    expectedBusinessObjectDefinition.setDataProviderName(DATA_PROVIDER_NAME);
    expectedBusinessObjectDefinition.setDisplayName(BDEF_DISPLAY_NAME);
    expectedBusinessObjectDefinition.setAttributes(new ArrayList<>());
    expectedBusinessObjectDefinition.setSampleDataFiles(new ArrayList<>());
    expectedBusinessObjectDefinition.setCreatedByUserId(businessObjectDefinition.getCreatedByUserId());
    expectedBusinessObjectDefinition.setLastUpdatedByUserId(businessObjectDefinition.getLastUpdatedByUserId());
    expectedBusinessObjectDefinition.setLastUpdatedOn(businessObjectDefinition.getLastUpdatedOn());
    expectedBusinessObjectDefinition.setBusinessObjectDefinitionChangeEvents(businessObjectDefinition.getBusinessObjectDefinitionChangeEvents());
    // Validate the newly created business object definition.
    assertEquals(expectedBusinessObjectDefinition, businessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Storage(org.finra.herd.model.api.xml.Storage) RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Schema(org.finra.herd.model.api.xml.Schema) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 8 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testValidateAndTrimRelationalTableRegistrationCreateRequestMissingOptionalParametersAsNulls.

@Test
public void testValidateAndTrimRelationalTableRegistrationCreateRequestMissingOptionalParametersAsNulls() {
    // Create a relational table registration create request with optional parameters passed as nulls.
    RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest = new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, NO_BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME);
    // Validate and trim the create request.
    relationalTableRegistrationHelperService.validateAndTrimRelationalTableRegistrationCreateRequest(relationalTableRegistrationCreateRequest);
    // Validate the results.
    assertEquals(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, NO_BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), relationalTableRegistrationCreateRequest);
}
Also used : RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) Test(org.junit.Test)

Example 9 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testRegisterRelationalTableBusinessObjectDefinitionDoesNotExist.

@Test
public void testRegisterRelationalTableBusinessObjectDefinitionDoesNotExist() {
    // Create a namespace.
    namespaceDaoTestHelper.createNamespaceEntity(BDEF_NAMESPACE);
    // Try to register a relational table when specified business object definition already exists.
    try {
        relationalTableRegistrationHelperService.registerRelationalTable(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns(), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_TRUE);
        fail();
    } catch (ObjectNotFoundException objectNotFoundException) {
        Assert.assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", BDEF_NAME, BDEF_NAMESPACE), objectNotFoundException.getMessage());
    }
}
Also used : RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 10 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testRegisterRelationalTableRequiredDatabaseEntitiesNoExist.

@Test
public void testRegisterRelationalTableRequiredDatabaseEntitiesNoExist() {
    // Create database entities required for relational table registration testing.
    relationalTableRegistrationServiceTestHelper.createDatabaseEntitiesForRelationalTableRegistrationTesting(BDEF_NAMESPACE, DATA_PROVIDER_NAME, STORAGE_NAME);
    // Try to register a relational table when specified namespace does not exist.
    try {
        relationalTableRegistrationHelperService.registerRelationalTable(new RelationalTableRegistrationCreateRequest(I_DO_NOT_EXIST, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns(), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
        fail();
    } catch (ObjectNotFoundException e) {
        Assert.assertEquals(String.format("Namespace \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage());
    }
    // Try to register a relational table when specified data provider does not exist.
    try {
        relationalTableRegistrationHelperService.registerRelationalTable(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, I_DO_NOT_EXIST, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns(), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
        fail();
    } catch (ObjectNotFoundException e) {
        Assert.assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage());
    }
    // Try to register a relational table when specified storage does not exist.
    try {
        relationalTableRegistrationHelperService.registerRelationalTable(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, I_DO_NOT_EXIST), relationalTableRegistrationServiceTestHelper.getExpectedSchemaColumns(), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
        fail();
    } catch (ObjectNotFoundException e) {
        Assert.assertEquals(String.format("Storage with name \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage());
    }
}
Also used : RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Aggregations

RelationalTableRegistrationCreateRequest (org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest)17 Test (org.junit.Test)17 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)4 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)3 Attribute (org.finra.herd.model.api.xml.Attribute)2 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)2 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)2 Schema (org.finra.herd.model.api.xml.Schema)2 Storage (org.finra.herd.model.api.xml.Storage)2 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)2 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 RelationalStorageAttributesDto (org.finra.herd.model.dto.RelationalStorageAttributesDto)1 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)1