Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.VariableExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.VARIABLE_EXPRESSION: {
        VariableExpression variableExpression = (VariableExpression) theEObject;
        T result = caseVariableExpression(variableExpression);
        if(result == null)
          result = caseExpression(variableExpression);
        if(result == null)
          result = defaultCase(theEObject);
View Full Code Here


  @Test
  public void test_Serialize_fromModel() throws Exception {
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    VariableExpression var = pf.createVariableExpression();
    var.setVarName("$a");
    statements.add(var);

    String s = serialize(pp);
    assertEquals("serialization should produce same result", "$a\n", s);
  }
View Full Code Here

      LiteralNameOrReference titleExpr = pf.createLiteralNameOrReference();
      titleExpr.setValue("test");
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- variable
      VariableExpression titleExpr = pf.createVariableExpression();
      titleExpr.setVarName("$test");
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- literal list
      LiteralList titleExpr = pf.createLiteralList();
      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

  public void test_Serialize_AppendExpression() {
    PuppetManifest pp = pf.createPuppetManifest();
    AppendExpression ae = pf.createAppendExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    b.setValue(true);
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    String s = serializeFormatted(pp);
View Full Code Here

  public void test_Serialize_AssignmentExpression() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression ae = pf.createAssignmentExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    b.setValue(true);
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    String s = serializeFormatted(pp);
View Full Code Here

  public void test_Serialize_MatchingExpression() {
    PuppetManifest pp = pf.createPuppetManifest();
    MatchingExpression me = pf.createMatchingExpression();
    LiteralRegex regex = pf.createLiteralRegex();
    regex.setValue("/[a-z]*/");
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    me.setLeftExpr(v);
    me.setOpName("=~");
    me.setRightExpr(regex);
    pp.getStatements().add(me);

View Full Code Here

    PuppetManifest pp = pf.createPuppetManifest();
    AppendExpression ae = pf.createAppendExpression();
    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);
View Full Code Here

  @Test
  public void test_Validate_AppendExpression_NotOk_Decimal() {
    PuppetManifest pp = pf.createPuppetManifest();
    AppendExpression ae = pf.createAppendExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$0");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

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

  @Test
  public void test_Validate_AppendExpression_NotOk_Scope() {
    PuppetManifest pp = pf.createPuppetManifest();
    AppendExpression ae = pf.createAppendExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$a::b");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

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

  @Test
  public void test_Validate_AppendExpression_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    AppendExpression ae = pf.createAppendExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertOK();
View Full Code Here

TOP

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

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.