]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14113 Make hotspot show WS public, add line hash of primary location
authorJean-Baptiste Lievremont <jeanbaptiste.lievremont@sonarsource.com>
Wed, 18 Nov 2020 21:23:15 +0000 (22:23 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 26 Nov 2020 20:06:29 +0000 (20:06 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/hotspot/ws/show-example.json
server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
sonar-ws/src/main/protobuf/ws-hotspots.proto

index 6bca86e2e882c9a44ca55fef3202a1043e420ed4..8140dd10bf8de3765a637f7cb573548860a269ce 100644 (file)
@@ -53,6 +53,7 @@ import org.sonarqube.ws.Hotspots;
 import org.sonarqube.ws.Hotspots.ShowWsResponse;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Strings.emptyToNull;
 import static com.google.common.base.Strings.nullToEmpty;
 import static java.lang.String.format;
 import static java.util.Collections.singleton;
@@ -91,8 +92,7 @@ public class ShowAction implements HotspotsWsAction {
       .createAction("show")
       .setHandler(this)
       .setDescription("Provides the details of a Security Hotspot.")
-      .setSince("8.1")
-      .setInternal(true);
+      .setSince("8.1");
 
     action.createParam(PARAM_HOTSPOT_KEY)
       .setDescription("Key of the Security Hotspot")
@@ -144,6 +144,7 @@ public class ShowAction implements HotspotsWsAction {
     ofNullable(hotspot.getStatus()).ifPresent(builder::setStatus);
     ofNullable(hotspot.getResolution()).ifPresent(builder::setResolution);
     ofNullable(hotspot.getLine()).ifPresent(builder::setLine);
+    ofNullable(emptyToNull(hotspot.getChecksum())).ifPresent(builder::setHash);
     builder.setMessage(nullToEmpty(hotspot.getMessage()));
     builder.setCreationDate(formatDateTime(hotspot.getIssueCreationDate()));
     builder.setUpdateDate(formatDateTime(hotspot.getIssueUpdateDate()));
index f43ea76a03ce8eb6ad42fca1a1656ce183b341bc..71f1f88710bc7c494f79ba75d85137b6e4f3a219 100644 (file)
@@ -23,6 +23,7 @@
   },
   "status": "TO_REVIEW",
   "line": 10,
+  "hash": "a227e508d6646b55a086ee11d63b21e9",
   "message": "message",
   "assignee": "joe",
   "author": "joe",
index a64c9013ca861ce2d6dfc72e8be4e86c987ba321..3c1acec46f4e9e277065344889dbf099f9373539 100644 (file)
@@ -130,8 +130,8 @@ public class ShowActionTest {
   }
 
   @Test
-  public void ws_is_internal() {
-    assertThat(actionTester.getDef().isInternal()).isTrue();
+  public void ws_is_public() {
+    assertThat(actionTester.getDef().isInternal()).isFalse();
   }
 
   @Test
@@ -911,6 +911,7 @@ public class ShowActionTest {
       .setAuthorLogin("joe")
       .setMessage("message")
       .setLine(10)
+      .setChecksum("a227e508d6646b55a086ee11d63b21e9")
       .setIssueCreationTime(time)
       .setIssueUpdateTime(time)
       .setAuthorLogin(author.getLogin())
index 40e6fb62af6ba667c76b5fd101064110a8e8e9e1..36ae0002267c3cd82e4faf3b12e94c648ff08901 100644 (file)
@@ -58,6 +58,7 @@ message ShowWsResponse {
   optional string status = 5;
   optional string resolution = 6;
   optional int32 line = 7;
+  optional string hash = 18;
   optional string message = 8;
   optional string assignee = 9;
   optional string author = 10;