ServiceConfigurator { public void applyDynamicParameters(String mustacheDir, ContainersConfig.ContainerType containerType, final Map<String, ?> dynamicParameters) { File configDir = new File(mustacheDir, ServiceFileConstants.CONTAINER_CONFIG_ROOT_DIRS.get(containerType)); Collection<File> files = FileUtils.listFiles(configDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); files.stream().forEach(file -> applyMustacheParameters(file, dynamicParameters)); }  ContainersConfig generateContainersConfig(String configDir); void applyDynamicParameters(String mustacheDir, ContainersConfig.ContainerType containerType,
                                            final Map<String, ?> dynamicParameters); void applyMustacheParameters(File file, Map<String, ?> parameters); void copyDirectory(String srcDir, String destDir); void createFirewallRules(Set<Integer> tcpPorts, Set<Integer> udpPorts, String directory); void createDockerContainerStartFile(
      Map<String, ContainerService.State> containerStates,
      Map<String, ContainerTemplateService.State> templateStates,
      DeploymentService.State deploymentState,
      String directory,
      Service service); StringBuilder buildDockerCommand(
      ContainerService.State containerState,
      ContainerTemplateService.State templateState,
      String entryPoint,
      String commands,
      Map<String, String> environmentVariables); static final String TCP_PORT_FIREWALL_TEMPLATE; static final String UDP_PORT_FIREWALL_TEMPLATE; static final String PORT_SUBSITUTION_KEY; static final String FIREWALL_RULE_FILENAME; static final String HAPROXY_CONF_DIR; static final String LIGHTWAVE_CONF_DIR; }
@Test public void testApplyDynamicParameters() throws Exception { FileUtils.copyDirectory(new File(configPath), new File(TMP_DIR)); ServiceConfigurator serviceConfigurator = new ServiceConfigurator(); ContainersConfig containersConfig = serviceConfigurator.generateContainersConfig(configPath); serviceConfigurator.applyDynamicParameters(TMP_DIR, ContainersConfig.ContainerType.PhotonControllerCore, containersConfig.getContainerSpecs().get( ContainersConfig.ContainerType.PhotonControllerCore.name()).getDynamicParameters()); Map<String, Object> dynamicParameters = new HashMap<>(); List<LoadBalancerServer> list = new ArrayList<>(); list.add(new LoadBalancerServer("server-1", "0.0.0.0")); list.add(new LoadBalancerServer("server-2", "1.1.1.1")); dynamicParameters.put("MGMT_API_HTTP_SERVERS", list); serviceConfigurator.applyDynamicParameters(TMP_DIR, ContainersConfig.ContainerType.LoadBalancer, dynamicParameters); File file = new File(TMP_DIR + "haproxy/haproxy.cfg"); String haproxyCfg = FileUtils.readFileToString(file); assertThat(haproxyCfg.contains("server server-1 0.0.0.0 check"), is(true)); assertThat(haproxyCfg.contains("server server-2 1.1.1.1 check"), is(true)); FileUtils.deleteDirectory(new File(TMP_DIR)); }