Search in sources :

Example 11 with AnalysisChange

use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange 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);
}
Also used : Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) STATUS_CLOSED(org.sonar.api.issue.Issue.STATUS_CLOSED) IssuesChangesNotificationBuilderTesting.newUserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newUserChange) Locale(java.util.Locale) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Notification(org.sonar.api.notifications.Notification) Set(java.util.Set) Sets(org.elasticsearch.common.util.set.Sets) Collectors.joining(java.util.stream.Collectors.joining) STATUS_TO_REVIEW(org.sonar.api.issue.Issue.STATUS_TO_REVIEW) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) STATUS_CONFIRMED(org.sonar.api.issue.Issue.STATUS_CONFIRMED) List(java.util.List) Stream(java.util.stream.Stream) STATUS_REVIEWED(org.sonar.api.issue.Issue.STATUS_REVIEWED) HtmlParagraphAssert(org.sonar.test.html.HtmlParagraphAssert) Change(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Change) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) HtmlFragmentAssert(org.sonar.test.html.HtmlFragmentAssert) HtmlListAssert(org.sonar.test.html.HtmlListAssert) I18n(org.sonar.core.i18n.I18n) STATUS_OPEN(org.sonar.api.issue.Issue.STATUS_OPEN) RunWith(org.junit.runner.RunWith) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Function(java.util.function.Function) IssuesChangesNotificationBuilderTesting.newBranch(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newBranch) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) RuleType(org.sonar.api.rules.RuleType) EmailSettings(org.sonar.api.config.EmailSettings) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SECURITY_HOTSPOT(org.sonar.api.rules.RuleType.SECURITY_HOTSPOT) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) STATUS_REOPENED(org.sonar.api.issue.Issue.STATUS_REOPENED) RandomStringUtils.randomAlphabetic(org.apache.commons.lang.RandomStringUtils.randomAlphabetic) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) Collectors.toList(java.util.stream.Collectors.toList) IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded) Collections(java.util.Collections) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) HtmlListAssert(org.sonar.test.html.HtmlListAssert) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) Test(org.junit.Test)

Example 12 with AnalysisChange

use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.

the class ChangesOnMyIssuesEmailTemplateTest method formats_returns_html_message_with_rules_ordered_by_name_when_analysis_change.

@Test
public void formats_returns_html_message_with_rules_ordered_by_name_when_analysis_change() {
    Project project = newProject("1");
    Rule rule1 = newRandomNotAHotspotRule("1");
    Rule rule2 = newRandomNotAHotspotRule("a");
    Rule rule3 = newRandomNotAHotspotRule("b");
    Rule rule4 = newRandomNotAHotspotRule("X");
    String host = randomAlphabetic(15);
    String issueStatus = randomValidStatus();
    List<ChangedIssue> changedIssues = Stream.of(rule1, rule2, rule3, rule4).map(rule -> newChangedIssue("issue_" + rule.getName(), issueStatus, project, rule)).collect(toList());
    Collections.shuffle(changedIssues);
    AnalysisChange analysisChange = newAnalysisChange();
    when(emailSettings.getServerBaseURL()).thenReturn(host);
    EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, ImmutableSet.copyOf(changedIssues)));
    HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph().hasList("Rule " + rule1.getName() + " - See the single issue", "Rule " + rule2.getName() + " - See the single issue", "Rule " + rule3.getName() + " - See the single issue", "Rule " + rule4.getName() + " - See the single issue").hasParagraph().hasParagraph().noMoreBlock();
}
Also used : Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) STATUS_CLOSED(org.sonar.api.issue.Issue.STATUS_CLOSED) IssuesChangesNotificationBuilderTesting.newUserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newUserChange) Locale(java.util.Locale) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Notification(org.sonar.api.notifications.Notification) Set(java.util.Set) Sets(org.elasticsearch.common.util.set.Sets) Collectors.joining(java.util.stream.Collectors.joining) STATUS_TO_REVIEW(org.sonar.api.issue.Issue.STATUS_TO_REVIEW) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) STATUS_CONFIRMED(org.sonar.api.issue.Issue.STATUS_CONFIRMED) List(java.util.List) Stream(java.util.stream.Stream) STATUS_REVIEWED(org.sonar.api.issue.Issue.STATUS_REVIEWED) HtmlParagraphAssert(org.sonar.test.html.HtmlParagraphAssert) Change(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Change) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) HtmlFragmentAssert(org.sonar.test.html.HtmlFragmentAssert) HtmlListAssert(org.sonar.test.html.HtmlListAssert) I18n(org.sonar.core.i18n.I18n) STATUS_OPEN(org.sonar.api.issue.Issue.STATUS_OPEN) RunWith(org.junit.runner.RunWith) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Function(java.util.function.Function) IssuesChangesNotificationBuilderTesting.newBranch(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newBranch) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) RuleType(org.sonar.api.rules.RuleType) EmailSettings(org.sonar.api.config.EmailSettings) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SECURITY_HOTSPOT(org.sonar.api.rules.RuleType.SECURITY_HOTSPOT) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) STATUS_REOPENED(org.sonar.api.issue.Issue.STATUS_REOPENED) RandomStringUtils.randomAlphabetic(org.apache.commons.lang.RandomStringUtils.randomAlphabetic) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) Collectors.toList(java.util.stream.Collectors.toList) IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded) Collections(java.util.Collections) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) Test(org.junit.Test)

Example 13 with AnalysisChange

use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.

the class ChangesOnMyIssuesEmailTemplateTest method format_sets_subject_with_project_name_and_branch_name_of_first_issue_in_set_when_change_from_Analysis.

@Test
public void format_sets_subject_with_project_name_and_branch_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(), newBranch("prj_" + i, "br_" + i), newRandomNotAHotspotRule("rule_" + i))).collect(toSet());
    AnalysisChange analysisChange = 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() + ", " + project.getBranchName().get());
}
Also used : Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) STATUS_CLOSED(org.sonar.api.issue.Issue.STATUS_CLOSED) IssuesChangesNotificationBuilderTesting.newUserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newUserChange) Locale(java.util.Locale) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Notification(org.sonar.api.notifications.Notification) Set(java.util.Set) Sets(org.elasticsearch.common.util.set.Sets) Collectors.joining(java.util.stream.Collectors.joining) STATUS_TO_REVIEW(org.sonar.api.issue.Issue.STATUS_TO_REVIEW) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) STATUS_CONFIRMED(org.sonar.api.issue.Issue.STATUS_CONFIRMED) List(java.util.List) Stream(java.util.stream.Stream) STATUS_REVIEWED(org.sonar.api.issue.Issue.STATUS_REVIEWED) HtmlParagraphAssert(org.sonar.test.html.HtmlParagraphAssert) Change(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Change) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) HtmlFragmentAssert(org.sonar.test.html.HtmlFragmentAssert) HtmlListAssert(org.sonar.test.html.HtmlListAssert) I18n(org.sonar.core.i18n.I18n) STATUS_OPEN(org.sonar.api.issue.Issue.STATUS_OPEN) RunWith(org.junit.runner.RunWith) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Function(java.util.function.Function) IssuesChangesNotificationBuilderTesting.newBranch(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newBranch) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) RuleType(org.sonar.api.rules.RuleType) EmailSettings(org.sonar.api.config.EmailSettings) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SECURITY_HOTSPOT(org.sonar.api.rules.RuleType.SECURITY_HOTSPOT) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) STATUS_REOPENED(org.sonar.api.issue.Issue.STATUS_REOPENED) RandomStringUtils.randomAlphabetic(org.apache.commons.lang.RandomStringUtils.randomAlphabetic) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) Collectors.toList(java.util.stream.Collectors.toList) IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded) Collections(java.util.Collections) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Random(java.util.Random) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) Test(org.junit.Test)

Example 14 with AnalysisChange

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_branch_when_analysis_change.

@Test
public void formats_returns_html_message_for_single_issue_on_branch_when_analysis_change() {
    String branchName = randomAlphabetic(6);
    Project project = newBranch("1", branchName);
    String ruleName = randomAlphabetic(8);
    String host = randomAlphabetic(15);
    String key = "key";
    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() + "&branch=" + branchName + "&issues=" + changedIssue.getKey() + "&open=" + changedIssue.getKey()).hasParagraph().hasParagraph().noMoreBlock();
}
Also used : IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) Test(org.junit.Test)

Example 15 with AnalysisChange

use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange in project sonarqube by SonarSource.

the class ChangesOnMyIssuesEmailTemplateTest method format_sets_message_id_with_project_key_of_first_issue_in_set_when_change_from_Analysis.

@Test
public void format_sets_message_id_with_project_key_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 = newAnalysisChange();
    EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));
    assertThat(emailMessage.getMessageId()).isEqualTo("changes-on-my-issues/" + changedIssues.iterator().next().getProject().getKey());
}
Also used : Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) STATUS_CLOSED(org.sonar.api.issue.Issue.STATUS_CLOSED) IssuesChangesNotificationBuilderTesting.newUserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newUserChange) Locale(java.util.Locale) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newProject(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newProject) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Project(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project) Notification(org.sonar.api.notifications.Notification) Set(java.util.Set) Sets(org.elasticsearch.common.util.set.Sets) Collectors.joining(java.util.stream.Collectors.joining) STATUS_TO_REVIEW(org.sonar.api.issue.Issue.STATUS_TO_REVIEW) Rule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule) STATUS_CONFIRMED(org.sonar.api.issue.Issue.STATUS_CONFIRMED) List(java.util.List) Stream(java.util.stream.Stream) STATUS_REVIEWED(org.sonar.api.issue.Issue.STATUS_REVIEWED) HtmlParagraphAssert(org.sonar.test.html.HtmlParagraphAssert) Change(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Change) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) IssuesChangesNotificationBuilderTesting.newRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRule) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) HtmlFragmentAssert(org.sonar.test.html.HtmlFragmentAssert) HtmlListAssert(org.sonar.test.html.HtmlListAssert) I18n(org.sonar.core.i18n.I18n) STATUS_OPEN(org.sonar.api.issue.Issue.STATUS_OPEN) RunWith(org.junit.runner.RunWith) STATUS_RESOLVED(org.sonar.api.issue.Issue.STATUS_RESOLVED) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Function(java.util.function.Function) IssuesChangesNotificationBuilderTesting.newBranch(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newBranch) IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newSecurityHotspotRule) RuleType(org.sonar.api.rules.RuleType) EmailSettings(org.sonar.api.config.EmailSettings) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SECURITY_HOTSPOT(org.sonar.api.rules.RuleType.SECURITY_HOTSPOT) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) STATUS_REOPENED(org.sonar.api.issue.Issue.STATUS_REOPENED) RandomStringUtils.randomAlphabetic(org.apache.commons.lang.RandomStringUtils.randomAlphabetic) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange) IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule) Collectors.toList(java.util.stream.Collectors.toList) IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.randomRuleTypeHotspotExcluded) Collections(java.util.Collections) Random(java.util.Random) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) IssuesChangesNotificationBuilderTesting.newChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newChangedIssue) IssuesChangesNotificationBuilderTesting.newAnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange) AnalysisChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange) Test(org.junit.Test)

Aggregations

AnalysisChange (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange)31 Test (org.junit.Test)28 ChangedIssue (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue)19 Random (java.util.Random)17 Project (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project)16 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)15 IssuesChangesNotificationBuilderTesting.newAnalysisChange (org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newAnalysisChange)15 Set (java.util.Set)14 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)13 Collections (java.util.Collections)13 IntStream (java.util.stream.IntStream)13 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 Rule (org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule)13 ImmutableSet (com.google.common.collect.ImmutableSet)12 IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule (org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.newRandomNotAHotspotRule)12 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)11 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)11 RunWith (org.junit.runner.RunWith)11 Notification (org.sonar.api.notifications.Notification)11 RuleType (org.sonar.api.rules.RuleType)11