aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-07 13:47:11 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-07 13:47:11 +0200
commitc4e562cb2fad74318b6a9bf733a0909263ff0271 (patch)
tree0fe921f6e80002afb18d0b86ac98cdeafa0a69d9
parentc5f3ff40749fb8eeb1d953571420b62f04d2aee5 (diff)
downloadsonarqube-c4e562cb2fad74318b6a9bf733a0909263ff0271.tar.gz
sonarqube-c4e562cb2fad74318b6a9bf733a0909263ff0271.zip
Update issue notification link
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java4
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java21
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt6
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt4
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt4
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt4
6 files changed, 35 insertions, 8 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java
index e2776bbdf8d..9a342524d2f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java
@@ -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("&currentIssue=").append(issueKey).append(NEW_LINE);
}
private void appendLine(StringBuilder sb, @Nullable String line) {
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java
index 02e00bacb0a..77a5f382533 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java
@@ -100,6 +100,24 @@ public class IssueChangesEmailTemplateTest {
}
@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()
.setFieldValue("comment", "How to fix it?")
@@ -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");
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt
new file mode 100644
index 00000000000..74e3c716b78
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt
@@ -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&currentIssue=ABCDE
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt
index d1230a17d45..1fc46b2e8f7 100644
--- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt
@@ -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&currentIssue=ABCDE
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt
index 8cc9ab6d1fe..aec09dd4b52 100644
--- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt
@@ -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&currentIssue=ABCDE
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt
index 995de7018e5..6bee33751fd 100644
--- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt
@@ -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&currentIssue=ABCDE