use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class ProjectCoverageExclusionsTest method shouldNotExcludeFileDuplicationBasedOnPattern.
@Test
public void shouldNotExcludeFileDuplicationBasedOnPattern() {
DefaultInputFile file = TestInputFileBuilder.create("foo", new File(baseDir, "moduleA"), new File(baseDir, "moduleA/src/org/polop/File.php")).setProjectBaseDir(baseDir.toPath()).build();
underTest = new ProjectCoverageAndDuplicationExclusions(mockConfig("", "moduleA/src/org/other/*"));
assertThat(underTest.isExcludedForCoverage(file)).isFalse();
assertThat(underTest.isExcludedForDuplication(file)).isFalse();
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class ProjectCoverageExclusionsTest method shouldNotExcludeFileCoverageBasedOnPattern.
@Test
public void shouldNotExcludeFileCoverageBasedOnPattern() {
DefaultInputFile file = TestInputFileBuilder.create("foo", new File(baseDir, "moduleA"), new File(baseDir, "moduleA/src/org/polop/File.php")).setProjectBaseDir(baseDir.toPath()).build();
underTest = new ProjectCoverageAndDuplicationExclusions(mockConfig("moduleA/src/org/other/*", ""));
assertThat(underTest.isExcludedForCoverage(file)).isFalse();
assertThat(underTest.isExcludedForDuplication(file)).isFalse();
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class ProjectCoverageExclusionsTest method shouldExcludeFileCoverageBasedOnPattern.
@Test
public void shouldExcludeFileCoverageBasedOnPattern() {
DefaultInputFile file = TestInputFileBuilder.create("foo", new File(baseDir, "moduleA"), new File(baseDir, "moduleA/src/org/polop/File.php")).setProjectBaseDir(baseDir.toPath()).build();
underTest = new ProjectCoverageAndDuplicationExclusions(mockConfig("moduleA/src/org/polop/*", ""));
assertThat(underTest.isExcludedForCoverage(file)).isTrue();
assertThat(underTest.isExcludedForDuplication(file)).isFalse();
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class BranchMediumTest method shouldNotSkipSensorForUnchangedFilesOnBranch.
@Test
public void shouldNotSkipSensorForUnchangedFilesOnBranch() throws Exception {
AnalysisResult result = getResult(tester.setBranchName("myBranch").setBranchTarget("master").setBranchType(BranchType.BRANCH));
final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH);
List<ScannerReport.Issue> issues = result.issuesFor(file);
assertThat(issues).isNotEmpty();
assertThat(logTester.logs()).doesNotContain(ONE_ISSUE_PER_LINE_IS_RESTRICTED_TO_CHANGED_FILES_ONLY);
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class BranchMediumTest method should_not_skip_report_for_unchanged_files_in_pr.
@Test
public void should_not_skip_report_for_unchanged_files_in_pr() {
// sanity check, normally report gets generated
AnalysisResult result = getResult(tester);
final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH);
assertThat(getResult(tester).getReportComponent(file)).isNotNull();
int fileId = file.scannerId();
assertThat(result.getReportReader().readChangesets(fileId)).isNotNull();
assertThat(result.getReportReader().hasCoverage(fileId)).isTrue();
assertThat(result.getReportReader().readFileSource(fileId)).isNotNull();
// file is not skipped for pull requests (need coverage, duplications coming soon)
AnalysisResult result2 = getResult(tester.setBranchType(BranchType.PULL_REQUEST));
final DefaultInputFile fileInPr = (DefaultInputFile) result2.inputFile(FILE_PATH);
assertThat(result2.getReportComponent(fileInPr)).isNotNull();
fileId = fileInPr.scannerId();
assertThat(result2.getReportReader().readChangesets(fileId)).isNull();
assertThat(result2.getReportReader().hasCoverage(fileId)).isTrue();
assertThat(result2.getReportReader().readFileSource(fileId)).isNull();
}
Aggregations