]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8924 update api documentation of api/qualityprofiles/search
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Wed, 3 May 2017 11:47:48 +0000 (13:47 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Thu, 4 May 2017 14:35:21 +0000 (16:35 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java

index 51df70a0807a79e4630c1151391b01aec723ff20..230cb25eaa9b21548a0b1a3e5fe6f3bda316fbd5 100644 (file)
@@ -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
index e09b527ba04c2adaad9f5c6b9ecd160bdf269002..7fc63c2e5a727887aac5c958fb2c25a28bfdfa4d 100644 (file)
@@ -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");
index 6a8b7b29e2151393172f44ea030bdf8a0bcaa6a3..e3bbeccafe78d129cee8c3a838b1773b33f79ed2 100644 (file)
@@ -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();