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