use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method allCallsClosureForEachNewObject.
@Test
public void allCallsClosureForEachNewObject() {
final TestClosure closure = context.mock(TestClosure.class);
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
container.all(TestUtil.toClosure(closure));
container.add("a");
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method canExecuteClosureForAllElementsInATypeFilteredCollection.
@Test
public void canExecuteClosureForAllElementsInATypeFilteredCollection() {
class OtherBean extends Bean {
public OtherBean(String name) {
super(name);
}
public OtherBean() {
}
}
final TestClosure closure = context.mock(TestClosure.class);
Bean bean1 = new Bean("b1");
final OtherBean bean2 = new OtherBean("b2");
container.add(bean1);
container.add(bean2);
context.checking(new Expectations() {
{
one(closure).call(bean2);
}
});
container.withType(OtherBean.class, TestUtil.toClosure(closure));
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method callsClosureWhenObjectAdded.
@Test
public void callsClosureWhenObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(closure).call(bean);
}
});
container.whenObjectAdded(TestUtil.toClosure(closure));
container.add(bean);
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method filteredCollectionExecutesClosureWhenMatchingObjectAdded.
@Test
public void filteredCollectionExecutesClosureWhenMatchingObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(closure).call(bean);
}
});
Spec<Bean> spec = new Spec<Bean>() {
public boolean isSatisfiedBy(Bean element) {
return element == bean;
}
};
container.matching(spec).whenObjectAdded(TestUtil.toClosure(closure));
container.add(bean);
container.add(new Bean());
}
use of org.gradle.util.TestClosure in project gradle by gradle.
the class DefaultNamedDomainObjectSetTest method allCallsClosureForEachNewObject.
@Test
public void allCallsClosureForEachNewObject() {
final TestClosure closure = context.mock(TestClosure.class);
final Bean bean = new Bean();
context.checking(new Expectations() {
{
one(closure).call(bean);
}
});
container.all(TestUtil.toClosure(closure));
container.add(bean);
}
Aggregations