Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.AtExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.AT_EXPRESSION: {
        AtExpression atExpression = (AtExpression) theEObject;
        T result = caseAtExpression(atExpression);
        if(result == null)
          result = caseParameterizedExpression(atExpression);
        if(result == null)
          result = caseExpression(atExpression);
View Full Code Here


        resourceType = RESOURCE_IS_REGULAR;
      // else the resource is BAD
    }
    else if(resourceExpr instanceof AtExpression) {
      resourceType = RESOURCE_IS_OVERRIDE;
      AtExpression at = (AtExpression) resourceExpr;
      Expression left = at.getLeftExpr();
      if(left instanceof LiteralNameOrReference)
        resourceTypeName = ((LiteralNameOrReference) left).getValue();
    }
    else if(resourceExpr instanceof CollectExpression) {
      resourceType = RESOURCE_IS_OVERRIDE;
View Full Code Here

    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    LiteralNameOrReference reqType = pf.createLiteralNameOrReference();
    reqType.setValue("Package");
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(reqType);
    at.getParameters().add(createSqString("a"));
    at.getParameters().add(createSqString("b"));
    at.getParameters().add(createSqString("c"));

    ResourceExpression vr = createResourceExpression("file", "x", "require", at);
    statements.add(vr);
    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_ResourceWithRequire, s);
View Full Code Here

    ResourceExpression re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    re.getResourceData().add(createResourceBody(null, "a", "1", "b", "2", "c", "3"));
    // swap the created LiteralNameOrReference for an AtExpression
    AtExpression reRef = pf.createAtExpression();
    reRef.setLeftExpr(re.getResourceExpr());
    re.setResourceExpr(reRef);
    // add a parameter (use of a default here is just because it requires no further value setting :)
    reRef.getParameters().add(pf.createLiteralDefault());

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_MULTIPLE_BODIES);

    // -- bodies with titles
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "File", "title in error", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    re.getResourceData().add(createResourceBody(null, "a", "1", "b", "2", "c", "3"));
    // swap the created LiteralNameOrReference for an AtExpression
    reRef = pf.createAtExpression();
    reRef.setLeftExpr(re.getResourceExpr());
    re.setResourceExpr(reRef);
    // add a parameter (use of a default here is just because it requires no further value setting :)
    reRef.getParameters().add(pf.createLiteralDefault());

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertAll(
      AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_WITH_TITLE),
      AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_MULTIPLE_BODIES));

    // -- states where the at expression is wrong

    // -- at expression has no parameters
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    // swap the created LiteralNameOrReference for an AtExpression
    reRef = pf.createAtExpression();
    reRef.setLeftExpr(re.getResourceExpr());
    re.setResourceExpr(reRef);

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.validator().checkAtExpression(reRef);
    tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_REFERENCE_NO_PARAMETERS);

    // -- at expression left is not a NameOrReference
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    // swap the created LiteralNameOrReference for an AtExpression with faulty leftExpr
    reRef = pf.createAtExpression();
    reRef.setLeftExpr(pf.createLiteralDefault());
    re.setResourceExpr(reRef);
    // add a parameter (use of a default here is just because it requires no further value setting :)
    reRef.getParameters().add(pf.createLiteralDefault());

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.validator().checkAtExpression(reRef);
    tester.diagnose().assertError(IPPDiagnostics.ISSUE__NOT_CLASSREF);

    // -- at expression left is null
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    // swap the created LiteralNameOrReference for an AtExpression with faulty leftExpr
    reRef = pf.createAtExpression();
    reRef.setLeftExpr(null);
    re.setResourceExpr(reRef);
    // add a parameter (use of a default here is just because it requires no further value setting :)
    reRef.getParameters().add(pf.createLiteralDefault());

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.validator().checkAtExpression(reRef);
    tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_REFERENCE_NO_REFERENCE);
View Full Code Here

    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    ResourceExpression re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    // swap the created LiteralNameOrReference for an AtExpression
    AtExpression reRef = pf.createAtExpression();
    reRef.setLeftExpr(re.getResourceExpr());
    re.setResourceExpr(reRef);
    // add a parameter (use of a default here is just because it requires no further value setting :)
    reRef.getParameters().add(pf.createLiteralDefault());

    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertOK();

    // add a second parameter and revalidate
    reRef.getParameters().add(pf.createLiteralDefault());
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertOK();

  }
View Full Code Here

    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    LiteralNameOrReference reqType = pf.createLiteralNameOrReference();
    reqType.setValue("Package");
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(reqType);
    at.getParameters().add(createNameOrReference("a"));
    at.getParameters().add(createNameOrReference("b"));
    at.getParameters().add(createNameOrReference("c"));

    ResourceExpression re = createResourceExpression("file", "x", "require", at);
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.validator().checkAtExpression(at);
View Full Code Here

      titleExpr.getElements().add(this.createNameOrReference("a"));
      titleExpr.getElements().add(this.createNameOrReference("b"));
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- hasharray access
      AtExpression titleExpr = pf.createAtExpression();
      titleExpr.setLeftExpr(createNameOrReference("Foo"));
      titleExpr.getParameters().add(createNameOrReference("a"));
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- selector
      SelectorExpression titleExpr = pf.createSelectorExpression();
      SelectorEntry entry = pf.createSelectorEntry();
      titleExpr.getParameters().add(entry);

      SingleQuotedString slhs = pf.createSingleQuotedString();
      slhs.setText("\'x\'");
      LiteralName entrylhs = pf.createLiteralName();
      entrylhs.setValue("a");

      titleExpr.setLeftExpr(slhs);
      entry.setLeftExpr(entrylhs);
      entry.setRightExpr(pf.createLiteralBoolean());
      subTestValidateExpressionTitles(titleExpr);
    }
  }
View Full Code Here

    pp.getStatements().add(ae);

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

    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(v);
    at.getParameters().add(createNameOrReference("a"));
    ae.setLeftExpr(at);
    tester.validate(pp).assertOK();
    s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Assignment2, s);
  }
View Full Code Here

    pp.getStatements().add(ae);

    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(v);
    at.getParameters().add(createNameOrReference("a"));

    ae.setLeftExpr(at);
    ae.setRightExpr(b);

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

    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertOK();

    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(v);
    at.getParameters().add(createNameOrReference("a"));
    ae.setLeftExpr(at);
    tester.validate(pp).assertOK();
  }
View Full Code Here

TOP

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

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.