diff options
Diffstat (limited to 'sonar-ws')
10 files changed, 831 insertions, 2 deletions
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 new file mode 100644 index 00000000000..63cb948ef9b --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java @@ -0,0 +1,99 @@ +/* + * 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 new file mode 100644 index 00000000000..3d146a4ed3b --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java @@ -0,0 +1,88 @@ +/* + * 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 new file mode 100644 index 00000000000..31786ffe58e --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java @@ -0,0 +1,86 @@ +/* + * 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 new file mode 100644 index 00000000000..99b1236b556 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java @@ -0,0 +1,99 @@ +/* + * 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 new file mode 100644 index 00000000000..4a0bcb9ba27 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java @@ -0,0 +1,108 @@ +/* + * 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 new file mode 100644 index 00000000000..a670e3619b0 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java @@ -0,0 +1,85 @@ +/* + * 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 new file mode 100644 index 00000000000..6851ea3d8da --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java @@ -0,0 +1,90 @@ +/* + * 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.WsUserGroups.CreateWsResponse; +import static org.sonarqube.ws.WsUserGroups.SearchWsResponse; +import static org.sonarqube.ws.WsUserGroups.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 new file mode 100644 index 00000000000..e3d282fc844 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java @@ -0,0 +1,26 @@ +/* + * 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/main/protobuf/ws-user_groups.proto b/sonar-ws/src/main/protobuf/ws-user_groups.proto index 7e085d75271..cd57e802bc3 100644 --- a/sonar-ws/src/main/protobuf/ws-user_groups.proto +++ b/sonar-ws/src/main/protobuf/ws-user_groups.proto @@ -25,15 +25,20 @@ option java_outer_classname = "WsUserGroups"; option optimize_for = SPEED; // WS api/user_groups/create -message CreateResponse { +message CreateWsResponse { optional Group group = 1; } // WS api/user_groups/update -message UpdateResponse { +message UpdateWsResponse { optional Group group = 1; } +// WS api/user_groups/search +message SearchWsResponse { + repeated Group groups = 1; +} + message Group { optional int64 id = 1; optional string organization = 2; 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 new file mode 100644 index 00000000000..57d19f13ab1 --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java @@ -0,0 +1,143 @@ +/* + * 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.WsUserGroups.CreateWsResponse; +import static org.sonarqube.ws.WsUserGroups.SearchWsResponse; +import static org.sonarqube.ws.WsUserGroups.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(); + } + +} |