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;
}
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.");
+ }
}
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;
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;
@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();