aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-04-23 11:45:03 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-26 20:20:53 +0200
commit5958b88243b4d4db54cdb20fb91fc45fac34e9d3 (patch)
treee409139da361b6be16b9ab45159c0e380197601f /sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue
parent601f29b81dab124ceacbce88caac687d70a298c6 (diff)
downloadsonarqube-5958b88243b4d4db54cdb20fb91fc45fac34e9d3.tar.gz
sonarqube-5958b88243b4d4db54cdb20fb91fc45fac34e9d3.zip
SONAR-10544 Set effort for external issues
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java
index e13e64d6b85..add4404b2a9 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ReportParserTest.java
@@ -39,7 +39,7 @@ public class ReportParserTest {
System.out.println(Paths.get("org/sonar/scanner/externalissue/report.json").toAbsolutePath());
Report report = parser.parse();
- assertThat(report.issues).hasSize(3);
+ assertThat(report.issues).hasSize(4);
assertThat(report.issues[0].engineId).isEqualTo("eslint");
assertThat(report.issues[0].ruleId).isEqualTo("rule1");
assertThat(report.issues[0].severity).isEqualTo("MAJOR");
@@ -52,6 +52,19 @@ public class ReportParserTest {
assertThat(report.issues[0].primaryLocation.textRange.endColumn).isEqualTo(4);
assertThat(report.issues[0].primaryLocation.textRange.endLine).isEqualTo(3);
assertThat(report.issues[0].secondaryLocations).isNull();
+
+ assertThat(report.issues[3].engineId).isEqualTo("eslint");
+ assertThat(report.issues[3].ruleId).isEqualTo("rule3");
+ assertThat(report.issues[3].severity).isEqualTo("MAJOR");
+ assertThat(report.issues[3].effortMinutes).isNull();
+ assertThat(report.issues[3].type).isEqualTo("BUG");
+ assertThat(report.issues[3].secondaryLocations).hasSize(2);
+ assertThat(report.issues[3].secondaryLocations[0].filePath).isEqualTo("file1.js");
+ assertThat(report.issues[3].secondaryLocations[0].message).isEqualTo("fix the bug here");
+ assertThat(report.issues[3].secondaryLocations[0].textRange.startLine).isEqualTo(1);
+ assertThat(report.issues[3].secondaryLocations[1].filePath).isEqualTo("file2.js");
+ assertThat(report.issues[3].secondaryLocations[1].message).isNull();
+ assertThat(report.issues[3].secondaryLocations[1].textRange.startLine).isEqualTo(2);
}
private Path path(String reportName) {
@@ -121,4 +134,12 @@ public class ReportParserTest {
exception.expectMessage("missing mandatory field 'filePath'");
parser.parse();
}
+
+ @Test
+ public void fail_if_message_not_set_in_primaryLocation() {
+ ReportParser parser = new ReportParser(path("report_missing_message.json"));
+ exception.expect(IllegalStateException.class);
+ exception.expectMessage("missing mandatory field 'message'");
+ parser.parse();
+ }
}