use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class ExternalIssuesMediumTest method testOneIssuePerLine_register_ad_hoc_rule.
@Test
public void testOneIssuePerLine_register_ad_hoc_rule() throws Exception {
File projectDir = new File("test-resources/mediumtest/xoo/sample");
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
AnalysisResult result = tester.newAnalysis(new File(tmpDir, "sonar-project.properties")).property(OneExternalIssuePerLineSensor.ACTIVATE, "true").property(OneExternalIssuePerLineSensor.REGISTER_AD_HOC_RULE, "true").execute();
assertThat(result.adHocRules()).extracting(ScannerReport.AdHocRule::getEngineId, ScannerReport.AdHocRule::getRuleId, ScannerReport.AdHocRule::getName, ScannerReport.AdHocRule::getDescription, ScannerReport.AdHocRule::getSeverity, ScannerReport.AdHocRule::getType).containsExactlyInAnyOrder(tuple(OneExternalIssuePerLineSensor.ENGINE_ID, OneExternalIssuePerLineSensor.RULE_ID, "An ad hoc rule", "blah blah", Severity.BLOCKER, IssueType.BUG));
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class IssuesOnDirMediumTest method issueOnRootFolder.
@Test
public void issueOnRootFolder() throws IOException {
File baseDir = temp.getRoot();
File xooFile1 = new File(baseDir, "sample1.xoo");
FileUtils.write(xooFile1, "Sample1 xoo\ncontent");
File xooFile2 = new File(baseDir, "sample2.xoo");
FileUtils.write(xooFile2, "Sample2 xoo\ncontent");
AnalysisResult result = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.task", "scan").put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.projectName", "Foo Project").put("sonar.projectVersion", "1.0-SNAPSHOT").put("sonar.projectDescription", "Description of Foo Project").put("sonar.sources", ".").build()).execute();
assertThat(result.issuesFor(result.project())).hasSize(2);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class IssuesOnDirMediumTest method scanTempProject.
@Test
public void scanTempProject() throws IOException {
File baseDir = temp.getRoot();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile1 = new File(srcDir, "sample1.xoo");
FileUtils.write(xooFile1, "Sample1 xoo\ncontent");
File xooFile2 = new File(srcDir, "sample2.xoo");
FileUtils.write(xooFile2, "Sample2 xoo\ncontent");
AnalysisResult result = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.task", "scan").put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.projectName", "Foo Project").put("sonar.projectVersion", "1.0-SNAPSHOT").put("sonar.projectDescription", "Description of Foo Project").put("sonar.sources", "src").build()).execute();
assertThat(result.issuesFor(result.project())).hasSize(2);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class MeasuresMediumTest method warnWhenSavingFolderMeasure.
@Test
public void warnWhenSavingFolderMeasure() throws IOException {
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "Sample xoo\n\n\ncontent", StandardCharsets.UTF_8);
File folderMeasures = new File(srcDir, "folder.measures");
FileUtils.write(folderMeasures, "tests:10", StandardCharsets.UTF_8);
AnalysisResult result = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.sources", "src").build()).execute();
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class MeasuresMediumTest method warnWhenSavingModuleMeasure.
@Test
public void warnWhenSavingModuleMeasure() throws IOException {
File moduleDir = new File(baseDir, "moduleA");
moduleDir.mkdirs();
srcDir = new File(moduleDir, "src");
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "Sample xoo\n\n\ncontent", StandardCharsets.UTF_8);
File moduleMeasures = new File(moduleDir, "module.measures");
FileUtils.write(moduleMeasures, "tests:10", StandardCharsets.UTF_8);
AnalysisResult result = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.modules", "moduleA").put("sonar.sources", "src").build()).execute();
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
}
Aggregations