Search in sources :

Example 16 with TestClosure

use of org.gradle.util.TestClosure in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method canExecuteClosureForAllElementsInATypeFilteredCollection.

// @Test
// public void canExecuteActionForAllElementsInATypeFilteredCollection() {
// final Action<CharSequence> action = context.mock(Action.class);
// 
// container.add("c");
// container.add(new StringBuffer("b"));
// 
// context.checking(new Expectations(){{
// one(action).execute("c");
// one(action).execute("a");
// }});
// 
// container.withType(String.class, action);
// container.add("a");
// }
@Test
public void canExecuteClosureForAllElementsInATypeFilteredCollection() {
    final TestClosure closure = context.mock(TestClosure.class);
    container.add("c");
    container.add(new StringBuffer("b"));
    context.checking(new Expectations() {

        {
            oneOf(closure).call("c");
            oneOf(closure).call("a");
        }
    });
    container.withType(String.class, TestUtil.toClosure(closure));
    container.add("a");
}
Also used : TestClosure(org.gradle.util.TestClosure) Expectations(org.jmock.Expectations) Test(org.junit.Test)

Aggregations

TestClosure (org.gradle.util.TestClosure)16 Expectations (org.jmock.Expectations)14 Test (org.junit.Test)13 Spec (org.gradle.api.specs.Spec)4 Task (org.gradle.api.Task)3