public class ComponentAction implements NavigationWsAction {
- private static final String PARAM_COMPONENT_KEY = "componentKey";
+ static final String PARAM_COMPONENT = "component";
private static final String PROPERTY_CONFIGURABLE = "configurable";
private static final String PROPERTY_HAS_ROLE_POLICY = "hasRolePolicy";
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.2");
- projectNavigation.createParam(PARAM_COMPONENT_KEY)
+ projectNavigation.createParam(PARAM_COMPONENT)
.setDescription("A component key.")
+ .setDeprecatedKey("componentKey", "6.4")
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
}
@Override
public void handle(Request request, Response response) throws Exception {
- String componentKey = request.mandatoryParam(PARAM_COMPONENT_KEY);
+ String componentKey = request.mandatoryParam(PARAM_COMPONENT);
try (DbSession session = dbClient.openSession(false)) {
ComponentDto component = componentFinder.getByKey(session, componentKey);
if (!userSession.hasComponentPermission(USER, component) &&
import org.junit.rules.ExpectedException;
import org.sonar.api.resources.ResourceType;
import org.sonar.api.resources.ResourceTypes;
+import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
+import static org.sonar.server.ui.ws.ComponentAction.PARAM_COMPONENT;
import static org.sonar.test.JsonAssert.assertJson;
public class ComponentActionTest {
.setLanguage("xoo");
}
+ @Test
+ public void check_definition() throws Exception {
+ init();
+ WebService.Action action = ws.getDef();
+
+ assertThat(action.since()).isEqualTo("5.2");
+ assertThat(action.isPost()).isFalse();
+ assertThat(action.isInternal()).isTrue();
+ assertThat(action.description()).isNotNull();
+ assertThat(action.responseExample()).isNotNull();
+ assertThat(action.changelog()).isEmpty();
+
+ WebService.Param componentId = action.param(PARAM_COMPONENT);
+ assertThat(componentId.isRequired()).isFalse();
+ assertThat(componentId.description()).isNotNull();
+ assertThat(componentId.exampleValue()).isNotNull();
+ assertThat(componentId.deprecatedKey()).isEqualTo("componentKey");
+ assertThat(componentId.deprecatedKeySince()).isEqualTo("6.4");
+ }
+
@Test
public void fail_on_missing_parameters() throws Exception {
init();