@Test public void fromExperiments () { final String PLATFORM_TYPE = "complex platform"; final String CONTAINER_AGGREGATOR = "aggregator"; final String EXPERIMENT_METHOD_NAME = "destroy"; Platform platform = mock(Platform.class); Experiment experiment = mock(Experiment.class); Container container = mock(Container.class); doReturn(PLATFORM_TYPE).when(platform).getPlatformType(); doReturn(container).when(experiment).getContainer(); doReturn(CONTAINER_AGGREGATOR).when(container).getAggregationIdentifier(); doReturn(EXPERIMENT_METHOD_NAME).when(experiment).getExperimentMethodName(); ExperimentSuite generatedExperimentSuite = ExperimentSuite.fromExperiments(platform, Set.of(experiment)); ExperimentSuite expectedExperimentSuite = new ExperimentSuite(PLATFORM_TYPE, ExperimentSuite.fromMap(Map.of(CONTAINER_AGGREGATOR, List .of(EXPERIMENT_METHOD_NAME)))); assertEquals(expectedExperimentSuite, generatedExperimentSuite); }
static ExperimentSuite fromExperiments (Platform platform, Collection<Experiment> experiments) { Map<String, List<String>> map = experiments.stream() .collect(Collectors.groupingBy(experiment -> Optional.of(experiment) .map(Experiment::getContainer) .map(Container::getAggregationIdentifier) .orElse("ungrouped"), Collectors.mapping(Experiment::getExperimentMethodName, Collectors.toList()))); return new ExperimentSuite(platform.getPlatformType(), fromMap(map)); }
ExperimentSuite { static ExperimentSuite fromExperiments (Platform platform, Collection<Experiment> experiments) { Map<String, List<String>> map = experiments.stream() .collect(Collectors.groupingBy(experiment -> Optional.of(experiment) .map(Experiment::getContainer) .map(Container::getAggregationIdentifier) .orElse("ungrouped"), Collectors.mapping(Experiment::getExperimentMethodName, Collectors.toList()))); return new ExperimentSuite(platform.getPlatformType(), fromMap(map)); } }
ExperimentSuite { static ExperimentSuite fromExperiments (Platform platform, Collection<Experiment> experiments) { Map<String, List<String>> map = experiments.stream() .collect(Collectors.groupingBy(experiment -> Optional.of(experiment) .map(Experiment::getContainer) .map(Container::getAggregationIdentifier) .orElse("ungrouped"), Collectors.mapping(Experiment::getExperimentMethodName, Collectors.toList()))); return new ExperimentSuite(platform.getPlatformType(), fromMap(map)); } @JsonCreator  ExperimentSuite(@JsonProperty(required = true, value = PLATFORM_TYPE_KEY) String platformType, @JsonProperty(required = true, value = EXPERIMENT_CRITERIA) Collection<ExperimentCriteria> experimentCriteria); }
ExperimentSuite { static ExperimentSuite fromExperiments (Platform platform, Collection<Experiment> experiments) { Map<String, List<String>> map = experiments.stream() .collect(Collectors.groupingBy(experiment -> Optional.of(experiment) .map(Experiment::getContainer) .map(Container::getAggregationIdentifier) .orElse("ungrouped"), Collectors.mapping(Experiment::getExperimentMethodName, Collectors.toList()))); return new ExperimentSuite(platform.getPlatformType(), fromMap(map)); } @JsonCreator  ExperimentSuite(@JsonProperty(required = true, value = PLATFORM_TYPE_KEY) String platformType, @JsonProperty(required = true, value = EXPERIMENT_CRITERIA) Collection<ExperimentCriteria> experimentCriteria); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); }
ExperimentSuite { static ExperimentSuite fromExperiments (Platform platform, Collection<Experiment> experiments) { Map<String, List<String>> map = experiments.stream() .collect(Collectors.groupingBy(experiment -> Optional.of(experiment) .map(Experiment::getContainer) .map(Container::getAggregationIdentifier) .orElse("ungrouped"), Collectors.mapping(Experiment::getExperimentMethodName, Collectors.toList()))); return new ExperimentSuite(platform.getPlatformType(), fromMap(map)); } @JsonCreator  ExperimentSuite(@JsonProperty(required = true, value = PLATFORM_TYPE_KEY) String platformType, @JsonProperty(required = true, value = EXPERIMENT_CRITERIA) Collection<ExperimentCriteria> experimentCriteria); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); static final String PLATFORM_TYPE_KEY; static final String EXPERIMENT_CRITERIA; }