final Task task2 = context.mock(Task.class, "task2");
final Task task3 = context.mock(Task.class, "task3");
final FileCollection source3 = context.mock(FileCollection.class, "source3");
context.checking(new Expectations(){{
TaskDependency dependency1 = context.mock(TaskDependency.class, "dep1");
TaskDependency dependency2 = context.mock(TaskDependency.class, "dep2");
TaskDependency dependency3 = context.mock(TaskDependency.class, "dep3");
allowing(source1).getBuildDependencies();
will(returnValue(dependency1));
allowing(dependency1).getDependencies(target);
will(returnValue(toSet(task1)));
allowing(source2).getBuildDependencies();
will(returnValue(dependency2));
allowing(dependency2).getDependencies(target);
will(returnValue(toSet(task2)));
allowing(source3).getBuildDependencies();
will(returnValue(dependency3));
allowing(dependency3).getDependencies(target);
will(returnValue(toSet(task3)));
}});
TaskDependency dependency = collection.getBuildDependencies();
assertThat(dependency.getDependencies(target), equalTo((Set) toSet(task1, task2)));
collection.sourceCollections.add(source3);
assertThat(dependency.getDependencies(target), equalTo((Set) toSet(task1, task2, task3)));
}