]> source.dussan.org Git - sonarqube.git/commitdiff
Fix URL in notification email on issue changes
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 30 Oct 2014 16:20:27 +0000 (17:20 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 30 Oct 2014 16:24:41 +0000 (17:24 +0100)
Replace request parameter componentRoot by componentRootUuid

plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java

index d8e94277b2a349fd8f50d60fa3c0f5ffdc38515e..6f99c8b9a572386eed44cfbded3f45164b7ec35f 100644 (file)
@@ -83,12 +83,12 @@ public class NewIssuesEmailTemplate extends EmailTemplate {
   }
 
   private void appendFooter(StringBuilder sb, Notification notification) {
-    String projectKey = notification.getFieldValue(FIELD_PROJECT_KEY);
+    String projectUuid = notification.getFieldValue("projectUuid");
     String dateString = notification.getFieldValue(FIELD_PROJECT_DATE);
-    if (projectKey != null && dateString != null) {
+    if (projectUuid != null && dateString != null) {
       Date date = DateUtils.parseDateTime(dateString);
-      String url = String.format("%s/issues/search#componentRoots=%s|createdAt=%s",
-        settings.getServerBaseURL(), encode(projectKey), encode(DateUtils.formatDateTime(date)));
+      String url = String.format("%s/issues/search#componentRootUUids=%s|createdAt=%s",
+        settings.getServerBaseURL(), encode(projectUuid), encode(DateUtils.formatDateTime(date)));
       sb.append("\n").append("See it in SonarQube: ").append(url).append("\n");
     }
   }
index 58bd220a9978782cd710503246d45ee0148ab217..6b7a5d6c6263495cca19ebdc1118b9caf6def49e 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.plugins.core.issue.notification;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -31,10 +30,11 @@ import org.sonar.core.i18n.DefaultI18n;
 import org.sonar.plugins.emailnotifications.api.EmailMessage;
 
 import java.util.Locale;
-import java.util.TimeZone;
 
 import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -82,6 +82,7 @@ public class NewIssuesEmailTemplateTest {
       .setFieldValue("count-BLOCKER", "0")
       .setFieldValue("projectName", "Struts")
       .setFieldValue("projectKey", "org.apache:struts")
+      .setFieldValue("projectUuid", "ABCDE")
       .setFieldValue("projectDate", "2010-05-18T14:50:45+0000");
 
     when(i18n.message(any(Locale.class), eq("severity.BLOCKER"), anyString())).thenReturn("Blocker");
@@ -102,7 +103,7 @@ public class NewIssuesEmailTemplateTest {
       "\n" +
       "   Blocker: 0   Critical: 5   Major: 10   Minor: 3   Info: 1\n" +
       "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/issues/search#componentRoots=org.apache%3Astruts|createdAt=2010-05-1");
+      "See it in SonarQube: http://nemo.sonarsource.org/issues/search#componentRootUUids=ABCDE|createdAt=2010-05-1");
   }
 
   @Test
index 96e012b8e493eab076125d56e604d0cefc599567..c451592b80f988a523d2e2c890d968a598a1b085 100644 (file)
@@ -59,6 +59,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent {
     Notification notification = newNotification(project, "new-issues")
       .setDefaultMessage(newIssues.size() + " new issues on " + project.getLongName() + ".\n")
       .setFieldValue("projectDate", DateUtils.formatDateTime(project.getAnalysisDate()))
+      .setFieldValue("projectUuid", project.getUuid())
       .setFieldValue("count", String.valueOf(newIssues.size()));
     for (String severity : Severity.ALL) {
       notification.setFieldValue("count-" + severity, String.valueOf(newIssues.issues(severity)));