@@ -92,7 +92,9 @@ public class IssueChangesEmailTemplate extends EmailTemplate { | |||
private void appendFooter(StringBuilder sb, Notification notification) { | |||
String issueKey = notification.getFieldValue("key"); | |||
sb.append("See it in SonarQube: ").append(settings.getServerBaseURL()).append("/issue/show/").append(issueKey).append(NEW_LINE); | |||
String componentKey = notification.getFieldValue("componentKey"); | |||
sb.append("See it in SonarQube: ").append(settings.getServerBaseURL()).append("/component/index#component=").append(componentKey) | |||
.append("¤tIssue=").append(issueKey).append(NEW_LINE); | |||
} | |||
private void appendLine(StringBuilder sb, @Nullable String line) { |
@@ -99,6 +99,24 @@ public class IssueChangesEmailTemplateTest { | |||
assertThat(email.getFrom()).isNull(); | |||
} | |||
@Test | |||
public void display_component_key_if_no_component_name() throws Exception { | |||
Notification notification = generateNotification() | |||
.setFieldValue("componentName", null); | |||
EmailMessage email = template.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/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt"), | |||
Charsets.UTF_8 | |||
); | |||
expected = StringUtils.remove(expected, '\r'); | |||
assertThat(message).isEqualTo(expected); | |||
} | |||
@Test | |||
public void test_email_with_multiple_changes() throws Exception { | |||
Notification notification = generateNotification() | |||
@@ -139,7 +157,8 @@ public class IssueChangesEmailTemplateTest { | |||
Notification notification = new Notification("issue-changes") | |||
.setFieldValue("projectName", "Struts") | |||
.setFieldValue("projectKey", "org.apache:struts") | |||
.setFieldValue("componentName", "org.apache.struts.Action") | |||
.setFieldValue("componentName", "Action") | |||
.setFieldValue("componentKey", "org.apache.struts.Action") | |||
.setFieldValue("key", "ABCDE") | |||
.setFieldValue("ruleName", "Avoid Cycles") | |||
.setFieldValue("message", "Has 3 cycles"); |
@@ -0,0 +1,6 @@ | |||
org.apache.struts.Action | |||
Rule: Avoid Cycles | |||
Message: Has 3 cycles | |||
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action¤tIssue=ABCDE |
@@ -1,7 +1,7 @@ | |||
org.apache.struts.Action | |||
Action | |||
Rule: Avoid Cycles | |||
Message: Has 3 cycles | |||
Action Plan changed to ABC 1.0 | |||
See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE | |||
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action¤tIssue=ABCDE |
@@ -1,7 +1,7 @@ | |||
org.apache.struts.Action | |||
Action | |||
Rule: Avoid Cycles | |||
Message: Has 3 cycles | |||
Assignee changed to louis | |||
See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE | |||
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action¤tIssue=ABCDE |
@@ -1,4 +1,4 @@ | |||
org.apache.struts.Action | |||
Action | |||
Rule: Avoid Cycles | |||
Message: Has 3 cycles | |||
@@ -7,4 +7,4 @@ Assignee changed to louis | |||
Resolution: FALSE-POSITIVE | |||
Status: RESOLVED | |||
See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE | |||
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action¤tIssue=ABCDE |