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_creates_rule_from_RuleRepository() {
    RuleKey ruleKey = RuleKey.of("foo", "bar");
    DefaultIssue issue = new DefaultIssue()
      .setRuleKey(ruleKey)
      .setKey("issueKey")
      .setStatus(STATUS_OPEN);
    Map<String, UserDto> assigneesByUuid = nonEmptyAssigneesByUuid();
    ReportComponent project = ReportComponent.builder(PROJECT, 1).build();
    String branchName = randomAlphabetic(12);
    ruleRepository.add(ruleKey);
    treeRootHolder.setRoot(project);
    analysisMetadata.setAnalysisDate(new Random().nextLong());
    analysisMetadata.setBranch(newNonMainBranch(BranchType.BRANCH, branchName));
    IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
    when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);

    IssuesChangesNotification notification = underTest.newIssuesChangesNotification(ImmutableSet.of(issue), assigneesByUuid);

    assertThat(notification).isSameAs(expected);
    IssuesChangesNotificationBuilder builder = verifyAndCaptureIssueChangeNotificationBuilder();
    assertThat(builder.getIssues()).hasSize(1);
    ChangedIssue changeIssue = builder.getIssues().iterator().next();
    assertThat(changeIssue.getRule().getKey()).isEqualTo(ruleKey);
    assertThat(changeIssue.getRule().getName()).isEqualTo(ruleRepository.getByKey(ruleKey).getName());
  }