RunMapperResult mapRun(Run run) {
    if (run.getResults().isEmpty()) {
      return new RunMapperResult();
    }

    String driverName = getToolDriverName(run);
    Map<String, Result.Level> ruleSeveritiesByRuleId = detectRulesSeverities(run, driverName);
    Map<String, Result.Level> ruleSeveritiesByRuleIdForNewCCT = detectRulesSeveritiesForNewTaxonomy(run, driverName);

    return new RunMapperResult()
      .newAdHocRules(toNewAdHocRules(run, driverName, ruleSeveritiesByRuleId, ruleSeveritiesByRuleIdForNewCCT))
      .newExternalIssues(toNewExternalIssues(run, driverName, ruleSeveritiesByRuleId, ruleSeveritiesByRuleIdForNewCCT));
  }
@Test
  public void mapRun_failsIfToolNotSet() {
    when(run.getTool()).thenReturn(null);

    assertThatIllegalArgumentException()
      .isThrownBy(() -> runMapper.mapRun(run))
      .withMessage("The run does not have a tool driver name defined.");
  }