@Override
  public void onIssue(Component component, DefaultIssue issue) {
    if (component.getType() != Component.Type.FILE || component.getUuid().equals(issue.componentUuid())) {
      return;
    }
    Optional<OriginalFile> originalFileOptional = movedFilesRepository.getOriginalFile(component);
    checkState(originalFileOptional.isPresent(),
      "Issue %s for component %s has a different component key but no original file exist in MovedFilesRepository",
      issue, component);
    OriginalFile originalFile = originalFileOptional.get();
    String fileUuid = originalFile.uuid();
    checkState(fileUuid.equals(issue.componentUuid()),
      "Issue %s doesn't belong to file %s registered as original file of current file %s",
      issue, fileUuid, component);

    // changes the issue's component uuid, and set issue as changed, to enforce it is persisted to DB
    issueUpdater.setIssueComponent(issue, component.getUuid(), component.getKey(), new Date(analysisMetadataHolder.getAnalysisDate()));
  }
@Test
  public void onIssue_update_component_and_module_fields_to_component_and_flag_issue_has_changed() {
    MovedFilesRepository.OriginalFile originalFile = new MovedFilesRepository.OriginalFile("original uuid", "original key");
    DefaultIssue issue = mockIssue(originalFile.uuid());
    when(movedFilesRepository.getOriginalFile(FILE))
      .thenReturn(Optional.of(originalFile));

    underTest.onIssue(FILE, issue);

    verify(issue).setComponentUuid(FILE.getUuid());
    verify(issue).setComponentKey(FILE.getKey());
    verify(issue).setUpdateDate(new Date(ANALYSIS_DATE));
    verify(issue).setChanged(true);
  }