@Test public void createContainersFromApplicationSummary () { ApplicationSummary applicationSummary; String name = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); Integer instances = new Random().nextInt(5) + 5; applicationSummary = ApplicationSummary.builder() .instances(instances) .name(name) .id(applicationId) .diskQuota(0) .memoryLimit(0) .requestedState(CLOUDFOUNDRY_APPLICATION_STARTED) .runningInstances(instances) .build(); CloudFoundryContainer[] containerCollection = IntStream.range(0, instances) .mapToObj(instance -> CloudFoundryContainer.builder() .name(name) .applicationId(applicationId) .instance(instance) .build()) .toArray(CloudFoundryContainer[]::new); assertThat(cloudFoundryContainerPlatform.createContainersFromApplicationSummary(applicationSummary), IsIterableContainingInAnyOrder .containsInAnyOrder(containerCollection)); }
Collection<CloudFoundryContainer> createContainersFromApplicationSummary (ApplicationSummary applicationSummary) { Integer instances = applicationSummary.getInstances(); return IntStream.range(0, instances) .mapToObj(i -> createSingleContainerFromApplicationSummary(applicationSummary, i)) .filter(Objects::nonNull) .collect(Collectors.toSet()); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { Collection<CloudFoundryContainer> createContainersFromApplicationSummary (ApplicationSummary applicationSummary) { Integer instances = applicationSummary.getInstances(); return IntStream.range(0, instances) .mapToObj(i -> createSingleContainerFromApplicationSummary(applicationSummary, i)) .filter(Objects::nonNull) .collect(Collectors.toSet()); } }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { Collection<CloudFoundryContainer> createContainersFromApplicationSummary (ApplicationSummary applicationSummary) { Integer instances = applicationSummary.getInstances(); return IntStream.range(0, instances) .mapToObj(i -> createSingleContainerFromApplicationSummary(applicationSummary, i)) .filter(Objects::nonNull) .collect(Collectors.toSet()); } @Autowired  CloudFoundryContainerPlatform(); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { Collection<CloudFoundryContainer> createContainersFromApplicationSummary (ApplicationSummary applicationSummary) { Integer instances = applicationSummary.getInstances(); return IntStream.range(0, instances) .mapToObj(i -> createSingleContainerFromApplicationSummary(applicationSummary, i)) .filter(Objects::nonNull) .collect(Collectors.toSet()); } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { Collection<CloudFoundryContainer> createContainersFromApplicationSummary (ApplicationSummary applicationSummary) { Integer instances = applicationSummary.getInstances(); return IntStream.range(0, instances) .mapToObj(i -> createSingleContainerFromApplicationSummary(applicationSummary, i)) .filter(Objects::nonNull) .collect(Collectors.toSet()); } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container);  }