Search in sources :

Example 1 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationRestControllerTest method testRelationalTableRegistrationRestControllerWithAppendToExistingBusinessObjectDefinitionRequestParameterSetToTrue.

@Test
public void testRelationalTableRegistrationRestControllerWithAppendToExistingBusinessObjectDefinitionRequestParameterSetToTrue() {
    RelationalTableRegistrationCreateRequest createRequest = new RelationalTableRegistrationCreateRequest();
    createRequest.setNamespace(BDEF_NAMESPACE);
    createRequest.setDataProviderName(DATA_PROVIDER_NAME);
    createRequest.setBusinessObjectDefinitionName(BDEF_NAME);
    createRequest.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    createRequest.setRelationalTableName(RELATIONAL_TABLE_NAME);
    createRequest.setStorageName(STORAGE_NAME);
    BusinessObjectData businessObjectData = new BusinessObjectData();
    businessObjectData.setId(businessObjectData.getId());
    businessObjectData.setNamespace(BDEF_NAMESPACE);
    businessObjectData.setBusinessObjectDefinitionName(BDEF_NAME);
    businessObjectData.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
    businessObjectData.setVersion(0);
    businessObjectData.setStatus("VALID");
    businessObjectData.setLatestVersion(true);
    businessObjectData.setBusinessObjectFormatFileType(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE);
    businessObjectData.setPartitionValue(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_VALUE);
    businessObjectData.setPartitionKey(BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_KEY);
    when(relationalTableRegistrationService.createRelationalTableRegistration(createRequest, APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_TRUE)).thenReturn(businessObjectData);
    BusinessObjectData returnedBusinessObjectData = relationalTableRegistrationRestController.createRelationalTableRegistration(createRequest, APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_TRUE);
    // Verify the external calls.
    verify(relationalTableRegistrationService).createRelationalTableRegistration(createRequest, APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_TRUE);
    verifyNoMoreInteractions(relationalTableRegistrationService);
    // Validate the returned object.
    assertEquals(businessObjectData, returnedBusinessObjectData);
}
Also used : RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Test(org.junit.Test)

Example 2 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesRequiredDatabaseEntitiesNoExist.

@Test
public void testGetRelationalStorageAttributesRequiredDatabaseEntitiesNoExist() {
    // Create database entities required for relational table registration testing.
    relationalTableRegistrationServiceTestHelper.createDatabaseEntitiesForRelationalTableRegistrationTesting(BDEF_NAMESPACE, DATA_PROVIDER_NAME, STORAGE_NAME);
    // Try to get a relational storage attributes when specified namespace does not exist.
    try {
        relationalTableRegistrationHelperService.getRelationalStorageAttributes(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), 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 get a relational storage attributes when specified data provider does not exist.
    try {
        relationalTableRegistrationHelperService.getRelationalStorageAttributes(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, I_DO_NOT_EXIST, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), 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 get a relational storage attributes when specified storage does not exist.
    try {
        relationalTableRegistrationHelperService.getRelationalStorageAttributes(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), 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)

Example 3 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesBusinessObjectFormatAlreadyExists.

@Test
public void testGetRelationalStorageAttributesBusinessObjectFormatAlreadyExists() {
    // 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);
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, 1, FORMAT_DESCRIPTION, true, PARTITION_KEY, PARTITION_KEY_GROUP);
    // 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_TRUE);
        fail();
    } catch (AlreadyExistsException alreadyExistsException) {
        Assert.assertEquals(String.format("Format with file type \"%s\" and usage \"%s\" already exists for business object definition \"%s\".", FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, FORMAT_USAGE_CODE, BDEF_NAME), alreadyExistsException.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 4 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testValidateAndTrimRelationalTableRegistrationCreateRequestMissingOptionalParametersAsBlanks.

@Test
public void testValidateAndTrimRelationalTableRegistrationCreateRequestMissingOptionalParametersAsBlanks() {
    // Create a relational table registration create request with optional parameters passed as blank strings.
    RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest = new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BLANK_TEXT, 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, EMPTY_STRING, 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 5 with RelationalTableRegistrationCreateRequest

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

the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesInvalidStoragePlatform.

@Test
public void testGetRelationalStorageAttributesInvalidStoragePlatform() {
    // Create database entities required for relational table registration testing.
    relationalTableRegistrationServiceTestHelper.createDatabaseEntitiesForRelationalTableRegistrationTesting(BDEF_NAMESPACE, DATA_PROVIDER_NAME, STORAGE_NAME);
    // Create another storage of a storage platfom type that is not supported by the relational table registration feature.
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME_2, STORAGE_PLATFORM_CODE);
    // Try to a get relational storage attributes when specified storage has an invalid storage platform type.
    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_2), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
        fail();
    } catch (IllegalArgumentException e) {
        Assert.assertEquals(String.format("Cannot register relational table in \"%s\" storage of %s storage platform type. Only %s storage platform type is supported by this feature.", STORAGE_NAME_2, STORAGE_PLATFORM_CODE, StoragePlatformEntity.RELATIONAL), e.getMessage());
    }
}
Also used : RelationalTableRegistrationCreateRequest(org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest) 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