Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.RelationshipExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.RELATIONSHIP_EXPRESSION: {
        RelationshipExpression relationshipExpression = (RelationshipExpression) theEObject;
        T result = caseRelationshipExpression(relationshipExpression);
        if(result == null)
          result = caseBinaryOpExpression(relationshipExpression);
        if(result == null)
          result = caseBinaryExpression(relationshipExpression);
View Full Code Here


  public void test_Serialize_RelationshipExpression() {
    // -- serialize file { 'file1': } -> file{'file2': } -> file{'file3' : }
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    RelationshipExpression rel1 = pf.createRelationshipExpression();
    RelationshipExpression rel2 = pf.createRelationshipExpression();
    ResourceExpression r1 = createResourceExpression("file", "file1");
    ResourceExpression r2 = createResourceExpression("file", "file2");
    ResourceExpression r3 = createResourceExpression("file", "file3");

    rel1.setOpName("->");
    rel1.setLeftExpr(r1);
    rel1.setRightExpr(r2);
    rel2.setOpName("->");
    rel2.setLeftExpr(rel1);
    rel2.setRightExpr(r3);

    statements.add(rel2);

    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Relationship, s);
View Full Code Here

  @Test
  public void test_Validate_RelationshipExpression_NotOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    // -- check file { 'file1': } -> file{'file2': } -> file{'file3' : }
    RelationshipExpression rel1 = pf.createRelationshipExpression();
    pp.getStatements().add(rel1);

    ResourceExpression r1 = createResourceExpression("file", "file1");
    LiteralNameOrReference r2 = createNameOrReference("a");

    rel1.setOpName("->");
    rel1.setLeftExpr(r1);
    rel1.setRightExpr(r2);

    tester.validate(pp).assertError(IPPDiagnostics.ISSUE__UNSUPPORTED_EXPRESSION);
  }
View Full Code Here

   */
  @Test
  public void test_Validate_RelationshipExpression_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    // -- check file { 'file1': } -> file{'file2': } -> file{'file3' : }
    RelationshipExpression rel1 = pf.createRelationshipExpression();
    RelationshipExpression rel2 = pf.createRelationshipExpression();
    pp.getStatements().add(rel2);
    ResourceExpression r1 = createResourceExpression("file", "'file1'");
    ResourceExpression r2 = createResourceExpression("file", "'file2'");
    ResourceExpression r3 = createResourceExpression("file", "'file3'");

    rel1.setOpName("->");
    rel1.setLeftExpr(r1);
    rel1.setRightExpr(r2);
    rel2.setOpName("->");
    rel2.setLeftExpr(rel1);
    rel2.setRightExpr(r3);

    tester.validator().checkRelationshipExpression(rel2);
    tester.diagnose().assertOK();

    // -- check the other operators
    rel2.setOpName("<-");
    tester.validator().checkRelationshipExpression(rel2);
    tester.diagnose().assertOK();

    rel2.setOpName("<~");
    tester.validator().checkRelationshipExpression(rel2);
    tester.diagnose().assertOK();

    rel2.setOpName("~>");
    tester.validator().checkRelationshipExpression(rel2);
    tester.diagnose().assertOK();

    // -- check the other possible left/right expressions
    // - virtual
    // - resource reference
    // - collect expression
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(createNameOrReference("x"));
    at.getParameters().add(createNameOrReference("a"));
    r1.setResourceExpr(at); // resource reference

    VirtualNameOrReference vn = pf.createVirtualNameOrReference();
    vn.setValue("y");
    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);

    rel2.setRightExpr(ce);

    tester.validator().checkRelationshipExpression(rel2);
    tester.diagnose().assertOK();

  }
View Full Code Here

TOP

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

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.