use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_master_when_analysis_change.
@Test
public void formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_master_when_analysis_change() {
Project project = newProject("1");
String ruleName = randomAlphabetic(8);
String host = randomAlphabetic(15);
Rule rule = newRule(ruleName, randomRuleTypeHotspotExcluded());
String issueStatus = randomValidStatus();
List<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(i -> newChangedIssue("issue_" + i, issueStatus, project, rule)).collect(toList());
AnalysisChange analysisChange = newAnalysisChange();
when(emailSettings.getServerBaseURL()).thenReturn(host);
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, ImmutableSet.copyOf(changedIssues)));
String expectedHref = host + "/project/issues?id=" + project.getKey() + "&issues=" + changedIssues.stream().map(ChangedIssue::getKey).collect(joining("%2C"));
String expectedLinkText = "See all " + changedIssues.size() + " issues";
HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph().hasList("Rule " + ruleName + " - " + expectedLinkText).withLink(expectedLinkText, expectedHref).hasParagraph().hasParagraph().noMoreBlock();
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method format_set_html_message_with_header_dealing_with_plural_when_change_from_Analysis.
@Test
public void format_set_html_message_with_header_dealing_with_plural_when_change_from_Analysis() {
Set<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(4)).mapToObj(i -> newChangedIssue(i + "", randomValidStatus(), newProject("prj_" + i), newRandomNotAHotspotRule("rule_" + i))).collect(toSet());
AnalysisChange analysisChange = newAnalysisChange();
EmailMessage singleIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues.stream().limit(1).collect(toSet())));
EmailMessage multiIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));
HtmlFragmentAssert.assertThat(singleIssueMessage.getMessage()).hasParagraph("Hi,").hasParagraph("An analysis has updated an issue assigned to you:");
HtmlFragmentAssert.assertThat(multiIssueMessage.getMessage()).hasParagraph("Hi,").hasParagraph("An analysis has updated issues assigned to you:");
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method AnalysisChange_equals.
@Test
public void AnalysisChange_equals() {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
AnalysisChange analysisChange2 = new AnalysisChange(1_000_000_000L);
assertThat(analysisChange1).isEqualTo(analysisChange2).isEqualTo(analysisChange1);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method AnalysisChange_toString.
@Test
public void AnalysisChange_toString() {
long date = 1_000_000_000L;
AnalysisChange userChange = new AnalysisChange(date);
assertThat(userChange).hasToString("AnalysisChange{1000000000}");
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method AnalysisChange_not_equals.
@Test
public void AnalysisChange_not_equals() {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
AnalysisChange analysisChange2 = new AnalysisChange(2_000_000_000L);
assertThat(analysisChange1).isNotEqualTo(analysisChange2);
}
Aggregations