/** Only false positive and won't fix resolutions */
  @Test
  public void ignore_other_resolutions() {
    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
    recipients.put("simon", emailChannel);
    recipients.put("freddy", twitterChannel);
    when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);

    Notification fixedNotif =
        new IssueChangeNotification()
            .setFieldValue("projectKey", "struts")
            .setFieldValue("changeAuthor", "godin")
            .setFieldValue("new.resolution", Issue.RESOLUTION_FIXED)
            .setFieldValue("assignee", "freddy");
    underTest.performDispatch(fixedNotif, context);

    verifyZeroInteractions(context);
  }
示例#2
0
 void saveIssue(
     DbSession session, DefaultIssue issue, IssueChangeContext context, @Nullable String comment) {
   String projectKey = issue.projectKey();
   if (projectKey == null) {
     throw new IllegalStateException(String.format("Issue '%s' has no project key", issue.key()));
   }
   issueStorage.save(session, issue);
   Rule rule = getNullableRuleByKey(issue.ruleKey());
   ComponentDto project = dbClient.componentDao().selectOrFailByKey(session, projectKey);
   notificationService.scheduleForSending(
       new IssueChangeNotification()
           .setIssue(issue)
           .setChangeAuthorLogin(context.login())
           .setRuleName(rule != null ? rule.getName() : null)
           .setProject(project.getKey(), project.name())
           .setComponent(dbClient.componentDao().selectOrFailByKey(session, issue.componentKey()))
           .setComment(comment));
 }
  @Test
  public void should_dispatch_to_subscribers() {
    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
    recipients.put("simon", emailChannel);
    recipients.put("freddy", twitterChannel);
    recipients.put("godin", twitterChannel);
    when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);

    Notification fpNotif =
        new IssueChangeNotification()
            .setFieldValue("projectKey", "struts")
            .setFieldValue("changeAuthor", "godin")
            .setFieldValue("new.resolution", Issue.RESOLUTION_FALSE_POSITIVE)
            .setFieldValue("assignee", "freddy");
    underTest.performDispatch(fpNotif, context);

    verify(context).addUser("simon", emailChannel);
    verify(context).addUser("freddy", twitterChannel);
    // do not notify the person who flagged the issue as false-positive
    verify(context, never()).addUser("godin", twitterChannel);
    verifyNoMoreInteractions(context);
  }