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