Search in sources :

Example 6 with RelationalStorageAttributesDto

use of org.finra.herd.model.dto.RelationalStorageAttributesDto in project herd by FINRAOS.

the class RelationalTableRegistrationServiceImpl method createRelationalTableRegistrationImpl.

/**
 * Creates a new relational table registration.
 *
 * @param relationalTableRegistrationCreateRequest the relational table registration create request
 * @param appendToExistingBusinessObjectDefinition boolean flag that determines if the format should be appended to an existing business object definition
 *
 * @return the information for the newly created business object data
 */
BusinessObjectData createRelationalTableRegistrationImpl(RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest, Boolean appendToExistingBusinessObjectDefinition) {
    // Validate the relational table registration create request.
    relationalTableRegistrationHelperService.validateAndTrimRelationalTableRegistrationCreateRequest(relationalTableRegistrationCreateRequest);
    // Get storage attributes required to perform relation table registration.
    // This method also validates database entities per specified relational table registration create request.
    RelationalStorageAttributesDto relationalStorageAttributesDto = relationalTableRegistrationHelperService.getRelationalStorageAttributes(relationalTableRegistrationCreateRequest, appendToExistingBusinessObjectDefinition);
    // Retrieve a list of actual schema columns for the specified relational table.
    // This method uses actual JDBC connection to retrieve a description of table columns.
    List<SchemaColumn> schemaColumns = relationalTableRegistrationHelperService.retrieveRelationalTableColumns(relationalStorageAttributesDto, relationalTableRegistrationCreateRequest.getRelationalSchemaName(), relationalTableRegistrationCreateRequest.getRelationalTableName());
    // Create a new relational table registration and return the information for the newly created business object data.
    return relationalTableRegistrationHelperService.registerRelationalTable(relationalTableRegistrationCreateRequest, schemaColumns, appendToExistingBusinessObjectDefinition);
}
Also used : RelationalStorageAttributesDto(org.finra.herd.model.dto.RelationalStorageAttributesDto) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn)

Example 7 with RelationalStorageAttributesDto

use of org.finra.herd.model.dto.RelationalStorageAttributesDto in project herd by FINRAOS.

the class RelationalTableRegistrationHelperServiceImplTest method testGetPasswordNoUserCredentialName.

@Test
public void testGetPasswordNoUserCredentialName() {
    // Call the method under test.
    String result = relationalTableRegistrationHelperServiceImpl.getPassword(new RelationalStorageAttributesDto(JDBC_URL, USERNAME, NO_USER_CREDENTIAL_NAME));
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertNull(result);
}
Also used : RelationalStorageAttributesDto(org.finra.herd.model.dto.RelationalStorageAttributesDto) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 8 with RelationalStorageAttributesDto

use of org.finra.herd.model.dto.RelationalStorageAttributesDto in project herd by FINRAOS.

the class RelationalTableRegistrationHelperServiceImplTest method testGetPassword.

@Test
public void testGetPassword() throws Exception {
    // Mock the external calls.
    when(configurationHelper.getProperty(ConfigurationValue.CREDSTASH_RELATIONAL_STORAGE_ENCRYPTION_CONTEXT)).thenReturn(CREDSTASH_ENCRYPTION_CONTEXT);
    when(credStashHelper.getCredentialFromCredStash(CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME)).thenReturn(PASSWORD);
    // Call the method under test.
    String result = relationalTableRegistrationHelperServiceImpl.getPassword(new RelationalStorageAttributesDto(JDBC_URL, USERNAME, USER_CREDENTIAL_NAME));
    // Verify the external calls.
    verify(configurationHelper).getProperty(ConfigurationValue.CREDSTASH_RELATIONAL_STORAGE_ENCRYPTION_CONTEXT);
    verify(credStashHelper).getCredentialFromCredStash(CREDSTASH_ENCRYPTION_CONTEXT, USER_CREDENTIAL_NAME);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(PASSWORD, result);
}
Also used : RelationalStorageAttributesDto(org.finra.herd.model.dto.RelationalStorageAttributesDto) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Aggregations

RelationalStorageAttributesDto (org.finra.herd.model.dto.RelationalStorageAttributesDto)8 Test (org.junit.Test)6 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)3 CredStashGetCredentialFailedException (org.finra.herd.dao.exception.CredStashGetCredentialFailedException)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)1 RelationalTableRegistrationCreateRequest (org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest)1 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)1 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1