private static String getProperty(String name, Configuration configuration) {
    return Optional.of(configuration.getStringArray(relaxPropertyName(name)))

        .filter(values -> values.length > 0)

        .map(Arrays::stream)

        .map(stream -> stream.collect(Collectors.joining(",")))

        .orElse(null);
  }
@Test
  public void assertDynamicEnvConfig()
      throws IOException {
    Map<String, Object> baseProperties = new HashMap<>();
    Map<String, String> mockedEnvironmentVariables = new HashMap<>();

    String configFile = File.createTempFile("pinot-configuration-test-4", ".properties").getAbsolutePath();

    baseProperties.put("server.host", "ENV_SERVER_HOST");
    baseProperties.put("not.templated.cli", "static-value");
    baseProperties.put("dynamic.env.config", "server.host");

    mockedEnvironmentVariables.put("ENV_VAR_HOST", "test-host");
    mockedEnvironmentVariables.put("TEST_PROPERTY", "test-property");
    mockedEnvironmentVariables.put("ENV_SERVER_HOST", "test-server-host");

    baseProperties.put("config.paths", "classpath:/pinot-configuration-4.properties");
    copyClasspathResource("/pinot-configuration-4.properties", configFile);

    PinotConfiguration configuration = new PinotConfiguration(baseProperties, mockedEnvironmentVariables);

    // Tests that cli arguments have the highest priority.
    Assert.assertEquals(configuration.getProperty("server.host"), "test-server-host");
    // Checking for non templated values
    Assert.assertEquals(configuration.getProperty("not.templated.cli"), "static-value");
    // Templated values in configFile
    Assert.assertEquals(configuration.getProperty("pinot.controller.host"), "test-host");
  }