]> source.dussan.org Git - sonarqube.git/commitdiff
Merge branch 'master' into branch-3.7
authorEric Hartmann <hartmann.eric@gmail.com>
Tue, 10 Sep 2013 08:58:45 +0000 (10:58 +0200)
committerEric Hartmann <hartmann.eric@gmail.com>
Tue, 10 Sep 2013 08:58:45 +0000 (10:58 +0200)
Conflicts:
plugins/sonar-core-plugin/pom.xml
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
plugins/sonar-cpd-plugin/pom.xml
plugins/sonar-dbcleaner-plugin/pom.xml
plugins/sonar-design-plugin/pom.xml
plugins/sonar-email-notifications-plugin/pom.xml
plugins/sonar-l10n-en-plugin/pom.xml
plugins/sonar-maven-batch-plugin/pom.xml
pom.xml
sonar-application/pom.xml
sonar-batch-maven-compat/pom.xml
sonar-batch/pom.xml
sonar-channel/pom.xml
sonar-check-api/pom.xml
sonar-colorizer/pom.xml
sonar-core/pom.xml
sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java
sonar-core/src/main/java/org/sonar/core/issue/IssueUpdater.java
sonar-core/src/test/java/org/sonar/core/issue/IssueNotificationsTest.java
sonar-core/src/test/java/org/sonar/core/issue/IssueUpdaterTest.java
sonar-deprecated/pom.xml
sonar-duplications/pom.xml
sonar-graph/pom.xml
sonar-home/pom.xml
sonar-java-api/pom.xml
sonar-markdown/pom.xml
sonar-maven-plugin/pom.xml
sonar-maven3-plugin/pom.xml
sonar-plugin-api/pom.xml
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
sonar-server/pom.xml
sonar-server/src/main/java/org/sonar/server/db/migrations/ConvertViolationsToIssues.java
sonar-squid/pom.xml
sonar-testing-harness/pom.xml
sonar-ws-client/pom.xml

1  2 
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/SendIssueNotificationsPostJobTest.java

index 736049d7ae8961c7300cda6c56b06bd13c0931a1,82a1fe70ff4ad7773f0fa778ea13bc37c42b9162..87276370b60a7ba83bef32257e956f79fdb33a8d
@@@ -119,26 -129,45 +129,65 @@@ public class SendIssueNotificationsPost
      SendIssueNotificationsPostJob job = new SendIssueNotificationsPostJob(issueCache, notifications, ruleFinder);
      job.executeOn(project, sensorContext);
  
-     verify(notifications, never()).sendChanges(eq(issue), eq(changeContext), any(Rule.class), any(Component.class), any(Component.class));
+     verify(notifications, never()).sendChanges(argThat(matchMapOf(issue, null)), eq(changeContext), any(Component.class), any(Component.class));
+   }
+   @Test
+   public void should_not_send_notification_on_any_change() throws Exception {
+     IssueChangeContext changeContext = mock(IssueChangeContext.class);
+     when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18"));
+     RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
+     DefaultIssue issue = new DefaultIssue()
+       .setChanged(true)
+       .setSendNotifications(false)
+       .setFieldChange(changeContext, "severity", "MINOR", "BLOCKER")
+       .setRuleKey(ruleKey);
+     when(issueCache.all()).thenReturn(Arrays.asList(issue));
+     when(ruleFinder.findByKey(ruleKey)).thenReturn(null);
+     SendIssueNotificationsPostJob job = new SendIssueNotificationsPostJob(issueCache, notifications, ruleFinder);
+     job.executeOn(project, sensorContext);
+     verify(notifications, never()).sendChanges(argThat(matchMapOf(issue, null)), eq(changeContext), any(Component.class), any(Component.class));
+   }
+   private static IsMapOfIssueAndRule matchMapOf(DefaultIssue issue, Rule rule) {
+     return new IsMapOfIssueAndRule(issue, rule);
+   }
+   static class IsMapOfIssueAndRule extends ArgumentMatcher<Map<DefaultIssue, Rule>> {
+     private DefaultIssue issue;
+     private Rule rule;
+     public IsMapOfIssueAndRule(DefaultIssue issue, Rule rule) {
+       this.issue = issue;
+       this.rule = rule;
+     }
+     public boolean matches(Object arg) {
+       Map map = (Map) arg;
+       return map.size() == 1 && map.get(issue) != null && map.get(issue).equals(rule);
+     }
    }
 +
 +  @Test
 +  public void should_not_send_notification_on_any_change() throws Exception {
 +    IssueChangeContext changeContext = mock(IssueChangeContext.class);
 +
 +    when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18"));
 +    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
 +    DefaultIssue issue = new DefaultIssue()
 +      .setChanged(true)
 +      .setSendNotifications(false)
 +      .setFieldChange(changeContext, "severity", "MINOR", "BLOCKER")
 +      .setRuleKey(ruleKey);
 +    when(issueCache.all()).thenReturn(Arrays.asList(issue));
 +    when(ruleFinder.findByKey(ruleKey)).thenReturn(null);
 +
 +    SendIssueNotificationsPostJob job = new SendIssueNotificationsPostJob(issueCache, notifications, ruleFinder);
 +    job.executeOn(project, sensorContext);
 +
 +    verify(notifications, never()).sendChanges(eq(issue), eq(changeContext), any(Rule.class), any(Component.class), any(Component.class));
 +  }
  }