NewExternalIssue mapResult(String driverName, @Nullable Result.Level ruleSeverity, @Nullable Result.Level ruleSeverityForNewTaxonomy, Result result) {
    NewExternalIssue newExternalIssue = sensorContext.newExternalIssue();
    newExternalIssue.type(DEFAULT_TYPE);
    newExternalIssue.engineId(driverName);
    newExternalIssue.severity(toSonarQubeSeverity(ruleSeverity));
    newExternalIssue.ruleId(requireNonNull(result.getRuleId(), "No ruleId found for issue thrown by driver " + driverName));
    newExternalIssue.cleanCodeAttribute(DEFAULT_CLEAN_CODE_ATTRIBUTE);
    newExternalIssue.addImpact(DEFAULT_SOFTWARE_QUALITY, toSonarQubeImpactSeverity(ruleSeverityForNewTaxonomy));

    mapLocations(result, newExternalIssue);
    return newExternalIssue;
  }
@Test
  public void mapResult_whenRelatedLocationExists_createsSecondaryFileLocation() {
    Location relatedLocation = new Location().withMessage(new Message().withText("Related location message"));
    result.withRelatedLocations(Set.of(relatedLocation));
    var newIssueLocationCall2 = mock(NewIssueLocation.class);
    when(mockExternalIssue.newLocation()).thenReturn(newExternalIssueLocation, newIssueLocationCall2);

    NewExternalIssue newExternalIssue = resultMapper.mapResult(DRIVER_NAME, WARNING, WARNING, result);

    verify(locationMapper).fillIssueInProjectLocation(newExternalIssueLocation);
    verify(locationMapper).fillIssueInFileLocation(newIssueLocationCall2, relatedLocation);
    verifyNoMoreInteractions(locationMapper);
    verify(newExternalIssue).at(newExternalIssueLocation);
    verify(newExternalIssue).addLocation(newIssueLocationCall2);
    verify(newExternalIssue, never()).addFlow(any());
    verify(newIssueLocationCall2).message("Related location message");
  }