@Test public void experimentContainerId () { Container firstContainer = mock(Container.class); Container secondContainer = mock(Container.class); long firstContainerIdentity = 12345678987654321L; long secondContainerIdentity = 98765432123456789L; doReturn(firstContainerIdentity).when(firstContainer).getIdentity(); doReturn(secondContainerIdentity).when(secondContainer).getIdentity(); doReturn(List.of(firstContainer)).when(firstPlatform).getRoster(); doReturn(List.of(secondContainer)).when(secondPlatform).getRoster(); Experiment firstContainerExperiment = mock(Experiment.class); doReturn(firstContainerExperiment).when(firstContainer).createExperiment(); Experiment secondContainerExperiment = mock(Experiment.class); doReturn(secondContainerExperiment).when(secondContainer).createExperiment(); doCallRealMethod().when(experimentManager).addExperiment(any()); assertThat(experimentManager.experimentContainerId(firstContainerIdentity), containsInAnyOrder(firstContainerExperiment)); assertThat(experimentManager.experimentContainerId(secondContainerIdentity), containsInAnyOrder(secondContainerExperiment)); }
Set<Experiment> experimentContainerId (Long containerIdentity) { return platformManager.getPlatforms() .stream() .map(Platform::getRoster) .flatMap(Collection::stream) .filter(container -> container.getIdentity() == containerIdentity) .map(Container::createExperiment) .map(this::addExperiment) .collect(Collectors.toSet()); }
ExperimentManager { Set<Experiment> experimentContainerId (Long containerIdentity) { return platformManager.getPlatforms() .stream() .map(Platform::getRoster) .flatMap(Collection::stream) .filter(container -> container.getIdentity() == containerIdentity) .map(Container::createExperiment) .map(this::addExperiment) .collect(Collectors.toSet()); } }
ExperimentManager { Set<Experiment> experimentContainerId (Long containerIdentity) { return platformManager.getPlatforms() .stream() .map(Platform::getRoster) .flatMap(Collection::stream) .filter(container -> container.getIdentity() == containerIdentity) .map(Container::createExperiment) .map(this::addExperiment) .collect(Collectors.toSet()); }  }
ExperimentManager { Set<Experiment> experimentContainerId (Long containerIdentity) { return platformManager.getPlatforms() .stream() .map(Platform::getRoster) .flatMap(Collection::stream) .filter(container -> container.getIdentity() == containerIdentity) .map(Container::createExperiment) .map(this::addExperiment) .collect(Collectors.toSet()); }  void setExperimentBackoffPeriod(Duration experimentBackoffPeriod); boolean areExperimentsInProgress(); }
ExperimentManager { Set<Experiment> experimentContainerId (Long containerIdentity) { return platformManager.getPlatforms() .stream() .map(Platform::getRoster) .flatMap(Collection::stream) .filter(container -> container.getIdentity() == containerIdentity) .map(Container::createExperiment) .map(this::addExperiment) .collect(Collectors.toSet()); }  void setExperimentBackoffPeriod(Duration experimentBackoffPeriod); boolean areExperimentsInProgress();  }