@Test public void subject() { Notification notification = newNotification(32); EmailMessage message = template.format(notification); assertThat(message.getSubject()).isEqualTo("Struts: 32 new issues (new debt: 1d3h)"); }
@Test public void message_id() { Notification notification = newNotification(32); EmailMessage message = template.format(notification); assertThat(message.getMessageId()).isEqualTo("new-issues/org.apache:struts"); }
@Test public void format_email_supports_single_issue() { Notification notification = newNotification(1); EmailMessage message = template.format(notification); assertThat(message.getSubject()) .isEqualTo("Struts: 1 new issue (new debt: 1d3h)"); assertThat(message.getMessage()) .contains("1 new issue (new debt: 1d3h)\n"); }
@Test public void no_format_is_not_the_correct_notification() { Notification notification = new Notification("my-new-issues"); EmailMessage message = template.format(notification); assertThat(message).isNull(); }
@Test public void subject_on_branch() { Notification notification = newNotification(32) .setFieldValue("branch", "feature1"); EmailMessage message = template.format(notification); assertThat(message.getSubject()).isEqualTo("Struts (feature1): 32 new issues (new debt: 1d3h)"); }
@Test public void format_email_with_no_assignees_tags_nor_components_nor_version() { Notification notification = newNotification(32); EmailMessage message = template.format(notification); // TODO datetime to be completed when test is isolated from JVM timezone assertThat(message.getMessage()) .startsWith("Project: Struts\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 10 Code Smell: 3\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&createdAt=2010-05-1"); }
@Test public void do_not_add_footer_when_properties_missing() { Notification notification = new Notification(NewIssuesNotification.TYPE) .setFieldValue(RULE_TYPE + ".count", "32") .setFieldValue("projectName", "Struts"); EmailMessage message = template.format(notification); assertThat(message.getMessage()).doesNotContain("See it"); }
@Test public void format_email_with_issue_on_branch() { Notification notification = newNotification(32) .setFieldValue("branch", "feature1"); EmailMessage message = template.format(notification); // TODO datetime to be completed when test is isolated from JVM timezone assertThat(message.getMessage()) .startsWith("Project: Struts\n" + "Branch: feature1\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 10 Code Smell: 3\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&branch=feature1&createdAt=2010-05-1"); }
@Test public void format_email_with_issue_on_branch_with_version() { Notification notification = newNotification(32) .setFieldValue("branch", "feature1") .setFieldValue("projectVersion", "42.1.1"); EmailMessage message = template.format(notification); // TODO datetime to be completed when test is isolated from JVM timezone assertThat(message.getMessage()) .startsWith("Project: Struts\n" + "Branch: feature1\n" + "Version: 42.1.1\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 10 Code Smell: 3\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&branch=feature1&createdAt=2010-05-1"); }
addComponents(notification); EmailMessage message = template.format(notification);