From 4f8796c39feec635aa736945839aad48170ae024 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Wed, 18 Nov 2020 22:23:15 +0100 Subject: [PATCH] SONAR-14113 Make hotspot show WS public, add line hash of primary location --- .../main/java/org/sonar/server/hotspot/ws/ShowAction.java | 5 +++-- .../resources/org/sonar/server/hotspot/ws/show-example.json | 1 + .../java/org/sonar/server/hotspot/ws/ShowActionTest.java | 5 +++-- sonar-ws/src/main/protobuf/ws-hotspots.proto | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java index 6bca86e2e88..8140dd10bf8 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java @@ -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())); diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/hotspot/ws/show-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/hotspot/ws/show-example.json index f43ea76a03c..71f1f88710b 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/hotspot/ws/show-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/hotspot/ws/show-example.json @@ -23,6 +23,7 @@ }, "status": "TO_REVIEW", "line": 10, + "hash": "a227e508d6646b55a086ee11d63b21e9", "message": "message", "assignee": "joe", "author": "joe", diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java index a64c9013ca8..3c1acec46f4 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java @@ -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()) diff --git a/sonar-ws/src/main/protobuf/ws-hotspots.proto b/sonar-ws/src/main/protobuf/ws-hotspots.proto index 40e6fb62af6..36ae0002267 100644 --- a/sonar-ws/src/main/protobuf/ws-hotspots.proto +++ b/sonar-ws/src/main/protobuf/ws-hotspots.proto @@ -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; -- 2.39.5