Search in sources :

Example 16 with ListSchemasRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.

the class DynamoDBMetadataHandlerTest method doListSchemaNamesGlueError.

@Test
public void doListSchemaNamesGlueError() throws Exception {
    when(glueClient.getDatabases(any())).thenThrow(new AmazonServiceException(""));
    ListSchemasRequest req = new ListSchemasRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME);
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertThat(new ArrayList<>(res.getSchemas()), equalTo(Collections.singletonList(DEFAULT_SCHEMA)));
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Test(org.junit.Test)

Example 17 with ListSchemasRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.

the class DynamoDBMetadataHandlerTest method doListSchemaNamesGlue.

@Test
public void doListSchemaNamesGlue() throws Exception {
    GetDatabasesResult result = new GetDatabasesResult().withDatabaseList(new Database().withName(DEFAULT_SCHEMA), new Database().withName("ddb").withLocationUri(DYNAMO_DB_FLAG), new Database().withName("s3").withLocationUri("blah"));
    when(glueClient.getDatabases(any())).thenReturn(result);
    ListSchemasRequest req = new ListSchemasRequest(TEST_IDENTITY, TEST_QUERY_ID, TEST_CATALOG_NAME);
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertThat(res.getSchemas().size(), equalTo(2));
    assertThat(res.getSchemas().contains("default"), is(true));
    assertThat(res.getSchemas().contains("ddb"), is(true));
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) GetDatabasesResult(com.amazonaws.services.glue.model.GetDatabasesResult) Database(com.amazonaws.services.glue.model.Database) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Test(org.junit.Test)

Example 18 with ListSchemasRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.

the class UserDefinedFunctionHandlerTest method testRequestTypeValidation.

@Test
public void testRequestTypeValidation() throws Exception {
    FederationRequest federationRequest = new ListSchemasRequest(null, "dummy_catalog", "dummy_qid");
    ObjectMapper objectMapper = VersionedObjectMapperFactory.create(allocator);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    objectMapper.writeValue(byteArrayOutputStream, federationRequest);
    byte[] inputData = byteArrayOutputStream.toByteArray();
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputData);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        handler.handleRequest(byteArrayInputStream, outputStream, null);
        fail();
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Expected a UserDefinedFunctionRequest but found"));
    }
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FederationRequest(com.amazonaws.athena.connector.lambda.request.FederationRequest) Test(org.junit.Test)

Example 19 with ListSchemasRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.

the class JdbcMetadataHandlerTest method doListSchemaNamesSQLException.

@Test(expected = RuntimeException.class)
public void doListSchemaNamesSQLException() throws SQLException {
    Mockito.when(this.connection.getMetaData().getSchemas()).thenThrow(new SQLException());
    this.jdbcMetadataHandler.doListSchemaNames(this.blockAllocator, new ListSchemasRequest(this.federatedIdentity, "testQueryId", "testCatalog"));
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 20 with ListSchemasRequest

use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.

the class PostGreSqlMuxJdbcMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    ListSchemasRequest listSchemasRequest = Mockito.mock(ListSchemasRequest.class);
    Mockito.when(listSchemasRequest.getCatalogName()).thenReturn("postgres");
    this.jdbcMetadataHandler.doListSchemaNames(this.allocator, listSchemasRequest);
    Mockito.verify(this.postGreSqlMetadataHandler, Mockito.times(1)).doListSchemaNames(Mockito.eq(this.allocator), Mockito.eq(listSchemasRequest));
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) Test(org.junit.Test)

Aggregations

ListSchemasRequest (com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest)31 Test (org.junit.Test)29 ListSchemasResponse (com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse)15 ArrayList (java.util.ArrayList)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 FederationRequest (com.amazonaws.athena.connector.lambda.request.FederationRequest)2 Database (com.amazonaws.services.glue.model.Database)2 GetDatabasesResult (com.amazonaws.services.glue.model.GetDatabasesResult)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Matchers.anyString (org.mockito.Matchers.anyString)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)1 TypedSerDeTest (com.amazonaws.athena.connector.lambda.serde.TypedSerDeTest)1 GetDatabasesRequest (com.amazonaws.services.glue.model.GetDatabasesRequest)1 DescribeLogGroupsRequest (com.amazonaws.services.logs.model.DescribeLogGroupsRequest)1 DescribeLogGroupsResult (com.amazonaws.services.logs.model.DescribeLogGroupsResult)1 LogGroup (com.amazonaws.services.logs.model.LogGroup)1 Database (com.amazonaws.services.timestreamwrite.model.Database)1 ListDatabasesRequest (com.amazonaws.services.timestreamwrite.model.ListDatabasesRequest)1