Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.EqualityExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.EQUALITY_EXPRESSION: {
        EqualityExpression equalityExpression = (EqualityExpression) theEObject;
        T result = caseEqualityExpression(equalityExpression);
        if(result == null)
          result = caseBinaryOpExpression(equalityExpression);
        if(result == null)
          result = caseBinaryExpression(equalityExpression);
View Full Code Here


    final PuppetManifest pp = pf.createPuppetManifest();
    final CollectExpression ce = pf.createCollectExpression();
    pp.getStatements().add(ce);

    ce.setClassReference(createNameOrReference("User"));
    EqualityExpression predicate = pf.createEqualityExpression();
    predicate.setLeftExpr(createNameOrReference("name"));
    predicate.setOpName("==");
    predicate.setRightExpr(createNameOrReference("Luke"));

    VirtualCollectQuery q = pf.createVirtualCollectQuery();
    q.setExpr(predicate);
    ce.setQuery(q);

    // -- add some attributes
    AttributeOperations aos = pf.createAttributeOperations();
    aos.getAttributes().add(createAttributeDefinition("role", "jedi"));
    aos.getAttributes().add(createAttributeAddition("tasks", "rakeleaves"));
    ce.setAttributes(aos);

    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Collect, s);

    // -- test exported query
    ExportedCollectQuery eq = pf.createExportedCollectQuery();
    eq.setExpr(predicate);
    ce.setQuery(eq);

    s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Collect_Exported, s);

    // -- test with more complex query
    // -- test non equality
    predicate.setOpName("!=");
    // -- test and / or
    AndExpression and = pf.createAndExpression();
    and.setLeftExpr(predicate);
    OrExpression or = pf.createOrExpression();

    EqualityExpression predicate2 = pf.createEqualityExpression();
    predicate2.setLeftExpr(createNameOrReference("name"));
    predicate2.setOpName("!=");
    predicate2.setRightExpr(createNameOrReference("Darth"));
    EqualityExpression predicate3 = pf.createEqualityExpression();
    predicate3.setLeftExpr(createNameOrReference("name"));
    predicate3.setOpName("!=");
    predicate3.setRightExpr(createNameOrReference("Vader"));
    or.setLeftExpr(predicate2);
    or.setRightExpr(predicate3);
    ParenthesisedExpression pe = pf.createParenthesisedExpression();
    pe.setExpr(or);
    and.setRightExpr(pe);
View Full Code Here

  public void test_Validate_Collect_Ok() {
    final PuppetManifest pp = pf.createPuppetManifest();
    final CollectExpression ce = pf.createCollectExpression();
    pp.getStatements().add(ce);
    ce.setClassReference(createNameOrReference("User"));
    EqualityExpression predicate = pf.createEqualityExpression();
    predicate.setLeftExpr(createNameOrReference("name"));
    predicate.setOpName("==");
    predicate.setRightExpr(createNameOrReference("Luke"));

    VirtualCollectQuery q = pf.createVirtualCollectQuery();
    q.setExpr(predicate);
    ce.setQuery(q);

    // -- test without attributes
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // -- add some attributes
    AttributeOperations aos = pf.createAttributeOperations();
    aos.getAttributes().add(createAttributeDefinition("x", "b"));
    aos.getAttributes().add(createAttributeAddition("y", "b"));
    ce.setAttributes(aos);
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // --test different class references
    ce.setClassReference(createNameOrReference("::User"));
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    ce.setClassReference(createNameOrReference("A::User::B"));
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // -- test exported query
    ExportedCollectQuery eq = pf.createExportedCollectQuery();
    eq.setExpr(predicate);
    ce.setQuery(eq);
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // -- test non equality
    predicate.setOpName("!=");
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // -- test and / or
    AndExpression and = pf.createAndExpression();
    and.setLeftExpr(predicate);
    OrExpression or = pf.createOrExpression();

    EqualityExpression predicate2 = pf.createEqualityExpression();
    predicate2.setLeftExpr(createNameOrReference("name"));
    predicate2.setOpName("!=");
    predicate2.setRightExpr(createNameOrReference("Darth"));
    EqualityExpression predicate3 = pf.createEqualityExpression();
    predicate3.setLeftExpr(createNameOrReference("name"));
    predicate3.setOpName("!=");
    predicate3.setRightExpr(createNameOrReference("Vader"));

    or.setLeftExpr(predicate2);
    or.setRightExpr(predicate3);
    ParenthesisedExpression pe = pf.createParenthesisedExpression();
    pe.setExpr(or);
View Full Code Here

    vn.setExported(true);
    r2.setResourceExpr(vn);

    CollectExpression ce = pf.createCollectExpression();
    ce.setClassReference(createNameOrReference("User"));
    EqualityExpression predicate = pf.createEqualityExpression();
    predicate.setLeftExpr(createNameOrReference("name"));
    predicate.setOpName("==");
    predicate.setRightExpr(createNameOrReference("Luke"));

    VirtualCollectQuery q = pf.createVirtualCollectQuery();
    q.setExpr(predicate);
    ce.setQuery(q);
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.pp.EqualityExpression

Copyright © 2018 www.massapicom. 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.