use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method format_email_with_all_fields_filled.
@Test
public void format_email_with_all_fields_filled() throws Exception {
Notification notification = newNotification();
addAssignees(notification);
addRules(notification);
addTags(notification);
addComponents(notification);
EmailMessage message = template.format(notification);
// TODO datetime to be completed when test is isolated from JVM timezone
String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_all_details.txt"), StandardCharsets.UTF_8);
assertThat(message.getMessage()).startsWith(StringUtils.remove(expectedContent, '\r'));
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class IssueChangesEmailTemplateTest method email_should_display_assignee_change.
@Test
public void email_should_display_assignee_change() throws Exception {
Notification notification = generateNotification().setFieldValue("old.assignee", "simon").setFieldValue("new.assignee", "louis");
EmailMessage email = underTest.format(notification);
assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");
String message = email.getMessage();
String expected = Resources.toString(Resources.getResource("org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt"), StandardCharsets.UTF_8);
expected = StringUtils.remove(expected, '\r');
assertThat(message).isEqualTo(expected);
assertThat(email.getFrom()).isNull();
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class IssueChangesEmailTemplateTest method test_email_with_multiple_changes.
@Test
public void test_email_with_multiple_changes() throws Exception {
Notification notification = generateNotification().setFieldValue("comment", "How to fix it?").setFieldValue("old.assignee", "simon").setFieldValue("new.assignee", "louis").setFieldValue("new.resolution", "FALSE-POSITIVE").setFieldValue("new.status", "RESOLVED").setFieldValue("new.type", "BUG").setFieldValue("new.tags", "bug performance");
EmailMessage email = underTest.format(notification);
assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");
String message = email.getMessage();
String expected = Resources.toString(Resources.getResource("org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt"), StandardCharsets.UTF_8);
expected = StringUtils.remove(expected, '\r');
assertThat(message).isEqualTo(expected);
assertThat(email.getFrom()).isNull();
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class IssueChangesEmailTemplateTest method display_component_key_if_no_component_name.
@Test
public void display_component_key_if_no_component_name() throws Exception {
Notification notification = generateNotification().setFieldValue("componentName", null);
EmailMessage email = underTest.format(notification);
assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");
String message = email.getMessage();
String expected = Resources.toString(Resources.getResource("org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt"), StandardCharsets.UTF_8);
expected = StringUtils.remove(expected, '\r');
assertThat(message).isEqualTo(expected);
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class IssueChangesEmailTemplateTest method email_should_display_resolution_change.
@Test
public void email_should_display_resolution_change() throws Exception {
Notification notification = generateNotification().setFieldValue("old.resolution", "FALSE-POSITIVE").setFieldValue("new.resolution", "FIXED");
EmailMessage email = underTest.format(notification);
assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");
String message = email.getMessage();
String expected = Resources.toString(Resources.getResource("org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_should_display_resolution_change.txt"), StandardCharsets.UTF_8);
expected = StringUtils.remove(expected, '\r');
assertThat(message).isEqualTo(expected);
assertThat(email.getFrom()).isNull();
}
Aggregations