### Question:
ElasticsearchMetadataEngine extends CommonsMetadataEngine<Client> { @Override @TimerJ protected void createCatalog(CatalogMetadata catalogMetadata, Connection<Client> connection) throws UnsupportedException, ExecutionException { createESIndex(catalogMetadata, connection); } ElasticsearchMetadataEngine(ConnectionHandler connectionHandler);   }### Answer:
@Test public void testCreateCatalog() throws Exception { ListenableActionFuture<CreateIndexResponse> listenableActionFuture = mock(ListenableActionFuture.class); CreateIndexRequestBuilder createIndexRequestBluilder = mock(CreateIndexRequestBuilder.class); when(createIndexRequestBluilder.execute()).thenReturn(listenableActionFuture); IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class); when(indicesAdminClient.prepareCreate(CATALOG_NAME)).thenReturn(createIndexRequestBluilder); AdminClient adminClient = mock(AdminClient.class); when(adminClient.indices()).thenReturn(indicesAdminClient); when(client.admin()).thenReturn(adminClient); Map<Selector, Selector> options = Collections.EMPTY_MAP; Map<TableName, TableMetadata> tables = Collections.EMPTY_MAP; CatalogMetadata catalogMetadata = new CatalogMetadata(new CatalogName(CATALOG_NAME), options, tables); prepareIndexExist(indicesAdminClient, false); elasticsearchMetadataEngine.createCatalog(new ClusterName(CLUSTER_NAME), catalogMetadata); verify(listenableActionFuture, times(1)).actionGet(); }
@Test public void testCreateCatalogWithOptions() throws Exception { ListenableActionFuture<CreateIndexResponse> listenableActionFuture = mock(ListenableActionFuture.class); CreateIndexRequestBuilder createIndexRequestBluilder = mock(CreateIndexRequestBuilder.class); when(createIndexRequestBluilder.execute()).thenReturn(listenableActionFuture); IndicesAdminClient indicesAdminClient = mock(IndicesAdminClient.class); when(indicesAdminClient.prepareCreate(CATALOG_NAME)).thenReturn(createIndexRequestBluilder); AdminClient adminClient = mock(AdminClient.class); when(adminClient.indices()).thenReturn(indicesAdminClient); when(client.admin()).thenReturn(adminClient); Map<Selector, Selector> options = new HashMap<>(); options.put(new StringSelector("key1"), new StringSelector("value1")); Map<String, String> optionsTranform = new HashMap<>(); optionsTranform.put("key1", "value1"); Map<TableName, TableMetadata> tables = Collections.EMPTY_MAP; CatalogMetadata catalogMetadata = new CatalogMetadata(new CatalogName(CATALOG_NAME), options, tables); prepareIndexExist(indicesAdminClient, false); elasticsearchMetadataEngine.createCatalog(new ClusterName(CLUSTER_NAME), catalogMetadata); verify(listenableActionFuture, times(1)).actionGet(); }