@Override
  public AppSettings load() {
    Properties p = loadPropertiesFile(homeDir);
    Set<String> keysOverridableFromEnv = stream(ProcessProperties.Property.values()).map(ProcessProperties.Property::getKey)
      .collect(Collectors.toSet());
    keysOverridableFromEnv.addAll(p.stringPropertyNames());

    // 1st pass to load static properties
    Props staticProps = reloadProperties(keysOverridableFromEnv, p);
    keysOverridableFromEnv.addAll(getDynamicPropertiesKeys(staticProps));

    // 2nd pass to load dynamic properties like `ldap.*.url` or `ldap.*.baseDn` which keys depend on values of static
    // properties loaded in 1st step
    Props props = reloadProperties(keysOverridableFromEnv, p);

    new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
    stream(consumers).forEach(c -> c.accept(props));
    return new AppSettingsImpl(props);
  }
@Test
  public void throws_ISE_if_file_fails_to_be_loaded() throws Exception {
    File homeDir = temp.newFolder();
    File propsFileAsDir = new File(homeDir, "conf/sonar.properties");
    FileUtils.forceMkdir(propsFileAsDir);
    AppSettingsLoaderImpl underTest = new AppSettingsLoaderImpl(system, new String[0], homeDir, serviceLoaderWrapper);

    assertThatThrownBy(() -> underTest.load())
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Cannot open file " + propsFileAsDir.getAbsolutePath());
  }