### Question:
ScenarioDefinition implements ImmutableBean { public static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mapping) { ArgChecker.notEmpty(mapping, "mappings"); int numScenarios = countScenarios(mapping, false); for (int i = 1; i < mapping.size(); i++) { if (mapping.get(i).getScenarioCount() != numScenarios) { throw new IllegalArgumentException( "All mappings must have the same number of perturbations. First mapping" + " has " + numScenarios + " perturbations, mapping " + i + " has " + mapping.get(i).getScenarioCount()); } } return new ScenarioDefinition(mapping, generateNames(numScenarios)); } private  ScenarioDefinition(
      List<? extends PerturbationMapping<?>> mappings,
      List<String> scenarioNames); static ScenarioDefinition empty(); static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mapping); static ScenarioDefinition ofMappings(PerturbationMapping<?>... mappings); static ScenarioDefinition ofMappings(
      List<? extends PerturbationMapping<?>> mappings,
      List<String> scenarioNames); int getScenarioCount(); static ScenarioDefinition.Meta meta(); static ScenarioDefinition.Builder builder(); @Override ScenarioDefinition.Meta metaBean(); ImmutableList<PerturbationMapping<?>> getMappings(); ImmutableList<String> getScenarioNames(); Builder toBuilder(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void ofMappings() { List<PerturbationMapping<Object>> mappings = ImmutableList.of(MAPPING_A, MAPPING_B, MAPPING_C); ScenarioDefinition scenarioDefinition = ScenarioDefinition.ofMappings(mappings); List<String> scenarioNames = ImmutableList.of("Scenario 1", "Scenario 2"); assertThat(scenarioDefinition.getMappings()).isEqualTo(mappings); assertThat(scenarioDefinition.getScenarioNames()).isEqualTo(scenarioNames); }
@Test public void ofMappingsWrongNumberOfScenarioNames() { List<PerturbationMapping<Object>> mappings = ImmutableList.of(MAPPING_A, MAPPING_B, MAPPING_C); List<String> scenarioNames = ImmutableList.of("foo", "bar", "baz"); assertThatIllegalArgumentException().isThrownBy(() -> ScenarioDefinition.ofMappings(mappings, scenarioNames)); }
@Test public void ofMappingsDifferentNumberOfScenarios() { PerturbationMapping<Object> mappingC = PerturbationMapping.of(FILTER_C, new TestPerturbation(27)); List<PerturbationMapping<Object>> mappings = ImmutableList.of(MAPPING_A, MAPPING_B, mappingC); assertThatIllegalArgumentException().isThrownBy(() -> ScenarioDefinition.ofMappings(mappings)); }
@Test public void ofMappingsWithNamesDifferentNumberOfScenarios() { PerturbationMapping<Object> mappingC = PerturbationMapping.of(FILTER_C, new TestPerturbation(27)); List<PerturbationMapping<Object>> mappings = ImmutableList.of(MAPPING_A, MAPPING_B, mappingC); List<String> scenarioNames = ImmutableList.of("foo", "bar"); assertThatIllegalArgumentException().isThrownBy(() -> ScenarioDefinition.ofMappings(mappings, scenarioNames)); }
@Test public void nonUniqueNames() { List<PerturbationMapping<Object>> mappings2 = ImmutableList.of(MAPPING_A, MAPPING_B, MAPPING_C); List<String> names2 = ImmutableList.of("foo", "foo"); assertThatIllegalArgumentException() .isThrownBy(() -> ScenarioDefinition.ofMappings(mappings2, names2)) .withMessage("Scenario names must be unique but duplicates were found: foo"); }