Package com.puppetlabs.geppetto.validation

Examples of com.puppetlabs.geppetto.validation.ValidationService


   * cfunc.
   */
  @Test
  public void validateDuplicateRoleDifferentEnv() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles3/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    options.setSearchPath("modules/*:roles/production/*");
    BuildResult buildResult = vs.validate(chain, root, options, null, SubMonitor.convert(null));

    // Without constraint that only things on path are validated - there should be two redefinition errors
    //
    assertEquals("There should be no errors", 0, countErrors(chain));
    AllModuleReferences exports = buildResult.getAllModuleReferences();
View Full Code Here


   * Use a path that reveals two versions of the role X.
   */
  @Test
  public void validateDuplicateRoleDuplicateRole() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles3/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    // options.setSearchPath("modules/*:roles/production/*");
    vs.validate(chain, root, options, null, SubMonitor.convert(null));

    // Without constraint that only things on path are validated - there should be two redefinition errors
    //
    List<Diagnostic> children = chain.getChildren();
    int count = 0;
View Full Code Here

   * cfunc.
   */
  @Test
  public void validateNodes() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    BuildResult buildResult = vs.validate(chain, root, options, null, SubMonitor.convert(null));
    AllModuleReferences exports = buildResult.getAllModuleReferences();

    Iterable<Export> visibleExports = exports.getVisibleExports(new File("roles/X"));
    Export exporteda = exports.findExportedClass("aclass", visibleExports);
    assertNotNull("Should have found exported 'aclass'", exporteda);
View Full Code Here

   * cfunc.
   */
  @Test
  public void validateNodes2() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testRoles2/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);
    BuildResult buildResult = vs.validate(chain, root, options, null, SubMonitor.convert(null));
    AllModuleReferences exports = buildResult.getAllModuleReferences();
    // dumpExports(exports);

    Iterable<Export> visibleExports = exports.getVisibleExports(new File("roles/X"));
    Export exporteda = exports.findExportedClass("aclass", visibleExports);
View Full Code Here

  }

  @Test
  public void relativeAmbiguityErrorReport() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/ambiguity/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(false);
    options.setCheckModuleSemantics(false);
    options.setCheckReferences(true);
    options.setFileType(FileType.MODULE_ROOT);

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__RESOURCE_AMBIGUOUS_REFERENCE);
    assertTrue(
      "Message text should contain a relative reference",
      chain.getChildren().get(0).getMessage().startsWith("Ambiguous reference to: 'fluff' found in: 1 resource [") &&
          chain.getChildren().get(0).getMessage().contains("manifests/ambigA.pp"));
View Full Code Here

  }

  @Test
  public void validateAString_NotOk() throws Exception {
    String code = "$a = ";
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, code, SubMonitor.convert(null));
    assertTrue("There should be errors", countErrors(chain) != 0);
  }
View Full Code Here

  }

  @Test
  public void validateAString_ok() throws Exception {
    String code = "$a = 'a::b'";
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, code, SubMonitor.convert(null));
    assertTrue("There should be no errors", countErrors(chain) == 0);
  }
View Full Code Here

  }

  @Test
  public void validateManifest_notok() throws Exception {
    File manifest = TestDataProvider.getTestFile(new Path("testData/manifests/not_ok_manifest.pp"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, manifest, null, null, SubMonitor.convert(null));
    assertTrue("There should be errors", countErrors(chain) != 0);
  }
View Full Code Here

  }

  @Test
  public void validateManifest_ok() throws Exception {
    File manifest = TestDataProvider.getTestFile(new Path("testData/manifests/ok_manifest.pp"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, manifest, null, null, SubMonitor.convert(null));
    assertTrue("There should be no errors", countErrors(chain) == 0);
  }
View Full Code Here

  }

  @Test
  public void validateModule_notok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/broken/broken-module/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, root, null, null, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertErrors(asserter.messageFragment("unexpected tIDENTIFIER"));
    // optionally accept Unknown variables, and hyphen in name, but no other warnings
    asserter.assertWarnings(
      asserter.issue(IPPDiagnostics.ISSUE__UNKNOWN_VARIABLE).optional().greedy(),
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.validation.ValidationService

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.