aboutsummaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java6
3 files changed, 15 insertions, 6 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
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java b/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java
index 7f14933a985..9f85faa3be9 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java
@@ -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")