@Override
  @CheckForNull
  public EmailMessage format(Notification notif) {
    if (!(notif instanceof ChangesOnMyIssuesNotification)) {
      return null;
    }

    ChangesOnMyIssuesNotification notification = (ChangesOnMyIssuesNotification) notif;

    if (notification.getChange() instanceof AnalysisChange) {
      checkState(!notification.getChangedIssues().isEmpty(), "changedIssues can't be empty");
      return formatAnalysisNotification(notification.getChangedIssues().keySet().iterator().next(), notification);
    }
    return formatMultiProject(notification);
  }
@Test
  public void format_set_html_message_with_header_dealing_with_plural_when_change_from_Analysis() {
    Set<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(4))
      .mapToObj(i -> newChangedIssue(i + "", randomValidStatus(), newProject("prj_" + i), newRandomNotAHotspotRule("rule_" + i)))
      .collect(toSet());
    AnalysisChange analysisChange = newAnalysisChange();

    EmailMessage singleIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues.stream().limit(1).collect(toSet())));
    EmailMessage multiIssueMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, changedIssues));

    HtmlFragmentAssert.assertThat(singleIssueMessage.getMessage())
      .hasParagraph("Hi,")
      .hasParagraph("An analysis has updated an issue assigned to you:");
    HtmlFragmentAssert.assertThat(multiIssueMessage.getMessage())
      .hasParagraph("Hi,")
      .hasParagraph("An analysis has updated issues assigned to you:");
  }