Search in sources :

Example 11 with ListSchemasRequest

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

the class OracleMuxJdbcMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    ListSchemasRequest listSchemasRequest = Mockito.mock(ListSchemasRequest.class);
    Mockito.when(listSchemasRequest.getCatalogName()).thenReturn("fakedatabase");
    this.jdbcMetadataHandler.doListSchemaNames(this.allocator, listSchemasRequest);
    Mockito.verify(this.oracleMetadataHandler, 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)

Example 12 with ListSchemasRequest

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

the class HiveMuxMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    ListSchemasRequest listSchemasRequest = Mockito.mock(ListSchemasRequest.class);
    Mockito.when(listSchemasRequest.getCatalogName()).thenReturn("metaHive");
    this.jdbcMetadataHandler.doListSchemaNames(this.allocator, listSchemasRequest);
    Mockito.verify(this.hiveMetadataHandler, 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)

Example 13 with ListSchemasRequest

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

the class CloudwatchMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() throws TimeoutException {
    logger.info("doListSchemas - enter");
    when(mockAwsLogs.describeLogGroups(any(DescribeLogGroupsRequest.class))).thenAnswer((InvocationOnMock invocationOnMock) -> {
        DescribeLogGroupsRequest request = (DescribeLogGroupsRequest) invocationOnMock.getArguments()[0];
        DescribeLogGroupsResult result = new DescribeLogGroupsResult();
        Integer nextToken;
        if (request.getNextToken() == null) {
            nextToken = 1;
        } else if (Integer.valueOf(request.getNextToken()) < 3) {
            nextToken = Integer.valueOf(request.getNextToken()) + 1;
        } else {
            nextToken = null;
        }
        List<LogGroup> logGroups = new ArrayList<>();
        if (request.getNextToken() == null || Integer.valueOf(request.getNextToken()) < 3) {
            for (int i = 0; i < 10; i++) {
                LogGroup nextLogGroup = new LogGroup();
                nextLogGroup.setLogGroupName("schema-" + String.valueOf(i));
                logGroups.add(nextLogGroup);
            }
        }
        result.withLogGroups(logGroups);
        if (nextToken != null) {
            result.setNextToken(String.valueOf(nextToken));
        }
        return result;
    });
    ListSchemasRequest req = new ListSchemasRequest(identity, "queryId", "default");
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertTrue(res.getSchemas().size() == 30);
    verify(mockAwsLogs, times(4)).describeLogGroups(any(DescribeLogGroupsRequest.class));
    verifyNoMoreInteractions(mockAwsLogs);
    logger.info("doListSchemas - exit");
}
Also used : DescribeLogGroupsResult(com.amazonaws.services.logs.model.DescribeLogGroupsResult) ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) LogGroup(com.amazonaws.services.logs.model.LogGroup) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) DescribeLogGroupsRequest(com.amazonaws.services.logs.model.DescribeLogGroupsRequest) Test(org.junit.Test)

Example 14 with ListSchemasRequest

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

the class MetricsMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    logger.info("doListSchemas - enter");
    ListSchemasRequest req = new ListSchemasRequest(identity, "queryId", "default");
    ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
    logger.info("doListSchemas - {}", res.getSchemas());
    assertTrue(res.getSchemas().size() == 1);
    assertEquals(defaultSchema, res.getSchemas().iterator().next());
    logger.info("doListSchemas - exit");
}
Also used : ListSchemasRequest(com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest) ListSchemasResponse(com.amazonaws.athena.connector.lambda.metadata.ListSchemasResponse) Test(org.junit.Test)

Example 15 with ListSchemasRequest

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

the class DataLakeGen2MuxMetadataHandlerTest method doListSchemaNames.

@Test
public void doListSchemaNames() {
    ListSchemasRequest listSchemasRequest = Mockito.mock(ListSchemasRequest.class);
    Mockito.when(listSchemasRequest.getCatalogName()).thenReturn("fakedatabase");
    this.jdbcMetadataHandler.doListSchemaNames(this.allocator, listSchemasRequest);
    Mockito.verify(this.dataLakeGen2MetadataHandler, 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