Package com.puppetlabs.geppetto.validation

Examples of com.puppetlabs.geppetto.validation.ValidationService


  }

  @Test
  public void validateModule_ok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/test-modules/test-module/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, root, null, null, SubMonitor.convert(null));

    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    // no errors
    asserter.assertErrors();
    // optionally accept Unknown variables, and hyphen in name, but no other warnings
View Full Code Here


  }

  @Test
  public void validateModuleWithSpaces_notok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/broken withSpaces/module"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, root, null, null, SubMonitor.convert(null));
    assertNotEquals("There should be errors", 0, countErrors(chain));
    for(Diagnostic d : chain)
      if(d instanceof FileDiagnostic) {
        File f = ((FileDiagnostic) d).getFile();
        assertEquals(
View Full Code Here

  }

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

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertNotEquals("There should be  errors", 0, countErrors(chain));
    Set<String> fileNames = Sets.newHashSet();
    for(Diagnostic d : chain) {
      if("This is not a boolean".equals(d.getMessage()))
        continue; // skip this (UGLY)
View Full Code Here

  }

  @Test
  public void validateRepository_ok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/forgeModules/lab42-activemq-0.1.2/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, root, null, null, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertAll(asserter.issue(IPPDiagnostics.ISSUE__STRING_BOOLEAN).optional().greedy());
  }
View Full Code Here

  }

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

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertNotEquals("There should be  errors", 0, countErrors(chain));
    Set<String> fileNames = Sets.newHashSet();
    for(Diagnostic d : chain)
      if(d instanceof FileDiagnostic && d.getSeverity() >= Diagnostic.ERROR)
        fileNames.add(((FileDiagnostic) d).getFile().getPath());
View Full Code Here

  }

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

    vs.validate(chain, root, options, new File[] { new File(root, "moduleB/") }, SubMonitor.convert(null));
    assertEquals("There should be no errors", 0, countErrors(chain));

  }
View Full Code Here

  }

  @Test
  public void validateSeveralRepositories_ok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/test-modules/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    vs.validate(chain, root, null, null, SubMonitor.convert(null));

    int hyphenWarning = 0;
    int otherIssues = 0;
    for(Diagnostic e : chain)
      if(IPPDiagnostics.ISSUE__INTERPOLATED_HYPHEN.equals(e.getIssue()) ||
View Full Code Here

  }

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

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__MISSING_COMMA);

    // Same but using a repository layout
    root = TestDataProvider.getTestFile(new Path("testData/ghbindcases/asrepo/"));
    vs = getValidationService();
    chain = new Diagnostic();
    options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__MISSING_COMMA);

    // Use API1 call to do the same as repository layout validation above
    vs = getValidationService();
    chain = new Diagnostic();
    options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validateRepository(chain, root, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__MISSING_COMMA);

    // just the manifest
    root = TestDataProvider.getTestFile(new Path(
      "testData/ghbindcases/asmodule/ghoneycutt-bind-1.0.0/manifests/master.pp"));

    vs = getValidationService();
    chain = new Diagnostic();
    options = getValidationOptions();
    options.setCheckLayout(false);
    options.setCheckModuleSemantics(false);
    options.setCheckReferences(false);
    options.setFileType(FileType.SINGLE_SOURCE_FILE);

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__MISSING_COMMA);

    // Validate single file in context of repo
    root = TestDataProvider.getTestFile(new Path("testData/ghbindcases/asrepo/"));
    vs = getValidationService();
    chain = new Diagnostic();
    options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validate(chain, root, options, new File[] { new File(
      root, "modules/ghoneycutt-bind-1.0.0/manifests/master.pp") }, SubMonitor.convert(null));
    assertContainsErrorCode(chain, IPPDiagnostics.ISSUE__MISSING_COMMA);
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertErrors(//
      asserter.messageFragment("Unknown class: 'generic'"), //
View Full Code Here

   * cfunc.
   */
  @Test
  public void pptpOptionHandling() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/testFor2_7_1/"));
    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.setPlatformURI(PuppetTarget.PUPPET26.getPlatformURI());
    vs.validate(chain, root, options, null, SubMonitor.convert(null));

    assertEquals("There should be 1 errors", 1, chain.getChildren().size());

    chain = new Diagnostic();
    options.setPlatformURI(PuppetTarget.PUPPET27.getPlatformURI());
    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    dumpErrors(chain);
    assertEquals("There should be 0 errors", 0, chain.getChildren().size());

  }
View Full Code Here

public class TestDependencyGraph extends AbstractValidationTest {
  @Test
  public void demoDependencyGraph() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/test-modules/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(true);
    options.setFileType(FileType.PUPPET_ROOT);

    // Write the dot to a file:
    File outputFolder = TestDataProvider.getTestOutputDir();
    FileOutputStream dotStream = new FileOutputStream(new File(outputFolder, "demoGraphSVG.dot"));

    BuildResult buildResult = vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertTrue("Validation had errors", chain.getSeverity() < Diagnostic.ERROR);
    getDependencyGraphProducer().produceGraph(
      null, "Demo DefaultModules Dependencies", null, dotStream, buildResult, chain);

    // produce SVG
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.