]> source.dussan.org Git - sonarqube.git/commitdiff
Update issue notification link
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 7 Jul 2014 11:47:11 +0000 (13:47 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 7 Jul 2014 11:47:11 +0000 (13:47 +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/display_component_key_if_no_component_name.txt [new file with mode: 0644]
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt

index e2776bbdf8d29256218004a0e9f52186ea132628..9a342524d2fb3b006c4fcc7e54bde9feb345852b 100644 (file)
@@ -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) {
index 02e00bacb0a03236cc645a2188aacbe7cdc73ed2..77a5f382533240b4b3943a07924507685d2713ae 100644 (file)
@@ -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");
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 (file)
index 0000000..74e3c71
--- /dev/null
@@ -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
index d1230a17d45a2a43db372120483056b77592b2bd..1fc46b2e8f7fdf961038bf34eb96a3e9f5f42f80 100644 (file)
@@ -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
index 8cc9ab6d1fefb9efeed129f807b0f49d6c50fd81..aec09dd4b523497cb5bf0e7784b219ed2110b1da 100644 (file)
@@ -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
index 995de7018e59ba86fabaa7c137c528fdbe82ad86..6bee33751fd997a6854a282e2626c950c8e0122e 100644 (file)
@@ -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