@Test public void createSingletonExperiment () { Container container = mock(Container.class); Experiment experiment = mock(Experiment.class); doReturn(container).when(firstPlatform).getContainerByIdentifier("identifier"); doReturn(experiment).when(container).createExperiment("experimentMethod"); assertSame(experiment, experimentManager.createSingleExperiment(firstPlatform, "identifier", "experimentMethod")); }
Experiment createSingleExperiment (Platform platform, String containerIdentifier, String experimentMethod) { Optional<Experiment> optionalExperiment = Optional.of(platform) .map(platform1 -> platform1.getContainerByIdentifier(containerIdentifier)) .map(container -> container.createExperiment(experimentMethod)); optionalExperiment.ifPresentOrElse(experiment -> log.debug("Created experiment {}", v("experiment", experiment)), () -> log .warn("Experiment of type {} could not be created for {} ", kv("experimentMethod", experimentMethod), kv("containerIdentifier", containerIdentifier))); return optionalExperiment.orElse(null); }
ExperimentManager { Experiment createSingleExperiment (Platform platform, String containerIdentifier, String experimentMethod) { Optional<Experiment> optionalExperiment = Optional.of(platform) .map(platform1 -> platform1.getContainerByIdentifier(containerIdentifier)) .map(container -> container.createExperiment(experimentMethod)); optionalExperiment.ifPresentOrElse(experiment -> log.debug("Created experiment {}", v("experiment", experiment)), () -> log .warn("Experiment of type {} could not be created for {} ", kv("experimentMethod", experimentMethod), kv("containerIdentifier", containerIdentifier))); return optionalExperiment.orElse(null); } }
ExperimentManager { Experiment createSingleExperiment (Platform platform, String containerIdentifier, String experimentMethod) { Optional<Experiment> optionalExperiment = Optional.of(platform) .map(platform1 -> platform1.getContainerByIdentifier(containerIdentifier)) .map(container -> container.createExperiment(experimentMethod)); optionalExperiment.ifPresentOrElse(experiment -> log.debug("Created experiment {}", v("experiment", experiment)), () -> log .warn("Experiment of type {} could not be created for {} ", kv("experimentMethod", experimentMethod), kv("containerIdentifier", containerIdentifier))); return optionalExperiment.orElse(null); }  }
ExperimentManager { Experiment createSingleExperiment (Platform platform, String containerIdentifier, String experimentMethod) { Optional<Experiment> optionalExperiment = Optional.of(platform) .map(platform1 -> platform1.getContainerByIdentifier(containerIdentifier)) .map(container -> container.createExperiment(experimentMethod)); optionalExperiment.ifPresentOrElse(experiment -> log.debug("Created experiment {}", v("experiment", experiment)), () -> log .warn("Experiment of type {} could not be created for {} ", kv("experimentMethod", experimentMethod), kv("containerIdentifier", containerIdentifier))); return optionalExperiment.orElse(null); }  void setExperimentBackoffPeriod(Duration experimentBackoffPeriod); boolean areExperimentsInProgress(); }
ExperimentManager { Experiment createSingleExperiment (Platform platform, String containerIdentifier, String experimentMethod) { Optional<Experiment> optionalExperiment = Optional.of(platform) .map(platform1 -> platform1.getContainerByIdentifier(containerIdentifier)) .map(container -> container.createExperiment(experimentMethod)); optionalExperiment.ifPresentOrElse(experiment -> log.debug("Created experiment {}", v("experiment", experiment)), () -> log .warn("Experiment of type {} could not be created for {} ", kv("experimentMethod", experimentMethod), kv("containerIdentifier", containerIdentifier))); return optionalExperiment.orElse(null); }  void setExperimentBackoffPeriod(Duration experimentBackoffPeriod); boolean areExperimentsInProgress();  }