Examples of Closure


Examples of groovy.lang.Closure

        assertThat(transformer.transform("original"), equalTo("original"));
    }

    @Test
    public void originalObjectIsSetAsDelegateForClosure() {
        Closure closure = HelperUtil.toClosure("{ substring(1, 3) }");

        transformer.add(closure);

        assertThat(transformer.transform("original"), equalTo("ri"));
    }
View Full Code Here

Examples of groovy.lang.Closure

        assertThat(transformer.transform("original"), equalTo("ri"));
    }
   
    @Test
    public void closureCanTransformAStringIntoAGString() {
        Closure closure = HelperUtil.toClosure("{ \"[$it]\" }");

        transformer.add(closure);

        assertThat(transformer.transform("original"), equalTo("[original]"));
    }
View Full Code Here

Examples of groovy.lang.Closure

        assertThat(fileCollection.getDependencySpec(), sameInstance(spec));
    }

    @Test
    public void filesWithClosureSpec() {
        Closure closure = HelperUtil.toClosure("{ dep -> dep.group == 'group1' }");
        final Set<File> fileSet = toSet(new File("somePath"));
        prepareForFilesBySpec(fileSet);
        assertThat(configuration.files(closure), equalTo(fileSet));
        assertThat(configuration.getState(), equalTo(Configuration.State.RESOLVED));
    }
View Full Code Here

Examples of groovy.lang.Closure

        assertThat(configuration.getState(), equalTo(Configuration.State.RESOLVED));
    }

    @Test
    public void fileCollectionWithClosureSpec() {
        Closure closure = HelperUtil.toClosure("{ dep -> dep.group == 'group1' }");
        DefaultConfiguration.ConfigurationFileCollection fileCollection = (DefaultConfiguration.ConfigurationFileCollection)
                configuration.fileCollection(closure);
        assertThat(fileCollection.getDependencySpec().isSatisfiedBy(HelperUtil.createDependency("group1", "name", "version")),
                equalTo(true));
        assertThat(fileCollection.getDependencySpec().isSatisfiedBy(HelperUtil.createDependency("group2", "name", "version")),
View Full Code Here

Examples of groovy.lang.Closure

    public void copyWithClosure() {
        prepareConfigurationForCopyTest();
        Set<Dependency> expectedDependenciesToCopy = new HashSet<Dependency>(configuration.getDependencies());
        configuration.addDependency(HelperUtil.createDependency("group3", "name3", "version3"));

        Closure specClosure = HelperUtil.toClosure("{ element ->  !element.group.equals(\"group3\")}");
        Configuration copiedConfiguration = configuration.copy(specClosure);

        assertThatCopiedConfigurationHasElementsAndName(copiedConfiguration, expectedDependenciesToCopy);
    }
View Full Code Here

Examples of groovy.lang.Closure

    public void copyRecursiveWithSpec() {
        prepareConfigurationForCopyRecursiveTest();
        Set<Dependency> expectedDependenciesToCopy = new HashSet<Dependency>(configuration.getAllDependencies());
        configuration.addDependency(HelperUtil.createDependency("group3", "name3", "version3"));

        Closure specClosure = HelperUtil.toClosure("{ element ->  !element.group.equals(\"group3\")}");
        Configuration copiedConfiguration = configuration.copyRecursive(specClosure);

        assertThatCopiedConfigurationHasElementsAndName(copiedConfiguration, expectedDependenciesToCopy);
    }
View Full Code Here

Examples of groovy.lang.Closure

    @Test
    public void eachObjectIsAvailableAsConfigureMethod() {
        Bean bean = new Bean();
        container.addObject("child", bean);

        Closure closure = toClosure("{ beanProperty = 'value' }");
        assertTrue(container.getAsDynamicObject().hasMethod("child", closure));
        container.getAsDynamicObject().invokeMethod("child", closure);
        assertThat(bean.getBeanProperty(), equalTo("value"));

        call("{ it.child { beanProperty = 'value 2' } }", container);
View Full Code Here

Examples of groovy.lang.Closure

    @Test
    public void addRuleByClosure() {
        String testPropertyKey = "org.gradle.test.addRuleByClosure";
        String expectedTaskName = "someTaskName";
        Closure ruleClosure = HelperUtil.toClosure(String.format("{ taskName -> System.setProperty('%s', '%s') }",
                testPropertyKey, expectedTaskName));
        container.addRule("description", ruleClosure);
        container.getRules().get(0).apply(expectedTaskName);
        assertThat(System.getProperty(testPropertyKey), equalTo(expectedTaskName));
        System.getProperties().remove(testPropertyKey);
View Full Code Here

Examples of loop.runtime.Closure

    }
  }

  private static void printResult(Object result) {
    if (result instanceof Closure) {
      Closure fun = (Closure) result;
      System.out.println("#function: " + fun.name);
    } else if (result instanceof Set) {
      String r = result.toString();
      System.out.println('{' + r.substring(1, r.length() - 1) + '}');
    }
View Full Code Here

Examples of lupos.engine.operators.singleinput.path.Closure

        // If there is a fixed subject or object, then we should consider it during evaluation!
        allowedSubjects = this.getSetOfLiterals(subjectNode);
        allowedObjects = this.getSetOfLiterals(objectNode);
      }

      final Closure closure = new Closure(subject, object, allowedSubjects, allowedObjects);
      startingOperator.addSucceedingOperator(new OperatorIDTuple(closure,0));

      final Item[] items = {subject,this.getVariable(subject.toString(),object.toString(),"predicate"),object};
      final TriplePattern tp = new TriplePattern(items);
      final LinkedList<TriplePattern> temp = new LinkedList<TriplePattern>();
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.