]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8730 use existing L18n for types in new issue notifications
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 28 Sep 2017 08:45:19 +0000 (10:45 +0200)
committerEric Hartmann <hartmann.eric@gmail.Com>
Mon, 2 Oct 2017 11:03:35 +0000 (13:03 +0200)
server/sonar-server/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java

index 8f6626c70a1262e6b12735201a9d7c6a84fa13bc..7a5eb221ac521a0dc5ae5c1137d56de3101d12cb 100644 (file)
@@ -179,7 +179,7 @@ public abstract class AbstractNewIssuesEmailTemplate extends EmailTemplate {
 
     for (Iterator<RuleType> ruleTypeIterator = Arrays.asList(RuleType.BUG, RuleType.VULNERABILITY, RuleType.CODE_SMELL).iterator(); ruleTypeIterator.hasNext();) {
       RuleType ruleType = ruleTypeIterator.next();
-      String ruleTypeLabel = i18n.message(getLocale(), "rule_type." + ruleType, ruleType.name());
+      String ruleTypeLabel = i18n.message(getLocale(), "issue.type." + ruleType, ruleType.name());
       message.append(ruleTypeLabel).append(": ").append(notification.getFieldValue(Metric.RULE_TYPE + DOT + ruleType + COUNT));
       if (ruleTypeIterator.hasNext()) {
         message.append(TAB);
index 1c88818d3c35dd8d63012525bc771b8f59809eb9..13092a3ba2f1f43eb361a11b2a844b3d9577b0df 100644 (file)
@@ -63,9 +63,9 @@ public class MyNewIssuesEmailTemplateTest {
     // returns the login passed in parameter
     when(userIndex.getNullableByLogin(anyString()))
       .thenAnswer((Answer<UserDoc>) invocationOnMock -> new UserDoc().setName((String) invocationOnMock.getArguments()[0]));
-    when(i18n.message(any(Locale.class), eq("rule_type.BUG"), anyString())).thenReturn("Bug");
-    when(i18n.message(any(Locale.class), eq("rule_type.CODE_SMELL"), anyString())).thenReturn("Code Smell");
-    when(i18n.message(any(Locale.class), eq("rule_type.VULNERABILITY"), anyString())).thenReturn("Vulnerability");
+    when(i18n.message(any(Locale.class), eq("issue.type.BUG"), anyString())).thenReturn("Bug");
+    when(i18n.message(any(Locale.class), eq("issue.type.CODE_SMELL"), anyString())).thenReturn("Code Smell");
+    when(i18n.message(any(Locale.class), eq("issue.type.VULNERABILITY"), anyString())).thenReturn("Vulnerability");
 
     underTest = new MyNewIssuesEmailTemplate(settings, i18n);
   }
index d674904afe249f8828c4a72d5602b659702456fc..02872c4f408b6420ae2fdb089b5a562d92c9818c 100644 (file)
@@ -61,9 +61,9 @@ public class NewIssuesEmailTemplateTest {
     // returns the login passed in parameter
     when(userIndex.getNullableByLogin(anyString()))
       .thenAnswer((Answer<UserDoc>) invocationOnMock -> new UserDoc().setName((String) invocationOnMock.getArguments()[0]));
-    when(i18n.message(any(Locale.class), eq("rule_type.CODE_SMELL"), anyString())).thenReturn("Code Smell");
-    when(i18n.message(any(Locale.class), eq("rule_type.VULNERABILITY"), anyString())).thenReturn("Vulnerability");
-    when(i18n.message(any(Locale.class), eq("rule_type.BUG"), anyString())).thenReturn("Bug");
+    when(i18n.message(any(Locale.class), eq("issue.type.CODE_SMELL"), anyString())).thenReturn("Code Smell");
+    when(i18n.message(any(Locale.class), eq("issue.type.VULNERABILITY"), anyString())).thenReturn("Vulnerability");
+    when(i18n.message(any(Locale.class), eq("issue.type.BUG"), anyString())).thenReturn("Bug");
 
     template = new NewIssuesEmailTemplate(settings, i18n);
   }
index 477f3ab48d3d2f13d0da0b508cb8f7156cbdb527..62b6117fdaf701428cf1c06d0ea1ff57aabbb1bf 100644 (file)
@@ -90,7 +90,6 @@ public class IssueNotificationsTest {
   @Parameter
   public boolean privateProject;
 
-
   @BeforeClass
   public static void setUp() {
     smtpServer = new Wiser(0);
@@ -151,13 +150,13 @@ public class IssueNotificationsTest {
 
     extractBodies(smtpServer.getMessages()).forEach(
       message -> assertThat(message)
-            .contains("Project: Sample")
-            .contains("Version: " + version)
-            .contains("17 new issues (new debt: 17min)")
-            .contains("Type")
-            .contains("One Issue Per Line (xoo): 17")
-            .contains("More details at: http://localhost:9000/project/issues?id=sample&createdAt=2015-12-15T00%3A00%3A00%2B")
-    );
+        .contains("Project: Sample")
+        .contains("Version: " + version)
+        .contains("17 new issues (new debt: 17min)")
+        .contains("Type")
+        .contains("Bug: ").contains("Code Smell: ").contains("Vulnerability: ")
+        .contains("One Issue Per Line (xoo): 17")
+        .contains("More details at: http://localhost:9000/project/issues?id=sample&createdAt=2015-12-15T00%3A00%3A00%2B"));
 
     clearSmtpMessages();
   }
@@ -202,8 +201,7 @@ public class IssueNotificationsTest {
       "sonar.projectVersion", version,
       "sonar.scm.provider", "xoo",
       "sonar.scm.disabled", "false",
-      "sonar.exclusions", "**/*"
-    );
+      "sonar.exclusions", "**/*");
 
     // No email since all code is ignored
     waitUntilAllNotificationsAreDelivered(1);
@@ -213,8 +211,7 @@ public class IssueNotificationsTest {
     runAnalysis("issue/xoo-with-scm",
       "sonar.projectVersion", version,
       "sonar.scm.provider", "xoo",
-      "sonar.scm.disabled", "false"
-    );
+      "sonar.scm.disabled", "false");
 
     // We expect to receive a notification for each subscriber with UserRole.user
     // And a personalized email for the assignee userWithUserRole