import org.sonarqube.ws.Users;
import org.sonarqube.ws.Users.GroupsWsResponse.Group;
import org.sonarqube.ws.client.user.GroupsRequest;
-import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
-import org.sonarqube.ws.client.usergroup.CreateWsRequest;
+import org.sonarqube.ws.client.usergroups.AddUserRequest;
+import org.sonarqube.ws.client.usergroups.CreateRequest;
import static java.util.Arrays.stream;
import static org.assertj.core.api.Assertions.assertThat;
}
@SafeVarargs
- public final UserGroups.Group generate(@Nullable Organizations.Organization organization, Consumer<CreateWsRequest.Builder>... populators) {
+ public final UserGroups.Group generate(@Nullable Organizations.Organization organization, Consumer<CreateRequest>... populators) {
int id = ID_GENERATOR.getAndIncrement();
- CreateWsRequest.Builder request = CreateWsRequest.builder()
+ CreateRequest request = new CreateRequest()
.setName("Group" + id)
.setDescription("Description " + id)
.setOrganization(organization != null ? organization.getKey() : null);
stream(populators).forEach(p -> p.accept(request));
- return session.wsClient().userGroups().create(request.build()).getGroup();
+ return session.wsClient().userGroups().create(request).getGroup();
}
public List<Group> getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) {
public GroupTester addMemberToGroups(Organizations.Organization organization, String userLogin, String... groups) {
for (String group : groups) {
- AddUserWsRequest request = AddUserWsRequest.builder()
+ AddUserRequest request = new AddUserRequest()
.setLogin(userLogin)
.setOrganization(organization.getKey())
- .setName(group)
- .build();
+ .setName(group);
session.wsClient().userGroups().addUser(request);
}
return this;
import org.sonarqube.ws.client.user.CreateRequest;
import org.sonarqube.ws.client.user.SearchRequest;
import org.sonarqube.ws.client.user.UsersService;
-import org.sonarqube.ws.client.usergroup.AddUserWsRequest;
+import org.sonarqube.ws.client.usergroups.AddUserRequest;
import static java.util.Arrays.stream;
public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) {
User user = generate(populators);
session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permission.AddUserWsRequest().setLogin(user.getLogin()).setPermission("admin"));
- session.wsClient().userGroups().addUser(AddUserWsRequest.builder().setLogin(user.getLogin()).setName("sonar-administrators").build());
+ session.wsClient().userGroups().addUser(new AddUserRequest().setLogin(user.getLogin()).setName("sonar-administrators"));
return user;
}
String organizationKey = organization.getKey();
User user = generate(populators);
session.wsClient().organizations().addMember(organizationKey, user.getLogin());
- session.wsClient().userGroups().addUser(AddUserWsRequest.builder()
+ session.wsClient().userGroups().addUser(new AddUserRequest()
.setOrganization(organizationKey)
.setLogin(user.getLogin())
- .setName("Owners")
- .build());
+ .setName("Owners"));
return user;
}
public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest.Builder>... populators) {
User user = generate(populators);
session.wsClient().organizations().addMember(DEFAULT_ORGANIZATION_KEY, user.getLogin());
- session.wsClient().userGroups().addUser(AddUserWsRequest.builder()
+ session.wsClient().userGroups().addUser(new AddUserRequest()
.setOrganization(DEFAULT_ORGANIZATION_KEY)
.setLogin(user.getLogin())
- .setName("sonar-administrators")
- .build());
+ .setName("sonar-administrators"));
return user;
}
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;
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;
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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());
- }
-
-}
+++ /dev/null
-/*
- * 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;
-
+++ /dev/null
-/*
- * 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();
- }
-
-}
import org.sonarqube.ws.client.user.CreateRequest;
import org.sonarqube.ws.client.user.SearchRequest;
import org.sonarqube.ws.client.user.UsersService;
+import org.sonarqube.ws.client.usergroups.AddUserRequest;
import util.selenium.Consumer;
import static java.util.Arrays.asList;
public String createAdminUser(String login, String password) {
createUser(login, password);
adminWsClient.permissions().addUser(new AddUserWsRequest().setLogin(login).setPermission("admin"));
- adminWsClient.userGroups().addUser(org.sonarqube.ws.client.usergroup.AddUserWsRequest.builder().setLogin(login).setName("sonar-administrators").build());
+ adminWsClient.userGroups().addUser(new AddUserRequest().setLogin(login).setName("sonar-administrators"));
return login;
}