Examples of Closure


Examples of groovy.lang.Closure

        Object action = actualArgs.get(Task.TASK_ACTION);
        if (action instanceof Action) {
            Action<? super Task> taskAction = (Action<? super Task>) action;
            task.doFirst(taskAction);
        } else if (action != null) {
            Closure closure = (Closure) action;
            task.doFirst(closure);
        }

        return task;
    }
View Full Code Here

Examples of groovy.lang.Closure

        for (Map.Entry<RelativePath, Closure> entry : elements.entrySet()) {
            if (stopFlag.get()) {
                break;
            }
            RelativePath path = entry.getKey();
            Closure generator = entry.getValue();
            visit.visit(path, generator);
        }
        return this;
    }
View Full Code Here

Examples of groovy.lang.Closure

        while (!queue.isEmpty()) {
            Object first = queue.removeFirst();
            if (first instanceof FileCollection) {
                result.add(first);
            } else if (first instanceof Closure) {
                Closure closure = (Closure) first;
                Object closureResult = closure.call();
                if (closureResult != null) {
                    queue.addFirst(closureResult);
                }
            } else if (first instanceof Collection) {
                Collection<?> collection = (Collection<?>) first;
View Full Code Here

Examples of groovy.lang.Closure

        assertSetContainsForAllTypes(tree, emptyList);
    }
   
    @Test
    public void canAddAnElementUsingAClosureToGeneratedContent() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);

        assertVisits(tree, toList("path/file.txt"), toList("path"));
        assertSetContainsForAllTypes(tree, toList("path/file.txt"));
View Full Code Here

Examples of groovy.lang.Closure

        rootDir.file("path/file.txt").assertContents(equalTo("content"));
    }

    @Test
    public void canAddMultipleElementsInDifferentDirs() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);
        tree.add("file.txt", closure);
        tree.add("path/subdir/file.txt", closure);

        assertVisits(tree, toList("path/file.txt", "file.txt", "path/subdir/file.txt"), toList("path", "path/subdir"));
View Full Code Here

Examples of groovy.lang.Closure

        assertSetContainsForAllTypes(tree, toList("path/file.txt", "file.txt", "path/subdir/file.txt"));
    }

    @Test
    public void canStopVisitingElements() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);
        tree.add("file.txt", closure);
        assertCanStopVisiting(tree);
    }
View Full Code Here

Examples of groovy.lang.Closure

            allowing(resolverMock).resolve('b');
            will(returnValue(file2));
        }});

        List<Character> files = toList('a');
        Closure closure = HelperUtil.returns(files);
        collection.from(closure);

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file1)));

        files.add('b');
View Full Code Here

Examples of groovy.lang.Closure

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file1, file2)));
    }

    @Test
    public void canUseAClosureToSpecifyASingleFile() {
        Closure closure = HelperUtil.returns('a');
        final File file = new File("1");

        collection.from(closure);

        context.checking(new Expectations() {{
View Full Code Here

Examples of groovy.lang.Closure

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file)));
    }

    @Test
    public void closureCanReturnNull() {
        Closure closure = HelperUtil.returns(null);

        collection.from(closure);

        assertThat(collection.getFiles(), isEmpty());
    }
View Full Code Here

Examples of groovy.lang.Closure

        }
    };

    @Test
    public void matchingWithClosureReturnsUnionOfFilteredSets() {
        final Closure closure = HelperUtil.TEST_CLOSURE;
        final FileTree filtered1 = context.mock(FileTree.class, "filtered1");
        final FileTree filtered2 = context.mock(FileTree.class, "filtered2");

        context.checking(new Expectations() {{
            one(source1).matching(closure);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.