]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4396 The email notification about 'New issues' should provide a link whose...
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 10 Jul 2013 09:12:36 +0000 (11:12 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 10 Jul 2013 09:12:36 +0000 (11:12 +0200)
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/test/java/org/sonar/core/issue/IssueNotificationsTest.java

index c07e6adaa29a317f8f265f80470d4ce99d8d3973..d479c508d1fef3cbac4b62be76f18349458fbcfb 100644 (file)
@@ -25,6 +25,7 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.plugins.emailnotifications.api.EmailMessage;
 import org.sonar.plugins.emailnotifications.api.EmailTemplate;
 
+import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.Date;
 
@@ -68,9 +69,17 @@ public class NewIssuesEmailTemplate extends EmailTemplate {
     if (projectKey != null && dateString != null) {
       Date date = DateUtils.parseDateTime(dateString);
       String url = String.format("%s/issues/search?componentRoots=%s&createdAfter=%s",
-        settings.getServerBaseURL(), URLEncoder.encode(projectKey), DateUtils.formatDate(date));
+        settings.getServerBaseURL(), encode(projectKey), encode(DateUtils.formatDateTime(date)));
       sb.append("\n").append("See it in SonarQube: ").append(url).append("\n");
     }
   }
 
+  public static String encode(String toEncode) {
+    try {
+      return URLEncoder.encode(toEncode, "UTF-8");
+    } catch (UnsupportedEncodingException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
 }
index f3f8b1cf42cff3360a03d9eb6d8c70dfea92588a..eb09ae9c7d9d0c2db1f0ca46618d21c716049e90 100644 (file)
@@ -64,7 +64,7 @@ public class NewIssuesEmailTemplateTest {
       .setFieldValue("count", "32")
       .setFieldValue("projectName", "Struts")
       .setFieldValue("projectKey", "org.apache:struts")
-      .setFieldValue("projectDate", "2010-05-18T15:50:45+0100");
+      .setFieldValue("projectDate", "2010-05-18T16:50:45+0200");
 
     EmailMessage message = template.format(notification);
     assertThat(message.getMessageId()).isEqualTo("new-issues/org.apache:struts");
@@ -73,7 +73,7 @@ public class NewIssuesEmailTemplateTest {
       "Project: Struts\n" +
       "32 new issues\n" +
       "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/issues/search?componentRoots=org.apache%3Astruts&createdAfter=2010-05-18\n");
+      "See it in SonarQube: http://nemo.sonarsource.org/issues/search?componentRoots=org.apache%3Astruts&createdAfter=2010-05-18T16%3A50%3A45%2B0200\n");
   }
 
   @Test
index 7f14933a9851338aebcc22a6b810bc647e26cd4a..9f85faa3be92478e0cbf9384340157806f47de7d 100644 (file)
@@ -57,7 +57,7 @@ public class IssueNotificationsTest {
   }
 
   @Test
-  public void sendNewIssues() throws Exception {
+  public void should_send_new_issues() throws Exception {
     Date date = DateUtils.parseDateTime("2013-05-18T00:00:03+0200");
     Project project = new Project("struts").setAnalysisDate(date);
     Notification notification = issueNotifications.sendNewIssues(project, 42);
@@ -68,7 +68,7 @@ public class IssueNotificationsTest {
   }
 
   @Test
-  public void sendChanges() throws Exception {
+  public void should_send_changes() throws Exception {
     IssueChangeContext context = IssueChangeContext.createScan(new Date());
     DefaultIssue issue = new DefaultIssue()
       .setMessage("the message")
@@ -93,7 +93,7 @@ public class IssueNotificationsTest {
   }
 
   @Test
-  public void sendChangesWithComment() throws Exception {
+  public void should_send_changes_with_comment() throws Exception {
     IssueChangeContext context = IssueChangeContext.createScan(new Date());
     DefaultIssue issue = new DefaultIssue()
       .setMessage("the message")