Examples of PuppetManifest


Examples of com.puppetlabs.geppetto.pp.PuppetManifest

  }

  @Test
  public void test_Serialize_ResourceWithRequires() {
    // --with attribute definition
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    LiteralNameOrReference reqType = pf.createLiteralNameOrReference();
    reqType.setValue("Package");
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(reqType);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

  }

  @Test
  public void test_Serialize_TwoResources() throws Exception {
    // --with attribute definition
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    statements.add(createResourceExpression("file", "r1", "owner", "fred"));
    statements.add(createResourceExpression("file", "r2", "owner", "fred"));
    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_TwoResources, s);

    // --with attribute addition
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    statements.add(createResourceExpression(true, "File", "a resource", "owner", "fred"));
    s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_ResourceOneAddAttribute, s);
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

  }

  @Test
  public void test_Serialize_VirtualResource() {
    // --with attribute definition
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    ResourceExpression vr = createVirtualResourceExpression("file", "a resource", "owner", "fred");
    statements.add(vr);
    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_VirtualResource, s);

    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    vr = createVirtualExportedResourceExpression("file", "a resource", "owner", "fred");
    statements.add(vr);
    s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_VirtualResourceExported, s);
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

   */
  @Test
  public void test_Validate_DefaultResourceNotOk() {

    // -- multiple bodies
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    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"));
    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"));
    statements.add(re);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

      AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_MULTIPLE_BODIES));
  }

  @Test
  public void test_Validate_DefaultResourceOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    ResourceExpression re = createResourceExpression(
      "File", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    statements.add(re);
    tester.validator().checkResourceExpression(re);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

  @Test
  public void test_Validate_Override_NotOk() {
    // -- states where the at expression is ok

    // -- multiple bodies
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    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);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

   * - at expression with NameOrReference as left expression
   * - at least one parameter in the at expression
   */
  @Test
  public void test_Validate_Override_ok() {
    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());
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

   */
  @Test
  public void test_Validate_RegularResourceNotOk() {

    // -- missing title
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    ResourceExpression re = createResourceExpression(
      "file", NOTITLE, "owner", createValue("0777"), "group", createValue("0666"), "other", createValue("0555"));
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertError(IPPDiagnostics.ISSUE__RESOURCE_WITHOUT_TITLE);

    // -- additive statements
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      true, "file", "title", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    // error will occur as many times as there are additions,so check using "any"
    tester.diagnose().assertAny(AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__RESOURCE_WITH_ADDITIONS));

    // -- non conforming resource expression
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      false, "file", "title", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    statements.add(re);
    re.setResourceExpr(pf.createLiteralDefault());
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

   */
  @Test
  public void test_Validate_RegularResourceOk() {

    // -- Resource with a couple of attribute definitions
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    ResourceExpression re = createResourceExpression(
      "file", "a resource", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertOK();

    // --Resource with empty body
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression("file", "a resource");
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertOK();

    // --Resource with multiple bodies
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "file", "a resource", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    re.getResourceData().add(createResourceBody("another resource", "a", "1", "b", "2", "c", "3"));
    statements.add(re);
    tester.validator().checkResourceExpression(re);
    tester.diagnose().assertOK();

    // --Resource with multiple bodies, one (in the middle) being empty
    pp = pf.createPuppetManifest();
    statements = pp.getStatements();
    re = createResourceExpression(
      "file", "a resource", "owner", createValue("0777"), "group", createValue("0666"), "other",
      createValue("0555"));
    re.getResourceData().add(createResourceBody("another resource1"));
    re.getResourceData().add(createResourceBody("another resource2", "a", "1", "b", "2", "c", "3"));
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.PuppetManifest

  }

  @Test
  public void test_Validate_ResourceWithRequires() {
    // --with attribute definition
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();

    LiteralNameOrReference reqType = pf.createLiteralNameOrReference();
    reqType.setValue("Package");
    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(reqType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.