]> source.dussan.org Git - sonarqube.git/commitdiff
Remove legacy sonar-ws code for users
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Mon, 4 Dec 2017 17:34:00 +0000 (18:34 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 6 Dec 2017 13:40:17 +0000 (14:40 +0100)
25 files changed:
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/GroupTester.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/OrganizationTester.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java
sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java
sonar-ws/src/test/java/org/sonarqube/ws/client/user/CreateRequestTest.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/user/GroupsRequestTest.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/user/UpdateRequestTest.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/user/UsersServiceTest.java [deleted file]
tests/src/test/java/org/sonarqube/tests/issue/AutoAssignTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
tests/src/test/java/org/sonarqube/tests/startup/StartupIndexationTest.java
tests/src/test/java/org/sonarqube/tests/user/BaseIdentityProviderTest.java
tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java
tests/src/test/java/org/sonarqube/tests/user/OnboardingTest.java
tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/UserEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/user/UsersPageTest.java
tests/src/test/java/util/user/UserRule.java

index 29dfee6b234b56f91d28518138506f313e7822cb..3a901674e8ad2f789e81818b71481a93f117efe1 100644 (file)
@@ -29,9 +29,9 @@ import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.UserGroups;
 import org.sonarqube.ws.Users;
 import org.sonarqube.ws.Users.GroupsWsResponse.Group;
-import org.sonarqube.ws.client.user.GroupsRequest;
 import org.sonarqube.ws.client.usergroups.AddUserRequest;
 import org.sonarqube.ws.client.usergroups.CreateRequest;
+import org.sonarqube.ws.client.users.GroupsRequest;
 
 import static java.util.Arrays.stream;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -58,10 +58,9 @@ public class GroupTester {
   }
 
   public List<Group> getGroupsOfUser(@Nullable Organizations.Organization organization, String userLogin) {
-    GroupsRequest request = GroupsRequest.builder()
+    GroupsRequest request = new GroupsRequest()
       .setOrganization(organization != null ? organization.getKey() : null)
-      .setLogin(userLogin)
-      .build();
+      .setLogin(userLogin);
     Users.GroupsWsResponse response = session.users().service().groups(request);
     return response.getGroupsList();
   }
index e6bdc24940be47819f81d4e569667a12aa49beb0..acbcb940f3de60377ce7791b7d6adc86b3634b87 100644 (file)
@@ -35,7 +35,7 @@ import org.sonarqube.ws.client.organizations.DeleteRequest;
 import org.sonarqube.ws.client.organizations.OrganizationsService;
 import org.sonarqube.ws.client.organizations.SearchMembersRequest;
 import org.sonarqube.ws.client.organizations.SearchRequest;
-import org.sonarqube.ws.client.user.GroupsRequest;
+import org.sonarqube.ws.client.users.GroupsRequest;
 
 import static java.util.Arrays.stream;
 
@@ -128,12 +128,11 @@ public class OrganizationTester {
   }
 
   private void verifyMembersGroupMembership(String userLogin, @Nullable Organizations.Organization organization, boolean isMember) {
-    List<Users.GroupsWsResponse.Group> groups = session.wsClient().users().groups(GroupsRequest.builder()
+    List<Users.GroupsWsResponse.Group> groups = session.wsClient().users().groups(new GroupsRequest()
       .setLogin(userLogin)
       .setOrganization(organization != null ? organization.getKey() : null)
-      .setQuery("Members")
-      .setSelected("selected")
-      .build())
+      .setQ("Members")
+      .setSelected("selected"))
       .getGroupsList();
     Assertions.assertThat(groups).hasSize(isMember ? 1 : 0);
   }
index fca8bf4f1b895e0941c0da9920b4b6e1bba949a1..c5309c3578ece12ccaab254ce622de98bd88967e 100644 (file)
@@ -28,10 +28,10 @@ import org.sonarqube.ws.Users;
 import org.sonarqube.ws.Users.CreateWsResponse.User;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.organizations.AddMemberRequest;
-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 org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UsersService;
 
 import static java.util.Arrays.stream;
 
@@ -47,7 +47,7 @@ public class UserTester {
   }
 
   void deleteAll() {
-    session.wsClient().users().search(SearchRequest.builder().build()).getUsersList()
+    session.wsClient().users().search(new SearchRequest()).getUsersList()
       .stream()
       .filter(u -> !"admin".equals(u.getLogin()))
       .forEach(u -> {
@@ -57,23 +57,23 @@ public class UserTester {
   }
 
   @SafeVarargs
-  public final User generate(Consumer<CreateRequest.Builder>... populators) {
+  public final User generate(Consumer<CreateRequest>... populators) {
     int id = ID_GENERATOR.getAndIncrement();
     String login = "login" + id;
-    CreateRequest.Builder request = CreateRequest.builder()
+    CreateRequest request = new CreateRequest()
       .setLogin(login)
       .setPassword(login)
       .setName("name" + id)
       .setEmail(id + "@test.com");
     stream(populators).forEach(p -> p.accept(request));
-    return service().create(request.build()).getUser();
+    return service().create(request).getUser();
   }
 
   /**
    * For standalone mode only
    */
   @SafeVarargs
-  public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) {
+  public final User generateAdministrator(Consumer<CreateRequest>... populators) {
     User user = generate(populators);
     session.wsClient().permissions().addUser(new org.sonarqube.ws.client.permissions.AddUserRequest().setLogin(user.getLogin()).setPermission("admin"));
     session.wsClient().userGroups().addUser(new AddUserRequest().setLogin(user.getLogin()).setName("sonar-administrators"));
@@ -81,7 +81,7 @@ public class UserTester {
   }
 
   @SafeVarargs
-  public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+  public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest>... populators) {
     String organizationKey = organization.getKey();
     User user = generate(populators);
     session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organizationKey).setLogin(user.getLogin()));
@@ -93,7 +93,7 @@ public class UserTester {
   }
 
   @SafeVarargs
-  public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest.Builder>... populators) {
+  public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest>... populators) {
     User user = generate(populators);
     session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(DEFAULT_ORGANIZATION_KEY).setLogin(user.getLogin()));
     session.wsClient().userGroups().addUser(new AddUserRequest()
@@ -104,14 +104,14 @@ public class UserTester {
   }
 
   @SafeVarargs
-  public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+  public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest>... populators) {
     User user = generate(populators);
     session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()));
     return user;
   }
 
   @SafeVarargs
-  public final User generateMemberOfDefaultOrganization(Consumer<CreateRequest.Builder>... populators) {
+  public final User generateMemberOfDefaultOrganization(Consumer<CreateRequest>... populators) {
     User user = generate(populators);
     session.wsClient().organizations().addMember(new AddMemberRequest().setOrganization(DEFAULT_ORGANIZATION_KEY).setLogin(user.getLogin()));
     return user;
@@ -122,7 +122,7 @@ public class UserTester {
   }
 
   public Optional<Users.SearchWsResponse.User> getByLogin(String login) {
-    List<Users.SearchWsResponse.User> users = session.wsClient().users().search(SearchRequest.builder().setQuery(login).build()).getUsersList();
+    List<Users.SearchWsResponse.User> users = session.wsClient().users().search(new SearchRequest().setQ(login)).getUsersList();
     if (users.size() == 1) {
       return Optional.of(users.get(0));
     }
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java
deleted file mode 100644 (file)
index c2a71a4..0000000
+++ /dev/null
@@ -1,130 +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.user;
-
-import java.util.List;
-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;
-import static java.util.Collections.emptyList;
-
-@Immutable
-public class CreateRequest {
-
-  private final String login;
-  private final String password;
-  private final String name;
-  private final String email;
-  private final List<String> scmAccounts;
-  private final boolean local;
-
-  private CreateRequest(Builder builder) {
-    this.login = builder.login;
-    this.password = builder.password;
-    this.name = builder.name;
-    this.email = builder.email;
-    this.scmAccounts = builder.scmAccounts;
-    this.local = builder.local;
-  }
-
-  public String getLogin() {
-    return login;
-  }
-
-  @CheckForNull
-  public String getPassword() {
-    return password;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getEmail() {
-    return email;
-  }
-
-  public List<String> getScmAccounts() {
-    return scmAccounts;
-  }
-
-  public boolean isLocal() {
-    return local;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private String login;
-    private String password;
-    private String name;
-    private String email;
-    private List<String> scmAccounts = emptyList();
-    private boolean local = true;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setLogin(String login) {
-      this.login = login;
-      return this;
-    }
-
-    public Builder setPassword(@Nullable String password) {
-      this.password = password;
-      return this;
-    }
-
-    public Builder setName(String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setEmail(@Nullable String email) {
-      this.email = email;
-      return this;
-    }
-
-    public Builder setScmAccounts(List<String> scmAccounts) {
-      this.scmAccounts = scmAccounts;
-      return this;
-    }
-
-    public Builder setLocal(boolean local) {
-      this.local = local;
-      return this;
-    }
-
-    public CreateRequest build() {
-      checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
-      checkArgument(!isNullOrEmpty(name), "Name is mandatory and must not be empty");
-      checkArgument(!local || !isNullOrEmpty(password), "Password is mandatory and must not be empty");
-      checkArgument(local || isNullOrEmpty(password), "Password should only be set on local user");
-      return new CreateRequest(this);
-    }
-  }
-}
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
deleted file mode 100644 (file)
index 161a388..0000000
+++ /dev/null
@@ -1,128 +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.user;
-
-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 GroupsRequest {
-
-  private final String login;
-  private final String organization;
-  private final String query;
-  private final String selected;
-  private final Integer page;
-  private final Integer pageSize;
-
-  private GroupsRequest(Builder builder) {
-    this.login = builder.login;
-    this.organization = builder.organization;
-    this.query = builder.query;
-    this.selected = builder.selected;
-    this.page = builder.page;
-    this.pageSize = builder.pageSize;
-  }
-
-  public String getLogin() {
-    return login;
-  }
-
-  @CheckForNull
-  public String getOrganization() {
-    return organization;
-  }
-
-  @CheckForNull
-  public String getQuery() {
-    return query;
-  }
-
-  @CheckForNull
-  public String getSelected() {
-    return selected;
-  }
-
-  @CheckForNull
-  public Integer getPage() {
-    return page;
-  }
-
-  @CheckForNull
-  public Integer getPageSize() {
-    return pageSize;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private String login;
-    private String organization;
-    private String query;
-    private String selected;
-    private Integer page;
-    private Integer pageSize;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setLogin(String login) {
-      this.login = login;
-      return this;
-    }
-
-    public Builder setOrganization(@Nullable String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public Builder setQuery(@Nullable String query) {
-      this.query = query;
-      return this;
-    }
-
-    public Builder setSelected(@Nullable String selected) {
-      this.selected = selected;
-      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 GroupsRequest build() {
-      checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
-      return new GroupsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java
deleted file mode 100644 (file)
index 52e19f3..0000000
+++ /dev/null
@@ -1,100 +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.user;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class SearchRequest {
-
-  private final Integer page;
-  private final Integer pageSize;
-  private final String query;
-  private final List<String> possibleFields;
-
-  private SearchRequest(Builder builder) {
-    this.page = builder.page;
-    this.pageSize = builder.pageSize;
-    this.query = builder.query;
-    this.possibleFields = builder.additionalFields;
-  }
-
-  @CheckForNull
-  public Integer getPage() {
-    return page;
-  }
-
-  @CheckForNull
-  public Integer getPageSize() {
-    return pageSize;
-  }
-
-  @CheckForNull
-  public String getQuery() {
-    return query;
-  }
-
-  public List<String> getPossibleFields() {
-    return possibleFields;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private Integer page;
-    private Integer pageSize;
-    private String query;
-    private List<String> additionalFields = new ArrayList<>();
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setPage(@Nullable Integer page) {
-      this.page = page;
-      return this;
-    }
-
-    public Builder setPageSize(@Nullable Integer pageSize) {
-      this.pageSize = pageSize;
-      return this;
-    }
-
-    public Builder setQuery(@Nullable String query) {
-      this.query = query;
-      return this;
-    }
-
-    public Builder setPossibleFields(List<String> possibleFields) {
-      this.additionalFields = possibleFields;
-      return this;
-    }
-
-    public SearchRequest build() {
-      return new SearchRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java
deleted file mode 100644 (file)
index 40d5fbd..0000000
+++ /dev/null
@@ -1,101 +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.user;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static java.util.Collections.emptyList;
-
-public class UpdateRequest {
-
-  private final String login;
-  private final String name;
-  private final String email;
-  private final List<String> scmAccounts;
-
-  private UpdateRequest(Builder builder) {
-    this.login = builder.login;
-    this.name = builder.name;
-    this.email = builder.email;
-    this.scmAccounts = builder.scmAccounts;
-  }
-
-  public String getLogin() {
-    return login;
-  }
-
-  @CheckForNull
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getEmail() {
-    return email;
-  }
-
-  public List<String> getScmAccounts() {
-    return scmAccounts;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private String login;
-    private String name;
-    private String email;
-    private List<String> scmAccounts = emptyList();
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setLogin(String login) {
-      this.login = login;
-      return this;
-    }
-
-    public Builder setName(@Nullable String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setEmail(@Nullable String email) {
-      this.email = email;
-      return this;
-    }
-
-    public Builder setScmAccounts(List<String> scmAccounts) {
-      this.scmAccounts = scmAccounts;
-      return this;
-    }
-
-    public UpdateRequest build() {
-      checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
-      return new UpdateRequest(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
deleted file mode 100644 (file)
index 9f2cb3f..0000000
+++ /dev/null
@@ -1,113 +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.user;
-
-import java.util.List;
-import org.sonarqube.ws.Users.CreateWsResponse;
-import org.sonarqube.ws.Users.CurrentWsResponse;
-import org.sonarqube.ws.Users.GroupsWsResponse;
-import org.sonarqube.ws.Users.SearchWsResponse;
-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 org.sonarqube.ws.client.WsResponse;
-
-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.client.user.UsersWsParameters.ACTION_CREATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CURRENT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_DEACTIVATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_GROUPS;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SEARCH;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SKIP_ONBOARDING_TUTORIAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_UPDATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.CONTROLLER_USERS;
-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;
-
-public class UsersService extends BaseService {
-
-  public UsersService(WsConnector wsConnector) {
-    super(wsConnector, CONTROLLER_USERS);
-  }
-
-  public SearchWsResponse search(SearchRequest request) {
-    List<String> additionalFields = request.getPossibleFields();
-    return call(new GetRequest(path(ACTION_SEARCH))
-      .setParam(PAGE, request.getPage())
-      .setParam(PAGE_SIZE, request.getPageSize())
-      .setParam(TEXT_QUERY, request.getQuery())
-      .setParam(FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null),
-      SearchWsResponse.parser());
-  }
-
-  public CreateWsResponse create(CreateRequest request) {
-    return call(new PostRequest(path(ACTION_CREATE))
-      .setParam(PARAM_LOGIN, request.getLogin())
-      .setParam(PARAM_PASSWORD, request.getPassword())
-      .setParam(PARAM_NAME, request.getName())
-      .setParam(PARAM_EMAIL, request.getEmail())
-      .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts())
-      .setParam(PARAM_LOCAL, request.isLocal()),
-      CreateWsResponse.parser());
-  }
-
-  public void update(UpdateRequest request) {
-    call(new PostRequest(path(ACTION_UPDATE))
-      .setParam(PARAM_LOGIN, request.getLogin())
-      .setParam(PARAM_NAME, request.getName())
-      .setParam(PARAM_EMAIL, request.getEmail())
-      .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts()));
-  }
-
-  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())
-      .setParam(PAGE_SIZE, request.getPageSize()),
-      GroupsWsResponse.parser());
-  }
-
-  public CurrentWsResponse current() {
-    return call(new GetRequest(path(ACTION_CURRENT)), CurrentWsResponse.parser());
-  }
-
-  public WsResponse skipOnboardingTutorial() {
-    return call(new PostRequest(path(ACTION_SKIP_ONBOARDING_TUTORIAL)));
-  }
-
-  public void deactivate(String login) {
-    call(new PostRequest(path(ACTION_DEACTIVATE))
-      .setParam(PARAM_LOGIN, login));
-  }
-
-}
index 7852c6846c80700ce86d55110f1660f6fb908afc..5fc4b9ece4ba76ea22b9cf1b0b40573e4ae0f970 100644 (file)
@@ -36,8 +36,8 @@ public class CreateRequest {
   private String login;
   private String name;
   private String password;
-  private String scmAccount;
-  private String scmAccounts;
+  private List<String> scmAccount;
+  private List<String> scmAccounts;
 
   /**
    * Example value: "myname@email.com"
@@ -110,12 +110,12 @@ public class CreateRequest {
   /**
    * Example value: "scmAccount=firstValue&scmAccount=secondValue&scmAccount=thirdValue"
    */
-  public CreateRequest setScmAccount(String scmAccount) {
+  public CreateRequest setScmAccount(List<String> scmAccount) {
     this.scmAccount = scmAccount;
     return this;
   }
 
-  public String getScmAccount() {
+  public List<String> getScmAccount() {
     return scmAccount;
   }
 
@@ -124,12 +124,12 @@ public class CreateRequest {
    * @deprecated since 6.1
    */
   @Deprecated
-  public CreateRequest setScmAccounts(String scmAccounts) {
+  public CreateRequest setScmAccounts(List<String> scmAccounts) {
     this.scmAccounts = scmAccounts;
     return this;
   }
 
-  public String getScmAccounts() {
+  public List<String> getScmAccounts() {
     return scmAccounts;
   }
 }
index f456762369bb16c68c9eb8d00ae2c25c9cb17b67..b1ba17efd69649eeaf5838eb72c0e0d97556f062 100644 (file)
@@ -66,8 +66,8 @@ public class UsersService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
    * @since 3.7
    */
-  public void create(CreateRequest request) {
-    call(
+  public CreateWsResponse create(CreateRequest request) {
+    return call(
       new PostRequest(path("create"))
         .setParam("email", request.getEmail())
         .setParam("local", request.getLocal())
@@ -75,7 +75,7 @@ public class UsersService extends BaseService {
         .setParam("name", request.getName())
         .setParam("password", request.getPassword())
         .setParam("scmAccount", request.getScmAccount())
-        .setParam("scmAccounts", request.getScmAccounts()),
+        .setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
       CreateWsResponse.parser());
   }
 
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/CreateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/CreateRequestTest.java
deleted file mode 100644 (file)
index 91ec63a..0000000
+++ /dev/null
@@ -1,130 +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.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CreateRequestTest {
-
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  CreateRequest.Builder underTest = CreateRequest.builder();
-
-  @Test
-  public void create_request() {
-    CreateRequest result = underTest
-      .setLogin("john")
-      .setPassword("123456")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .setScmAccounts(asList("jo", "hn"))
-      .build();
-
-    assertThat(result.getLogin()).isEqualTo("john");
-    assertThat(result.getPassword()).isEqualTo("123456");
-    assertThat(result.getName()).isEqualTo("John");
-    assertThat(result.getEmail()).isEqualTo("john@doo.com");
-    assertThat(result.getScmAccounts()).containsOnly("jo", "hn");
-    assertThat(result.isLocal()).isTrue();
-  }
-
-  @Test
-  public void create_request_for_local_user() {
-    CreateRequest result = underTest
-      .setLogin("john")
-      .setPassword("123456")
-      .setName("John")
-      .setLocal(true)
-      .build();
-
-    assertThat(result.isLocal()).isTrue();
-  }
-
-  @Test
-  public void create_request_for_none_local_user() {
-    CreateRequest result = underTest
-      .setLogin("john")
-      .setName("John")
-      .setLocal(false)
-      .build();
-
-    assertThat(result.isLocal()).isFalse();
-  }
-
-  @Test
-  public void scm_accounts_is_empty_by_default() throws Exception {
-    CreateRequest result = underTest
-      .setLogin("john")
-      .setPassword("123456")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .build();
-
-    assertThat(result.getScmAccounts()).isEmpty();
-  }
-
-  @Test
-  public void fail_when_empty_login() {
-    expectedException.expect(IllegalArgumentException.class);
-    underTest
-      .setLogin("")
-      .setPassword("123456")
-      .setName("John")
-      .build();
-  }
-
-  @Test
-  public void fail_when_empty_password_on_local_user() {
-    expectedException.expect(IllegalArgumentException.class);
-    underTest
-      .setLogin("john")
-      .setPassword("")
-      .setName("John")
-      .build();
-  }
-
-  @Test
-  public void fail_when_empty_name() {
-    expectedException.expect(IllegalArgumentException.class);
-    underTest
-      .setLogin("john")
-      .setPassword("12345")
-      .setName("")
-      .build();
-  }
-
-  @Test
-  public void fail_when_password_is_set_on_none_local_user() {
-    expectedException.expect(IllegalArgumentException.class);
-    underTest
-      .setLogin("john")
-      .setPassword("12345")
-      .setName("12345")
-      .setLocal(false)
-      .build();
-  }
-
-}
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
deleted file mode 100644 (file)
index 58270e8..0000000
+++ /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.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GroupsRequestTest {
-
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  GroupsRequest.Builder underTest = GroupsRequest.builder();
-
-  @Test
-  public void create_request() {
-    GroupsRequest result = underTest
-      .setLogin("john")
-      .setOrganization("orga-uuid")
-      .setSelected("all")
-      .setQuery("sonar-users")
-      .setPage(10)
-      .setPageSize(50)
-      .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);
-    assertThat(result.getPageSize()).isEqualTo(50);
-  }
-
-  @Test
-  public void create_request_wih_minimal_fields() {
-    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();
-    assertThat(result.getPageSize()).isNull();
-  }
-
-  @Test
-  public void fail_when_empty_login() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Login is mandatory and must not be empty");
-
-    underTest.setLogin("").build();
-  }
-
-  @Test
-  public void fail_when_null_login() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Login is mandatory and must not be empty");
-
-    underTest.build();
-  }
-
-}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UpdateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/user/UpdateRequestTest.java
deleted file mode 100644 (file)
index 3f21906..0000000
+++ /dev/null
@@ -1,71 +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.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class UpdateRequestTest {
-
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  UpdateRequest.Builder underTest = UpdateRequest.builder();
-
-  @Test
-  public void create_request() {
-    UpdateRequest result = underTest
-      .setLogin("john")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .setScmAccounts(asList("jo", "hn"))
-      .build();
-
-    assertThat(result.getLogin()).isEqualTo("john");
-    assertThat(result.getName()).isEqualTo("John");
-    assertThat(result.getEmail()).isEqualTo("john@doo.com");
-    assertThat(result.getScmAccounts()).containsOnly("jo", "hn");
-  }
-
-  @Test
-  public void scm_accounts_is_empty_by_default() throws Exception {
-    UpdateRequest result = underTest
-      .setLogin("john")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .build();
-
-    assertThat(result.getScmAccounts()).isEmpty();
-  }
-
-  @Test
-  public void fail_when_empty_login() {
-    expectedException.expect(IllegalArgumentException.class);
-    underTest
-      .setLogin("")
-      .setName("John")
-      .build();
-  }
-
-}
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
deleted file mode 100644 (file)
index a0d870b..0000000
+++ /dev/null
@@ -1,138 +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.user;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.Users;
-import org.sonarqube.ws.Users.CreateWsResponse;
-import org.sonarqube.ws.Users.GroupsWsResponse;
-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.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.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;
-
-public class UsersServiceTest {
-
-  @Rule
-  public ServiceTester<UsersService> serviceTester = new ServiceTester<>(new UsersService(mock(WsConnector.class)));
-
-  private UsersService underTest = serviceTester.getInstanceUnderTest();
-
-  @Test
-  public void search() {
-    underTest.search(SearchRequest.builder()
-      .setQuery("john")
-      .setPage(10)
-      .setPageSize(50)
-      .setPossibleFields(asList("email", "name"))
-      .build());
-
-    assertThat(serviceTester.getGetParser()).isSameAs(Users.SearchWsResponse.parser());
-    serviceTester.assertThat(serviceTester.getGetRequest())
-      .hasParam(TEXT_QUERY, "john")
-      .hasParam(PAGE, 10)
-      .hasParam(PAGE_SIZE, 50)
-      .hasParam(FIELDS, "email,name")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void create() {
-    underTest.create(CreateRequest.builder()
-      .setLogin("john")
-      .setPassword("123456")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .setScmAccounts(asList("jo", "hn"))
-      .setLocal(true)
-      .build());
-
-    assertThat(serviceTester.getPostParser()).isSameAs(CreateWsResponse.parser());
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam(PARAM_LOGIN, "john")
-      .hasParam(PARAM_PASSWORD, "123456")
-      .hasParam(PARAM_NAME, "John")
-      .hasParam(PARAM_EMAIL, "john@doo.com")
-      .hasParam(PARAM_SCM_ACCOUNT, asList("jo", "hn"))
-      .hasParam(PARAM_LOCAL, "true")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void update() {
-    underTest.update(UpdateRequest.builder()
-      .setLogin("john")
-      .setName("John")
-      .setEmail("john@doo.com")
-      .setScmAccounts(asList("jo", "hn"))
-      .build());
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam(PARAM_LOGIN, "john")
-      .hasParam(PARAM_NAME, "John")
-      .hasParam(PARAM_EMAIL, "john@doo.com")
-      .hasParam(PARAM_SCM_ACCOUNT, asList("jo", "hn"))
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void groups() {
-    underTest.groups(GroupsRequest.builder()
-      .setLogin("john")
-      .setOrganization("orga-uuid")
-      .setSelected("all")
-      .setQuery("sonar-users")
-      .setPage(10)
-      .setPageSize(50)
-      .build());
-
-    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)
-      .hasParam(PAGE_SIZE, 50)
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void current() {
-    underTest.current();
-
-    assertThat(serviceTester.getGetParser()).isSameAs(Users.CurrentWsResponse.parser());
-  }
-}
index 89d0628ca7396801768506fa63d3613056e157bf..367351225af3e3a2dcec5e86adb863edab6984f3 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonarqube.tests.issue;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
@@ -33,11 +32,12 @@ import org.sonar.wsclient.issue.IssueQuery;
 import org.sonarqube.ws.Users;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.user.CreateRequest;
-import org.sonarqube.ws.client.user.SearchRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
 import util.ProjectAnalysis;
 import util.ProjectAnalysisRule;
 
+import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.groups.Tuple.tuple;
 import static util.ItUtils.newAdminWsClient;
@@ -180,18 +180,17 @@ public class AutoAssignTest extends AbstractIssueTest {
 
   private static void createUser(String login, String name, String email, String... scmAccounts) {
     newAdminWsClient(ORCHESTRATOR).users().create(
-      CreateRequest.builder()
+      new CreateRequest()
         .setLogin(login)
         .setName(name)
         .setEmail(email)
         .setPassword("xxxxxxx")
-        .setScmAccounts(Arrays.asList(scmAccounts))
-        .build());
+        .setScmAccounts(asList(scmAccounts)));
   }
 
   private static void deleteAllUsers() {
     WsClient wsClient = newAdminWsClient(ORCHESTRATOR);
-    Users.SearchWsResponse searchResponse = wsClient.users().search(SearchRequest.builder().build());
+    Users.SearchWsResponse searchResponse = wsClient.users().search(new SearchRequest());
     searchResponse.getUsersList().forEach(user -> {
       wsClient.wsConnector().call(new PostRequest("api/users/deactivate").setParam("login", user.getLogin()));
     });
index d401be4a1860a258380d1c033b2ad3c1b5e7af60..ff304fc81247de14993632c8debd8ebf44274617 100644 (file)
@@ -33,6 +33,7 @@ import org.sonarqube.ws.Users.CreateWsResponse.User;
 import org.sonarqube.ws.client.HttpException;
 import org.sonarqube.ws.client.organizations.RemoveMemberRequest;
 import org.sonarqube.ws.client.permissions.AddUserRequest;
+import org.sonarqube.ws.client.users.DeactivateRequest;
 
 public class OrganizationMembershipTest {
 
@@ -108,7 +109,7 @@ public class OrganizationMembershipTest {
     User user = tester.users().generate();
     addMembership(organization, user);
 
-    tester.users().service().deactivate(user.getLogin());
+    tester.users().service().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
     tester.organizations().assertThatNotMemberOf(organization, user);
   }
 
index 8032a439d3b51c257d9ae0ef5e927abf4cde5548..073bed971cc6d8a639f9abbadbb5e0c54e12d6ac 100644 (file)
@@ -36,7 +36,7 @@ import org.junit.rules.Timeout;
 import org.sonarqube.qa.util.LogsTailer;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Users;
-import org.sonarqube.ws.client.user.SearchRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static util.ItUtils.pluginArtifact;
@@ -64,7 +64,7 @@ public class StartupIndexationTest {
          LogsTailer.Watch sonarQubeIsUpWatcher = sonarQube.logsTailer.watch("SonarQube is up")) {
       sonarQube.resume();
       sonarQubeIsUpWatcher.waitForLog(20, TimeUnit.SECONDS);
-      SearchRequest searchRequest = SearchRequest.builder().setQuery("admin").build();
+      SearchRequest searchRequest = new SearchRequest().setQ("admin");
       Users.SearchWsResponse searchWsResponse = sonarQube.tester.wsClient().users().search(searchRequest);
       assertThat(searchWsResponse.getUsersCount()).isEqualTo(1);
       assertThat(searchWsResponse.getUsers(0).getName()).isEqualTo("Administrator");
index db5b754b00043c07f8dbc787d9b151fa1e11f188..cf1951f11948cf18cccf33c67aa0c7df22f00a82 100644 (file)
@@ -34,7 +34,7 @@ import org.sonarqube.qa.util.pageobjects.Navigation;
 import org.sonarqube.tests.Category4Suite;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
 import util.user.UserRule;
 import util.user.Users;
 
@@ -284,12 +284,11 @@ public class BaseIdentityProviderTest {
     setUserCreatedByAuthPlugin(USER_LOGIN, USER_PROVIDER_ID, USER_NAME, USER_EMAIL);
 
     // Provision none local user in database
-    newAdminWsClient(ORCHESTRATOR).users().create(CreateRequest.builder()
+    newAdminWsClient(ORCHESTRATOR).users().create(new CreateRequest()
       .setLogin(USER_LOGIN)
       .setName(USER_NAME)
       .setEmail(USER_EMAIL)
-      .setLocal(false)
-      .build());
+      .setLocal("false"));
     assertThat(userRule.getUserByLogin(USER_LOGIN).get())
       .extracting(Users.User::isLocal, Users.User::getExternalIdentity, Users.User::getExternalProvider)
       .containsOnly(false, USER_LOGIN, "sonarqube");
index 1955c1c2f62e4b61d2ea4da878a922bc2f0b9dfb..15916189fbca542eea7c66c5fd078dc5717e4430 100644 (file)
@@ -39,7 +39,8 @@ import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.WsClientFactories;
 import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
+import org.sonarqube.ws.client.users.DeactivateRequest;
 import org.sonarqube.ws.client.usertokens.GenerateRequest;
 import org.sonarqube.ws.client.usertokens.RevokeRequest;
 import org.sonarqube.ws.client.usertokens.SearchRequest;
@@ -235,15 +236,14 @@ public class LocalAuthenticationTest {
   @Test
   public void authenticate_on_user_that_was_disabled() {
     User user = tester.users().generate(u -> u.setLogin("test").setPassword("password"));
-    tester.users().service().deactivate(user.getLogin());
+    tester.users().service().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
 
-    tester.users().service().create(CreateRequest.builder()
+    tester.users().service().create(new CreateRequest()
       .setLogin("test")
       .setName("Test")
       .setEmail("test@email.com")
       .setScmAccounts(asList("test1", "test2"))
-      .setPassword("password")
-      .build());
+      .setPassword("password"));
 
     assertThat(checkAuthenticationWithAuthenticateWebService("test", "password")).isTrue();
     assertThat(tester.users().getByLogin("test").get())
index 9052ad8b32c0cbd0de9a2543b6bbf23834b3bc90..56b79bfc3c329470a51340aedd974294a8d39261 100644 (file)
@@ -39,7 +39,7 @@ import org.sonarqube.ws.Users.SearchWsResponse.User;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.permissions.AddUserRequest;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
 import util.selenium.Selenese;
 
 import static com.codeborne.selenide.Condition.visible;
@@ -197,12 +197,11 @@ public class OAuth2IdentityProviderTest {
     enablePlugin();
 
     // Provision none local user in database
-    tester.wsClient().users().create(CreateRequest.builder()
+    tester.wsClient().users().create(new CreateRequest()
       .setLogin(USER_LOGIN)
       .setName(USER_NAME)
       .setEmail(USER_EMAIL)
-      .setLocal(false)
-      .build());
+      .setLocal("false"));
     User user = tester.users().getByLogin(USER_LOGIN).get();
     assertThat(user.getLocal()).isFalse();
     assertThat(user.getExternalIdentity()).isEqualTo(USER_LOGIN);
index b3638e6019b132c75622ffbd641cd3a458f8df20..fd40d9e894b9b184ac942357a385a46bd5fd2969 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Users.CreateWsResponse.User;
 import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.users.DeactivateRequest;
 import util.ItUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -125,7 +126,7 @@ public class OnboardingTest {
     tester.as(user.getLogin()).wsClient().users().skipOnboardingTutorial();
     verifyTutorial(user, false);
 
-    tester.wsClient().users().deactivate(user.getLogin());
+    tester.wsClient().users().deactivate(new DeactivateRequest().setLogin(user.getLogin()));
     User reactivatedUser = tester.users().generate(u -> u.setLogin(user.getLogin()).setName(user.getName()).setPassword(user.getLogin()));
 
     verifyTutorial(reactivatedUser, true);
index a99d247263cf73fe844dc7cec57d86b3b44d69e3..bdee1e4f5dbd58ca8d1c7ab2080fa9b80b69b147 100644 (file)
@@ -43,7 +43,7 @@ import org.sonarqube.qa.util.pageobjects.SystemInfoPage;
 import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
-import org.sonarqube.ws.client.user.CreateRequest;
+import org.sonarqube.ws.client.users.CreateRequest;
 import util.user.UserRule;
 import util.user.Users;
 
@@ -324,12 +324,11 @@ public class RealmAuthenticationTest {
 
   @Test
   public void provision_user_before_authentication() {
-    tester.wsClient().users().create(CreateRequest.builder()
+    tester.wsClient().users().create(new CreateRequest()
       .setLogin(USER_LOGIN)
       .setName("Tester Testerovich")
       .setEmail("tester@example.org")
-      .setLocal(false)
-      .build());
+      .setLocal("false"));
     // The user is created in SonarQube but doesn't exist yet in external authentication system
     verifyAuthenticationIsNotOk(USER_LOGIN, "123");
 
index f73b1fab03d781498df825ecd9091c4fca71ec55..fdf1448a1de7cb5826bdd65aa7534b1d7e94dc00 100644 (file)
@@ -29,11 +29,11 @@ import org.junit.Test;
 import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonarqube.tests.Byteman;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Byteman;
 import org.sonarqube.ws.Users.CreateWsResponse.User;
-import org.sonarqube.ws.client.user.SearchRequest;
-import org.sonarqube.ws.client.user.UpdateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UpdateRequest;
 import util.ItUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -98,7 +98,7 @@ public class UserEsResilienceTest {
     // Renaming is not propagated to index as long as recovery does not
     // run.
     String newName = "renamed";
-    tester.users().service().update(UpdateRequest.builder().setLogin(login).setName(newName).build());
+    tester.users().service().update(new UpdateRequest().setLogin(login).setName(newName));
     assertThat(isReturnedInSearch(newName)).isFalse();
 
     while (!isReturnedInSearch(newName)) {
@@ -129,7 +129,7 @@ public class UserEsResilienceTest {
     // Renaming is not propagated to index as long as recovery does not
     // run.
     String newName = "renamed";
-    expectHttpError(500, () -> tester.users().service().update(UpdateRequest.builder().setLogin(login).setName(newName).build()));
+    expectHttpError(500, () -> tester.users().service().update(new UpdateRequest().setLogin(login).setName(newName)));
     assertThat(isReturnedInSearch(newName)).isFalse();
 
     while (!isReturnedInSearch(newName)) {
@@ -139,7 +139,7 @@ public class UserEsResilienceTest {
   }
 
   private boolean isReturnedInSearch(String name) {
-    return tester.users().service().search(SearchRequest.builder().setQuery(name).build()).getUsersCount() == 1L;
+    return tester.users().service().search(new SearchRequest().setQ(name)).getUsersCount() == 1L;
   }
 
 }
index 2aa83ffae749bd02872d6518a2d598952460e74d..143b9aa168cb4806c9a4f78ecb3d754788fc4040 100644 (file)
 package org.sonarqube.tests.user;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.junit.After;
-import org.sonarqube.ws.Users.CreateWsResponse.User;
-import org.sonarqube.qa.util.Tester;
-import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
-import org.sonarqube.tests.Category1Suite;
 import java.util.List;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.UsersManagementPage;
+import org.sonarqube.tests.Category1Suite;
 import org.sonarqube.ws.Users;
-import org.sonarqube.ws.client.user.GroupsRequest;
+import org.sonarqube.ws.Users.CreateWsResponse.User;
+import org.sonarqube.ws.client.users.GroupsRequest;
 import util.user.UserRule;
 
-
 import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -95,7 +94,7 @@ public class UsersPageTest {
     tester.groups().generate(null, g -> g.setName(group));
     tester.groups().addMemberToGroups(tester.organizations().getDefaultOrganization(), login, group);
 
-    List<Users.GroupsWsResponse.Group> result = tester.as(adminUser.getLogin()).wsClient().users().groups(GroupsRequest.builder().setLogin(login).build()).getGroupsList();
+    List<Users.GroupsWsResponse.Group> result = tester.as(adminUser.getLogin()).wsClient().users().groups(new GroupsRequest().setLogin(login)).getGroupsList();
     assertThat(result).extracting(Users.GroupsWsResponse.Group::getName).contains(group);
   }
 }
index 77c8562bfea2a2df6d80f76a3f807ae26da70a8c..06cee60d42acae9a55623bcfc11b1a43d4fc0424 100644 (file)
@@ -37,9 +37,9 @@ import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.permissions.AddUserRequest;
 import org.sonarqube.ws.client.roots.SetRootRequest;
-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.users.CreateRequest;
+import org.sonarqube.ws.client.users.SearchRequest;
+import org.sonarqube.ws.client.users.UsersService;
 import util.selenium.Consumer;
 
 import static java.util.Arrays.asList;
@@ -109,28 +109,28 @@ public class UserRule extends ExternalResource implements GroupManagement {
   }
 
   public Users.CreateWsResponse.User createUser(String login, String name, @Nullable String email, String password) {
-    CreateRequest.Builder request = CreateRequest.builder()
+    CreateRequest request = new CreateRequest()
       .setLogin(login)
       .setName(name)
       .setEmail(email)
       .setPassword(password);
-    return adminWsClient().users().create(request.build()).getUser();
+    return adminWsClient().users().create(request).getUser();
   }
 
   /**
    * Create user with randomly generated values. By default password is the login.
    */
   @SafeVarargs
-  public final org.sonarqube.ws.Users.CreateWsResponse.User generate(Consumer<CreateRequest.Builder>... populators) {
+  public final org.sonarqube.ws.Users.CreateWsResponse.User generate(Consumer<CreateRequest>... populators) {
     int id = ID_GENERATOR.getAndIncrement();
     String login = "login" + id;
-    CreateRequest.Builder request = CreateRequest.builder()
+    CreateRequest request = new CreateRequest()
       .setLogin(login)
       .setName("name" + id)
       .setEmail(id + "@test.com")
       .setPassword(login);
     stream(populators).forEach(p -> p.accept(request));
-    return adminWsClient().users().create(request.build()).getUser();
+    return adminWsClient().users().create(request).getUser();
   }
 
   public void createUser(String login, String password) {
@@ -181,7 +181,7 @@ public class UserRule extends ExternalResource implements GroupManagement {
 
   public void deactivateAllUsers() {
     UsersService service = newAdminWsClient(orchestrator).users();
-    List<String> logins = service.search(SearchRequest.builder().build()).getUsersList()
+    List<String> logins = service.search(new SearchRequest()).getUsersList()
       .stream()
       .filter(u -> !u.getLogin().equals("admin"))
       .map(u -> u.getLogin())