aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-28 10:31:28 +0200
committerEric Hartmann <hartmann.eric@gmail.Com>2017-10-02 13:03:35 +0200
commitd5d34de3b57dc1e533d4ba2cc61c5ffea9dd4dd7 (patch)
tree7c43c4d8a8f1d5c9cfb6d929a02f12b2c699cd08 /server
parent929c3d426c51982272dabf5b3e6472b4a155eb60 (diff)
downloadsonarqube-d5d34de3b57dc1e533d4ba2cc61c5ffea9dd4dd7.tar.gz
sonarqube-d5d34de3b57dc1e533d4ba2cc61c5ffea9dd4dd7.zip
SONAR-9725 support singular in subject of new issue notifications
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplate.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java2
4 files changed, 12 insertions, 4 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
index ec3ccd8a803..8f6626c70a1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
@@ -111,9 +111,11 @@ public abstract class AbstractNewIssuesEmailTemplate extends EmailTemplate {
protected abstract boolean shouldNotFormat(Notification notification);
protected String subject(Notification notification, String fullProjectName) {
- return String.format("%s: %s new issues (new debt: %s)",
+ int issueCount = Integer.parseInt(notification.getFieldValue(Metric.RULE_TYPE + COUNT));
+ return String.format("%s: %s new issue%s (new debt: %s)",
fullProjectName,
- notification.getFieldValue(Metric.RULE_TYPE + COUNT),
+ issueCount,
+ issueCount > 1 ? "s" : "",
notification.getFieldValue(Metric.EFFORT + COUNT));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplate.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplate.java
index fcf02e34b46..dd75a4cf95c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplate.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplate.java
@@ -47,8 +47,10 @@ public class MyNewIssuesEmailTemplate extends AbstractNewIssuesEmailTemplate {
@Override
protected String subject(Notification notification, String fullProjectName) {
- return String.format("You have %s new issues on project %s",
- notification.getFieldValue(Metric.RULE_TYPE + COUNT),
+ int issueCount = Integer.parseInt(notification.getFieldValue(Metric.RULE_TYPE + COUNT));
+ return String.format("You have %s new issue%s on project %s",
+ issueCount,
+ issueCount > 1 ? "s" : "",
fullProjectName);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
index 98741da80e7..1c88818d3c3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
@@ -185,6 +185,8 @@ public class MyNewIssuesEmailTemplateTest {
EmailMessage message = underTest.format(notification);
+ assertThat(message.getSubject())
+ .isEqualTo("You have 1 new issue on project Struts");
assertThat(message.getMessage())
.contains("1 new issue (new debt: 1d3h)\n");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
index 36d78f01ae0..d674904afe2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
@@ -167,6 +167,8 @@ public class NewIssuesEmailTemplateTest {
EmailMessage message = template.format(notification);
+ assertThat(message.getSubject())
+ .isEqualTo("Struts: 1 new issue (new debt: 1d3h)");
assertThat(message.getMessage())
.contains("1 new issue (new debt: 1d3h)\n");
}