use of org.sonar.wsclient.issue.Issues in project sonarqube by SonarSource.
the class IssueNotificationsTest method notifications_for_bulk_change_ws.
/**
* SONAR-4606
*/
@Test
public void notifications_for_bulk_change_ws() throws Exception {
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.projectDate", "2015-12-15");
Issues issues = issueClient.find(IssueQuery.create().componentRoots(PROJECT_KEY));
Issue issue = issues.list().get(0);
// bulk change without notification by default
issuesService.bulkChange(BulkChangeRequest.builder().setIssues(singletonList(issue.key())).setAssign(USER_LOGIN).setSetSeverity("MINOR").build());
// bulk change with notification
issuesService.bulkChange(BulkChangeRequest.builder().setIssues(singletonList(issue.key())).setSetSeverity("BLOCKER").setSendNotifications(true).build());
waitUntilAllNotificationsAreDelivered(2);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
emails.next();
MimeMessage 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("Severity: BLOCKER (was MINOR)");
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.Issues in project sonarqube by SonarSource.
the class IssuePurgeTest method purge_old_closed_issues.
/**
* SONAR-4308
*/
@Test
public void purge_old_closed_issues() throws Exception {
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "5000");
// Generate some issues
xooSampleAnalysis.withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-01").run();
// All the issues are open
List<Issue> issuesList = searchIssues();
for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNull();
}
// Second scan with empty profile -> all issues are resolved and closed
// -> Not deleted because less than 5000 days long
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-15").run();
issuesList = searchIssues();
assertThat(issuesList).isNotEmpty();
for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNotNull();
assertThat(issue.status()).isEqualTo("CLOSED");
}
// Third scan -> closed issues are deleted
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "1");
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-20").run();
Issues issues = issueClient().find(IssueQuery.create());
assertThat(issues.list()).isEmpty();
assertThat(issues.paging().total()).isZero();
}
use of org.sonar.wsclient.issue.Issues in project sonarqube by SonarSource.
the class IssuePurgeTest method purge_old_closed_issues_when_zero_closed_issues_wanted.
/**
* SONAR-7108
*/
@Test
public void purge_old_closed_issues_when_zero_closed_issues_wanted() throws Exception {
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "5000");
// Generate some issues
xooSampleAnalysis.withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-01").run();
// All the issues are open
List<Issue> issueList = searchIssues();
for (Issue issue : issueList) {
assertThat(issue.resolution()).isNull();
}
// Second scan with empty profile -> all issues are resolved and closed
// -> Not deleted because less than 5000 days long
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-15").run();
issueList = searchIssues();
assertThat(issueList).isNotEmpty();
for (Issue issue : issueList) {
assertThat(issue.resolution()).isNotNull();
assertThat(issue.status()).isEqualTo("CLOSED");
}
// Third scan -> closed issues are deleted
projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "0");
xooSampleAnalysis.withXooEmptyProfile().withProperties("sonar.dynamicAnalysis", "false", "sonar.projectDate", "2014-10-20").run();
Issues issues = issueClient().find(IssueQuery.create());
assertThat(issues.list()).isEmpty();
assertThat(issues.paging().total()).isZero();
}
use of org.sonar.wsclient.issue.Issues 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.Issues 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();
}
Aggregations