aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar
diff options
context:
space:
mode:
authorWojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com>2023-06-07 17:18:52 +0200
committersonartech <sonartech@sonarsource.com>2023-06-07 20:02:43 +0000
commit2bb7acebc75ff7ae6cb0a413ac298f048a43d534 (patch)
treeba395f4cab6fb308bdbc983c46898c02892bdddc /sonar-scanner-engine/src/test/java/org/sonar
parent1a607ea5d761c72dc2fc1ebea8d2c92c72af3ced (diff)
downloadsonarqube-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.java14
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);