]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8894 Define WS api/organizations/search_members
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 16 Mar 2017 18:20:19 +0000 (19:20 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 21 Mar 2017 12:05:50 +0000 (13:05 +0100)
server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java
server/sonar-server/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/organization/ws/search_members-example.json [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/organization/ws/OrganizationsWsModuleTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java [new file with mode: 0644]

index 688dc8d05509daed662356922d3e4e1b0dc8d512..2fba735fdf96540d3237e0b9599ff5d282d7bfbc 100644 (file)
@@ -115,6 +115,7 @@ public class SearchProjectsAction implements ComponentsWsAction {
     action.createParam(PARAM_ORGANIZATION)
       .setDescription("the organization to search projects in")
       .setRequired(false)
+      .setInternal(true)
       .setSince("6.3");
     action.createParam(Param.FACETS)
       .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.")
index 8180fab03b2a7670cc265b7974274b39b001f256..e521c412d13e271c449dcdbb603e02f7c58e373f 100644 (file)
@@ -35,6 +35,7 @@ public class OrganizationsWsModule extends Module {
       EnableSupportAction.class,
       RemoveMemberAction.class,
       SearchAction.class,
+      SearchMembersAction.class,
       SearchMyOrganizationsAction.class,
       UpdateAction.class);
   }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java
new file mode 100644 (file)
index 0000000..764ce85
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.organization.ws;
+
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+
+import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
+
+public class SearchMembersAction implements OrganizationsWsAction {
+  @Override
+  public void define(WebService.NewController context) {
+    WebService.NewAction action = context.createAction("search_members")
+      .setResponseExample(getClass().getResource("search_members-example.json"))
+      .setSince("6.4")
+      .setInternal(true)
+      .setHandler(this);
+
+    action.addSelectionModeParam();
+    action.addSearchQuery("freddy", "names", "logins");
+    action.addPagingParams(50, MAX_LIMIT);
+
+    action.createParam("organization")
+      .setDescription("Organization key")
+      .setInternal(true)
+      .setRequired(false);
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    // TODO
+  }
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/search_members-example.json b/server/sonar-server/src/main/resources/org/sonar/server/organization/ws/search_members-example.json
new file mode 100644 (file)
index 0000000..2c63c08
--- /dev/null
@@ -0,0 +1,2 @@
+{
+}
index 89dc3e1b070009be2772aee5df1b79a6349381c9..9e12ededad7baedc8834db2a5acdded1229f1816 100644 (file)
@@ -33,7 +33,7 @@ public class OrganizationsWsModuleTest {
     ComponentContainer container = new ComponentContainer();
     underTest.configure(container);
     assertThat(container.getPicoContainer().getComponentAdapters())
-      .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 10);
+      .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 11);
   }
 
 }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
new file mode 100644 (file)
index 0000000..0a79b63
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.organization.ws;
+
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SearchMembersActionTest {
+
+  private WsActionTester ws = new WsActionTester(new SearchMembersAction());
+
+  @Test
+  public void definition() {
+    WebService.Action action = ws.getDef();
+
+    assertThat(action.key()).isEqualTo("search_members");
+    assertThat(action.params()).extracting(WebService.Param::key)
+      .containsOnly("q", "selected", "p", "ps", "organization");
+    assertThat(action.responseExampleAsString()).isNotEmpty();
+    assertThat(action.since()).isEqualTo("6.4");
+    assertThat(action.isInternal()).isTrue();
+    assertThat(action.isPost()).isFalse();
+  }
+}