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_shouldNotFail_whenExtensionsDontHaveRules() {
    when(run.getTool().getDriver().getRules()).thenReturn(Set.of(rule));
    ToolComponent extension = mock(ToolComponent.class);
    when(extension.getRules()).thenReturn(null);
    when(run.getTool().getExtensions()).thenReturn(Set.of(extension));

    try (MockedStatic<RulesSeverityDetector> detector = mockStatic(RulesSeverityDetector.class)) {
      detector.when(() -> RulesSeverityDetector.detectRulesSeverities(run, TEST_DRIVER)).thenReturn(Map.of(RULE_ID, WARNING));
      detector.when(() -> RulesSeverityDetector.detectRulesSeveritiesForNewTaxonomy(run, TEST_DRIVER)).thenReturn(Map.of(RULE_ID, WARNING));

      assertThatNoException().isThrownBy(() -> runMapper.mapRun(run));
    }
  }