use of org.sonar.test.html.HtmlListAssert in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method format_set_html_message_with_issues_grouped_by_status_closed_or_any_other_when_change_from_analysis.
@Test
public void format_set_html_message_with_issues_grouped_by_status_closed_or_any_other_when_change_from_analysis() {
Project project = newProject("foo");
Rule rule = newRandomNotAHotspotRule("bar");
Set<ChangedIssue> changedIssues = Arrays.stream(ISSUE_STATUSES).map(status -> newChangedIssue(status + "", status, project, rule)).collect(toSet());
AnalysisChange analysisChange = newAnalysisChange();
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));
HtmlListAssert htmlListAssert = HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph("Closed issue:").withoutLink().hasList("Rule " + rule.getName() + " - See the single issue").withLinkOn("See the single issue").hasParagraph("Open issues:").withoutLink().hasList("Rule " + rule.getName() + " - See all " + (ISSUE_STATUSES.length - 1) + " issues").withLinkOn("See all " + (ISSUE_STATUSES.length - 1) + " issues");
verifyEnd(htmlListAssert);
}
use of org.sonar.test.html.HtmlListAssert in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method format_set_html_message_with_footer.
private void format_set_html_message_with_footer(Change change, String issueStatus, Function<HtmlParagraphAssert, HtmlListAssert> skipContent, RuleType ruleType) {
String wordingNotification = randomAlphabetic(20);
String host = randomAlphabetic(15);
when(i18n.message(Locale.ENGLISH, "notification.dispatcher.ChangesOnMyIssue", "notification.dispatcher.ChangesOnMyIssue")).thenReturn(wordingNotification);
when(emailSettings.getServerBaseURL()).thenReturn(host);
Project project = newProject("foo");
Rule rule = newRule("bar", ruleType);
Set<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(4)).mapToObj(i -> newChangedIssue(i + "", issueStatus, project, rule)).collect(toSet());
EmailMessage singleIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(change, changedIssues.stream().limit(1).collect(toSet())));
EmailMessage multiIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(change, changedIssues));
Stream.of(singleIssueMessage, multiIssueMessage).forEach(issueMessage -> {
HtmlParagraphAssert htmlAssert = HtmlFragmentAssert.assertThat(issueMessage.getMessage()).hasParagraph().hasParagraph();
// skip content
HtmlListAssert htmlListAssert = skipContent.apply(htmlAssert);
String footerText = "You received this email because you are subscribed to \"" + wordingNotification + "\" notifications from SonarQube." + " Click here to edit your email preferences.";
htmlListAssert.hasEmptyParagraph().hasParagraph(footerText).withSmallOn(footerText).withLink("here", host + "/account/notifications").noMoreBlock();
});
}
use of org.sonar.test.html.HtmlListAssert 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);
}
Aggregations