use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class ScannerTest method module_should_load_own_settings_from_database.
// SONAR-4680
@Test
public void module_should_load_own_settings_from_database() {
String rootModuleKey = "com.sonarsource.it.samples:multi-modules-sample";
orchestrator.getServer().provisionProject(rootModuleKey, "Sonar :: Integration Tests :: Multi-modules Sample");
String propKey = "myFakeProperty";
String moduleBKey = rootModuleKey + ":module_b";
resetSettings(orchestrator, rootModuleKey, propKey);
BuildResult result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
assertThat(result.getLogs()).doesNotContain(rootModuleKey + ":" + propKey);
assertThat(result.getLogs()).doesNotContain(moduleBKey + ":" + propKey);
// Set property only on root project
setServerProperty(orchestrator, rootModuleKey, propKey, "project");
result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = project");
// Override property on moduleB
setServerProperty(orchestrator, moduleBKey, propKey, "moduleB");
result = scan("shared/xoo-multi-modules-sample", "sonar.showSettings", propKey);
assertThat(result.getLogs()).contains(rootModuleKey + ":" + propKey + " = project");
assertThat(result.getLogs()).contains(moduleBKey + ":" + propKey + " = moduleB");
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class ScannerTest method should_create_project_without_name_version.
@Test
public void should_create_project_without_name_version() {
// some of the sub-modules have a name defined, others don't
BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
assertThat(buildResult.isSuccess()).isTrue();
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "not provided");
assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "not provided");
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class IssueJsonReportTest method precise_issue_location.
@Test
public void precise_issue_location() throws IOException {
orchestrator.getServer().restoreProfile(getResource("multiline.xml"));
orchestrator.getServer().provisionProject("sample-multiline", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample-multiline", "xoo", "multiline");
File projectDir = ItUtils.projectDir("shared/xoo-precise-issues");
SonarScanner runner = SonarScanner.create(projectDir, "sonar.analysis.mode", "issues", "sonar.verbose", "true", "sonar.report.export.path", "sonar-report.json");
BuildResult result = orchestrator.executeBuild(runner);
assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(2);
JSONObject obj = ItUtils.getJSONReport(result);
JSONArray issues = (JSONArray) obj.get("issues");
JSONObject issue1 = (JSONObject) issues.get(0);
JSONObject issue2 = (JSONObject) issues.get(1);
assertThat(issue1.get("startLine")).isIn(6L);
assertThat(issue1.get("line")).isIn(6L);
assertThat(issue1.get("endLine")).isIn(6L);
assertThat(issue1.get("startOffset")).isIn(27L);
assertThat(issue1.get("endOffset")).isIn(32L);
assertThat(issue2.get("startLine")).isIn(9L);
assertThat(issue2.get("line")).isIn(9L);
assertThat(issue2.get("endLine")).isIn(15L);
assertThat(issue2.get("startOffset")).isIn(20L);
assertThat(issue2.get("endOffset")).isIn(2L);
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class IssueJsonReportTest method issue_line.
@Test
public void issue_line() throws IOException {
orchestrator.getServer().restoreProfile(getResource("one-issue-per-line.xml"));
orchestrator.getServer().provisionProject("sample", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
File projectDir = ItUtils.projectDir("shared/xoo-sample");
SonarScanner runner = SonarScanner.create(projectDir, "sonar.analysis.mode", "issues", "sonar.verbose", "true", "sonar.report.export.path", "sonar-report.json");
BuildResult result = orchestrator.executeBuild(runner);
assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
JSONObject obj = ItUtils.getJSONReport(result);
JSONArray issues = (JSONArray) obj.get("issues");
for (Object issue : issues) {
JSONObject jsonIssue = (JSONObject) issue;
assertThat(jsonIssue.get("startLine")).isNotNull();
assertThat(jsonIssue.get("line")).isEqualTo(jsonIssue.get("startLine"));
assertThat(jsonIssue.get("endLine")).isEqualTo(jsonIssue.get("startLine"));
assertThat(jsonIssue.get("endOffset")).isNotNull();
assertThat(jsonIssue.get("startOffset")).isNotNull();
}
List<Long> lineNumbers = new ArrayList<>(16);
for (long i = 1L; i < 18; i++) {
lineNumbers.add(i);
}
assertThat(issues).extracting("startLine").containsAll(lineNumbers);
assertThat(issues).extracting("endLine").containsAll(lineNumbers);
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class IssuesModeTest method runFirstAnalysisAndFlagIssueAsWontFix.
private File runFirstAnalysisAndFlagIssueAsWontFix() throws IOException {
restoreProfile("one-issue-per-line.xml");
orchestrator.getServer().provisionProject("sample", "xoo-sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
// First run (publish mode)
SonarScanner runner = configureRunner("shared/xoo-sample");
orchestrator.executeBuild(runner);
// First issues mode
File homeDir = temp.newFolder();
runner = configureRunnerIssues("shared/xoo-sample", homeDir);
BuildResult result = orchestrator.executeBuild(runner);
// 17 issues
assertThat(ItUtils.countIssuesInJsonReport(result, false)).isEqualTo(17);
// Flag one issue as false positive
JSONObject obj = ItUtils.getJSONReport(result);
String key = ((JSONObject) ((JSONArray) obj.get("issues")).get(0)).get("key").toString();
orchestrator.getServer().adminWsClient().issueClient().doTransition(key, "falsepositive");
return homeDir;
}
Aggregations