Browse Source

Display prefixes "Rule" and "Message" in issue change emails

tags/3.6
Simon Brandhof 11 years ago
parent
commit
ff74fb60ab

+ 2
- 7
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java View 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) {

+ 0
- 20
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java View 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);

+ 2
- 2
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_changes.txt View File

@@ -1,6 +1,6 @@
org.apache.struts.Action
Avoid Cycles
Has 3 cycles
Rule: Avoid Cycles
Message: Has 3 cycles

Comment: How to fix it?
Assignee: louis (was simon)

+ 0
- 6
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_issue_message_same_than_rule_name.txt View File

@@ -1,6 +0,0 @@
org.apache.struts.Action
Avoid Cycles

Assignee: louis

See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE

Loading…
Cancel
Save