Package com.puppetlabs.geppetto.validation

Examples of com.puppetlabs.geppetto.validation.ValidationService


  }

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


  }

  @Test
  public void validateCiruclarRepositories() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/circularModules/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();

    // Set options like API1 would behave for a validateRepository
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(false);
    options.setFileType(FileType.PUPPET_ROOT);
    options.setProblemsAdvisor(new DefaultPotentialProblemsAdvisor());

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

    int circularity = 0;
    int otherErrors = 0;

    for(Diagnostic e : chain)
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.validateManifest(chain, manifest, 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.validateManifest(chain, manifest, 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.validateRepository(chain, root, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    asserter.assertErrors(asserter.issue("jruby.syntax.error"));
    // 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

  }

  @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.validateRepository(chain, root, SubMonitor.convert(null));
    DiagnosticsAsserter asserter = new DiagnosticsAsserter(chain);
    // no errors
    asserter.assertErrors();
    // optionally accept Unknown variables, and hyphen in name, but no other warnings
    asserter.assertWarnings(
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.validateRepository(chain, root, SubMonitor.convert(null));
    assertNotEquals("There should be errors", 0, chain.getChildren().size());
    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();

    // Set options like API1 would behave for a validateRepository
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(false);
    options.setCheckReferences(false);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    assertNotEquals("There should be  errors", 0, chain.getChildren().size());
    Set<String> fileNames = Sets.newHashSet();
    for(Diagnostic d : chain) {
      if("This is not a boolean".equals(d.getMessage()))
        continue; // skip this error (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();

    // Set options like API1 would behave for a validateRepository
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(false);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validate(chain, root, options, 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 validateSeveralRepositories_ok() throws Exception {
    File root = TestDataProvider.getTestFile(new Path("testData/test-modules/"));
    ValidationService vs = getValidationService();
    Diagnostic chain = new Diagnostic();

    // Set options like API1 would behave for a validateRepository
    ValidationOptions options = getValidationOptions();
    options.setCheckLayout(true);
    options.setCheckModuleSemantics(true);
    options.setCheckReferences(false);
    options.setFileType(FileType.PUPPET_ROOT);

    vs.validate(chain, root, options, null, SubMonitor.convert(null));
    int hyphenWarning = 0;
    for(Diagnostic e : chain)
      if(IPPDiagnostics.ISSUE__INTERPOLATED_HYPHEN.equals(e.getIssue()) ||
          IPPDiagnostics.ISSUE__HYPHEN_IN_NAME.equals(e.getIssue()))
        hyphenWarning++;
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.