Search in sources :

Example 21 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class IssueChangesEmailTemplateTest method notification_sender_should_be_the_author_of_change.

@Test
public void notification_sender_should_be_the_author_of_change() {
    db.users().insertUser(newUserDto().setLogin("simon").setName("Simon"));
    Notification notification = new IssueChangeNotification().setChangeAuthorLogin("simon").setProject("Struts", "org.apache:struts");
    EmailMessage message = underTest.format(notification);
    assertThat(message.getFrom()).isEqualTo("Simon");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 22 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class IssueChangesEmailTemplateTest method should_ignore_non_issue_changes.

@Test
public void should_ignore_non_issue_changes() {
    Notification notification = new Notification("other");
    EmailMessage message = underTest.format(notification);
    assertThat(message).isNull();
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 23 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method format_email_with_all_fields_filled.

@Test
public void format_email_with_all_fields_filled() throws Exception {
    Notification notification = newNotification();
    addTags(notification);
    addRules(notification);
    addComponents(notification);
    EmailMessage message = underTest.format(notification);
    // TODO datetime to be completed when test is isolated from JVM timezone
    assertStartsWithFile(message.getMessage(), getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_all_details.txt"));
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 24 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method format_email_with_no_assignees_tags_nor_components.

@Test
public void format_email_with_no_assignees_tags_nor_components() throws Exception {
    Notification notification = newNotification();
    EmailMessage message = underTest.format(notification);
    // TODO datetime to be completed when test is isolated from JVM timezone
    assertStartsWithFile(message.getMessage(), getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_no_assignee_tags_components.txt"));
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 25 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class NewIssuesEmailTemplateTest method subject.

@Test
public void subject() {
    Notification notification = newNotification();
    EmailMessage message = template.format(notification);
    assertThat(message.getSubject()).isEqualTo("Struts: 32 new issues (new debt: 1d3h)");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Aggregations

EmailMessage (org.sonar.plugins.emailnotifications.api.EmailMessage)34 Test (org.junit.Test)29 Notification (org.sonar.api.notifications.Notification)25 MimeMessage (javax.mail.internet.MimeMessage)2 Matchers.anyString (org.mockito.Matchers.anyString)2 WiserMessage (org.subethamail.wiser.WiserMessage)2 EmailException (org.apache.commons.mail.EmailException)1 User (org.sonar.api.user.User)1