use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueCreationTest method plugin_can_override_profile_severity.
@Test
public void plugin_can_override_profile_severity() throws Exception {
ORCHESTRATOR.getServer().provisionProject(SAMPLE_PROJECT_KEY, SAMPLE_PROJECT_KEY);
// The rule "OneBlockerIssuePerFile" is enabled with severity "INFO"
ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/IssueCreationTest/override-profile-severity.xml"));
ORCHESTRATOR.getServer().associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "override-profile-severity");
// But it's hardcoded "blocker" when plugin generates the issue
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");
Issues issues = search(IssueQuery.create().rules("xoo:OneBlockerIssuePerFile"));
assertThat(issues.size()).isGreaterThan(0);
for (Issue issue : issues.list()) {
assertThat(issue.severity()).isEqualTo("BLOCKER");
}
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueCreationTest method use_rule_name_if_issue_has_no_message.
/**
* See SONAR-4785
*/
@Test
public void use_rule_name_if_issue_has_no_message() {
ORCHESTRATOR.getServer().provisionProject(SAMPLE_PROJECT_KEY, SAMPLE_PROJECT_KEY);
ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/IssueCreationTest/with-custom-message.xml"));
ORCHESTRATOR.getServer().associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, "xoo", "with-custom-message");
// First analysis, the issue is generated with a message
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.customMessage.message", "a message");
Issue issue = issueClient().find(IssueQuery.create()).list().get(0);
assertThat(issue.message()).isEqualTo("a message");
// Second analysis, the issue is generated without any message, the name of the rule is used
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample");
issue = issueClient().find(IssueQuery.create()).list().get(0);
assertThat(issue.message()).isEqualTo("Issue With Custom Message");
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueFilterExtensionTest method should_filter_issues.
@Test
public void should_filter_issues() {
// first analysis without issue-filter
analysis.run();
// Issue filter removes issues on lines < 5
// Deprecated violation filter removes issues detected by PMD
List<Issue> unresolvedIssues = searchResolvedIssues(xooMultiModuleProjectKey);
int issuesBeforeLine5 = countIssuesBeforeLine5(unresolvedIssues);
int pmdIssues = countModuleIssues(unresolvedIssues);
assertThat(issuesBeforeLine5).isGreaterThan(0);
assertThat(pmdIssues).isGreaterThan(0);
// Enable issue filters
analysis.withProperties("enableIssueFilters", "true").run();
unresolvedIssues = searchResolvedIssues(xooMultiModuleProjectKey);
List<Issue> resolvedIssues = searchUnresolvedIssues(xooMultiModuleProjectKey);
assertThat(countIssuesBeforeLine5(unresolvedIssues)).isZero();
assertThat(countModuleIssues(unresolvedIssues)).isZero();
assertThat(countModuleIssues(resolvedIssues)).isGreaterThan(0);
for (Issue issue : resolvedIssues) {
// SONAR-6364 no line number on closed issues
assertThat(issue.line()).isNull();
}
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssueNotificationsTest method notifications_for_new_issues_and_issue_changes.
@Test
public void notifications_for_new_issues_and_issue_changes() throws Exception {
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.projectDate", "2015-12-15");
// change assignee
Issues issues = issueClient.find(IssueQuery.create().componentRoots(PROJECT_KEY));
Issue issue = issues.list().get(0);
issueClient.assign(issue.key(), USER_LOGIN);
waitUntilAllNotificationsAreDelivered(2);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
assertThat(emails.hasNext()).isTrue();
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat((String) message.getContent()).contains("Sample");
assertThat((String) message.getContent()).contains("17 new issues (new debt: 17min)");
assertThat((String) message.getContent()).contains("Severity");
assertThat((String) message.getContent()).contains("One Issue Per Line (xoo): 17");
assertThat((String) message.getContent()).contains("See it in SonarQube: http://localhost:9000/component_issues?id=sample#createdAt=2015-12-15T00%3A00%3A00%2B");
assertThat(emails.hasNext()).isTrue();
message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat((String) message.getContent()).contains("sample/Sample.xoo");
assertThat((String) message.getContent()).contains("Assignee changed to Tester");
assertThat((String) message.getContent()).contains("See it in SonarQube: http://localhost:9000/issues/search#issues=" + issue.key());
assertThat(emails.hasNext()).isFalse();
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssuePurgeTest method resolve_issues_when_removing_module.
/**
* SONAR-5200
*/
@Test
public void resolve_issues_when_removing_module() throws Exception {
// Generate some issues
xooMultiModuleAnalysis.withProperties("sonar.dynamicAnalysis", "false").run();
// All the issues are open
List<Issue> issues = searchIssues();
for (Issue issue : issues) {
assertThat(issue.resolution()).isNull();
}
Issue issue = issues.get(0);
int issuesOnModuleB = searchIssues(IssueQuery.create().componentRoots("com.sonarsource.it.samples:multi-modules-sample:module_b")).size();
assertThat(issuesOnModuleB).isEqualTo(28);
// Second scan without module B -> issues on module B are resolved as removed and closed
xooMultiModuleAnalysis.withProperties("sonar.dynamicAnalysis", "false", "sonar.modules", "module_a").run();
// Resolved should should all be mark as REMOVED and affect to module b
List<Issue> reloadedIssues = searchIssues(IssueQuery.create().resolved(true));
assertThat(reloadedIssues).hasSize(issuesOnModuleB);
for (Issue reloadedIssue : reloadedIssues) {
assertThat(reloadedIssue.resolution()).isEqualTo("FIXED");
assertThat(reloadedIssue.status()).isEqualTo("CLOSED");
assertThat(reloadedIssue.componentKey()).contains("com.sonarsource.it.samples:multi-modules-sample:module_b");
assertThat(reloadedIssue.updateDate().before(issue.updateDate())).isFalse();
assertThat(reloadedIssue.closeDate()).isNotNull();
assertThat(reloadedIssue.closeDate().before(reloadedIssue.creationDate())).isFalse();
}
}
Aggregations