Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.CollectExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.COLLECT_EXPRESSION: {
        CollectExpression collectExpression = (CollectExpression) theEObject;
        T result = caseCollectExpression(collectExpression);
        if(result == null)
          result = caseExpression(collectExpression);
        if(result == null)
          result = defaultCase(theEObject);
View Full Code Here


      if(left instanceof LiteralNameOrReference)
        resourceTypeName = ((LiteralNameOrReference) left).getValue();
    }
    else if(resourceExpr instanceof CollectExpression) {
      resourceType = RESOURCE_IS_OVERRIDE;
      CollectExpression collect = (CollectExpression) resourceExpr;
      Expression classReference = collect.getClassReference();
      if(classReference instanceof LiteralNameOrReference)
        resourceTypeName = ((LiteralNameOrReference) classReference).getValue();
    }

    /*
 
View Full Code Here

  // @fmtOn

  @Test
  public void test_Serialize_CollectExpr() {
    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
View Full Code Here

  }

  @Test
  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("!=");
View Full Code Here

    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.CollectExpression

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.