]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9219 Deprecate parameters "developer{Id|Key}" in web services api/measures...
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 11 May 2017 21:21:12 +0000 (23:21 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 12 May 2017 07:52:41 +0000 (09:52 +0200)
server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWsParametersBuilder.java
server/sonar-server/src/main/java/org/sonar/server/ws/KeyExamples.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java

index d989f70f4ce6a682dba3bc076d120397a010890a..61877ece378df20931d1084949a5b1cb2d946c0d 100644 (file)
@@ -21,8 +21,6 @@ package org.sonar.server.measure.ws;
 
 import org.sonar.api.server.ws.WebService.NewAction;
 import org.sonar.api.server.ws.WebService.NewParam;
-import org.sonar.core.util.Uuids;
-import org.sonar.server.ws.KeyExamples;
 
 import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_FIELDS;
 import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
@@ -51,12 +49,13 @@ class MeasuresWsParametersBuilder {
   }
 
   static void createDeveloperParameters(NewAction action) {
-    action.createParam(PARAM_DEVELOPER_ID)
-      .setDescription("Developer id. If set, developer's measures are returned. Only with Developer Cockpit plugin.")
-      .setExampleValue(Uuids.UUID_EXAMPLE_01);
-    action.createParam(PARAM_DEVELOPER_KEY)
-      .setDescription("Developer key. If set, developer's measures are returned. Only with Developer Cockpit plugin.")
-      .setExampleValue(KeyExamples.KEY_DEVELOPER_EXAMPLE_001);
+    deprecateDeveloperParameter(action, PARAM_DEVELOPER_ID);
+    deprecateDeveloperParameter(action, PARAM_DEVELOPER_KEY);
   }
 
+  private static void deprecateDeveloperParameter(NewAction action, String key) {
+    action.createParam(key)
+      .setDeprecatedSince("6.4")
+      .setDescription("Deprecated parameter, used previously with the Developer Cockpit plugin. No measures are returned if parameter is set.");
+  }
 }
index f9073234e8b20646d0d5304a4f9a389056eea1f2..93c1513a3e8c0d6050e3941cbdb375f2683a3e0a 100644 (file)
@@ -25,7 +25,6 @@ public class KeyExamples {
   public static final String KEY_PROJECT_EXAMPLE_001 = "my_project";
   public static final String KEY_PROJECT_EXAMPLE_002 = "another_project";
   public static final String KEY_PROJECT_EXAMPLE_003 = "third_project";
-  public static final String KEY_DEVELOPER_EXAMPLE_001 = "DEV:ada@lovelace.com";
 
   public static final String KEY_ORG_EXAMPLE_001 = "my-org";
   public static final String KEY_ORG_EXAMPLE_002 = "foo-company";
index 8a648a7d2ce176b8395e676e936ff1f3bbc160b5..8978622eee026ff6d3bc850780f8182624ce3414 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
@@ -45,8 +46,8 @@ import org.sonarqube.ws.WsMeasures.ComponentWsResponse;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
-import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
+import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonar.db.component.ComponentTesting.newView;
 import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -66,17 +67,28 @@ public class ComponentActionTest {
 
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
-  ComponentDbTester componentDb = new ComponentDbTester(db);
-  DbClient dbClient = db.getDbClient();
-  final DbSession dbSession = db.getSession();
+  private ComponentDbTester componentDb = new ComponentDbTester(db);
+  private DbClient dbClient = db.getDbClient();
+  private final DbSession dbSession = db.getSession();
 
-  WsActionTester ws = new WsActionTester(new ComponentAction(dbClient, new ComponentFinder(dbClient), userSession));
+  private WsActionTester ws = new WsActionTester(new ComponentAction(dbClient, new ComponentFinder(dbClient), userSession));
 
   @Before
   public void setUp() {
     userSession.logIn().setRoot();
   }
 
+  @Test
+  public void test_definition_of_web_service() {
+    WebService.Action def = ws.getDef();
+
+    assertThat(def.since()).isEqualTo("5.4");
+    assertThat(def.params()).extracting(WebService.Param::key)
+      .containsExactlyInAnyOrder("componentId", "componentKey", "metricKeys", "additionalFields", "developerId", "developerKey");
+    assertThat(def.param("developerId").deprecatedSince()).isEqualTo("6.4");
+    assertThat(def.param("developerKey").deprecatedSince()).isEqualTo("6.4");
+  }
+
   @Test
   public void json_example() {
     insertJsonExampleData();