ElasticsearchDependenciesJob { static String parseHosts(String hosts) { StringBuilder to = new StringBuilder(); String[] hostParts = hosts.split(",", -1); for (int i = 0; i < hostParts.length; i++) { String host = hostParts[i]; if (host.startsWith("http")) { URI httpUri = URI.create(host); int port = httpUri.getPort(); if (port == -1) { port = host.startsWith("https") ? 443 : 80; } to.append(httpUri.getHost()).append(":").append(port); } else { to.append(host); } if (i + 1 < hostParts.length) { to.append(','); } } return to.toString(); } ElasticsearchDependenciesJob(Builder builder); static Builder builder(); void run();  }
@Test public void parseHosts_http_defaultPort() { Assertions.assertThat(ElasticsearchDependenciesJob.parseHosts("http: }
@Test public void parseHosts_https_defaultPort() { Assertions.assertThat(ElasticsearchDependenciesJob.parseHosts("https: }
@Test public void parseHosts_default() { Assertions.assertThat(ElasticsearchDependenciesJob.parseHosts("1.1.1.1")).isEqualTo("1.1.1.1"); }
@Test public void parseHosts_commaDelimits() { Assertions.assertThat(ElasticsearchDependenciesJob.parseHosts("1.1.1.1:9200,2.2.2.2:9200")).isEqualTo("1.1.1.1:9200,2.2.2.2:9200"); }