]> source.dussan.org Git - sonarqube.git/commitdiff
Generate client for api/user_groups
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 23 Nov 2017 21:53:45 +0000 (22:53 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 29 Nov 2017 19:24:11 +0000 (20:24 +0100)
14 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/UserTester.java
sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java [deleted file]
tests/src/test/java/util/user/UserRule.java

index 7a3bd5e8fcafc87c6b5088fc55b829196635429f..29dfee6b234b56f91d28518138506f313e7822cb 100644 (file)
@@ -30,8 +30,8 @@ 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.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;
@@ -47,14 +47,14 @@ public class GroupTester {
   }
 
   @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) {
@@ -68,11 +68,10 @@ public class GroupTester {
 
   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;
index 8b38ca267a28fc8424d22adaaed9805f9534627b..d5546e5761a29433f609ae9a9e477515039e7954 100644 (file)
@@ -30,7 +30,7 @@ import org.sonarqube.ws.client.PostRequest;
 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;
 
@@ -75,7 +75,7 @@ public class UserTester {
   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;
   }
 
@@ -84,11 +84,10 @@ public class UserTester {
     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;
   }
 
@@ -96,11 +95,10 @@ public class UserTester {
   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;
   }
 
index 7c1445edcb29472d1c9f0dfa4aa128bd86ec71f6..7ae83705d7a611bd16a6229cd30debfd16ef8119 100644 (file)
@@ -38,7 +38,7 @@ import org.sonarqube.ws.client.rules.RulesService;
 import org.sonarqube.ws.client.settings.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
 import org.sonarqube.ws.client.user.UsersService;
-import org.sonarqube.ws.client.usergroup.UserGroupsService;
+import org.sonarqube.ws.client.usergroups.UserGroupsService;
 import org.sonarqube.ws.client.usertokens.UserTokensService;
 import org.sonarqube.ws.client.webhooks.WebhooksService;
 
index 2854977c5dfb834a2b8e6404fc6f83a54733ad5b..96c20272caf7778525ed5bc7c377203f7fb9b040 100644 (file)
@@ -38,7 +38,7 @@ import org.sonarqube.ws.client.rules.RulesService;
 import org.sonarqube.ws.client.settings.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
 import org.sonarqube.ws.client.user.UsersService;
-import org.sonarqube.ws.client.usergroup.UserGroupsService;
+import org.sonarqube.ws.client.usergroups.UserGroupsService;
 import org.sonarqube.ws.client.usertokens.UserTokensService;
 import org.sonarqube.ws.client.webhooks.WebhooksService;
 
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/AddUserWsRequest.java
deleted file mode 100644 (file)
index b48108c..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class AddUserWsRequest {
-
-  private final Long id;
-  private final String name;
-  private final String login;
-  private final String organization;
-
-  private AddUserWsRequest(Builder builder) {
-    this.id = builder.id;
-    this.name = builder.name;
-    this.login = builder.login;
-    this.organization = builder.organization;
-  }
-
-  @CheckForNull
-  public Long getId() {
-    return id;
-  }
-
-  @CheckForNull
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getLogin() {
-    return login;
-  }
-
-  @CheckForNull
-  public String getOrganization() {
-    return organization;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private Long id;
-    private String name;
-    private String login;
-    private String organization;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setId(@Nullable Long id) {
-      this.id = id;
-      return this;
-    }
-
-    public Builder setName(@Nullable String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setLogin(@Nullable String login) {
-      this.login = login;
-      return this;
-    }
-
-    public Builder setOrganization(@Nullable String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public AddUserWsRequest build() {
-      return new AddUserWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/CreateWsRequest.java
deleted file mode 100644 (file)
index 3d146a4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-@Immutable
-public class CreateWsRequest {
-
-  private final String name;
-  private final String description;
-  private final String organization;
-
-  private CreateWsRequest(Builder builder) {
-    this.name = builder.name;
-    this.description = builder.description;
-    this.organization = builder.organization;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getDescription() {
-    return description;
-  }
-
-  public String getOrganization() {
-    return organization;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private String name;
-    private String description;
-    private String organization;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setName(String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setDescription(@Nullable String description) {
-      this.description = description;
-      return this;
-    }
-
-    public Builder setOrganization(String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public CreateWsRequest build() {
-      checkArgument(!isNullOrEmpty(name), "Name is mandatory and must not be empty");
-      return new CreateWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/DeleteWsRequest.java
deleted file mode 100644 (file)
index 31786ff..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class DeleteWsRequest {
-
-  private final Long id;
-  private final String name;
-  private final String organization;
-
-  private DeleteWsRequest(Builder builder) {
-    this.id = builder.id;
-    this.name = builder.name;
-    this.organization = builder.organization;
-  }
-
-  @CheckForNull
-  public Long getId() {
-    return id;
-  }
-
-  @CheckForNull
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getOrganization() {
-    return organization;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private Long id;
-    private String name;
-    private String organization;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setId(@Nullable Long id) {
-      this.id = id;
-      return this;
-    }
-
-    public Builder setName(@Nullable String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setOrganization(@Nullable String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public DeleteWsRequest build() {
-      return new DeleteWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/RemoveUserWsRequest.java
deleted file mode 100644 (file)
index 0b498ec..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class RemoveUserWsRequest {
-
-  private final Long id;
-  private final String name;
-  private final String login;
-  private final String organization;
-
-  private RemoveUserWsRequest(Builder builder) {
-    this.id = builder.id;
-    this.name = builder.name;
-    this.login = builder.login;
-    this.organization = builder.organization;
-  }
-
-  @CheckForNull
-  public Long getId() {
-    return id;
-  }
-
-  @CheckForNull
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getLogin() {
-    return login;
-  }
-
-  @CheckForNull
-  public String getOrganization() {
-    return organization;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private Long id;
-    private String name;
-    private String login;
-    private String organization;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setId(@Nullable Long id) {
-      this.id = id;
-      return this;
-    }
-
-    public Builder setName(@Nullable String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setLogin(@Nullable String login) {
-      this.login = login;
-      return this;
-    }
-
-    public Builder setOrganization(@Nullable String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public RemoveUserWsRequest build() {
-      return new RemoveUserWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/SearchWsRequest.java
deleted file mode 100644 (file)
index 4a0bcb9..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class SearchWsRequest {
-  private final String query;
-  private final Integer page;
-  private final Integer pageSize;
-  private final String organization;
-  private final List<String> fields;
-
-  private SearchWsRequest(Builder builder) {
-    this.query = builder.query;
-    this.page = builder.page;
-    this.pageSize = builder.pageSize;
-    this.organization = builder.organization;
-    this.fields = builder.fields;
-  }
-
-  @CheckForNull
-  public String getQuery() {
-    return query;
-  }
-
-  @CheckForNull
-  public Integer getPageSize() {
-    return pageSize;
-  }
-
-  @CheckForNull
-  public Integer getPage() {
-    return page;
-  }
-
-  @CheckForNull
-  public String getOrganization() {
-    return organization;
-  }
-
-  @CheckForNull
-  public List<String> getFields() {
-    return fields;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static final class Builder {
-    private String query;
-    private Integer page;
-    private Integer pageSize;
-    private String organization;
-    private List<String> fields;
-
-    public Builder setQuery(@Nullable String query) {
-      this.query = query;
-      return this;
-    }
-
-    public Builder setPage(@Nullable Integer page) {
-      this.page = page;
-      return this;
-    }
-
-    public Builder setPageSize(@Nullable Integer pageSize) {
-      this.pageSize = pageSize;
-      return this;
-    }
-
-    public Builder setOrganization(@Nullable String organization) {
-      this.organization = organization;
-      return this;
-    }
-
-    public Builder setFields(@Nullable List<String> fields) {
-      this.fields = fields;
-      return this;
-    }
-
-    public SearchWsRequest build() {
-      return new SearchWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UpdateWsRequest.java
deleted file mode 100644 (file)
index a670e36..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.usergroup;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class UpdateWsRequest {
-
-  private final long id;
-  private final String name;
-  private final String description;
-
-  private UpdateWsRequest(Builder builder) {
-    this.id = builder.id;
-    this.name = builder.name;
-    this.description = builder.description;
-  }
-
-  public long getId() {
-    return id;
-  }
-
-  @CheckForNull
-  public String getName() {
-    return name;
-  }
-
-  @CheckForNull
-  public String getDescription() {
-    return description;
-  }
-
-  public static Builder builder() {
-    return new Builder();
-  }
-
-  public static class Builder {
-    private long id;
-    private String name;
-    private String description;
-
-    private Builder() {
-      // enforce factory method use
-    }
-
-    public Builder setId(long id) {
-      this.id = id;
-      return this;
-    }
-
-    public Builder setName(@Nullable String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setDescription(@Nullable String description) {
-      this.description = description;
-      return this;
-    }
-
-    public UpdateWsRequest build() {
-      return new UpdateWsRequest(this);
-    }
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/UserGroupsService.java
deleted file mode 100644 (file)
index 9cd0a38..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.usergroup;
-
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-
-import static org.sonar.api.server.ws.WebService.Param.FIELDS;
-import static org.sonar.api.server.ws.WebService.Param.PAGE;
-import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
-import static org.sonarqube.ws.UserGroups.CreateWsResponse;
-import static org.sonarqube.ws.UserGroups.SearchWsResponse;
-import static org.sonarqube.ws.UserGroups.UpdateWsResponse;
-
-public class UserGroupsService extends BaseService {
-
-  public UserGroupsService(WsConnector wsConnector) {
-    super(wsConnector, "api/user_groups");
-  }
-
-  public CreateWsResponse create(CreateWsRequest request) {
-    return call(new PostRequest(path("create"))
-      .setParam("name", request.getName())
-      .setParam("description", request.getDescription())
-      .setParam("organization", request.getOrganization()),
-      CreateWsResponse.parser());
-  }
-
-  public UpdateWsResponse update(UpdateWsRequest request) {
-    return call(new PostRequest(path("update"))
-      .setParam("id", request.getId())
-      .setParam("name", request.getName())
-      .setParam("description", request.getDescription()),
-      UpdateWsResponse.parser());
-  }
-
-  public void delete(DeleteWsRequest request) {
-    call(new PostRequest(path("delete"))
-      .setParam("id", request.getId())
-      .setParam("name", request.getName())
-      .setParam("organization", request.getOrganization()));
-  }
-
-  public void addUser(AddUserWsRequest request) {
-    call(new PostRequest(path("add_user"))
-      .setParam("id", request.getId())
-      .setParam("name", request.getName())
-      .setParam("login", request.getLogin())
-      .setParam("organization", request.getOrganization()));
-  }
-
-  public void removeUser(RemoveUserWsRequest request) {
-    call(new PostRequest(path("remove_user"))
-      .setParam("id", request.getId())
-      .setParam("name", request.getName())
-      .setParam("login", request.getLogin())
-      .setParam("organization", request.getOrganization()));
-  }
-
-  public SearchWsResponse search(SearchWsRequest request) {
-    return call(new GetRequest(path("search"))
-      .setParam(TEXT_QUERY, request.getQuery())
-      .setParam(PAGE, request.getPage())
-      .setParam(PAGE_SIZE, request.getPageSize())
-      .setParam("organization", request.getOrganization())
-      .setParam(FIELDS, inlineMultipleParamValue(request.getFields())),
-      SearchWsResponse.parser());
-  }
-
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/usergroup/package-info.java
deleted file mode 100644 (file)
index e3d282f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-
-@ParametersAreNonnullByDefault
-package org.sonarqube.ws.client.usergroup;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/usergroup/UserGroupsServiceTest.java
deleted file mode 100644 (file)
index d4bac21..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonarqube.ws.client.usergroup;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.client.ServiceTester;
-import org.sonarqube.ws.client.WsConnector;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.sonarqube.ws.UserGroups.CreateWsResponse;
-import static org.sonarqube.ws.UserGroups.SearchWsResponse;
-import static org.sonarqube.ws.UserGroups.UpdateWsResponse;
-
-public class UserGroupsServiceTest {
-
-  @Rule
-  public ServiceTester<UserGroupsService> serviceTester = new ServiceTester<>(new UserGroupsService(mock(WsConnector.class)));
-
-  private UserGroupsService underTest = serviceTester.getInstanceUnderTest();
-
-  @Test
-  public void create() {
-    underTest.create(CreateWsRequest.builder()
-      .setName("sonar-users")
-      .setDescription("All users")
-      .setOrganization("org")
-      .build());
-
-    assertThat(serviceTester.getPostParser()).isSameAs(CreateWsResponse.parser());
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam("name", "sonar-users")
-      .hasParam("description", "All users")
-      .hasParam("organization", "org")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void update() {
-    underTest.update(UpdateWsRequest.builder()
-      .setId(10L)
-      .setName("sonar-users")
-      .setDescription("All users")
-      .build());
-
-    assertThat(serviceTester.getPostParser()).isSameAs(UpdateWsResponse.parser());
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam("id", "10")
-      .hasParam("name", "sonar-users")
-      .hasParam("description", "All users")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void delete() {
-    underTest.delete(DeleteWsRequest.builder()
-      .setId(10L)
-      .setName("sonar-users")
-      .setOrganization("orga")
-      .build());
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam("id", "10")
-      .hasParam("name", "sonar-users")
-      .hasParam("organization", "orga")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void addUser() throws Exception {
-    underTest.addUser(AddUserWsRequest.builder()
-      .setId(10L)
-      .setName("sonar-users")
-      .setLogin("john")
-      .setOrganization("org")
-      .build());
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam("id", "10")
-      .hasParam("name", "sonar-users")
-      .hasParam("login", "john")
-      .hasParam("organization", "org")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void removeUser() throws Exception {
-    underTest.removeUser(RemoveUserWsRequest.builder()
-      .setId(10L)
-      .setName("sonar-users")
-      .setLogin("john")
-      .setOrganization("org")
-      .build());
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasParam("id", "10")
-      .hasParam("name", "sonar-users")
-      .hasParam("login", "john")
-      .hasParam("organization", "org")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void search() {
-    underTest.search(SearchWsRequest.builder()
-      .setQuery("sonar-users")
-      .setPage(10)
-      .setPageSize(50)
-      .setOrganization("orga")
-      .setFields(asList("name", "description"))
-      .build());
-
-    assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser());
-    serviceTester.assertThat(serviceTester.getGetRequest())
-      .hasParam("q", "sonar-users")
-      .hasParam("p", 10)
-      .hasParam("ps", 50)
-      .hasParam("organization", "orga")
-      .hasParam("f", "name,description")
-      .andNoOtherParam();
-  }
-
-}
index 65863a9629df91701c9275c73635e275bb33213a..9e8cc191020016ed042a0379d5457ee1d172aef8 100644 (file)
@@ -40,6 +40,7 @@ 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.usergroups.AddUserRequest;
 import util.selenium.Consumer;
 
 import static java.util.Arrays.asList;
@@ -148,7 +149,7 @@ public class UserRule extends ExternalResource implements GroupManagement {
   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;
   }