aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-07-10 11:12:36 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-07-10 11:12:36 +0200
commit993f49f30c5731197957300e69e9881c6ee1e970 (patch)
tree3fd6db157681725adbd8b5e8fadf3a4c332e47f0 /plugins
parent0e22ff26bbb34b098f1fa738abaf600473ab092f (diff)
downloadsonarqube-993f49f30c5731197957300e69e9881c6ee1e970.tar.gz
sonarqube-993f49f30c5731197957300e69e9881c6ee1e970.zip
SONAR-4396 The email notification about 'New issues' should provide a link whose parameter 'createdAfter' must define a time and not only a date
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java11
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java4
2 files changed, 12 insertions, 3 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java
index c07e6adaa29..d479c508d1f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java
@@ -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);
+ }
+ }
+
}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
index f3f8b1cf42c..eb09ae9c7d9 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
@@ -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