ScenarioDefinition implements ImmutableBean { public FilteredScenarioDefinition filter(String name) { ArgumentChecker.notEmpty(name, "name"); List<ScenarioArgument<?, ?>> args = new ArrayList<>(); for (Map.Entry<ScenarioArgumentKey, ScenarioArgument<?, ?>> entry : _columnArguments.entries()) { if (entry.getKey().getName().equals(name)) { args.add(entry.getValue()); } } for (ScenarioArgument<?, ?> argument : _arguments.values()) { args.add(argument); } return new FilteredScenarioDefinition(args); } ScenarioDefinition(ScenarioArgument<?, ?>... arguments);  ScenarioDefinition(List<ScenarioArgument<?, ?>> arguments);  ScenarioDefinition(List<ScenarioArgument<?, ?>> arguments,
                            Map<String, List<ScenarioArgument<?, ?>>> columnArguments); private  ScenarioDefinition(List<ScenarioArgument<?, ?>> arguments,
                             ImmutableListMultimap<ScenarioArgumentKey, ScenarioArgument<?, ?>> columnArguments); private  ScenarioDefinition(
      ListMultimap<Class<? extends ScenarioFunction<?, ?>>, ScenarioArgument<?, ?>> arguments,
      ListMultimap<ScenarioArgumentKey, ScenarioArgument<?, ?>> columnArguments); ScenarioDefinition mergedWith(ScenarioDefinition other); ScenarioDefinition with(List<ScenarioArgument<?, ?>> arguments); ScenarioDefinition with(ScenarioArgument<?, ?>... arguments); ScenarioDefinition with(List<ScenarioArgument<?, ?>> arguments, String... names); ScenarioDefinition with(ScenarioArgument<?, ?> argument, String... names); FilteredScenarioDefinition filter(String name); Set<Class<? extends ScenarioFunction<?, ?>>> getFunctionTypes(); boolean isEmpty(); static ScenarioDefinition.Meta meta(); static ScenarioDefinition.Builder builder(); @Override ScenarioDefinition.Meta metaBean(); @Override Property<R> property(String propertyName); @Override Set<String> propertyNames(); Builder toBuilder(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final ScenarioDefinition EMPTY; }
@Test public void filter() { List<ScenarioArgument<?, ?>> argList = ImmutableList.<ScenarioArgument<?, ?>>of(_arg11); Map<String, List<ScenarioArgument<?, ?>>> argMap = new HashMap<>(); argMap.put("foo", ImmutableList.<ScenarioArgument<?, ?>>of(_arg21)); ScenarioDefinition scenarioDefinition = new ScenarioDefinition(argList, argMap); FilteredScenarioDefinition barArgs = scenarioDefinition.filter("bar"); List<Arg1> barArgs1 = barArgs.getArguments(new Fn1()); assertEquals(1, barArgs1.size()); assertTrue(barArgs1.contains(_arg11)); List<Arg2> barArgs2 = barArgs.getArguments(new Fn2()); assertTrue(barArgs2.isEmpty()); FilteredScenarioDefinition fooArgs = scenarioDefinition.filter("foo"); List<Arg1> fooArgs1 = fooArgs.getArguments(new Fn1()); assertEquals(1, fooArgs1.size()); assertTrue(fooArgs1.contains(_arg11)); List<Arg2> fooArgs2 = fooArgs.getArguments(new Fn2()); assertEquals(1, fooArgs2.size()); assertTrue(fooArgs2.contains(_arg21)); }