@Test void testCreateClient() throws Exception { initMockClient(); int port = 8032; String clusterName = "testCluster"; when(preBuildClientFactory.build(clusterName, null)) .thenReturn(unConnectedClient, unConnectedClient, connectedClient); ClientFactory clientFactory = new ClientFactory( retryTemplate, clusterName, singletonList(new InetSocketAddress(port)), preBuildClientFactory); Client client = clientFactory.createClient(); assertEquals(connectedClient, client); verify(preBuildClientFactory, times(3)).build(clusterName, null); verify(unConnectedClient, times(2)).close(); }
Client createClient() throws InterruptedException { Client client = retryTemplate.execute(this::tryCreateClient); LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName); return client; }
ClientFactory { Client createClient() throws InterruptedException { Client client = retryTemplate.execute(this::tryCreateClient); LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName); return client; } }
ClientFactory { Client createClient() throws InterruptedException { Client client = retryTemplate.execute(this::tryCreateClient); LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName); return client; } ClientFactory(
      RetryTemplate retryTemplate,
      String clusterName,
      List<InetSocketAddress> inetAddresses,
      PreBuiltTransportClientFactory preBuiltTransportClientFactory); }
ClientFactory { Client createClient() throws InterruptedException { Client client = retryTemplate.execute(this::tryCreateClient); LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName); return client; } ClientFactory(
      RetryTemplate retryTemplate,
      String clusterName,
      List<InetSocketAddress> inetAddresses,
      PreBuiltTransportClientFactory preBuiltTransportClientFactory);  }
ClientFactory { Client createClient() throws InterruptedException { Client client = retryTemplate.execute(this::tryCreateClient); LOG.info("Connected to Elasticsearch cluster '{}'.", clusterName); return client; } ClientFactory(
      RetryTemplate retryTemplate,
      String clusterName,
      List<InetSocketAddress> inetAddresses,
      PreBuiltTransportClientFactory preBuiltTransportClientFactory);   }