]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15824 WebService changelog not shown
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 9 Dec 2021 17:25:15 +0000 (11:25 -0600)
committerLukasz Jarocki <lukasz.jarocki@sonarsource.com>
Mon, 13 Dec 2021 14:22:58 +0000 (15:22 +0100)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityStatusAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java
sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java

index e07ee4a6da4cb73145a8aaf7df2737a5a4d2b841..81d4c0d2002da624c8c7e1df16dd935b11f7f007 100644 (file)
@@ -60,8 +60,9 @@ public class GetBindingAction implements AlmSettingsWsAction {
         "Requires the 'Administer' permission on the project")
       .setSince("8.1")
       .setResponseExample(getClass().getResource("example-get_binding.json"))
-      .setChangelog(new Change("8.6", "Azure binding now contains the project and repository names"))
-      .setChangelog(new Change("8.7", "Azure binding now contains a monorepo flag for monorepo feature in Enterprise Edition and above"))
+      .setChangelog(
+        new Change("8.6", "Azure binding now contains the project and repository names"),
+        new Change("8.7", "Azure binding now contains a monorepo flag for monorepo feature in Enterprise Edition and above"))
       .setHandler(this);
 
     action
index 278122969a065b14a5ff7c55da1b4575dd9b5e19..dccdd745345dd081b52190e90db700080b39b35f 100644 (file)
@@ -58,9 +58,10 @@ public class ProjectAction implements BatchWsAction {
       .setDescription("Return project repository")
       .setResponseExample(getClass().getResource("project-example.json"))
       .setSince("4.5")
-      .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY)))
-      .setChangelog(new Change("7.6", "Stop returning settings"))
-      .setChangelog(new Change("7.7", "Stop supporting preview mode, removed timestamp and last analysis date"))
+      .setChangelog(
+        new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY)),
+        new Change("7.6", "Stop returning settings"),
+        new Change("7.7", "Stop supporting preview mode, removed timestamp and last analysis date"))
       .setInternal(true)
       .setHandler(this);
 
index 6828b1d9ad2ac7826eb00a1a45ab21e917ddf8f0..0e45fc952df135677f4b5f4c1eea6ab6fbd229a9 100644 (file)
@@ -74,10 +74,11 @@ public class ActivityStatusAction implements CeWsAction {
       .setDescription("Key of the component (project) to filter on")
       .setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);
 
-    action.setChangelog(new Change("6.6", "New field 'inProgress' in response"));
-    action.setChangelog(new Change("7.8", "New field 'pendingTime' in response, only included when there are pending tasks"));
-    action.setChangelog(new Change("8.8", "Parameter 'componentId' is now deprecated."));
-    action.setChangelog(new Change("8.8", "Parameter 'componentKey' is now removed. Please use parameter 'component' instead."));
+    action.setChangelog(
+      new Change("6.6", "New field 'inProgress' in response"),
+      new Change("7.8", "New field 'pendingTime' in response, only included when there are pending tasks"),
+      new Change("8.8", "Parameter 'componentId' is now deprecated."),
+      new Change("8.8", "Parameter 'componentKey' is now removed. Please use parameter 'component' instead."));
   }
 
   @Override
index e09ad8e8068b301953e2bd3d01e8adfd5d61cbcc..cd929b90cb1404a1e942928395f40e949b56060a 100644 (file)
@@ -87,8 +87,9 @@ public class BulkDeleteAction implements ProjectsWsAction {
         parameterRequiredMessage)
       .setSince("5.2")
       .setHandler(this)
-      .setChangelog(new Change("7.8", parameterRequiredMessage))
-      .setChangelog(new Change("9.1", "The parameter '" + PARAM_ANALYZED_BEFORE + "' "
+      .setChangelog(
+        new Change("7.8", parameterRequiredMessage),
+        new Change("9.1", "The parameter '" + PARAM_ANALYZED_BEFORE + "' "
         + "takes into account the analysis of all branches and pull requests, not only the main branch."));
 
     action
index 63f67a97384b683830acb736c5db8c7c502caa26..73321785fdd64473a7162284def37d1e53149e11 100644 (file)
@@ -135,11 +135,11 @@ public class SearchAction implements RulesWsAction {
     WebService.NewAction action = controller.createAction(ACTION)
       .addPagingParams(100, MAX_PAGE_SIZE)
       .setHandler(this)
-      .setChangelog(new Change("7.1", "The field 'scope' has been added to the response"))
-      .setChangelog(new Change("7.1", "The field 'scope' has been added to the 'f' parameter"))
-      .setChangelog(new Change("7.2", "The field 'isExternal' has been added to the response"))
-      .setChangelog(new Change("7.2", "The field 'includeExternal' has been added to the 'f' parameter"))
-      .setChangelog(new Change("7.5", "The field 'updatedAt' has been added to the 'f' parameter"));
+      .setChangelog(new Change("7.1", "The field 'scope' has been added to the response"),
+        new Change("7.1", "The field 'scope' has been added to the 'f' parameter"),
+        new Change("7.2", "The field 'isExternal' has been added to the response"),
+        new Change("7.2", "The field 'includeExternal' has been added to the 'f' parameter"),
+        new Change("7.5", "The field 'updatedAt' has been added to the 'f' parameter"));
 
     action.createParam(FACETS)
       .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.")
index 6e4e59b84a700e624271f0a5bd00cc97613b2c16..f3ff6b3208fd89089581fbb9d3dbb4f011690685 100644 (file)
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -328,14 +329,15 @@ public interface WebService extends Definable<WebService.Context> {
 
     /**
      * List of changes made to the contract or valuable insight. Example: changes to the response format.
+     * Calling this method multiple times will not override previously set changes - all changes will be added.
      *
      * @since 6.4
      */
     public NewAction setChangelog(Change... changes) {
-      this.changelog = stream(requireNonNull(changes))
+      requireNonNull(changes);
+      Arrays.stream(changes)
         .filter(Objects::nonNull)
-        .collect(Collectors.toList());
-
+        .forEach(this.changelog::add);
       return this;
     }
 
index 5c2573e7a1234ecfc542619714c172fd5b65a97a..3ecb95f38b387f9e38a106b3a7dafebc13330bb3 100644 (file)
@@ -92,6 +92,25 @@ public class WebServiceTest {
       tuple("6.4", "Last event"), tuple("6.0", "Old event"), tuple("4.5.6", "Very old event"));
   }
 
+  @Test
+  public void add_changelog_if_called_twice() {
+    WebService webService = context -> {
+      NewController newController = context.createController("api/rule");
+      newDefaultAction(newController, "list")
+        .setDescription("desc")
+        .setChangelog(new Change("1.0", "change1"))
+        .setChangelog(new Change("2.0", "change2"));
+      newController.done();
+    };
+
+    webService.define(context);
+    assertThat(context.controller("api/rule").action("list").changelog())
+      .extracting(Change::getVersion, Change::getDescription)
+      .containsOnly(
+        tuple("1.0", "change1"),
+        tuple("2.0", "change2"));
+  }
+
   @Test
   public void fail_if_duplicated_ws_keys() {
     MetricWs metricWs = new MetricWs();