From ed5105e4294e2e3a2887e9d09c0384fbadb57a35 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 10 Jun 2013 21:29:21 +0200 Subject: [PATCH] SONAR-4283 do not persist notifications of changes on new issues --- .../issue/notification/SendIssueNotificationsPostJob.java | 2 +- .../notification/SendIssueNotificationsPostJobTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJob.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJob.java index 32a3d0a5b22..a93f38fd783 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJob.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJob.java @@ -56,7 +56,7 @@ public class SendIssueNotificationsPostJob implements PostJob { if (issue.isNew() && issue.resolution() == null) { newIssues++; } - if (issue.isChanged()) { + if (!issue.isNew() && issue.isChanged()) { Rule rule = ruleFinder.findByKey(issue.ruleKey()); // TODO warning - rules with status REMOVED are currently ignored, but should not if (rule != null) { diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJobTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJobTest.java index fd9af8ea8ec..fc61ced163a 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJobTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJobTest.java @@ -84,12 +84,12 @@ public class SendIssueNotificationsPostJobTest { } @Test - public void should_send_notif_if_issue_change() throws Exception { - + public void should_send_notification_if_issue_change() throws Exception { when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18")); RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles"); Rule rule = new Rule("squid", "AvoidCycles"); DefaultIssue issue = new DefaultIssue() + .setNew(false) .setChanged(true) .setFieldChange(mock(IssueChangeContext.class), "severity", "MINOR", "BLOCKER") .setRuleKey(ruleKey); @@ -103,7 +103,7 @@ public class SendIssueNotificationsPostJobTest { } @Test - public void should_not_send_notif_if_issue_change_on_removed_rule() throws Exception { + public void should_not_send_notification_if_issue_change_on_removed_rule() throws Exception { IssueChangeContext changeContext = mock(IssueChangeContext.class); when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18")); -- 2.39.5