aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorJacek <52388493+jacek-poreda-sonarsource@users.noreply.github.com>2019-09-17 09:09:22 +0200
committerSonarTech <sonartech@sonarsource.com>2019-09-24 20:21:17 +0200
commit07370a8a8f90ba0340847c40783f420aedc0a139 (patch)
treeb627601195fc58083876a22ea55bfb0f2ab2dc27 /server/sonar-webserver-webapi
parente8f1a84869bcb72af1ca30fa78b9c936a3e028a3 (diff)
downloadsonarqube-07370a8a8f90ba0340847c40783f420aedc0a139.tar.gz
sonarqube-07370a8a8f90ba0340847c40783f420aedc0a139.zip
WS bug fixes (#2070)
- add example to show new code period action - list available types for set new code period action - fix empty responses for protobuff enum - add new code periods WS ITs
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java12
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json (renamed from server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json)0
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json6
4 files changed, 19 insertions, 5 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
index 3837853b3f4..0394cc27a70 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
@@ -20,9 +20,11 @@
package org.sonar.server.newcodeperiod.ws;
import com.google.common.base.Preconditions;
+import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
@@ -93,7 +95,13 @@ public class SetAction implements NewCodePeriodsWsAction {
.setDescription("Branch key");
action.createParam(PARAM_TYPE)
.setRequired(true)
- .setDescription("Type");
+ .setDescription("Type<br/>" +
+ "Only new code periods of the following types are allowed:" +
+ "<ul>" +
+ Arrays.stream(NewCodePeriodType.values())
+ .map(newCodePeriodType -> "<li>" + newCodePeriodType.name() + "</li>")
+ .collect(Collectors.joining()) +
+ "</ul>");
action.createParam(PARAM_VALUE)
.setDescription("Value");
}
@@ -139,7 +147,7 @@ public class SetAction implements NewCodePeriodsWsAction {
}
private void setValue(DbSession dbSession, NewCodePeriodDto dto, NewCodePeriodType type, @Nullable ComponentDto projectBranch,
- @Nullable String branch, @Nullable String value) {
+ @Nullable String branch, @Nullable String value) {
switch (type) {
case PREVIOUS_VERSION:
Preconditions.checkArgument(value == null, "Unexpected value for type '%s'", type);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
index 86f95269dfe..c46343aca4b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
@@ -42,7 +42,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_ID_AND_KEY;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.NewCodePeriods.*;
+import static org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
public class ShowAction implements NewCodePeriodsWsAction {
private static final String PARAM_BRANCH = "branch";
@@ -70,7 +70,7 @@ public class ShowAction implements NewCodePeriodsWsAction {
"<li>'Administer' rights on the specified component</li>" +
"</ul>")
.setSince("8.0")
- .setResponseExample(getClass().getResource("show_new_code_period-example.json"))
+ .setResponseExample(getClass().getResource("show-example.json"))
.setHandler(this);
action.createParam(PARAM_PROJECT)
@@ -90,7 +90,7 @@ public class ShowAction implements NewCodePeriodsWsAction {
try (DbSession dbSession = dbClient.openSession(false)) {
- ComponentDto projectBranch = null;
+ ComponentDto projectBranch;
String projectUuid = null;
String branchUuid = null;
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json
index 537c0ecebfd..537c0ecebfd 100644
--- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json
new file mode 100644
index 00000000000..59786307e94
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json
@@ -0,0 +1,6 @@
+{
+ "projectKey": "org.sonarsource.project:project",
+ "branchKey": "branch-1.1",
+ "type": "PREVIOUS_VERSION",
+ "inherited": true
+}