Search in sources :

Example 1 with ListTablesRequest

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

the class CompositeHandlerTest method doListTables.

@Test
public void doListTables() throws Exception {
    ListTablesRequest req = mock(ListTablesRequest.class);
    when(req.getRequestType()).thenReturn(MetadataRequestType.LIST_TABLES);
    compositeHandler.handleRequest(allocator, req, new ByteArrayOutputStream(), objectMapper);
    verify(mockMetadataHandler, times(1)).doListTables(any(BlockAllocatorImpl.class), any(ListTablesRequest.class));
}
Also used : BlockAllocatorImpl(com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl) ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 2 with ListTablesRequest

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

the class GlueMetadataHandlerTest method doListTablesWithLargePageSize.

@Test
public void doListTablesWithLargePageSize() throws Exception {
    ListTablesRequest req = new ListTablesRequest(IdentityUtil.fakeIdentity(), queryId, catalog, schema, null, GET_TABLES_REQUEST_MAX_RESULTS + 50);
    logger.info("Request - {}", req);
    ListTablesResponse actualResponse = handler.doListTables(allocator, req);
    logger.info("Response - {}", actualResponse);
    assertEquals("Lists do not match.", fullListResponse, actualResponse);
}
Also used : ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse) Test(org.junit.Test)

Example 3 with ListTablesRequest

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

the class GlueMetadataHandlerTest method doListTablesWithPagination.

@Test
public void doListTablesWithPagination() throws Exception {
    logger.info("First paginated request");
    ListTablesRequest req = new ListTablesRequest(IdentityUtil.fakeIdentity(), queryId, catalog, schema, null, 3);
    logger.info("Request - {}", req);
    ListTablesResponse expectedResponse = new ListTablesResponse(req.getCatalogName(), new ImmutableList.Builder<TableName>().add(new TableName(req.getSchemaName(), "table1")).add(new TableName(req.getSchemaName(), "table2")).add(new TableName(req.getSchemaName(), "table3")).build(), "table4");
    ListTablesResponse actualResponse = handler.doListTables(allocator, req);
    logger.info("Response - {}", actualResponse);
    assertEquals("Lists do not match.", expectedResponse, actualResponse);
    logger.info("Second paginated request");
    req = new ListTablesRequest(IdentityUtil.fakeIdentity(), queryId, catalog, schema, actualResponse.getNextToken(), 3);
    logger.info("Request - {}", req);
    expectedResponse = new ListTablesResponse(req.getCatalogName(), new ImmutableList.Builder<TableName>().add(new TableName(req.getSchemaName(), "table4")).add(new TableName(req.getSchemaName(), "table5")).build(), null);
    actualResponse = handler.doListTables(allocator, req);
    logger.info("Response - {}", actualResponse);
    assertEquals("Lists do not match.", expectedResponse, actualResponse);
}
Also used : GlueMetadataHandler.getSourceTableName(com.amazonaws.athena.connector.lambda.handlers.GlueMetadataHandler.getSourceTableName) TableName(com.amazonaws.athena.connector.lambda.domain.TableName) ImmutableList(com.google.common.collect.ImmutableList) ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse) Test(org.junit.Test)

Example 4 with ListTablesRequest

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

the class GlueMetadataHandlerTest method doListTablesWithUnlimitedPageSize.

@Test
public void doListTablesWithUnlimitedPageSize() throws Exception {
    ListTablesRequest req = new ListTablesRequest(IdentityUtil.fakeIdentity(), queryId, catalog, schema, null, UNLIMITED_PAGE_SIZE_VALUE);
    logger.info("Request - {}", req);
    ListTablesResponse actualResponse = handler.doListTables(allocator, req);
    logger.info("Response - {}", actualResponse);
    assertEquals("Lists do not match.", fullListResponse, actualResponse);
}
Also used : ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) ListTablesResponse(com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse) Test(org.junit.Test)

Example 5 with ListTablesRequest

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

the class MySqlMuxJdbcMetadataHandlerTest method doListTables.

@Test
public void doListTables() {
    ListTablesRequest listTablesRequest = Mockito.mock(ListTablesRequest.class);
    Mockito.when(listTablesRequest.getCatalogName()).thenReturn("fakedatabase");
    this.jdbcMetadataHandler.doListTables(this.allocator, listTablesRequest);
    Mockito.verify(this.mySqlMetadataHandler, Mockito.times(1)).doListTables(Mockito.eq(this.allocator), Mockito.eq(listTablesRequest));
}
Also used : ListTablesRequest(com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest) Test(org.junit.Test)

Aggregations

ListTablesRequest (com.amazonaws.athena.connector.lambda.metadata.ListTablesRequest)33 Test (org.junit.Test)31 ListTablesResponse (com.amazonaws.athena.connector.lambda.metadata.ListTablesResponse)17 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)13 ArrayList (java.util.ArrayList)5 ImmutableList (com.google.common.collect.ImmutableList)4 SchemaBuilder (com.amazonaws.athena.connector.lambda.data.SchemaBuilder)3 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)2 GetTablesResult (com.amazonaws.services.glue.model.GetTablesResult)2 Table (com.amazonaws.services.glue.model.Table)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 BlockAllocator (com.amazonaws.athena.connector.lambda.data.BlockAllocator)1 Split (com.amazonaws.athena.connector.lambda.domain.Split)1 Constraints (com.amazonaws.athena.connector.lambda.domain.predicate.Constraints)1 EquatableValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.EquatableValueSet)1 Range (com.amazonaws.athena.connector.lambda.domain.predicate.Range)1 SortedRangeSet (com.amazonaws.athena.connector.lambda.domain.predicate.SortedRangeSet)1 ValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.ValueSet)1