ServiceConfigurator { public ContainersConfig generateContainersConfig(String configDir) { ObjectMapper mapper = new ObjectMapper(); List<ContainersConfig.Spec> containers = new ArrayList<ContainersConfig.Spec>(); for (ContainersConfig.ContainerType containerType : ContainersConfig.ContainerType.values()) { File configFile = new File(configDir, ServiceFileConstants.CONTAINER_CONFIG_ROOT_DIRS.get(containerType) + ServiceFileConstants.CONTAINER_CONFIG_FILES.get(containerType)); ContainersConfig.Spec containerConfigSpec = null; try { containerConfigSpec = mapper.readValue(configFile, ContainersConfig.Spec.class); } catch (Exception e) { throw new RuntimeException(e); } containerConfigSpec.setType(containerType.name()); containers.add(containerConfigSpec); } ContainersConfig containersConfig = new ContainersConfig(); containersConfig.setContainers(containers); return containersConfig; }  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 testGenerateContainersConfig() throws Exception { ServiceConfigurator serviceConfigurator = new ServiceConfigurator(); ContainersConfig containersConfig = serviceConfigurator.generateContainersConfig(configPath); assertThat(containersConfig.getContainerSpecs().size(), is(ContainersConfig.ContainerType.values().length)); Spec spec = containersConfig.getContainerSpecs().get(ContainersConfig.ContainerType.PhotonControllerCore.name()); assertThat(spec.getContainerImage(), is("esxcloud/photon-controller-core")); assertThat(spec.getPortBindings().size(), is(2)); assertThat(spec.getVolumeBindings().size(), is(6)); assertThat(spec.getDynamicParameters().size(), is(21)); }