### Question:
ElasticsearchMetadataHandler extends GlueMetadataHandler { @Override public ListTablesResponse doListTables(BlockAllocator allocator, ListTablesRequest request) throws RuntimeException { logger.debug("doListTables: enter - " + request); List<TableName> indices = new ArrayList<>(); try { String endpoint = getDomainEndpoint(request.getSchemaName()); AwsRestHighLevelClient client = clientFactory.getOrCreateClient(endpoint); try { for (String index : client.getAliases()) { if (index.startsWith(".")) { logger.info("Ignoring system index: {}", index); continue; } indices.add(new TableName(request.getSchemaName(), index)); } } catch (IOException error) { throw new RuntimeException("Error retrieving indices: " + error.getMessage(), error); } } catch (RuntimeException error) { throw new RuntimeException("Error processing request to list indices: " + error.getMessage(), error); } return new ListTablesResponse(request.getCatalogName(), indices); } ElasticsearchMetadataHandler(); @VisibleForTesting protected  ElasticsearchMetadataHandler(AWSGlue awsGlue,
                                           EncryptionKeyFactory keyFactory,
                                           AWSSecretsManager awsSecretsManager,
                                           AmazonAthena athena,
                                           String spillBucket,
                                           String spillPrefix,
                                           ElasticsearchDomainMapProvider domainMapProvider,
                                           AwsRestHighLevelClientFactory clientFactory,
                                           long queryTimeout); @Override ListSchemasResponse doListSchemaNames(BlockAllocator allocator, ListSchemasRequest request); @Override ListTablesResponse doListTables(BlockAllocator allocator, ListTablesRequest request); @Override GetTableResponse doGetTable(BlockAllocator allocator, GetTableRequest request); @Override void getPartitions(BlockWriter blockWriter, GetTableLayoutRequest request, QueryStatusChecker queryStatusChecker); @Override GetSplitsResponse doGetSplits(BlockAllocator allocator, GetSplitsRequest request);  }### Answer:
@Test public void doListTables() throws Exception { logger.info("doListTables - enter"); Collection<TableName> mockIndices = ImmutableList.of(new TableName("movies", "customer"), new TableName("movies", "movies")); when(domainMapProvider.getDomainMap(null)).thenReturn(ImmutableMap.of("movies", "https: handler = new ElasticsearchMetadataHandler(awsGlue, new LocalKeyFactory(), awsSecretsManager, amazonAthena, "spill-bucket", "spill-prefix", domainMapProvider, clientFactory, 10); when(mockClient.getAliases()).thenReturn(ImmutableSet.of("movies", ".kibana_1", "customer")); ListTablesRequest req = new ListTablesRequest(fakeIdentity(), "queryId", "elasticsearch", "movies"); Collection<TableName> realIndices = handler.doListTables(allocator, req).getTables(); logger.info("doListTables - {}", realIndices); assertFalse("Real indices list is empty!", realIndices.isEmpty()); assertTrue("Real and mocked indices list are different!", indicesEqual(realIndices, mockIndices)); logger.info("doListTables - exit"); }