Search in sources :

Example 1 with OracleMetadataHandler

use of com.amazonaws.athena.connectors.oracle.OracleMetadataHandler in project aws-athena-query-federation by awslabs.

the class OracleMetadataHandlerTest method doGetTableLayoutWithSQLException.

@Test(expected = RuntimeException.class)
public void doGetTableLayoutWithSQLException() throws Exception {
    Constraints constraints = Mockito.mock(Constraints.class);
    TableName tableName = new TableName("testSchema", "testTable");
    Schema partitionSchema = this.oracleMetadataHandler.getPartitionSchema("testCatalogName");
    Set<String> partitionCols = partitionSchema.getFields().stream().map(Field::getName).collect(Collectors.toSet());
    GetTableLayoutRequest getTableLayoutRequest = new GetTableLayoutRequest(this.federatedIdentity, "testQueryId", "testCatalogName", tableName, constraints, partitionSchema, partitionCols);
    Connection connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
    JdbcConnectionFactory jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class);
    Mockito.when(jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(connection);
    Mockito.when(connection.getMetaData().getSearchStringEscape()).thenThrow(new SQLException());
    OracleMetadataHandler oracleMetadataHandler = new OracleMetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, jdbcConnectionFactory);
    oracleMetadataHandler.doGetTableLayout(Mockito.mock(BlockAllocator.class), getTableLayoutRequest);
}
Also used : JdbcConnectionFactory(com.amazonaws.athena.connectors.jdbc.connection.JdbcConnectionFactory) TableName(com.amazonaws.athena.connector.lambda.domain.TableName) Constraints(com.amazonaws.athena.connector.lambda.domain.predicate.Constraints) SQLException(java.sql.SQLException) Schema(org.apache.arrow.vector.types.pojo.Schema) BlockAllocator(com.amazonaws.athena.connector.lambda.data.BlockAllocator) Connection(java.sql.Connection) OracleMetadataHandler(com.amazonaws.athena.connectors.oracle.OracleMetadataHandler) JdbcCredentialProvider(com.amazonaws.athena.connectors.jdbc.connection.JdbcCredentialProvider) Test(org.junit.Test)

Example 2 with OracleMetadataHandler

use of com.amazonaws.athena.connectors.oracle.OracleMetadataHandler in project aws-athena-query-federation by awslabs.

the class OracleMetadataHandlerTest method setup.

@Before
public void setup() {
    this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class, Mockito.RETURNS_DEEP_STUBS);
    this.connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(this.connection);
    this.secretsManager = Mockito.mock(AWSSecretsManager.class);
    this.athena = Mockito.mock(AmazonAthena.class);
    Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"username\": \"testUser\", \"password\": \"testPassword\"}"));
    this.oracleMetadataHandler = new OracleMetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, this.jdbcConnectionFactory);
    this.federatedIdentity = Mockito.mock(FederatedIdentity.class);
}
Also used : JdbcConnectionFactory(com.amazonaws.athena.connectors.jdbc.connection.JdbcConnectionFactory) GetSecretValueResult(com.amazonaws.services.secretsmanager.model.GetSecretValueResult) FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity) AWSSecretsManager(com.amazonaws.services.secretsmanager.AWSSecretsManager) Connection(java.sql.Connection) OracleMetadataHandler(com.amazonaws.athena.connectors.oracle.OracleMetadataHandler) GetSecretValueRequest(com.amazonaws.services.secretsmanager.model.GetSecretValueRequest) JdbcCredentialProvider(com.amazonaws.athena.connectors.jdbc.connection.JdbcCredentialProvider) AmazonAthena(com.amazonaws.services.athena.AmazonAthena) Before(org.junit.Before)

Aggregations

JdbcConnectionFactory (com.amazonaws.athena.connectors.jdbc.connection.JdbcConnectionFactory)2 JdbcCredentialProvider (com.amazonaws.athena.connectors.jdbc.connection.JdbcCredentialProvider)2 OracleMetadataHandler (com.amazonaws.athena.connectors.oracle.OracleMetadataHandler)2 Connection (java.sql.Connection)2 BlockAllocator (com.amazonaws.athena.connector.lambda.data.BlockAllocator)1 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)1 Constraints (com.amazonaws.athena.connector.lambda.domain.predicate.Constraints)1 FederatedIdentity (com.amazonaws.athena.connector.lambda.security.FederatedIdentity)1 AmazonAthena (com.amazonaws.services.athena.AmazonAthena)1 AWSSecretsManager (com.amazonaws.services.secretsmanager.AWSSecretsManager)1 GetSecretValueRequest (com.amazonaws.services.secretsmanager.model.GetSecretValueRequest)1 GetSecretValueResult (com.amazonaws.services.secretsmanager.model.GetSecretValueResult)1 SQLException (java.sql.SQLException)1 Schema (org.apache.arrow.vector.types.pojo.Schema)1 Before (org.junit.Before)1 Test (org.junit.Test)1