From fdc0cf83bbe58b24504bbafa52dfa135cbbb17c6 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 23 Jun 2017 15:12:35 +0200 Subject: [PATCH] SONAR-9442 Update notification first sentence and add line breaks --- .../BuiltInQualityProfilesNotificationTemplate.java | 4 ++-- .../BuiltInQualityProfilesNotificationTemplateTest.java | 6 +++--- .../BuiltInQualityProfilesNotificationTest.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplate.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplate.java index e30294c2ada..8572d30e8a1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplate.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplate.java @@ -49,8 +49,7 @@ public class BuiltInQualityProfilesNotificationTemplate extends EmailTemplate { } BuiltInQualityProfilesNotification profilesNotification = parse(notification); - - StringBuilder message = new StringBuilder("Built-in quality profiles have been updated:\n"); + StringBuilder message = new StringBuilder("The following built-in profiles have been updated:\n\n"); profilesNotification.getProfiles().stream() .sorted(Comparator.comparing(Profile::getLanguageName).thenComparing(Profile::getProfileName)) .forEach(profile -> { @@ -80,6 +79,7 @@ public class BuiltInQualityProfilesNotificationTemplate extends EmailTemplate { if (removedRules > 0) { message.append(" ").append(removedRules).append(" rules removed\n"); } + message.append("\n"); }); message.append("This is a good time to review your quality profiles and update them to benefit from the latest evolutions: "); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplateTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplateTest.java index 176a22aa7e7..c3514e636a2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplateTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesNotificationTemplateTest.java @@ -169,7 +169,7 @@ public class BuiltInQualityProfilesNotificationTemplateTest { EmailMessage emailMessage = underTest.format(notification.serialize()); - assertThat(emailMessage.getMessage()).containsSequence("Built-in quality profiles have been updated:\n", + assertThat(emailMessage.getMessage()).containsSequence("The following built-in profiles have been updated:\n", profileTitleText(profileName1, languageKey1, languageName1), " 2 new rules\n", profileTitleText(profileName2, languageKey2, languageName2), @@ -236,9 +236,9 @@ public class BuiltInQualityProfilesNotificationTemplateTest { } private void assertMessage(EmailMessage emailMessage, String expectedProfileDetails) { - assertThat(emailMessage.getMessage()).containsSequence("Built-in quality profiles have been updated:\n", + assertThat(emailMessage.getMessage()).containsSequence("The following built-in profiles have been updated:\n\n", expectedProfileDetails, - "This is a good time to review your quality profiles and update them to benefit from the latest evolutions: " + server.getPublicRootUrl() + "/profiles"); + "\nThis is a good time to review your quality profiles and update them to benefit from the latest evolutions: " + server.getPublicRootUrl() + "/profiles"); } private String profileTitleText(String profileName, String languageKey, String languageName) { diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java index 92a7b897789..8593dc17a08 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java @@ -134,7 +134,7 @@ public class BuiltInQualityProfilesNotificationTest { String url = orchestrator.getServer().getUrl(); assertThat(messages.get(0).getMimeMessage().getContent().toString()) .containsSequence( - "Built-in quality profiles have been updated:", + "The following built-in profiles have been updated:", "\"Basic\" - Foo: " + url + "/profiles/changelog?language=foo&name=Basic&since=", "&to=", " 1 new rules", " 3 rules have been updated", -- 2.39.5