use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class FPOrWontFixNotificationTest method equals_is_based_on_issues_change_and_resolution.
@Test
public void equals_is_based_on_issues_change_and_resolution() {
Rule rule = newRandomNotAHotspotRule("rule_name");
Project project = new Project.Builder("prj_uuid").setKey("prj_key").setProjectName("prj_name").build();
Set<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(i -> new ChangedIssue.Builder("key_" + i).setNewStatus("status").setRule(rule).setProject(project).build()).collect(Collectors.toSet());
AnalysisChange change = new AnalysisChange(12);
User user = new User("uuid", "login", null);
FPOrWontFixNotification underTest = new FPOrWontFixNotification(change, changedIssues, WONT_FIX);
assertThat(underTest).isEqualTo(new FPOrWontFixNotification(change, changedIssues, WONT_FIX)).isEqualTo(new FPOrWontFixNotification(change, ImmutableSet.copyOf(changedIssues), WONT_FIX)).isNotEqualTo(new Object()).isNotNull().isNotEqualTo(new FPOrWontFixNotification(change, Collections.emptySet(), WONT_FIX)).isNotEqualTo(new FPOrWontFixNotification(change, ImmutableSet.of(changedIssues.iterator().next()), WONT_FIX)).isNotEqualTo(new FPOrWontFixNotification(new AnalysisChange(14), changedIssues, WONT_FIX)).isNotEqualTo(new FPOrWontFixNotification(new IssuesChangesNotificationBuilder.UserChange(12, user), changedIssues, WONT_FIX)).isNotEqualTo(new FPOrWontFixNotification(change, changedIssues, FP));
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method IssuesChangesNotificationBuilder_getters.
@Test
public void IssuesChangesNotificationBuilder_getters() {
Set<ChangedIssue> changedIssues = IntStream.range(0, 10).mapToObj(i -> new ChangedIssue.Builder("key" + i).setRule(newRule("repository", "key", RuleType.CODE_SMELL, "name")).setProject(new Project.Builder("uuid" + i).setKey("key").setProjectName("name").setBranchName("branch-name").build()).setNewStatus("status").setNewResolution("resolution").setAssignee(new User("uuid" + i, "login", "name")).build()).collect(Collectors.toSet());
AnalysisChange analysisChange = new AnalysisChange(1_000_000_000L);
IssuesChangesNotificationBuilder builder = new IssuesChangesNotificationBuilder(changedIssues, analysisChange);
assertThat(builder.getIssues()).isEqualTo(changedIssues);
assertThat(builder.getChange()).isEqualTo(analysisChange);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange 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.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method format_sets_subject_with_project_name_of_first_issue_in_set_when_change_from_Analysis.
@Test
public void format_sets_subject_with_project_name_of_first_issue_in_set_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 = IssuesChangesNotificationBuilderTesting.newAnalysisChange();
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));
Project project = changedIssues.iterator().next().getProject();
assertThat(emailMessage.getSubject()).isEqualTo("Analysis has changed some of your issues in " + project.getProjectName());
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method formats_returns_html_message_for_single_issue_on_master_when_analysis_change.
@Test
public void formats_returns_html_message_for_single_issue_on_master_when_analysis_change() {
Project project = newProject("1");
String ruleName = randomAlphabetic(8);
String host = randomAlphabetic(15);
ChangedIssue changedIssue = newChangedIssue("key", randomValidStatus(), project, ruleName, randomRuleTypeHotspotExcluded());
AnalysisChange analysisChange = newAnalysisChange();
when(emailSettings.getServerBaseURL()).thenReturn(host);
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, ImmutableSet.of(changedIssue)));
HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph().hasList("Rule " + ruleName + " - See the single issue").withLink("See the single issue", host + "/project/issues?id=" + project.getKey() + "&issues=" + changedIssue.getKey() + "&open=" + changedIssue.getKey()).hasParagraph().hasParagraph().noMoreBlock();
}
Aggregations