use of org.sonar.api.issue.Issue.STATUS_OPEN in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method format_set_html_message_with_issue_status_title_handles_plural_when_change_from_analysis.
@Test
public void format_set_html_message_with_issue_status_title_handles_plural_when_change_from_analysis() {
Project project = newProject("foo");
Rule rule = newRandomNotAHotspotRule("bar");
Set<ChangedIssue> closedIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(status -> newChangedIssue(status + "", STATUS_CLOSED, project, rule)).collect(toSet());
Set<ChangedIssue> openIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(status -> newChangedIssue(status + "", STATUS_OPEN, project, rule)).collect(toSet());
AnalysisChange analysisChange = newAnalysisChange();
EmailMessage closedIssuesMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, closedIssues));
EmailMessage openIssuesMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, openIssues));
HtmlListAssert htmlListAssert = HtmlFragmentAssert.assertThat(closedIssuesMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph("Closed issues:").hasList();
verifyEnd(htmlListAssert);
htmlListAssert = HtmlFragmentAssert.assertThat(openIssuesMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph("Open issues:").hasList();
verifyEnd(htmlListAssert);
}
use of org.sonar.api.issue.Issue.STATUS_OPEN in project sonarqube by SonarSource.
the class IssueWorkflowTest method automatically_reopen_closed_issue_to_most_recent_previous_status_from_changelog.
@Test
@UseDataProvider("allStatusesLeadingToClosed")
public void automatically_reopen_closed_issue_to_most_recent_previous_status_from_changelog(String previousStatus) {
DefaultIssue[] issues = Arrays.stream(SUPPORTED_RESOLUTIONS_FOR_UNCLOSING).map(resolution -> {
DefaultIssue issue = newClosedIssue(resolution);
Date now = new Date();
addStatusChange(issue, addDays(now, -60), STATUS_OPEN, STATUS_CONFIRMED);
addStatusChange(issue, addDays(now, -10), STATUS_CONFIRMED, previousStatus);
setStatusPreviousToClosed(issue, previousStatus);
return issue;
}).toArray(DefaultIssue[]::new);
Date now = new Date();
underTest.start();
Arrays.stream(issues).forEach(issue -> {
underTest.doAutomaticTransition(issue, IssueChangeContext.createScan(now));
assertThat(issue.status()).isEqualTo(previousStatus);
assertThat(issue.updateDate()).isEqualTo(DateUtils.truncate(now, Calendar.SECOND));
assertThat(issue.closeDate()).isNull();
assertThat(issue.isChanged()).isTrue();
});
}
Aggregations