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;
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);
+ }
+ }
+
}
.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");
"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
}
@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);
}
@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")
}
@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")