diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-03-17 17:14:45 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-03-21 13:05:50 +0100 |
commit | 5acc864451b7a727c55697093fbf0439af6994bf (patch) | |
tree | 4a63fa16ae21c5a73dd181e5fcc1ec1f4fd435fc /sonar-ws | |
parent | 14cbaf7f117d8e6fac992459a4e32089b1a81fbe (diff) | |
download | sonarqube-5acc864451b7a727c55697093fbf0439af6994bf.tar.gz sonarqube-5acc864451b7a727c55697093fbf0439af6994bf.zip |
SONAR-8968 Add organization parameter in api/users/groups
Diffstat (limited to 'sonar-ws')
5 files changed, 26 insertions, 4 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java index 4b44f65ff43..161a388e385 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java @@ -30,6 +30,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; public class GroupsRequest { private final String login; + private final String organization; private final String query; private final String selected; private final Integer page; @@ -37,6 +38,7 @@ public class GroupsRequest { private GroupsRequest(Builder builder) { this.login = builder.login; + this.organization = builder.organization; this.query = builder.query; this.selected = builder.selected; this.page = builder.page; @@ -48,6 +50,11 @@ public class GroupsRequest { } @CheckForNull + public String getOrganization() { + return organization; + } + + @CheckForNull public String getQuery() { return query; } @@ -73,6 +80,7 @@ public class GroupsRequest { public static class Builder { private String login; + private String organization; private String query; private String selected; private Integer page; @@ -87,6 +95,11 @@ public class GroupsRequest { return this; } + public Builder setOrganization(@Nullable String organization) { + this.organization = organization; + return this; + } + public Builder setQuery(@Nullable String query) { this.query = query; return this; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java index 1a55512f6e0..d984c5ea55b 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java @@ -37,6 +37,7 @@ import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOCAL; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_PASSWORD; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SCM_ACCOUNT; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SELECTED; @@ -69,6 +70,7 @@ public class UsersService extends BaseService { public GroupsWsResponse groups(GroupsRequest request) { return call(new GetRequest(path(ACTION_GROUPS)) .setParam(PARAM_LOGIN, request.getLogin()) + .setParam(PARAM_ORGANIZATION, request.getOrganization()) .setParam(PARAM_SELECTED, request.getSelected()) .setParam(TEXT_QUERY, request.getQuery()) .setParam(PAGE, request.getPage()) diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java index cf1946786b3..ba674caf9d3 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersWsParameters.java @@ -27,6 +27,7 @@ public class UsersWsParameters { public static final String ACTION_UPDATE = "update"; public static final String ACTION_GROUPS = "groups"; + public static final String PARAM_ORGANIZATION = "organization"; public static final String PARAM_LOGIN = "login"; public static final String PARAM_PASSWORD = "password"; public static final String PARAM_NAME = "name"; diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/GroupsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/GroupsRequestTest.java index 082e5f720b6..58270e89608 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/GroupsRequestTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/GroupsRequestTest.java @@ -37,6 +37,7 @@ public class GroupsRequestTest { public void create_request() { GroupsRequest result = underTest .setLogin("john") + .setOrganization("orga-uuid") .setSelected("all") .setQuery("sonar-users") .setPage(10) @@ -44,6 +45,7 @@ public class GroupsRequestTest { .build(); assertThat(result.getLogin()).isEqualTo("john"); + assertThat(result.getOrganization()).isEqualTo("orga-uuid"); assertThat(result.getSelected()).isEqualTo("all"); assertThat(result.getQuery()).isEqualTo("sonar-users"); assertThat(result.getPage()).isEqualTo(10); @@ -52,9 +54,12 @@ public class GroupsRequestTest { @Test public void create_request_wih_minimal_fields() { - GroupsRequest result = underTest.setLogin("john").build(); + GroupsRequest result = underTest + .setLogin("john") + .build(); assertThat(result.getLogin()).isEqualTo("john"); + assertThat(result.getOrganization()).isNull(); assertThat(result.getSelected()).isNull(); assertThat(result.getQuery()).isNull(); assertThat(result.getPage()).isNull(); @@ -66,9 +71,7 @@ public class GroupsRequestTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Login is mandatory and must not be empty"); - underTest - .setLogin("") - .build(); + underTest.setLogin("").build(); } @Test diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UsersServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UsersServiceTest.java index 37902de632c..c92f7619ffe 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UsersServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UsersServiceTest.java @@ -36,6 +36,7 @@ import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOCAL; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_PASSWORD; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SCM_ACCOUNT; import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SELECTED; @@ -90,6 +91,7 @@ public class UsersServiceTest { public void groups() { underTest.groups(GroupsRequest.builder() .setLogin("john") + .setOrganization("orga-uuid") .setSelected("all") .setQuery("sonar-users") .setPage(10) @@ -99,6 +101,7 @@ public class UsersServiceTest { assertThat(serviceTester.getGetParser()).isSameAs(GroupsWsResponse.parser()); serviceTester.assertThat(serviceTester.getGetRequest()) .hasParam(PARAM_LOGIN, "john") + .hasParam(PARAM_ORGANIZATION, "orga-uuid") .hasParam(PARAM_SELECTED, "all") .hasParam(TEXT_QUERY, "sonar-users") .hasParam(PAGE, 10) |