diff options
author | Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> | 2023-06-07 17:18:52 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-07 20:02:43 +0000 |
commit | 2bb7acebc75ff7ae6cb0a413ac298f048a43d534 (patch) | |
tree | ba395f4cab6fb308bdbc983c46898c02892bdddc /sonar-scanner-engine/src/test/java/org/sonar | |
parent | 1a607ea5d761c72dc2fc1ebea8d2c92c72af3ced (diff) | |
download | sonarqube-2bb7acebc75ff7ae6cb0a413ac298f048a43d534.tar.gz sonarqube-2bb7acebc75ff7ae6cb0a413ac298f048a43d534.zip |
SONAR-19160 handle missing locations in SARIF import. (#8476)
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar')
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/ResultMapperTest.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/ResultMapperTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/ResultMapperTest.java index c6eaed7f556..309a8ed9503 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/ResultMapperTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/ResultMapperTest.java @@ -129,7 +129,19 @@ public class ResultMapperTest { } @Test - public void mapResult_whenLocationNotFound_createsProjectLocation() { + public void mapResult_whenLocationsIsEmpty_createsProjectLocation() { + NewExternalIssue newExternalIssue = resultMapper.mapResult(DRIVER_NAME, WARNING, result); + + verify(locationMapper).fillIssueInProjectLocation(result, newExternalIssueLocation); + verifyNoMoreInteractions(locationMapper); + verify(newExternalIssue).at(newExternalIssueLocation); + verify(newExternalIssue, never()).addLocation(any()); + verify(newExternalIssue, never()).addFlow(any()); + } + + @Test + public void mapResult_whenLocationsIsNull_createsProjectLocation() { + when(result.getLocations()).thenReturn(null); NewExternalIssue newExternalIssue = resultMapper.mapResult(DRIVER_NAME, WARNING, result); verify(locationMapper).fillIssueInProjectLocation(result, newExternalIssueLocation); |