aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-10-12 14:36:05 +0200
committerTeryk Bellahsene <teryk@users.noreply.github.com>2017-10-16 09:27:14 +0200
commit40605449fcf7a1bf44129dfe7e4acd606829fedc (patch)
tree146e4748ac1da9bf162d7dfadf471cf18aedb7e5
parent7ee2cc6372f66afc24e0fd4f780bab8dfcdb4409 (diff)
downloadsonarqube-40605449fcf7a1bf44129dfe7e4acd606829fedc.tar.gz
sonarqube-40605449fcf7a1bf44129dfe7e4acd606829fedc.zip
SONAR-9823 WS api/issues/search returns the line hash
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java1
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/issue/ws/search-example.json1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java5
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json2
-rw-r--r--sonar-ws/src/main/protobuf/ws-issues.proto1
5 files changed, 8 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
index 2b9190efa43..7fe84776842 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
@@ -184,6 +184,7 @@ public class SearchResponseFormat {
issueBuilder.setEffort(effortValue);
}
setNullable(dto.getLine(), issueBuilder::setLine);
+ setNullable(emptyToNull(dto.getChecksum()), issueBuilder::setHash);
completeIssueLocations(dto, issueBuilder);
issueBuilder.setAuthor(nullToEmpty(dto.getAuthorLogin()));
setNullable(dto.getIssueCreationDate(), issueBuilder::setCreationDate, DateUtils::formatDateTime);
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/search-example.json b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/search-example.json
index bba05e3c70a..6f0828e593a 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/search-example.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/search-example.json
@@ -15,6 +15,7 @@
"severity": "MINOR",
"message": "'3' is a magic number.",
"line": 81,
+ "hash":"a227e508d6646b55a086ee11d63b21e9",
"textRange": {
"startLine": 81,
"endLine": 81,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index fcad3faf27c..478417c4d69 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -172,6 +172,8 @@ public class SearchActionTest {
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setEffort(10L)
+ .setLine(42)
+ .setChecksum("a227e508d6646b55a086ee11d63b21e9")
.setMessage("the message")
.setStatus(Issue.STATUS_RESOLVED)
.setResolution(Issue.RESOLUTION_FIXED)
@@ -185,8 +187,7 @@ public class SearchActionTest {
session.commit();
issueIndexer.indexOnStartup(issueIndexer.getIndexTypes());
- ws.newRequest().execute()
- .assertJson(this.getClass(), "response_contains_all_fields_except_additional_fields.json");
+ ws.newRequest().execute().assertJson(this.getClass(), "response_contains_all_fields_except_additional_fields.json");
}
@Test
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
index 48675c596fc..f7656e728d2 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
@@ -12,6 +12,8 @@
"effort": "10min",
"assignee": "simon",
"author": "John",
+ "line": 42,
+ "hash": "a227e508d6646b55a086ee11d63b21e9",
"tags": [
"bug",
"owasp"
diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto
index 226691f512d..a1309679f58 100644
--- a/sonar-ws/src/main/protobuf/ws-issues.proto
+++ b/sonar-ws/src/main/protobuf/ws-issues.proto
@@ -68,6 +68,7 @@ message Issue {
optional string project = 6;
optional string subProject = 7;
optional int32 line = 8;
+ optional string hash = 31;
optional sonarqube.ws.commons.TextRange textRange = 9;
repeated Flow flows = 10;
optional string resolution = 11;