Package org.sonar.api.batch.fs.internal

Examples of org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile


  @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

  @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

  @Test
  public void no_filters() throws Exception {
    DeprecatedFileFilters filters = new DeprecatedFileFilters();

    InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java").setFile(temp.newFile());
    assertThat(filters.accept(inputFile)).isTrue();
  }
View Full Code Here

  public void at_least_one_filter() throws Exception {
    DeprecatedFileFilters filters = new DeprecatedFileFilters(new FileSystemFilter[] {filter});

    File basedir = temp.newFolder();
    File file = temp.newFile();
    InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java")
      .setSourceDirAbsolutePath(new File(basedir, "src/main/java").getAbsolutePath())
      .setPathRelativeToSourceDir("Foo.java")
      .setFile(file)
      .setType(InputFile.Type.MAIN);
    when(filter.accept(eq(file), any(DeprecatedFileFilters.DeprecatedContext.class))).thenReturn(false);
View Full Code Here

    when(statusDetection.status("foo", "src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
      .thenReturn(InputFile.Status.ADDED);

    InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
      langDetection, statusDetection, fs, analysisMode);
    DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
    inputFile = builder.complete(inputFile, InputFile.Type.MAIN);

    assertThat(inputFile.type()).isEqualTo(InputFile.Type.MAIN);
    assertThat(inputFile.file()).isEqualTo(srcFile.getAbsoluteFile());
    assertThat(inputFile.absolutePath()).isEqualTo(PathUtils.sanitize(srcFile.getAbsolutePath()));
    assertThat(inputFile.language()).isEqualTo("java");
    assertThat(inputFile.key()).isEqualTo("struts:src/main/java/foo/Bar.java");
    assertThat(inputFile.relativePath()).isEqualTo("src/main/java/foo/Bar.java");
    assertThat(inputFile.lines()).isEqualTo(1);
    assertThat(inputFile.sourceDirAbsolutePath()).isNull();
    assertThat(inputFile.pathRelativeToSourceDir()).isNull();
    assertThat(inputFile.deprecatedKey()).isNull();
  }
View Full Code Here

    FileUtils.touch(srcFile);
    when(fs.baseDir()).thenReturn(basedir);

    InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
      langDetection, statusDetection, fs, analysisMode);
    DeprecatedDefaultInputFile inputFile = builder.create(srcFile);

    assertThat(inputFile).isNull();
  }
View Full Code Here

    // lang
    when(langDetection.language(any(InputFile.class))).thenReturn(null);

    InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
      langDetection, statusDetection, fs, analysisMode);
    DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
    inputFile = builder.complete(inputFile, InputFile.Type.MAIN);

    assertThat(inputFile).isNull();
  }
View Full Code Here

    when(statusDetection.status("foo", "src/main/java/foo/Bar.java", "6c1d64c0b3555892fe7273e954f6fb5a"))
      .thenReturn(InputFile.Status.ADDED);

    InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
      langDetection, statusDetection, fs, analysisMode);
    DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
    inputFile = builder.complete(inputFile, InputFile.Type.MAIN);

    assertThat(inputFile.pathRelativeToSourceDir()).isEqualTo("foo/Bar.java");
    assertThat(inputFile.sourceDirAbsolutePath()).isEqualTo(PathUtils.sanitize(sourceDir.getAbsolutePath()));
    assertThat(inputFile.deprecatedKey()).isEqualTo("struts:foo.Bar");
  }
View Full Code Here

    when(statusDetection.status("foo", "src/Bar.php", "6c1d64c0b3555892fe7273e954f6fb5a"))
      .thenReturn(InputFile.Status.ADDED);

    InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
      langDetection, statusDetection, fs, analysisMode);
    DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
    inputFile = builder.complete(inputFile, InputFile.Type.MAIN);

    assertThat(inputFile.pathRelativeToSourceDir()).isEqualTo("foo/Bar.php");
    assertThat(inputFile.sourceDirAbsolutePath()).isEqualTo(PathUtils.sanitize(sourceDir.getAbsolutePath()));
    assertThat(inputFile.deprecatedKey()).isEqualTo("struts:foo/Bar.php");

  }
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile

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.