diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-04-11 08:52:42 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-04-13 11:51:55 +0200 |
commit | c082ed70b27c151884a2b364937b85173637675e (patch) | |
tree | ac6c07d500dc2a510a10d975708cb8f5af5c2242 /sonar-ws | |
parent | e94c7b5f322a16ecf8c278114e119d9913b6505c (diff) | |
download | sonarqube-c082ed70b27c151884a2b364937b85173637675e.tar.gz sonarqube-c082ed70b27c151884a2b364937b85173637675e.zip |
Replace SQL by WS in OrganizationMembershipTest IT
Diffstat (limited to 'sonar-ws')
-rw-r--r-- | sonar-ws/src/main/java/org/sonarqube/ws/client/organization/OrganizationService.java | 19 | ||||
-rw-r--r-- | sonar-ws/src/test/java/org/sonarqube/ws/client/organization/OrganizationServiceTest.java | 20 |
2 files changed, 37 insertions, 2 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/organization/OrganizationService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/organization/OrganizationService.java index c0395baeaba..1968f92caa1 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/organization/OrganizationService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/organization/OrganizationService.java @@ -20,6 +20,7 @@ package org.sonarqube.ws.client.organization; import javax.annotation.Nullable; +import org.sonarqube.ws.Organizations.SearchMembersWsResponse; import org.sonarqube.ws.Organizations.SearchWsResponse; import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; @@ -27,6 +28,9 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsConnector; import static java.util.Objects.requireNonNull; +import static org.sonar.api.server.ws.WebService.Param.PAGE; +import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; +import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonarqube.ws.Organizations.CreateWsResponse; import static org.sonarqube.ws.Organizations.UpdateWsResponse; @@ -39,8 +43,8 @@ public class OrganizationService extends BaseService { public SearchWsResponse search(SearchWsRequest request) { GetRequest get = new GetRequest(path("search")) .setParam("organizations", inlineMultipleParamValue(request.getOrganizations())) - .setParam("p", request.getPage()) - .setParam("ps", request.getPageSize()); + .setParam(PAGE, request.getPage()) + .setParam(PAGE_SIZE, request.getPageSize()); return call(get, SearchWsResponse.parser()); } @@ -74,6 +78,17 @@ public class OrganizationService extends BaseService { call(post).failIfNotSuccessful(); } + public SearchMembersWsResponse searchMembers(SearchMembersWsRequest request) { + GetRequest get = new GetRequest(path("search_members")) + .setParam("organization", request.getOrganization()) + .setParam("selected", request.getSelected()) + .setParam(TEXT_QUERY, request.getQuery()) + .setParam(PAGE, request.getPage()) + .setParam(PAGE_SIZE, request.getPageSize()); + + return call(get, SearchMembersWsResponse.parser()); + } + public void addMember(String organizationKey, String login) { PostRequest post = new PostRequest(path("add_member")) .setParam("organization", requireNonNull(organizationKey)) diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/organization/OrganizationServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/organization/OrganizationServiceTest.java index 4703f3ff8a5..a8909f452bd 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/organization/OrganizationServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/organization/OrganizationServiceTest.java @@ -55,6 +55,26 @@ public class OrganizationServiceTest { } @Test + public void search_members() { + underTest.searchMembers(new SearchMembersWsRequest() + .setOrganization("orga") + .setSelected("selected") + .setQuery("john") + .setPage(2) + .setPageSize(10)); + GetRequest getRequest = serviceTester.getGetRequest(); + + assertThat(serviceTester.getGetParser()).isSameAs(Organizations.SearchMembersWsResponse.parser()); + serviceTester.assertThat(getRequest) + .hasParam("organization", "orga") + .hasParam("selected", "selected") + .hasParam("q", "john") + .hasParam("p", 2) + .hasParam("ps", 10) + .andNoOtherParam(); + } + + @Test public void add_member() { underTest.addMember("O1", "login-1"); |