@Override
  public void onIssue(Component component, DefaultIssue issue) {
    if (issue.authorLogin() != null) {
      return;
    }
    loadScmChangesets(component);
    Optional<String> scmAuthor = guessScmAuthor(issue, component);

    if (scmAuthor.isPresent()) {
      if (scmAuthor.get().length() <= IssueDto.AUTHOR_MAX_SIZE) {
        issueUpdater.setNewAuthor(issue, scmAuthor.get(), changeContext);
      } else {
        LOGGER.debug("SCM account '{}' is too long to be stored as issue author", scmAuthor.get());
      }
    }

    if (issue.assignee() == null) {
      UserIdDto userId = scmAuthor.map(scmAccountToUser::getNullable).orElse(defaultAssignee.loadDefaultAssigneeUserId());
      issueUpdater.setNewAssignee(issue, userId, changeContext);
    }
  }
@Test
  void assign_to_last_committer_of_file_if_issue_is_global_to_file() {
    addScmUser("henry", buildUserId("u123", "Henry V"));
    Changeset changeset1 = Changeset.newChangesetBuilder()
      .setAuthor("john")
      .setDate(1_000L)
      .setRevision("rev-1")
      .build();
    // Latest changeset
    Changeset changeset2 = Changeset.newChangesetBuilder()
      .setAuthor("henry")
      .setDate(2_000L)
      .setRevision("rev-2")
      .build();
    scmInfoRepository.setScmInfo(FILE_REF, changeset1, changeset2, changeset1);

    DefaultIssue issue = newIssueOnLines();

    underTest.onIssue(FILE, issue);

    assertThat(issue.assignee()).isEqualTo("u123");
    assertThat(issue.assigneeLogin()).isEqualTo("Henry V");
  }