ElasticsearchConnectionManager implements ElasticsearchClientResolver, ElasticsearchConfigurationObserver { @Override public RestHighLevelClient getRestHighLevelClient() { return getRestHighLevelClient(null); }  void addElasticsearchConnection(
		ElasticsearchConnection elasticsearchConnection); @Override int compareTo(
		ElasticsearchConfigurationObserver elasticsearchConfigurationObserver); ElasticsearchConnection getElasticsearchConnection(); ElasticsearchConnection getElasticsearchConnection(
		boolean preferLocalCluster); ElasticsearchConnection getElasticsearchConnection(
		String connectionId); String getLocalClusterConnectionId(); @Override int getPriority(); @Override RestHighLevelClient getRestHighLevelClient(); @Override RestHighLevelClient getRestHighLevelClient(String connectionId); @Override RestHighLevelClient getRestHighLevelClient(
		String connectionId, boolean preferLocalCluster); boolean isCrossClusterReplicationEnabled(); @Override void onElasticsearchConfigurationUpdate(); void removeElasticsearchConnection(String connectionId);  }
@Test public void testGetExplicitRestHighLevelClientWhenRestClientNull() { try { _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_3_CONNECTION_ID); Assert.fail(); } catch (ElasticsearchConnectionNotInitializedException elasticsearchConnectionNotInitializedException) { String message = elasticsearchConnectionNotInitializedException.getMessage(); Assert.assertTrue( message.contains("REST high level client not found")); } }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeDisabled() { Assert.assertEquals( _remoteElasticsearchConnection1.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_1_CONNECTION_ID)); Assert.assertEquals( _remoteElasticsearchConnection2.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_2_CONNECTION_ID)); }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeDisabledAndConnectionDoesNotExist() { try { _elasticsearchConnectionManager.getRestHighLevelClient("none"); Assert.fail(); } catch (ElasticsearchConnectionNotInitializedException elasticsearchConnectionNotInitializedException) { String message = elasticsearchConnectionNotInitializedException.getMessage(); Assert.assertTrue( message.contains("Elasticsearch connection not found")); } }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeDisabledAndDifferentConnectionId() { setRemoteConnectionId(_REMOTE_1_CONNECTION_ID); Assert.assertEquals( _remoteElasticsearchConnection2.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_2_CONNECTION_ID)); }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeDisabledAndIdNull() { Assert.assertEquals( _sidecarElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient(null)); }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeEnabled() { enableRemoteMode(); Assert.assertEquals( _remoteElasticsearchConnection1.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_1_CONNECTION_ID)); Assert.assertEquals( _remoteElasticsearchConnection2.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_2_CONNECTION_ID)); }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeEnabledAndConnectionDoesNotExist() { enableRemoteMode(); try { _elasticsearchConnectionManager.getRestHighLevelClient("none"); Assert.fail(); } catch (ElasticsearchConnectionNotInitializedException elasticsearchConnectionNotInitializedException) { String message = elasticsearchConnectionNotInitializedException.getMessage(); Assert.assertTrue( message.contains("Elasticsearch connection not found")); } }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeEnabledAndDifferentConnectionId() { enableRemoteMode(); setRemoteConnectionId(_REMOTE_1_CONNECTION_ID); Assert.assertEquals( _remoteElasticsearchConnection2.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient( _REMOTE_2_CONNECTION_ID)); }
@Test public void testGetExplicitRestHighLevelClientWithRemoteModeEnabledAndIdNull() { enableRemoteMode(); Assert.assertEquals( _defaultRemoteElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient(null)); }
@Test public void testGetRestHighLevelClientWithRemoteModeDisabled() { Assert.assertEquals( _sidecarElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); }
@Test public void testGetRestHighLevelClientWithRemoteModeDisabledAndConnectionId() { setRemoteConnectionId(_REMOTE_1_CONNECTION_ID); Assert.assertEquals( _sidecarElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); setRemoteConnectionId(_REMOTE_2_CONNECTION_ID); Assert.assertEquals( _sidecarElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); }
@Test public void testGetRestHighLevelClientWithRemoteModeEnabled() { enableRemoteMode(); Assert.assertEquals( _defaultRemoteElasticsearchConnection.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); }
@Test public void testGetRestHighLevelClientWithRemoteModeEnabledAndConnectionId() { enableRemoteMode(); setRemoteConnectionId(_REMOTE_1_CONNECTION_ID); Assert.assertEquals( _remoteElasticsearchConnection1.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); setRemoteConnectionId(_REMOTE_2_CONNECTION_ID); Assert.assertEquals( _remoteElasticsearchConnection2.getRestHighLevelClient(), _elasticsearchConnectionManager.getRestHighLevelClient()); }