public IssuesChangesNotification newIssuesChangesNotification(Set<DefaultIssue> issues, Map<String, UserDto> assigneesByUuid) {
    AnalysisChange change = new AnalysisChange(analysisMetadataHolder.getAnalysisDate());
    Set<ChangedIssue> changedIssues = issues.stream()
      .map(issue -> new ChangedIssue.Builder(issue.key())
        .setAssignee(getAssignee(issue.assignee(), assigneesByUuid))
        .setNewStatus(issue.status())
        .setNewIssueStatus(issue.status() != null ? IssueStatus.of(issue.status(), issue.resolution()) : null)
        .setRule(getRuleByRuleKey(issue.ruleKey()))
        .setProject(getProject())
        .build())
      .collect(Collectors.toSet());

    return issuesChangesSerializer.serialize(new IssuesChangesNotificationBuilder(changedIssues, change));
  }
@Test
  public void newIssuesChangesNotification_fails_with_ISE_if_rule_of_issue_does_not_exist_in_repository() {
    RuleKey ruleKey = RuleKey.of("foo", "bar");
    DefaultIssue issue = new DefaultIssue()
      .setRuleKey(ruleKey);
    Map<String, UserDto> assigneesByUuid = nonEmptyAssigneesByUuid();
    analysisMetadata.setAnalysisDate(new Random().nextLong());

    assertThatThrownBy(() -> underTest.newIssuesChangesNotification(ImmutableSet.of(issue), assigneesByUuid))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Can not find rule " + ruleKey + " in RuleRepository");
  }