ScenarioDefinition implements ImmutableBean { public ScenarioDefinition mergedWith(ScenarioDefinition other) { ArgumentChecker.notNull(other, "other"); ImmutableListMultimap<Class<? extends ScenarioFunction<?, ?>>, ScenarioArgument<?, ?>> arguments; if (_arguments.isEmpty()) { arguments = other._arguments; } else if (other._arguments.isEmpty()) { arguments = _arguments; } else { ImmutableListMultimap.Builder<Class<? extends ScenarioFunction<?, ?>>, ScenarioArgument<?, ?>> builder = ImmutableListMultimap.builder(); arguments = builder.putAll(other._arguments).putAll(_arguments).build(); } ImmutableListMultimap<ScenarioArgumentKey, ScenarioArgument<?, ?>> columnArguments; if (_columnArguments.isEmpty()) { columnArguments = other._columnArguments; } else if (other._columnArguments.isEmpty()) { columnArguments = _columnArguments; } else { ImmutableListMultimap.Builder<ScenarioArgumentKey, ScenarioArgument<?, ?>> builder = ImmutableListMultimap.builder(); columnArguments = builder.putAll(other._columnArguments).putAll(_columnArguments).build(); } return new ScenarioDefinition(arguments, columnArguments); } 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 mergedWith() { Arg1 arg13 = new Arg1(); Arg2 arg23 = new Arg2(); ScenarioDefinition args1 = new ScenarioDefinition(_arg11).with(_arg12, "foo").with(arg13, "bar"); ScenarioDefinition args2 = new ScenarioDefinition(_arg21).with(_arg22, "foo").with(arg23, "bar"); ScenarioDefinition merged = args1.mergedWith(args2); FilteredScenarioDefinition fooArgs = merged.filter("foo"); FilteredScenarioDefinition barArgs = merged.filter("bar"); List<Arg1> fooArgs1 = fooArgs.getArguments(new Fn1()); assertEquals(2, fooArgs1.size()); assertTrue(fooArgs1.contains(_arg11)); assertTrue(fooArgs1.contains(_arg12)); List<Arg1> barArgs1 = barArgs.getArguments(new Fn1()); assertEquals(2, barArgs1.size()); assertTrue(barArgs1.contains(_arg11)); assertTrue(barArgs1.contains(arg13)); List<Arg2> fooArgs2 = fooArgs.getArguments(new Fn2()); assertEquals(2, fooArgs2.size()); assertTrue(fooArgs2.contains(_arg21)); assertTrue(fooArgs2.contains(_arg22)); List<Arg2> barArgs2 = barArgs.getArguments(new Fn2()); assertEquals(2, barArgs2.size()); assertTrue(barArgs2.contains(_arg21)); assertTrue(barArgs2.contains(arg23)); }