public void completeDefaults(Props props) {
    // init string properties
    for (Map.Entry<Object, Object> entry : defaults().entrySet()) {
      props.setDefault(entry.getKey().toString(), entry.getValue().toString());
    }

    boolean clusterEnabled = props.valueAsBoolean(CLUSTER_ENABLED.getKey(), false);
    if (!clusterEnabled) {
      props.setDefault(SEARCH_HOST.getKey(), InetAddress.getLoopbackAddress().getHostAddress());
      props.setDefault(SEARCH_PORT.getKey(), "9001");
      fixPortIfZero(props, Property.SEARCH_HOST.getKey(), SEARCH_PORT.getKey());
      fixEsTransportPortIfNull(props);
    }
  }
@Test
  public void completeDefaults_sets_default_values_for_sonar_search_host_and_sonar_search_port_and_random_port_for_sonar_es_port_in_non_cluster_mode() throws Exception {
    Properties p = new Properties();
    p.setProperty("sonar.cluster.enabled", "false");
    Props props = new Props(p);

    processProperties.completeDefaults(props);

    String address = props.value("sonar.search.host");
    assertThat(address).isNotEmpty();
    assertThat(InetAddress.getByName(address).isLoopbackAddress()).isTrue();
    assertThat(props.valueAsInt("sonar.search.port")).isEqualTo(9001);
    assertThat(props.valueAsInt("sonar.es.port")).isPositive();
  }