use of org.sonar.test.html.HtmlParagraphAssert 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();
});
}
Aggregations