Package org.sonar.api.batch.fs

Examples of org.sonar.api.batch.fs.FilePredicate


  @Rule
  public TemporaryFolder temp = new TemporaryFolder();

  @Test
  public void key() throws Exception {
    FilePredicate predicate = new AdditionalFilePredicates.KeyPredicate("struts:Action.java");

    DefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "Action.java");
    assertThat(predicate.apply(inputFile)).isTrue();

    inputFile = new DeprecatedDefaultInputFile("struts", "Filter.java");
    assertThat(predicate.apply(inputFile)).isFalse();
  }
View Full Code Here


    assertThat(predicate.apply(inputFile)).isFalse();
  }

  @Test
  public void deprecated_key() throws Exception {
    FilePredicate predicate = new AdditionalFilePredicates.DeprecatedKeyPredicate("struts:Action.java");

    DeprecatedDefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "Action.java").setDeprecatedKey("struts:Action.java");
    assertThat(predicate.apply(inputFile)).isTrue();

    inputFile = new DeprecatedDefaultInputFile("struts", "Filter.java").setDeprecatedKey("struts:Filter.java");
    assertThat(predicate.apply(inputFile)).isFalse();
  }
View Full Code Here

  }

  @Test
  public void absolute_path_of_source_dir() throws Exception {
    File dir = temp.newFolder();
    FilePredicate predicate = new AdditionalFilePredicates.SourceDirPredicate(dir.getAbsolutePath());

    DeprecatedDefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "Action.java").setSourceDirAbsolutePath(dir.getAbsolutePath());
    assertThat(predicate.apply(inputFile)).isTrue();

    inputFile = new DeprecatedDefaultInputFile("struts", "Filter.java").setSourceDirAbsolutePath(temp.newFolder().getAbsolutePath());
    assertThat(predicate.apply(inputFile)).isFalse();
  }
View Full Code Here

    assertThat(predicate.apply(inputFile)).isFalse();
  }

  @Test
  public void path_relative_to_source_dir() throws Exception {
    FilePredicate predicate = new AdditionalFilePredicates.SourceRelativePathPredicate("foo/Bar.php");

    DeprecatedDefaultInputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/php/foo/Bar.php").setPathRelativeToSourceDir("foo/Bar.php");
    assertThat(predicate.apply(inputFile)).isTrue();

    inputFile = new DeprecatedDefaultInputFile("foo", "foo/Bar.php").setPathRelativeToSourceDir("Bar.php");
    assertThat(predicate.apply(inputFile)).isFalse();
  }
View Full Code Here

    return true;
  }

  private boolean fsCondition(DefaultSensorDescriptor descriptor) {
    if (!descriptor.languages().isEmpty() || !descriptor.types().isEmpty()) {
      FilePredicate langPredicate = descriptor.languages().isEmpty() ? fs.predicates().all() : fs.predicates().hasLanguages(descriptor.languages());

      FilePredicate typePredicate = descriptor.types().isEmpty() ? fs.predicates().all() : fs.predicates().none();
      for (InputFile.Type type : descriptor.types()) {
        typePredicate = fs.predicates().or(
          typePredicate,
          fs.predicates().hasType(type));
      }
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.fs.FilePredicate

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.