diff options
author | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-01-31 17:15:14 +0100 |
---|---|---|
committer | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2013-01-31 17:15:14 +0100 |
commit | 3cb5d59379d5b052e256e6a34547562b5cd9678f (patch) | |
tree | 97401ea30bc871cc3576094db56678113d050613 /plugins | |
parent | a65c759c562b567b28e0e3eac63895af20d01f41 (diff) | |
download | sonarqube-3cb5d59379d5b052e256e6a34547562b5cd9678f.tar.gz sonarqube-3cb5d59379d5b052e256e6a34547562b5cd9678f.zip |
SONAR-3959 Set the default message on existing notifications
Diffstat (limited to 'plugins')
5 files changed, 35 insertions, 32 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/GenerateAlertEvents.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/GenerateAlertEvents.java index 3e4d6150920..f62ac81950e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/GenerateAlertEvents.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/GenerateAlertEvents.java @@ -97,6 +97,7 @@ public class GenerateAlertEvents implements Decorator { protected void notifyUsers(Resource<?> resource, String alertName, String alertText, Level alertLevel, boolean isNewAlert) { Notification notification = new Notification("alerts") + .setDefaultMessage("Alert on " + resource.getLongName() + ": " + alertName) .setFieldValue("projectName", resource.getLongName()) .setFieldValue("projectKey", resource.getKey()) .setFieldValue("projectId", String.valueOf(resource.getId())) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java index 96a3a064e4b..6bf1301bc55 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java @@ -57,6 +57,7 @@ public class ReviewNotifications implements BatchExtension { private Notification createReviewNotification(ReviewDto review, Project project, @Nullable Resource resource) { return new Notification("review-changed") + .setDefaultMessage("Review #" + review.getId() + " has changed.") .setFieldValue("reviewId", String.valueOf(review.getId())) .setFieldValue("project", project.getRoot().getLongName()) .setFieldValue("projectId", String.valueOf(project.getId())) 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 18e10114331..a123d7a1918 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 @@ -19,14 +19,9 @@ */ package org.sonar.plugins.core.timemachine; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; - +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Sets; import org.apache.commons.lang.StringUtils; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorBarriers; @@ -51,9 +46,13 @@ import org.sonar.api.rules.Violation; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Sets; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; @DependsUpon(DecoratorBarriers.END_OF_VIOLATION_TRACKING) public class NewViolationsDecorator implements Decorator { @@ -218,6 +217,7 @@ public class NewViolationsDecorator implements Decorator { // Maybe we should check if this is the first analysis or not? DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd"); Notification notification = new Notification("new-violations") + .setDefaultMessage(newViolationsCount.intValue() + " new violations on " + project.getLongName() + ".") .setFieldValue("count", String.valueOf(newViolationsCount.intValue())) .setFieldValue("projectName", project.getLongName()) .setFieldValue("projectKey", project.getKey()) diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java index 994bb282a70..b7847a67793 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/GenerateAlertEventsTest.java @@ -195,6 +195,7 @@ public class GenerateAlertEventsTest { private void verifyNotificationSent(String alertName, String alertText, String alertLevel, String isNewAlert) { Notification notification = new Notification("alerts") + .setDefaultMessage("Alert on " + project.getLongName() + ": " + alertName) .setFieldValue("projectName", project.getLongName()) .setFieldValue("projectKey", project.getKey()) .setFieldValue("projectId", String.valueOf(project.getId())) 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 f5f803bc952..3f7867edd78 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 @@ -19,26 +19,7 @@ */ package org.sonar.plugins.core.timemachine; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - +import com.google.common.collect.Lists; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.time.DateUtils; import org.hamcrest.BaseMatcher; @@ -62,7 +43,25 @@ import org.sonar.api.rules.Violation; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; -import com.google.common.collect.Lists; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class NewViolationsDecoratorTest { private Rule rule1; @@ -243,6 +242,7 @@ public class NewViolationsDecoratorTest { DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd"); Notification notification = new Notification("new-violations") + .setDefaultMessage("32 new violations on LongName.") .setFieldValue("count", "32") .setFieldValue("projectName", "LongName") .setFieldValue("projectKey", "key") |