use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.
the class CompositeHandlerTest method doListSchemaNames.
@Test
public void doListSchemaNames() throws Exception {
ListSchemasRequest req = mock(ListSchemasRequest.class);
when(req.getRequestType()).thenReturn(MetadataRequestType.LIST_SCHEMAS);
compositeHandler.handleRequest(allocator, req, new ByteArrayOutputStream(), objectMapper);
verify(mockMetadataHandler, times(1)).doListSchemaNames(any(BlockAllocatorImpl.class), any(ListSchemasRequest.class));
}
use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.
the class GlueMetadataHandlerTest method doListSchemaNames.
@Test
public void doListSchemaNames() throws Exception {
List<Database> databases = new ArrayList<>();
databases.add(new Database().withName("db1"));
databases.add(new Database().withName("db2"));
when(mockGlue.getDatabases(any(GetDatabasesRequest.class))).thenAnswer((InvocationOnMock invocationOnMock) -> {
GetDatabasesRequest request = (GetDatabasesRequest) invocationOnMock.getArguments()[0];
assertEquals(accountId, request.getCatalogId());
GetDatabasesResult mockResult = mock(GetDatabasesResult.class);
if (request.getNextToken() == null) {
when(mockResult.getDatabaseList()).thenReturn(databases);
when(mockResult.getNextToken()).thenReturn("next");
} else {
// only return real info on 1st call
when(mockResult.getDatabaseList()).thenReturn(new ArrayList<>());
when(mockResult.getNextToken()).thenReturn(null);
}
return mockResult;
});
ListSchemasRequest req = new ListSchemasRequest(IdentityUtil.fakeIdentity(), queryId, catalog);
ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
logger.info("doListSchemas - {}", res.getSchemas());
assertEquals(databases.stream().map(next -> next.getName()).collect(Collectors.toList()), new ArrayList<>(res.getSchemas()));
verify(mockGlue, times(2)).getDatabases(any(GetDatabasesRequest.class));
}
use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.
the class ExampleMetadataHandlerTest method doListSchemas.
@Test
public void doListSchemas() {
logger.info("doListSchemas - enter");
ListSchemasRequest req = new ListSchemasRequest(IdentityUtil.fakeIdentity(), "queryId", "default");
ObjectMapperUtil.assertSerialization(req);
ListSchemasResponse res = metadataHandler.doListSchemaNames(allocator, req);
ObjectMapperUtil.assertSerialization(res);
logger.info("doListSchemas - {}", res.getSchemas());
assertFalse(res.getSchemas().isEmpty());
logger.info("doListSchemas - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.
the class HbaseMetadataHandlerTest method doListSchemaNames.
@Test
public void doListSchemaNames() throws IOException {
NamespaceDescriptor[] schemaNames = { NamespaceDescriptor.create("schema1").build(), NamespaceDescriptor.create("schema2").build(), NamespaceDescriptor.create("schema3").build() };
when(mockClient.listNamespaceDescriptors()).thenReturn(schemaNames);
ListSchemasRequest req = new ListSchemasRequest(IDENTITY, QUERY_ID, DEFAULT_CATALOG);
ListSchemasResponse res = handler.doListSchemaNames(allocator, req);
logger.info("doListSchemas - {}", res.getSchemas());
Set<String> expectedSchemaName = new HashSet<>();
expectedSchemaName.add("schema1");
expectedSchemaName.add("schema2");
expectedSchemaName.add("schema3");
assertEquals(expectedSchemaName, new HashSet<>(res.getSchemas()));
logger.info("doListSchemaNames: exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.ListSchemasRequest in project aws-athena-query-federation by awslabs.
the class ListSchemasRequestSerDeTest method beforeTest.
@Before
public void beforeTest() throws IOException {
expected = new ListSchemasRequest(federatedIdentity, "test-query-id", "test-catalog");
String expectedSerDeFile = utils.getResourceOrFail("serde/v2", "ListSchemasRequest.json");
expectedSerDeText = utils.readAllAsString(expectedSerDeFile).trim();
}
Aggregations