]> source.dussan.org Git - sonarqube.git/commitdiff
Display prefixes "Rule" and "Message" in issue change emails
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 4 Jun 2013 08:16:25 +0000 (10:16 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 4 Jun 2013 08:18:35 +0000 (10:18 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_changes.txt
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_message_same_than_rule_name.txt [deleted file]

index 43dff3e911fbe377c7d1bb0eefc6ea45ccd553fd..31408445e4c673bf4935ba22de11e6eebefa06ce 100644 (file)
@@ -85,14 +85,9 @@ public class IssueChangesEmailTemplate extends EmailTemplate {
   }
 
   private void appendHeader(Notification notif, StringBuilder sb) {
-    String ruleName = notif.getFieldValue("ruleName");
-    String issueMessage = notif.getFieldValue("message");
-
     appendLine(sb, StringUtils.defaultString(notif.getFieldValue("componentName"), notif.getFieldValue("componentKey")));
-    appendLine(sb, ruleName);
-    if (!Objects.equal(ruleName, issueMessage)) {
-      appendLine(sb, issueMessage);
-    }
+    appendField(sb, "Rule", null, notif.getFieldValue("ruleName"));
+    appendField(sb, "Message", null, notif.getFieldValue("message"));
   }
 
   private void appendFooter(StringBuilder sb, Notification notification) {
index 7814c072c732d9abafdd573eb418bd542a95f519..64384c40f39c2d6d8d1dbfef29802bfb10b2040a 100644 (file)
@@ -84,26 +84,6 @@ public class IssueChangesEmailTemplateTest {
     assertThat(email.getFrom()).isNull();
   }
 
-  @Test
-  public void test_email_with_issue_message_same_than_rule_name() {
-    Notification notification = new Notification("issue-changes")
-      .setFieldValue("projectName", "Struts")
-      .setFieldValue("projectKey", "org.apache:struts")
-      .setFieldValue("componentName", "org.apache.struts.Action")
-      .setFieldValue("key", "ABCDE")
-      .setFieldValue("new.assignee", "louis")
-
-      // same rule name and issue msg -> display once
-      .setFieldValue("ruleName", "Avoid Cycles")
-      .setFieldValue("message", "Avoid Cycles");
-
-    EmailMessage email = template.format(notification);
-    String message = email.getMessage();
-    String expectedMessage = TestUtils.getResourceContent("/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_message_same_than_rule_name.txt");
-    expectedMessage = StringUtils.remove(expectedMessage, '\r');
-    assertThat(message).isEqualTo(expectedMessage);
-  }
-
   @Test
   public void notification_sender_should_be_the_author_of_change() {
     User user = mock(User.class);
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_message_same_than_rule_name.txt b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_message_same_than_rule_name.txt
deleted file mode 100644 (file)
index f97b5d1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-org.apache.struts.Action
-Avoid Cycles
-
-Assignee: louis
-
-See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE