use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method assertExecutesWhenReadyListenerBeforeExecute.
void assertExecutesWhenReadyListenerBeforeExecute(Action<TestClosure> whenReadySubscriber) {
final TestClosure runnable = context.mock(TestClosure.class);
Task a = task("a");
whenReadySubscriber.execute(runnable);
taskExecuter.addTasks(toList(a));
context.checking(new Expectations() {
{
one(runnable).call(taskExecuter);
}
});
taskExecuter.execute();
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method allCallsClosureForEachExistingObject.
@Test
public void allCallsClosureForEachExistingObject() {
final TestClosure closure = context.mock(TestClosure.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(closure).call(bean);
}
});
container.add(bean);
container.all(TestUtil.toClosure(closure));
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method canGetFilteredCollectionContainingAllObjectsWhichMeetSpec.
@Test
public void canGetFilteredCollectionContainingAllObjectsWhichMeetSpec() {
final Bean bean1 = new Bean("a");
Bean bean2 = new Bean("b");
Bean bean3 = new Bean("c");
Spec<Bean> spec = new Spec<Bean>() {
public boolean isSatisfiedBy(Bean element) {
return element != bean1;
}
};
TestClosure testClosure = new TestClosure() {
public Object call(Object param) {
return param != bean1;
}
};
container.add(bean1);
container.add(bean2);
container.add(bean3);
assertThat(toList(container.matching(spec)), equalTo(toList(bean2, bean3)));
assertThat(toList(container.matching(TestUtil.toClosure(testClosure))), equalTo(toList(bean2, bean3)));
assertThat(container.matching(spec).findByName("a"), nullValue());
assertThat(container.matching(spec).findByName("b"), sameInstance(bean2));
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method callsClosureWithNewObjectAsParameterWhenObjectAdded.
@Test
public void callsClosureWithNewObjectAsParameterWhenObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
container.whenObjectAdded(TestUtil.toClosure(closure));
container.add("a");
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method callsClosureWithRemovedObjectAsParameterWhenObjectRemoved.
@Test
public void callsClosureWithRemovedObjectAsParameterWhenObjectRemoved() {
final TestClosure closure = context.mock(TestClosure.class);
container.add("a");
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
container.whenObjectRemoved(TestUtil.toClosure(closure));
container.remove("a");
}
Aggregations