@Override
  public SarifImportResults importSarif(SarifSchema210 sarif210) {
    int successFullyImportedIssues = 0;
    int successFullyImportedRuns = 0;
    int failedRuns = 0;

    List<Run> runs = requireNonNull(sarif210.getRuns(), "The runs section of the Sarif report is null");
    for (Run run : runs) {
      RunMapperResult runMapperResult = tryMapRun(run);
      if (runMapperResult.isSuccess()) {
        List<NewAdHocRule> newAdHocRules = runMapperResult.getNewAdHocRules();
        newAdHocRules.forEach(NewAdHocRule::save);

        List<NewExternalIssue> newExternalIssues = runMapperResult.getNewExternalIssues();
        successFullyImportedRuns += 1;
        successFullyImportedIssues += newExternalIssues.size();
        newExternalIssues.forEach(NewExternalIssue::save);
      } else {
        failedRuns += 1;
      }
    }
    return SarifImportResults.builder()
      .successFullyImportedIssues(successFullyImportedIssues)
      .successFullyImportedRuns(successFullyImportedRuns)
      .failedRuns(failedRuns)
      .build();
  }
@Test
  public void importSarif_shouldDelegateRunMapping_toRunMapper() {
    SarifSchema210 sarif210 = mock(SarifSchema210.class);

    Run run1 = mock(Run.class);
    Run run2 = mock(Run.class);
    when(sarif210.getRuns()).thenReturn(List.of(run1, run2));

    NewExternalIssue issue1run1 = mock(NewExternalIssue.class);
    NewExternalIssue issue2run1 = mock(NewExternalIssue.class);
    NewExternalIssue issue1run2 = mock(NewExternalIssue.class);
    when(runMapper.mapRun(run1)).thenReturn(new RunMapperResult().newExternalIssues(List.of(issue1run1, issue2run1)));
    when(runMapper.mapRun(run2)).thenReturn(new RunMapperResult().newExternalIssues(List.of(issue1run2)));

    SarifImportResults sarifImportResults = sarif210Importer.importSarif(sarif210);

    assertThat(sarifImportResults.getSuccessFullyImportedIssues()).isEqualTo(3);
    assertThat(sarifImportResults.getSuccessFullyImportedRuns()).isEqualTo(2);
    assertThat(sarifImportResults.getFailedRuns()).isZero();
    verify(issue1run1).save();
    verify(issue2run1).save();
    verify(issue1run2).save();
  }