diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-23 22:53:45 +0100 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-11-29 20:24:11 +0100 |
commit | e1588798acce44a0fcb4e99a1104d62b0ae8d271 (patch) | |
tree | a3214dc4244a7b7c670fbcbca420871ffc8cd338 /sonar-ws/src | |
parent | 097cd25c9e4012da091c71718e9cc067b31098a3 (diff) | |
download | sonarqube-e1588798acce44a0fcb4e99a1104d62b0ae8d271.tar.gz sonarqube-e1588798acce44a0fcb4e99a1104d62b0ae8d271.zip |
Generate client for api/user_groups
Diffstat (limited to 'sonar-ws/src')
11 files changed, 2 insertions, 826 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index 7c1445edcb2..7ae83705d7a 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -38,7 +38,7 @@ import org.sonarqube.ws.client.rules.RulesService; import org.sonarqube.ws.client.settings.SettingsService; import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.user.UsersService; -import org.sonarqube.ws.client.usergroup.UserGroupsService; +import org.sonarqube.ws.client.usergroups.UserGroupsService; import org.sonarqube.ws.client.usertokens.UserTokensService; import org.sonarqube.ws.client.webhooks.WebhooksService; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 2854977c5df..96c20272caf 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -38,7 +38,7 @@ import org.sonarqube.ws.client.rules.RulesService; import org.sonarqube.ws.client.settings.SettingsService; import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.user.UsersService; -import org.sonarqube.ws.client.usergroup.UserGroupsService; +import org.sonarqube.ws.client.usergroups.UserGroupsService; import org.sonarqube.ws.client.usertokens.UserTokensService; import org.sonarqube.ws.client.webhooks.WebhooksService; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java deleted file mode 100644 index b48108ca3f1..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class AddUserWsRequest { - - private final Long id; - private final String name; - private final String login; - private final String organization; - - private AddUserWsRequest(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.login = builder.login; - this.organization = builder.organization; - } - - @CheckForNull - public Long getId() { - return id; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getLogin() { - return login; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Long id; - private String name; - private String login; - private String organization; - - private Builder() { - // enforce factory method use - } - - public Builder setId(@Nullable Long id) { - this.id = id; - return this; - } - - public Builder setName(@Nullable String name) { - this.name = name; - return this; - } - - public Builder setLogin(@Nullable String login) { - this.login = login; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public AddUserWsRequest build() { - return new AddUserWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java deleted file mode 100644 index 3d146a4ed3b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Strings.isNullOrEmpty; - -@Immutable -public class CreateWsRequest { - - private final String name; - private final String description; - private final String organization; - - private CreateWsRequest(Builder builder) { - this.name = builder.name; - this.description = builder.description; - this.organization = builder.organization; - } - - public String getName() { - return name; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public String getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String name; - private String description; - private String organization; - - private Builder() { - // enforce factory method use - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setDescription(@Nullable String description) { - this.description = description; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public CreateWsRequest build() { - checkArgument(!isNullOrEmpty(name), "Name is mandatory and must not be empty"); - return new CreateWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java deleted file mode 100644 index 31786ffe58e..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class DeleteWsRequest { - - private final Long id; - private final String name; - private final String organization; - - private DeleteWsRequest(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.organization = builder.organization; - } - - @CheckForNull - public Long getId() { - return id; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Long id; - private String name; - private String organization; - - private Builder() { - // enforce factory method use - } - - public Builder setId(@Nullable Long id) { - this.id = id; - return this; - } - - public Builder setName(@Nullable String name) { - this.name = name; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public DeleteWsRequest build() { - return new DeleteWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java deleted file mode 100644 index 0b498ec2b8f..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class RemoveUserWsRequest { - - private final Long id; - private final String name; - private final String login; - private final String organization; - - private RemoveUserWsRequest(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.login = builder.login; - this.organization = builder.organization; - } - - @CheckForNull - public Long getId() { - return id; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getLogin() { - return login; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Long id; - private String name; - private String login; - private String organization; - - private Builder() { - // enforce factory method use - } - - public Builder setId(@Nullable Long id) { - this.id = id; - return this; - } - - public Builder setName(@Nullable String name) { - this.name = name; - return this; - } - - public Builder setLogin(@Nullable String login) { - this.login = login; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public RemoveUserWsRequest build() { - return new RemoveUserWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java deleted file mode 100644 index 4a0bcb9ba27..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class SearchWsRequest { - private final String query; - private final Integer page; - private final Integer pageSize; - private final String organization; - private final List<String> fields; - - private SearchWsRequest(Builder builder) { - this.query = builder.query; - this.page = builder.page; - this.pageSize = builder.pageSize; - this.organization = builder.organization; - this.fields = builder.fields; - } - - @CheckForNull - public String getQuery() { - return query; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - @CheckForNull - public List<String> getFields() { - return fields; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String query; - private Integer page; - private Integer pageSize; - private String organization; - private List<String> fields; - - public Builder setQuery(@Nullable String query) { - this.query = query; - return this; - } - - public Builder setPage(@Nullable Integer page) { - this.page = page; - return this; - } - - public Builder setPageSize(@Nullable Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setFields(@Nullable List<String> fields) { - this.fields = fields; - return this; - } - - public SearchWsRequest build() { - return new SearchWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java deleted file mode 100644 index a670e3619b0..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class UpdateWsRequest { - - private final long id; - private final String name; - private final String description; - - private UpdateWsRequest(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.description = builder.description; - } - - public long getId() { - return id; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private long id; - private String name; - private String description; - - private Builder() { - // enforce factory method use - } - - public Builder setId(long id) { - this.id = id; - return this; - } - - public Builder setName(@Nullable String name) { - this.name = name; - return this; - } - - public Builder setDescription(@Nullable String description) { - this.description = description; - return this; - } - - public UpdateWsRequest build() { - return new UpdateWsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java deleted file mode 100644 index 9cd0a388db7..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.WsConnector; - -import static org.sonar.api.server.ws.WebService.Param.FIELDS; -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.UserGroups.CreateWsResponse; -import static org.sonarqube.ws.UserGroups.SearchWsResponse; -import static org.sonarqube.ws.UserGroups.UpdateWsResponse; - -public class UserGroupsService extends BaseService { - - public UserGroupsService(WsConnector wsConnector) { - super(wsConnector, "api/user_groups"); - } - - public CreateWsResponse create(CreateWsRequest request) { - return call(new PostRequest(path("create")) - .setParam("name", request.getName()) - .setParam("description", request.getDescription()) - .setParam("organization", request.getOrganization()), - CreateWsResponse.parser()); - } - - public UpdateWsResponse update(UpdateWsRequest request) { - return call(new PostRequest(path("update")) - .setParam("id", request.getId()) - .setParam("name", request.getName()) - .setParam("description", request.getDescription()), - UpdateWsResponse.parser()); - } - - public void delete(DeleteWsRequest request) { - call(new PostRequest(path("delete")) - .setParam("id", request.getId()) - .setParam("name", request.getName()) - .setParam("organization", request.getOrganization())); - } - - public void addUser(AddUserWsRequest request) { - call(new PostRequest(path("add_user")) - .setParam("id", request.getId()) - .setParam("name", request.getName()) - .setParam("login", request.getLogin()) - .setParam("organization", request.getOrganization())); - } - - public void removeUser(RemoveUserWsRequest request) { - call(new PostRequest(path("remove_user")) - .setParam("id", request.getId()) - .setParam("name", request.getName()) - .setParam("login", request.getLogin()) - .setParam("organization", request.getOrganization())); - } - - public SearchWsResponse search(SearchWsRequest request) { - return call(new GetRequest(path("search")) - .setParam(TEXT_QUERY, request.getQuery()) - .setParam(PAGE, request.getPage()) - .setParam(PAGE_SIZE, request.getPageSize()) - .setParam("organization", request.getOrganization()) - .setParam(FIELDS, inlineMultipleParamValue(request.getFields())), - SearchWsResponse.parser()); - } - -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java deleted file mode 100644 index e3d282fc844..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - - -@ParametersAreNonnullByDefault -package org.sonarqube.ws.client.usergroup; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java deleted file mode 100644 index d4bac214257..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.sonarqube.ws.client.usergroup; - -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.sonarqube.ws.UserGroups.CreateWsResponse; -import static org.sonarqube.ws.UserGroups.SearchWsResponse; -import static org.sonarqube.ws.UserGroups.UpdateWsResponse; - -public class UserGroupsServiceTest { - - @Rule - public ServiceTester<UserGroupsService> serviceTester = new ServiceTester<>(new UserGroupsService(mock(WsConnector.class))); - - private UserGroupsService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void create() { - underTest.create(CreateWsRequest.builder() - .setName("sonar-users") - .setDescription("All users") - .setOrganization("org") - .build()); - - assertThat(serviceTester.getPostParser()).isSameAs(CreateWsResponse.parser()); - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasParam("name", "sonar-users") - .hasParam("description", "All users") - .hasParam("organization", "org") - .andNoOtherParam(); - } - - @Test - public void update() { - underTest.update(UpdateWsRequest.builder() - .setId(10L) - .setName("sonar-users") - .setDescription("All users") - .build()); - - assertThat(serviceTester.getPostParser()).isSameAs(UpdateWsResponse.parser()); - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasParam("id", "10") - .hasParam("name", "sonar-users") - .hasParam("description", "All users") - .andNoOtherParam(); - } - - @Test - public void delete() { - underTest.delete(DeleteWsRequest.builder() - .setId(10L) - .setName("sonar-users") - .setOrganization("orga") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasParam("id", "10") - .hasParam("name", "sonar-users") - .hasParam("organization", "orga") - .andNoOtherParam(); - } - - @Test - public void addUser() throws Exception { - underTest.addUser(AddUserWsRequest.builder() - .setId(10L) - .setName("sonar-users") - .setLogin("john") - .setOrganization("org") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasParam("id", "10") - .hasParam("name", "sonar-users") - .hasParam("login", "john") - .hasParam("organization", "org") - .andNoOtherParam(); - } - - @Test - public void removeUser() throws Exception { - underTest.removeUser(RemoveUserWsRequest.builder() - .setId(10L) - .setName("sonar-users") - .setLogin("john") - .setOrganization("org") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasParam("id", "10") - .hasParam("name", "sonar-users") - .hasParam("login", "john") - .hasParam("organization", "org") - .andNoOtherParam(); - } - - @Test - public void search() { - underTest.search(SearchWsRequest.builder() - .setQuery("sonar-users") - .setPage(10) - .setPageSize(50) - .setOrganization("orga") - .setFields(asList("name", "description")) - .build()); - - assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasParam("q", "sonar-users") - .hasParam("p", 10) - .hasParam("ps", 50) - .hasParam("organization", "orga") - .hasParam("f", "name,description") - .andNoOtherParam(); - } - -} |