From 29418552e2af9dfe54a92e48fd98c07828015266 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Wed, 3 May 2017 13:47:48 +0200 Subject: [PATCH] SONAR-8924 update api documentation of api/qualityprofiles/search --- .../server/qualityprofile/ws/SearchAction.java | 9 ++++++++- .../qualityprofile/ws/QProfilesWsTest.java | 12 ------------ .../qualityprofile/ws/SearchActionTest.java | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java index 51df70a0807..230cb25eaa9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java @@ -38,6 +38,7 @@ import org.sonar.db.qualityprofile.QualityProfileDto; import org.sonar.server.util.LanguageParamUtils; import org.sonarqube.ws.QualityProfiles.SearchWsResponse; import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; +import org.sonarqube.ws.client.component.ComponentsWsParameters; import org.sonarqube.ws.client.qualityprofile.SearchWsRequest; import static java.lang.String.format; @@ -75,7 +76,13 @@ public class SearchAction implements QProfileWsAction { .setHandler(this) .setResponseExample(getClass().getResource("search-example.json")); - QProfileWsSupport.createOrganizationParam(action) + action + .createParam(ComponentsWsParameters.PARAM_ORGANIZATION) + .setDescription("Organization key. If no organization key is provided, this defaults to the organization of the specified project. If neither organization nor project are" + + "specified, the default organization will be used.") + .setRequired(false) + .setInternal(true) + .setExampleValue("my-org") .setSince("6.4"); action diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java index e09b527ba04..7fc63c2e5a7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java @@ -97,18 +97,6 @@ public class QProfilesWsTest { assertThat(controller.actions()).isNotEmpty(); } - @Test - public void define_search() { - WebService.Action search = controller.action("search"); - assertThat(search).isNotNull(); - assertThat(search.isPost()).isFalse(); - assertThat(search.params()).hasSize(5); - assertThat(search.param("language").possibleValues()).containsOnly(xoo1Key, xoo2Key); - assertThat(search.param("language").deprecatedSince()).isEqualTo("6.4"); - assertThat(search.param("profileName").deprecatedSince()).isEqualTo("6.4"); - assertThat(search.param("organization").since()).isEqualTo("6.4"); - } - @Test public void define_set_default_action() { WebService.Action setDefault = controller.action("set_default"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index 6a8b7b29e21..e3bbeccafe7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -29,6 +29,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; import org.sonar.api.rule.RuleStatus; +import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; import org.sonar.db.DbClient; @@ -105,6 +106,23 @@ public class SearchActionTest { ws = new WsActionTester(underTest); } + @Test + public void define_search() { + WebService.Action search = ws.getDef(); + assertThat(search).isNotNull(); + assertThat(search.isPost()).isFalse(); + assertThat(search.param("language").possibleValues()).containsExactly("xoo1", "xoo2"); + assertThat(search.param("language").deprecatedSince()).isEqualTo("6.4"); + assertThat(search.param("profileName").deprecatedSince()).isEqualTo("6.4"); + assertThat(search.param("projectKey")).isNotNull(); + assertThat(search.param("defaults")).isNotNull(); + assertThat(search.param("organization")).isNotNull(); + assertThat(search.param("organization").isRequired()).isFalse(); + assertThat(search.param("organization").isInternal()).isTrue(); + assertThat(search.param("organization").description()).isNotEmpty(); + assertThat(search.param("organization").since()).isEqualTo("6.4"); + } + @Test public void ws_returns_the_profiles_of_default_organization() throws Exception { OrganizationDto organization = getDefaultOrganization(); -- 2.39.5