From 6c02ac9db7537a9fab87bc5b9e7b3d50ec1494f4 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 8 Feb 2012 10:41:04 +0100 Subject: [PATCH] SONAR-2747 Improve email message --- .../plugins/core/timemachine/NewViolationsDecorator.java | 3 +-- .../plugins/core/timemachine/NewViolationsDecoratorTest.java | 3 +-- .../newviolations/NewViolationsEmailTemplate.java | 4 +--- .../newviolations/NewViolationsEmailTemplateTest.java | 5 ++--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java index d714cada4fa..4cd71f04f5d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java @@ -223,8 +223,7 @@ public class NewViolationsDecorator implements Decorator { .setFieldValue("projectName", project.getLongName()) .setFieldValue("projectKey", project.getKey()) .setFieldValue("projectId", String.valueOf(project.getId())) - .setFieldValue("fromDate", dateformat.format(pastSnapshot.getTargetDate())) - .setFieldValue("toDate", dateformat.format(new Date())); + .setFieldValue("fromDate", dateformat.format(pastSnapshot.getTargetDate())); notificationManager.scheduleForSending(notification); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java index a5ee668fa1c..f5f803bc952 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java @@ -247,8 +247,7 @@ public class NewViolationsDecoratorTest { .setFieldValue("projectName", "LongName") .setFieldValue("projectKey", "key") .setFieldValue("projectId", "45") - .setFieldValue("fromDate", dateformat.format(pastDate.getTime())) - .setFieldValue("toDate", dateformat.format(new Date())); + .setFieldValue("fromDate", dateformat.format(pastDate.getTime())); verify(notificationManager, times(1)).scheduleForSending(eq(notification)); } diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplate.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplate.java index bfd105102d9..690b60335b2 100644 --- a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplate.java +++ b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplate.java @@ -47,11 +47,9 @@ public class NewViolationsEmailTemplate extends EmailTemplate { String projectName = notification.getFieldValue("projectName"); String violationsCount = notification.getFieldValue("count"); String fromDate = notification.getFieldValue("fromDate"); - String toDate = notification.getFieldValue("toDate"); sb.append("Project: ").append(projectName).append('\n'); - sb.append(violationsCount).append(" new violations on last analysis"); - sb.append(" (introduced between ").append(fromDate).append(" and ").append(toDate).append(")").append('\n'); + sb.append(violationsCount).append(" new violations introduced since ").append(fromDate).append('\n'); appendFooter(sb, notification); EmailMessage message = new EmailMessage() diff --git a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplateTest.java b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplateTest.java index 4fc6c220945..fdca5da0091 100644 --- a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplateTest.java +++ b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/newviolations/NewViolationsEmailTemplateTest.java @@ -67,15 +67,14 @@ public class NewViolationsEmailTemplateTest { .setFieldValue("projectName", "Foo") .setFieldValue("projectKey", "org.sonar.foo:foo") .setFieldValue("projectId", "45") - .setFieldValue("fromDate", "2012-01-02") - .setFieldValue("toDate", "2012-01-15"); + .setFieldValue("fromDate", "2012-01-02"); EmailMessage message = template.format(notification); assertThat(message.getMessageId(), is("new-violations/45")); assertThat(message.getSubject(), is("New violations for project Foo")); assertThat(message.getMessage(), is("" + "Project: Foo\n" + - "32 new violations on last analysis (introduced between 2012-01-02 and 2012-01-15)\n" + + "32 new violations introduced since 2012-01-02\n" + "\n" + "See it in Sonar: http://nemo.sonarsource.org/drilldown/measures/org.sonar.foo:foo?metric=new_violations&period=1\n")); } -- 2.39.5