use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class ExampleMetadataHandlerTest method doGetTableFail.
@Test(expected = LambdaFunctionException.class)
public void doGetTableFail() {
try {
logger.info("doGetTableFail - enter");
GetTableRequest req = new GetTableRequest(IdentityUtil.fakeIdentity(), "queryId", "default", new TableName("lambda", "fake"));
metadataHandler.doGetTable(allocator, req);
} catch (Exception ex) {
logger.info("doGetTableFail: ", ex);
throw new LambdaFunctionException(ex.getMessage(), false, "repackaged");
}
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class CompositeHandlerTest method doGetTable.
@Test
public void doGetTable() throws Exception {
GetTableRequest req = mock(GetTableRequest.class);
when(req.getRequestType()).thenReturn(MetadataRequestType.GET_TABLE);
compositeHandler.handleRequest(allocator, req, new ByteArrayOutputStream(), objectMapper);
verify(mockMetadataHandler, times(1)).doGetTable(any(BlockAllocatorImpl.class), any(GetTableRequest.class));
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class GlueMetadataHandlerTest method testGetCatalog.
@Test
public void testGetCatalog() {
// Catalog should be the account from the request
MetadataRequest req = new GetTableRequest(IdentityUtil.fakeIdentity(), queryId, catalog, new TableName(schema, table));
String catalog = handler.getCatalog(req);
assertEquals(IdentityUtil.fakeIdentity().getAccount(), catalog);
// Catalog should be the account from the lambda context's function arn
when(mockContext.getInvokedFunctionArn()).thenReturn("arn:aws:lambda:us-east-1:012345678912:function:athena-123");
req.setContext(mockContext);
catalog = handler.getCatalog(req);
assertEquals("012345678912", catalog);
// Catalog should be the account from the request since function arn is invalid
when(mockContext.getInvokedFunctionArn()).thenReturn("arn:aws:lambda:us-east-1:012345678912:function:");
req.setContext(mockContext);
catalog = handler.getCatalog(req);
assertEquals(IdentityUtil.fakeIdentity().getAccount(), catalog);
// Catalog should be the account from the request since function arn is null
when(mockContext.getInvokedFunctionArn()).thenReturn(null);
req.setContext(mockContext);
catalog = handler.getCatalog(req);
assertEquals(IdentityUtil.fakeIdentity().getAccount(), catalog);
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class ExampleMetadataHandlerTest method doGetTable.
@Test
public void doGetTable() {
logger.info("doGetTable - enter");
GetTableRequest req = new GetTableRequest(IdentityUtil.fakeIdentity(), "queryId", "default", new TableName("custom_source", "fake_table"));
ObjectMapperUtil.assertSerialization(req);
GetTableResponse res = metadataHandler.doGetTable(allocator, req);
ObjectMapperUtil.assertSerialization(res);
assertTrue(res.getSchema().getFields().size() > 0);
assertTrue(res.getSchema().getCustomMetadata().size() > 0);
logger.info("doGetTable - {}", res);
logger.info("doGetTable - exit");
}
use of com.amazonaws.athena.connector.lambda.metadata.GetTableRequest in project aws-athena-query-federation by awslabs.
the class GetTableRequestSerDeTest method deserialize.
@Test
public void deserialize() throws IOException {
logger.info("deserialize: enter");
InputStream input = new ByteArrayInputStream(expectedSerDeText.getBytes());
GetTableRequest actual = (GetTableRequest) mapper.readValue(input, FederationRequest.class);
logger.info("deserialize: deserialized[{}]", actual);
assertEquals(expected, actual);
logger.info("deserialize: exit");
}
Aggregations