From 9bd3b8f3857e1434b97b73f39b9ffd88bdd703cc Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Mon, 4 Dec 2017 18:34:50 +0100 Subject: [PATCH] Remove legacy sonar-ws code for projects --- .../org/sonarqube/qa/util/ProjectTester.java | 22 +-- .../sonarqube/ws/client/DefaultWsClient.java | 2 +- .../client/project/BulkUpdateKeyRequest.java | 113 ----------- .../ws/client/project/CreateRequest.java | 113 ----------- .../ws/client/project/DeleteRequest.java | 59 ------ .../ws/client/project/ProjectsService.java | 140 ------------- .../project/SearchMyProjectsRequest.java | 72 ------- .../ws/client/project/SearchRequest.java | 179 ----------------- .../ws/client/project/UpdateKeyRequest.java | 88 --------- .../project/UpdateVisibilityRequest.java | 66 ------- .../client/project/ProjectsServiceTest.java | 184 ------------------ .../ws/client/project/SearchRequestTest.java | 81 -------- .../client/project/UpdateKeyRequestTest.java | 49 ----- .../tests/analysis/IssueExclusionsTest.java | 2 +- .../ExecuteAnalysisPermissionTest.java | 6 +- .../authorization/IssuePermissionTest.java | 4 +- .../ProvisioningPermissionTest.java | 6 +- .../tests/issue/IssueNotificationsTest.java | 2 +- .../sonarqube/tests/issue/IssueTagsTest.java | 9 +- .../issue/OrganizationIssueAssignTest.java | 9 +- .../tests/organization/BillingTest.java | 12 +- .../project/ProjectBulkDeletionTest.java | 26 +-- .../tests/project/ProjectDeletionTest.java | 22 +-- .../tests/project/ProjectFilterTest.java | 8 +- .../tests/project/ProjectKeyUpdateTest.java | 36 +--- .../project/ProjectProvisioningTest.java | 10 +- .../tests/project/ProjectSearchTest.java | 21 +- .../project/ProjectVisibilityPageTest.java | 4 +- .../sonarqube/tests/ui/UiExtensionsTest.java | 11 +- .../sonarqube/tests/webhook/WebhooksTest.java | 5 +- 30 files changed, 96 insertions(+), 1265 deletions(-) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java index 00eaf34ca73..0e1043480d8 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/ProjectTester.java @@ -24,10 +24,10 @@ import java.util.function.Consumer; import javax.annotation.Nullable; import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects; -import org.sonarqube.ws.client.project.CreateRequest; -import org.sonarqube.ws.client.project.DeleteRequest; -import org.sonarqube.ws.client.project.ProjectsService; -import org.sonarqube.ws.client.project.SearchRequest; +import org.sonarqube.ws.client.projects.CreateRequest; +import org.sonarqube.ws.client.projects.DeleteRequest; +import org.sonarqube.ws.client.projects.ProjectsService; +import org.sonarqube.ws.client.projects.SearchRequest; import static java.util.Arrays.stream; import static java.util.Collections.singletonList; @@ -44,24 +44,24 @@ public class ProjectTester { void deleteAll() { ProjectsService service = session.wsClient().projects(); - service.search(SearchRequest.builder().setQualifiers(singletonList("TRK")).build()).getComponentsList().forEach(p -> - service.delete(DeleteRequest.builder().setKey(p.getKey()).build())); + service.search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList().forEach(p -> + service.delete(new DeleteRequest().setProject(p.getKey()))); } @SafeVarargs - public final Projects.CreateWsResponse.Project provision(Consumer... populators) { + public final Projects.CreateWsResponse.Project provision(Consumer... populators) { return provision(null, populators); } @SafeVarargs - public final Projects.CreateWsResponse.Project provision(@Nullable Organizations.Organization organization, Consumer... populators) { + public final Projects.CreateWsResponse.Project provision(@Nullable Organizations.Organization organization, Consumer... populators) { int id = ID_GENERATOR.getAndIncrement(); - CreateRequest.Builder request = CreateRequest.builder() - .setKey("key" + id) + CreateRequest request = new CreateRequest() + .setProject("key" + id) .setName("Name " + id) .setOrganization(organization != null ? organization.getKey() : null); stream(populators).forEach(p -> p.accept(request)); - return session.wsClient().projects().create(request.build()).getProject(); + return session.wsClient().projects().create(request).getProject(); } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index ecef12eecfd..daa1a503ce0 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -45,8 +45,8 @@ import org.sonarqube.ws.client.profiles.ProfilesService; import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService; import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; -import org.sonarqube.ws.client.projects.ProjectsService; import org.sonarqube.ws.client.projecttags.ProjectTagsService; +import org.sonarqube.ws.client.projects.ProjectsService; import org.sonarqube.ws.client.properties.PropertiesService; import org.sonarqube.ws.client.qualitygates.QualitygatesService; import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java deleted file mode 100644 index 980f6361f87..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java +++ /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.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import static com.google.common.base.Preconditions.checkArgument; - -@Immutable -public class BulkUpdateKeyRequest { - private final String id; - private final String key; - private final String from; - private final String to; - private final boolean dryRun; - - public BulkUpdateKeyRequest(Builder builder) { - this.id = builder.id; - this.key = builder.key; - this.from = builder.from; - this.to = builder.to; - this.dryRun = builder.dryRun; - } - - @CheckForNull - public String getId() { - return id; - } - - @CheckForNull - public String getKey() { - return key; - } - - public String getFrom() { - return from; - } - - public String getTo() { - return to; - } - - public boolean isDryRun() { - return dryRun; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String id; - private String key; - private String from; - private String to; - private boolean dryRun; - - private Builder() { - // enforce method constructor - } - - public Builder setId(@Nullable String id) { - this.id = id; - return this; - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public Builder setFrom(String from) { - this.from = from; - return this; - } - - public Builder setTo(String to) { - this.to = to; - return this; - } - - public Builder setDryRun(boolean dryRun) { - this.dryRun = dryRun; - return this; - } - - public BulkUpdateKeyRequest build() { - checkArgument(from != null && !from.isEmpty(), "The string to match must not be empty"); - checkArgument(to != null && !to.isEmpty(), "The string replacement must not be empty"); - return new BulkUpdateKeyRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java deleted file mode 100644 index 61c89eeabfc..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java +++ /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.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class CreateRequest { - - private final String organization; - private final String key; - private final String name; - private final String branch; - @CheckForNull - private final String visibility; - - private CreateRequest(Builder builder) { - this.organization = builder.organization; - this.key = builder.key; - this.name = builder.name; - this.branch = builder.branch; - this.visibility = builder.visibility; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - @CheckForNull - public String getKey() { - return key; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - @CheckForNull - public String getVisibility() { - return visibility; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String key; - private String name; - private String branch; - @CheckForNull - private String visibility; - - private Builder() { - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public Builder setName(@Nullable String name) { - this.name = name; - return this; - } - - public Builder setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public Builder setVisibility(@Nullable String visibility) { - this.visibility = visibility; - return this; - } - - public CreateRequest build() { - return new CreateRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java deleted file mode 100644 index 0d798bd54f2..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java +++ /dev/null @@ -1,59 +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.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class DeleteRequest { - - private final String key; - - private DeleteRequest(Builder builder) { - this.key = builder.key; - } - - @CheckForNull - public String getKey() { - return key; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String key; - - private Builder() { - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public DeleteRequest build() { - return new DeleteRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java deleted file mode 100644 index e169f4f96e1..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java +++ /dev/null @@ -1,140 +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.project; - -import com.google.common.base.Joiner; -import org.sonarqube.ws.Projects.BulkUpdateKeyWsResponse; -import org.sonarqube.ws.Projects.CreateWsResponse; -import org.sonarqube.ws.Projects.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 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.project.ProjectsWsParameters.ACTION_BULK_UPDATE_KEY; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_CREATE; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_SEARCH; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_KEY; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_VISIBILITY; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.CONTROLLER; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ANALYZED_BEFORE; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NAME; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ON_PROVISIONED_ONLY; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECTS; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_IDS; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_VISIBILITY; - -/** - * Maps web service {@code api/projects}. - * - * @since 5.5 - */ -public class ProjectsService extends BaseService { - - public ProjectsService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER); - } - - /** - * Provisions a new project. - * - * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx. - */ - public CreateWsResponse create(CreateRequest project) { - PostRequest request = new PostRequest(path(ACTION_CREATE)) - .setParam(PARAM_ORGANIZATION, project.getOrganization()) - .setParam(PARAM_PROJECT, project.getKey()) - .setParam(PARAM_NAME, project.getName()) - .setParam(PARAM_BRANCH, project.getBranch()) - .setParam(PARAM_VISIBILITY, project.getVisibility()); - return call(request, CreateWsResponse.parser()); - } - - /** - * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx. - */ - public void delete(DeleteRequest request) { - call(new PostRequest(path("delete")) - .setParam("project", request.getKey())); - } - - public void bulkDelete(SearchRequest request) { - PostRequest post = new PostRequest(path("bulk_delete")) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers())) - .setParam(PARAM_ANALYZED_BEFORE, request.getAnalyzedBefore()) - .setParam(TEXT_QUERY, request.getQuery()) - .setParam(PARAM_ON_PROVISIONED_ONLY, request.isOnProvisionedOnly()) - .setParam(PARAM_PROJECTS, inlineMultipleParamValue(request.getProjects())) - .setParam(PARAM_PROJECT_IDS, inlineMultipleParamValue(request.getProjectIds())); - - call(post); - } - - public void updateKey(UpdateKeyRequest request) { - PostRequest post = new PostRequest(path(ACTION_UPDATE_KEY)) - .setParam(PARAM_PROJECT_ID, request.getId()) - .setParam(PARAM_FROM, request.getKey()) - .setParam(PARAM_TO, request.getNewKey()); - - call(post); - } - - public BulkUpdateKeyWsResponse bulkUpdateKey(BulkUpdateKeyRequest request) { - PostRequest post = new PostRequest(path(ACTION_BULK_UPDATE_KEY)) - .setParam(PARAM_PROJECT_ID, request.getId()) - .setParam(PARAM_PROJECT, request.getKey()) - .setParam(ProjectsWsParameters.PARAM_FROM, request.getFrom()) - .setParam(ProjectsWsParameters.PARAM_TO, request.getTo()); - - return call(post, BulkUpdateKeyWsResponse.parser()); - } - - public SearchWsResponse search(SearchRequest request) { - GetRequest get = new GetRequest(path(ACTION_SEARCH)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALIFIERS, Joiner.on(",").join(request.getQualifiers())) - .setParam(PARAM_ANALYZED_BEFORE, request.getAnalyzedBefore()) - .setParam(TEXT_QUERY, request.getQuery()) - .setParam(PAGE, request.getPage()) - .setParam(PAGE_SIZE, request.getPageSize()) - .setParam(PARAM_ON_PROVISIONED_ONLY, request.isOnProvisionedOnly()) - .setParam(PARAM_PROJECTS, inlineMultipleParamValue(request.getProjects())) - .setParam(PARAM_PROJECT_IDS, inlineMultipleParamValue(request.getProjectIds())); - return call(get, SearchWsResponse.parser()); - } - - public void updateVisibility(UpdateVisibilityRequest request) { - PostRequest post = new PostRequest(path(ACTION_UPDATE_VISIBILITY)) - .setParam(PARAM_PROJECT, request.getProject()) - .setParam(PARAM_VISIBILITY, request.getVisibility()); - call(post); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java deleted file mode 100644 index a0b6b3d80db..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java +++ /dev/null @@ -1,72 +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.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class SearchMyProjectsRequest { - private final Integer page; - private final Integer pageSize; - - private SearchMyProjectsRequest(Builder builder) { - this.page = builder.page; - this.pageSize = builder.pageSize; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Integer page; - private Integer pageSize; - - private Builder() { - // enforce method constructor - } - - public Builder setPage(@Nullable Integer page) { - this.page = page; - return this; - } - - public Builder setPageSize(@Nullable Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - public SearchMyProjectsRequest build() { - return new SearchMyProjectsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java deleted file mode 100644 index 5cf2b559dc9..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java +++ /dev/null @@ -1,179 +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.project; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Collections.singletonList; -import static java.util.Objects.requireNonNull; -import static org.sonarqube.ws.client.project.ProjectsWsParameters.MAX_PAGE_SIZE; - -public class SearchRequest { - - private final String organization; - private final String query; - private final List qualifiers; - private final String visibility; - private final Integer page; - private final Integer pageSize; - private final String analyzedBefore; - private final boolean onProvisionedOnly; - private final List projects; - private final List projectIds; - - public SearchRequest(Builder builder) { - this.organization = builder.organization; - this.query = builder.query; - this.qualifiers = builder.qualifiers; - this.visibility = builder.visibility; - this.page = builder.page; - this.pageSize = builder.pageSize; - this.analyzedBefore = builder.analyzedBefore; - this.onProvisionedOnly = builder.onProvisionedOnly; - this.projects = builder.projects; - this.projectIds = builder.projectIds; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public List getQualifiers() { - return qualifiers; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - @CheckForNull - public String getQuery() { - return query; - } - - @CheckForNull - public String getVisibility() { - return visibility; - } - - @CheckForNull - public String getAnalyzedBefore() { - return analyzedBefore; - } - - public boolean isOnProvisionedOnly() { - return onProvisionedOnly; - } - - @CheckForNull - public List getProjects() { - return projects; - } - - @CheckForNull - public List getProjectIds() { - return projectIds; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private List qualifiers = singletonList(Qualifiers.PROJECT); - private Integer page; - private Integer pageSize; - private String query; - private String visibility; - private String analyzedBefore; - private boolean onProvisionedOnly = false; - private List projects; - private List projectIds; - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setQualifiers(List qualifiers) { - this.qualifiers = requireNonNull(qualifiers, "Qualifiers cannot be null"); - 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 setQuery(@Nullable String query) { - this.query = query; - return this; - } - - public Builder setVisibility(@Nullable String visibility) { - this.visibility = visibility; - return this; - } - - public Builder setAnalyzedBefore(@Nullable String lastAnalysisBefore) { - this.analyzedBefore = lastAnalysisBefore; - return this; - } - - public Builder setOnProvisionedOnly(boolean onProvisionedOnly) { - this.onProvisionedOnly = onProvisionedOnly; - return this; - } - - public Builder setProjects(@Nullable List projects) { - this.projects = projects; - return this; - } - - public Builder setProjectIds(@Nullable List projectIds) { - this.projectIds = projectIds; - return this; - } - - public SearchRequest build() { - checkArgument(projects==null || !projects.isEmpty(), "Project key list must not be empty"); - checkArgument(projectIds==null || !projectIds.isEmpty(), "Project id list must not be empty"); - checkArgument(pageSize == null || pageSize <= MAX_PAGE_SIZE, "Page size must not be greater than %s", MAX_PAGE_SIZE); - return new SearchRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java deleted file mode 100644 index 0995a388c24..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonarqube.ws.client.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import static com.google.common.base.Preconditions.checkArgument; - -@Immutable -public class UpdateKeyRequest { - private final String id; - private final String key; - private final String newKey; - - public UpdateKeyRequest(Builder builder) { - this.id = builder.id; - this.key = builder.key; - this.newKey = builder.newKey; - } - - @CheckForNull - public String getId() { - return id; - } - - @CheckForNull - public String getKey() { - return key; - } - - public String getNewKey() { - return newKey; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String id; - private String key; - private String newKey; - - private Builder() { - // enforce method constructor - } - - public Builder setId(@Nullable String id) { - this.id = id; - return this; - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public Builder setNewKey(String newKey) { - this.newKey = newKey; - return this; - } - - public UpdateKeyRequest build() { - checkArgument(newKey != null && !newKey.isEmpty(), "The new key must not be empty"); - return new UpdateKeyRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java deleted file mode 100644 index 342b7a547b3..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java +++ /dev/null @@ -1,66 +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.project; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class UpdateVisibilityRequest { - private final String project; - private final String visibility; - - public UpdateVisibilityRequest(Builder builder) { - this.project = builder.project; - this.visibility = builder.visibility; - } - - @CheckForNull - public String getProject() { - return project; - } - - @CheckForNull - public String getVisibility() { - return visibility; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String project; - private String visibility; - - public Builder setProject(@Nullable String project) { - this.project = project; - return this; - } - - public Builder setVisibility(@Nullable String visibility) { - this.visibility = visibility; - return this; - } - - public UpdateVisibilityRequest build() { - return new UpdateVisibilityRequest(this); - } - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java deleted file mode 100644 index 9b8fbb04478..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java +++ /dev/null @@ -1,184 +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.project; - -import java.util.Arrays; -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.Projects; -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.assertj.core.data.MapEntry.entry; -import static org.mockito.Mockito.mock; -import static org.sonar.api.server.ws.WebService.Param.PAGE; -import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; - -public class ProjectsServiceTest { - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new ProjectsService(mock(WsConnector.class))); - - private ProjectsService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void creates_project() { - underTest.create(CreateRequest.builder() - .setKey("project_key") - .setName("Project Name") - .build()); - - assertThat(serviceTester.getPostParser()).isSameAs(Projects.CreateWsResponse.parser()); - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("project", "project_key"), - entry("name", "Project Name")); - } - - @Test - public void creates_project_on_organization() { - underTest.create(CreateRequest.builder() - .setOrganization("org_key") - .setKey("project_key") - .setName("Project Name") - .build()); - - assertThat(serviceTester.getPostParser()).isSameAs(Projects.CreateWsResponse.parser()); - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("organization", "org_key"), - entry("project", "project_key"), - entry("name", "Project Name")); - } - - @Test - public void creates_project_on_branch() { - underTest.create(CreateRequest.builder() - .setKey("project_key") - .setName("Project Name") - .setBranch("the_branch") - .build()); - - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("project", "project_key"), - entry("name", "Project Name"), - entry("branch", "the_branch")); - } - - @Test - public void creates_public_project() { - underTest.create(CreateRequest.builder() - .setKey("project_key") - .setName("Project Name") - .setVisibility("public") - .build()); - - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("project", "project_key"), - entry("name", "Project Name"), - entry("visibility", "public")); - } - - @Test - public void creates_private_project() { - underTest.create(CreateRequest.builder() - .setKey("project_key") - .setName("Project Name") - .setVisibility("private") - .build()); - - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("project", "project_key"), - entry("name", "Project Name"), - entry("visibility", "private")); - } - - @Test - public void delete() { - underTest.delete(DeleteRequest.builder().setKey("P1").build()); - - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/delete"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly(entry("project", "P1")); - } - - @Test - public void bulk_delete() { - underTest.bulkDelete(SearchRequest.builder() - .setOrganization("default") - .setQuery("project") - .setQualifiers(asList("TRK", "VW")) - .setAnalyzedBefore("2017-09-01") - .setProjects(Arrays.asList("P1", "P2")) - .setOnProvisionedOnly(true) - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("bulk_delete") - .hasParam("organization", "default") - .hasParam("q", "project") - .hasParam("analyzedBefore", "2017-09-01") - .hasParam("qualifiers", "TRK,VW") - .hasParam("onProvisionedOnly", "true") - .hasParam("projects", "P1,P2") - .andNoOtherParam(); - } - - @Test - public void search() { - underTest.search(SearchRequest.builder() - .setOrganization("default") - .setQuery("project") - .setQualifiers(asList("TRK", "VW")) - .setAnalyzedBefore("2017-09-01") - .setOnProvisionedOnly(true) - .setPage(3) - .setPageSize(10) - .build()); - - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("search") - .hasParam("organization", "default") - .hasParam("q", "project") - .hasParam("analyzedBefore", "2017-09-01") - .hasParam("qualifiers", "TRK,VW") - .hasParam("onProvisionedOnly", "true") - .hasParam(PAGE, 3) - .hasParam(PAGE_SIZE, 10) - .andNoOtherParam(); - } - - @Test - public void update_visibility() { - underTest.updateVisibility(UpdateVisibilityRequest.builder() - .setProject("project_key") - .setVisibility("public") - .build()); - - assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/update_visibility"); - assertThat(serviceTester.getPostRequest().getParams()).containsOnly( - entry("project", "project_key"), - entry("visibility", "public")); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java deleted file mode 100644 index ee64ad762ca..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java +++ /dev/null @@ -1,81 +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.project; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; - -public class SearchRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void create_request() throws Exception { - SearchRequest underTest = SearchRequest.builder() - .setOrganization("orga") - .setQuery("project") - .setQualifiers(asList("TRK", "VW")) - .setPage(5) - .setPageSize(10) - .build(); - - assertThat(underTest.getOrganization()).isEqualTo("orga"); - assertThat(underTest.getQuery()).isEqualTo("project"); - assertThat(underTest.getQualifiers()).containsOnly("TRK", "VW"); - assertThat(underTest.getPage()).isEqualTo(5); - assertThat(underTest.getPageSize()).isEqualTo(10); - } - - @Test - public void fail_when_page_size_is_greater_then_500() throws Exception { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Page size must not be greater than 500"); - - SearchRequest.builder() - .setPageSize(10000) - .build(); - } - - @Test - public void fail_if_project_key_list_is_empty() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Project key list must not be empty"); - - SearchRequest.builder() - .setProjects(emptyList()) - .build(); - } - - @Test - public void fail_if_project_id_list_is_empty() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Project id list must not be empty"); - - SearchRequest.builder() - .setProjectIds(emptyList()) - .build(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java deleted file mode 100644 index 7b99e955c7b..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java +++ /dev/null @@ -1,49 +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.project; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -public class UpdateKeyRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - UpdateKeyRequest.Builder underTest = UpdateKeyRequest.builder(); - - @Test - public void fail_if_new_key_is_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The new key must not be empty"); - - underTest.setNewKey(null).build(); - } - - @Test - public void fail_if_new_key_is_empty() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The new key must not be empty"); - - underTest.setNewKey("").build(); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java index 45b4a28a05d..a9f243a878f 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java @@ -237,7 +237,7 @@ public class IssueExclusionsTest { ItUtils.restoreProfile(orchestrator, getClass().getResource("/exclusions/IssueExclusionsTest/with-many-rules.xml")); tester.projects().provision(p -> p - .setKey("com.sonarsource.it.samples:multi-modules-exclusions") + .setProject("com.sonarsource.it.samples:multi-modules-exclusions") .setName("Sonar :: Integration Tests :: Multi-modules With Exclusions")); tester.wsClient().qualityprofiles().addProject(new AddProjectRequest().setProject("com.sonarsource.it.samples:multi-modules-exclusions") .setLanguage("xoo").setQualityProfile("with-many-rules")); diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/ExecuteAnalysisPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/ExecuteAnalysisPermissionTest.java index 6f6a4df3f49..f2b2116d14e 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/ExecuteAnalysisPermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/ExecuteAnalysisPermissionTest.java @@ -30,7 +30,7 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.client.permissions.AddGroupRequest; import org.sonarqube.ws.client.permissions.AddProjectCreatorToTemplateRequest; import org.sonarqube.ws.client.permissions.RemoveGroupRequest; -import org.sonarqube.ws.client.project.UpdateVisibilityRequest; +import org.sonarqube.ws.client.projects.UpdateVisibilityRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; @@ -78,7 +78,7 @@ public class ExecuteAnalysisPermissionTest { "You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator."); } - tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(PROJECT_KEY).setVisibility("private").build()); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(PROJECT_KEY).setVisibility("private")); try { // Execute anonymous analysis executeAnonymousAnalysis(); @@ -95,7 +95,7 @@ public class ExecuteAnalysisPermissionTest { executeAnonymousAnalysis(); // make project private - tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("sample").setVisibility("private").build()); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample").setVisibility("private")); // still no error executeAnonymousAnalysis(); diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java index 72e9c16b235..1f31815f899 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java @@ -35,7 +35,7 @@ import org.sonarqube.ws.Issues; import org.sonarqube.ws.client.issues.BulkChangeRequest; import org.sonarqube.ws.client.issues.ChangelogRequest; import org.sonarqube.ws.client.permissions.AddUserRequest; -import org.sonarqube.ws.client.project.UpdateVisibilityRequest; +import org.sonarqube.ws.client.projects.UpdateVisibilityRequest; import util.ItUtils; import static java.util.Arrays.asList; @@ -60,7 +60,7 @@ public class IssuePermissionTest { ItUtils.restoreProfile(orchestrator, getClass().getResource("/authorisation/one-issue-per-line-profile.xml")); orchestrator.getServer().provisionProject("privateProject", "PrivateProject"); - tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("privateProject").setVisibility("private").build()); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("privateProject").setVisibility("private")); orchestrator.getServer().associateProjectToQualityProfile("privateProject", "xoo", "one-issue-per-line"); SonarScanner privateProject = SonarScanner.create(projectDir("shared/xoo-sample")) .setProperty("sonar.projectKey", "privateProject") diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/ProvisioningPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/ProvisioningPermissionTest.java index 1fc4588d6cc..23d330be20d 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/ProvisioningPermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/ProvisioningPermissionTest.java @@ -31,7 +31,7 @@ import org.sonarqube.ws.client.permissions.AddGroupRequest; import org.sonarqube.ws.client.permissions.AddUserRequest; import org.sonarqube.ws.client.permissions.RemoveGroupRequest; import org.sonarqube.ws.client.permissions.RemoveUserRequest; -import org.sonarqube.ws.client.project.CreateRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -108,7 +108,7 @@ public class ProvisioningPermissionTest { final String newName = "New Project"; Project created = tester.as(USER_WITH_PROVISIONING, PASSWORD).wsClient().projects() - .create(CreateRequest.builder().setKey(newKey).setName(newName).build()) + .create(new CreateRequest().setProject(newKey).setName(newName)) .getProject(); assertThat(created).isNotNull(); @@ -124,7 +124,7 @@ public class ProvisioningPermissionTest { public void user_cannot_provision_project_through_ws_if_he_does_not_have_provisioning_permission() { ItUtils.expectForbiddenError(() -> { tester.as(USER_WITHOUT_PROVISIONING, PASSWORD).wsClient().projects() - .create(CreateRequest.builder().setKey("new-project").setName("New Project").build()) + .create(new CreateRequest().setProject("new-project").setName("New Project")) .getProject(); }); } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java index 9eed0add162..e1c15d12d24 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java @@ -288,7 +288,7 @@ public class IssueNotificationsTest { private void createSampleProject(String visibility) { // Create project Qualityprofiles.CreateWsResponse.QualityProfile profile = tester.qProfiles().createXooProfile(organization); - Project project = tester.projects().provision(organization, p -> p.setKey(PROJECT_KEY) + Project project = tester.projects().provision(organization, p -> p.setProject(PROJECT_KEY) .setName("Sample") .setVisibility(visibility)); tester.qProfiles() diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java index 6354d6f0b5b..94803195923 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java @@ -38,7 +38,7 @@ import org.sonarqube.ws.client.issues.SetTagsRequest; import org.sonarqube.ws.client.issues.TagsRequest; import org.sonarqube.ws.client.organizations.AddMemberRequest; import org.sonarqube.ws.client.permissions.AddUserRequest; -import org.sonarqube.ws.client.project.CreateRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -71,12 +71,11 @@ public class IssueTagsTest { restoreProfile(orchestrator, IssueTagsTest.class.getResource("/issue/one-issue-per-line-profile.xml"), organization.getKey()); String projectKey = newProjectKey(); tester.wsClient().projects().create( - CreateRequest.builder() - .setKey(projectKey) + new CreateRequest() + .setProject(projectKey) .setOrganization(organization.getKey()) .setName(randomAlphabetic(10)) - .setVisibility("private") - .build()); + .setVisibility("private")); analyzeProject(organization.getKey(), projectKey); String issue = tester.wsClient().issues().search(new SearchRequest()).getIssues(0).getKey(); diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java index 79b0b20cd0f..6cce0198625 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -37,8 +37,8 @@ import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.issues.AssignRequest; import org.sonarqube.ws.client.issues.BulkChangeRequest; import org.sonarqube.ws.client.issues.SearchRequest; -import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import util.issue.IssueRule; import static java.lang.String.format; @@ -185,11 +185,10 @@ public class OrganizationIssueAssignTest { private void provisionProject(String projectKey, String organization) { tester.wsClient().projects().create( - CreateRequest.builder() - .setKey(projectKey) + new CreateRequest() + .setProject(projectKey) .setName(projectKey) - .setOrganization(organization) - .build()); + .setOrganization(organization)); } private void analyseProject(String projectKey, String organization) { diff --git a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java index 0304a639f53..43a8f15e20d 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java @@ -35,8 +35,8 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.ce.TaskRequest; import org.sonarqube.ws.client.organizations.UpdateProjectVisibilityRequest; -import org.sonarqube.ws.client.project.CreateRequest; -import org.sonarqube.ws.client.project.UpdateVisibilityRequest; +import org.sonarqube.ws.client.projects.CreateRequest; +import org.sonarqube.ws.client.projects.UpdateVisibilityRequest; import util.ItUtils; import static java.lang.String.format; @@ -150,7 +150,7 @@ public class BillingTest { String projectKey = createPublicProject(); tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false"); - tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build()); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(projectKey).setVisibility("private")); assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey), "\"visibility\":\"private\""); } @@ -162,7 +162,7 @@ public class BillingTest { expectHttpError(400, format("Organization %s cannot use private project", organization.getKey()), - () -> tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build())); + () -> tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(projectKey).setVisibility("private"))); } @Test @@ -170,7 +170,7 @@ public class BillingTest { String projectKey = newProjectKey(); tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false"); - tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("public").build()); + tester.wsClient().projects().create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("public")); assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey), "\"visibility\":\"public\""); } @@ -183,7 +183,7 @@ public class BillingTest { expectHttpError(400, format("Organization %s cannot use private project", organization.getKey()), () -> tester.wsClient().projects() - .create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("private").build())); + .create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("private"))); } @Test diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionTest.java index ce7fdb4bc33..050eaaf079c 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionTest.java @@ -30,7 +30,8 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects.CreateWsResponse; import org.sonarqube.ws.Projects.SearchWsResponse.Component; -import org.sonarqube.ws.client.project.SearchRequest; +import org.sonarqube.ws.client.projects.BulkDeleteRequest; +import org.sonarqube.ws.client.projects.SearchRequest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.runProjectAnalysis; @@ -46,18 +47,18 @@ public class ProjectBulkDeletionTest { @Test public void delete_projects() { Organizations.Organization organization = tester.organizations().generate(); - CreateWsResponse.Project firstProvisionedProject = tester.projects().provision(organization, p -> p.setKey("first-provisioned-project")); - CreateWsResponse.Project secondProvisionedProject = tester.projects().provision(organization, p -> p.setKey("second-provisioned-project")); + CreateWsResponse.Project firstProvisionedProject = tester.projects().provision(organization, p -> p.setProject("first-provisioned-project")); + CreateWsResponse.Project secondProvisionedProject = tester.projects().provision(organization, p -> p.setProject("second-provisioned-project")); CreateWsResponse.Project analyzedProject = tester.projects().provision(organization); analyzeProject(analyzedProject.getKey(), organization.getKey()); - tester.wsClient().projects().bulkDelete(SearchRequest.builder() + tester.wsClient().projects().bulkDelete(new BulkDeleteRequest() .setOrganization(organization.getKey()) - .setQuery("FIRST-PROVISIONED") - .setOnProvisionedOnly(true).build()); + .setQ("FIRST-PROVISIONED") + .setOnProvisionedOnly("true")); - List projects = tester.wsClient().projects().search(SearchRequest.builder().setOrganization(organization.getKey()).build()).getComponentsList(); + List projects = tester.wsClient().projects().search(new SearchRequest().setOrganization(organization.getKey())).getComponentsList(); assertThat(projects).extracting(Component::getKey) .containsExactlyInAnyOrder(analyzedProject.getKey(), secondProvisionedProject.getKey()) .doesNotContain(firstProvisionedProject.getKey()); @@ -67,13 +68,14 @@ public class ProjectBulkDeletionTest { public void delete_more_than_50_projects_at_the_same_time() { Organizations.Organization organization = tester.organizations().generate(); IntStream.range(0, 60).forEach(i -> tester.projects().provision(organization)); - SearchRequest request = SearchRequest.builder().setOrganization(organization.getKey()).build(); - assertThat(tester.wsClient().projects().search(request).getPaging().getTotal()).isEqualTo(60); + SearchRequest searchRequest = new SearchRequest().setOrganization(organization.getKey()); + BulkDeleteRequest deleteRequest = new BulkDeleteRequest().setOrganization(organization.getKey()); + assertThat(tester.wsClient().projects().search(searchRequest).getPaging().getTotal()).isEqualTo(60); - tester.wsClient().projects().bulkDelete(request); + tester.wsClient().projects().bulkDelete(deleteRequest); - assertThat(tester.wsClient().projects().search(request).getComponentsList()).isEmpty(); - assertThat(tester.wsClient().projects().search(request).getPaging().getTotal()).isEqualTo(0); + assertThat(tester.wsClient().projects().search(searchRequest).getComponentsList()).isEmpty(); + assertThat(tester.wsClient().projects().search(searchRequest).getPaging().getTotal()).isEqualTo(0); } private void analyzeProject(String projectKey, String organizationKey) { diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java index 9f679c9b20a..22915b31255 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java @@ -32,8 +32,8 @@ import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; import org.sonarqube.qa.util.Tester; -import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Components; +import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.Users; @@ -41,9 +41,10 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.components.SearchProjectsRequest; -import org.sonarqube.ws.client.project.CreateRequest; -import org.sonarqube.ws.client.project.DeleteRequest; -import org.sonarqube.ws.client.project.SearchRequest; +import org.sonarqube.ws.client.projects.BulkDeleteRequest; +import org.sonarqube.ws.client.projects.CreateRequest; +import org.sonarqube.ws.client.projects.DeleteRequest; +import org.sonarqube.ws.client.projects.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -161,19 +162,18 @@ public class ProjectDeletionTest { } private void deleteProject(Project project) { - tester.wsClient().projects().delete(DeleteRequest.builder().setKey(project.getKey()).build()); + tester.wsClient().projects().delete(new DeleteRequest().setProject(project.getKey())); } private void bulkDeleteProjects(Organizations.Organization organization, Project... projects) { - SearchRequest request = SearchRequest.builder() + BulkDeleteRequest request = new BulkDeleteRequest() .setOrganization(organization.getKey()) - .setProjects(Arrays.stream(projects).map(Project::getKey).collect(Collectors.toList())) - .build(); + .setProjects(Arrays.stream(projects).map(Project::getKey).collect(Collectors.toList())); tester.wsClient().projects().bulkDelete(request); } private Project createProject(Organizations.Organization organization, String key, String name) { - CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build(); + CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey()); return tester.wsClient().projects().create(createRequest).getProject(); } @@ -194,7 +194,7 @@ public class ProjectDeletionTest { */ private boolean isInProjectsSearch(Organizations.Organization organization, String name) { Projects.SearchWsResponse response = tester.wsClient().projects().search( - SearchRequest.builder().setOrganization(organization.getKey()).setQuery(name).setQualifiers(singletonList("TRK")).build()); + new SearchRequest().setOrganization(organization.getKey()).setQ(name).setQualifiers(singletonList("TRK"))); return response.getComponentsCount() > 0; } @@ -229,6 +229,6 @@ public class ProjectDeletionTest { } private static void executeDeleteRequest(WsClient wsClient, String key) { - wsClient.projects().delete(DeleteRequest.builder().setKey(key).build()); + wsClient.projects().delete(new DeleteRequest().setProject(key)); } } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java index 02af1ddf6a0..57da2663e34 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java @@ -31,11 +31,11 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Common; -import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Components.Component; import org.sonarqube.ws.Components.SearchProjectsWsResponse; +import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.client.components.SearchProjectsRequest; -import org.sonarqube.ws.client.project.CreateRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -88,7 +88,7 @@ public class ProjectFilterTest { @Test public void provisioned_projects_should_be_included_to_results() throws Exception { String projectKey = newProjectKey(); - tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).build()); + tester.wsClient().projects().create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey())); SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey())); @@ -107,7 +107,7 @@ public class ProjectFilterTest { analyzeProject(projectKey2, "shared/xoo-sample"); // This project is provisioned, so has no leak period String projectKey3 = newProjectKey(); - tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey3).setName(projectKey3).setOrganization(organization.getKey()).build()); + tester.wsClient().projects().create(new CreateRequest().setProject(projectKey3).setName(projectKey3).setOrganization(organization.getKey())); SearchProjectsWsResponse response = searchProjects( new SearchProjectsRequest().setF(singletonList("leakPeriodDate")).setOrganization(organization.getKey())); diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java index d42e850af28..c448982532f 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java @@ -41,9 +41,8 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.components.ShowRequest; -import org.sonarqube.ws.client.project.BulkUpdateKeyRequest; -import org.sonarqube.ws.client.project.CreateRequest; -import org.sonarqube.ws.client.project.UpdateKeyRequest; +import org.sonarqube.ws.client.projects.UpdateKeyRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -74,32 +73,11 @@ public class ProjectKeyUpdateTest { Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent(); assertThat(project.getKey()).isEqualTo(PROJECT_KEY); - tester.wsClient().projects().updateKey(UpdateKeyRequest.builder() - .setKey(PROJECT_KEY) - .setNewKey(newProjectKey) - .build()); - - assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); - } - - @Test - public void bulk_update_key() { - analyzeXooSample(); - String newProjectKey = "another_project_key"; - Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent(); - assertThat(project.getKey()).isEqualTo(PROJECT_KEY); - - Projects.BulkUpdateKeyWsResponse result = tester.wsClient().projects().bulkUpdateKey(BulkUpdateKeyRequest.builder() - .setKey(PROJECT_KEY) + tester.wsClient().projects().updateKey(new UpdateKeyRequest() .setFrom(PROJECT_KEY) - .setTo(newProjectKey) - .build()); + .setTo(newProjectKey)); assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); - assertThat(result.getKeysCount()).isEqualTo(1); - assertThat(result.getKeys(0)) - .extracting(Projects.BulkUpdateKeyWsResponse.Key::getKey, Projects.BulkUpdateKeyWsResponse.Key::getNewKey, Projects.BulkUpdateKeyWsResponse.Key::getDuplicate) - .containsOnlyOnce(PROJECT_KEY, newProjectKey, false); } @Test @@ -229,15 +207,15 @@ public class ProjectKeyUpdateTest { } private void updateKey(Projects.CreateWsResponse.Project project, String newKey) { - tester.wsClient().projects().updateKey(UpdateKeyRequest.builder().setKey(project.getKey()).setNewKey(newKey).build()); + tester.wsClient().projects().updateKey(new UpdateKeyRequest().setFrom(project.getKey()).setTo(newKey)); } private void updateKey(String initialKey, String newKey) { - tester.wsClient().projects().updateKey(UpdateKeyRequest.builder().setKey(initialKey).setNewKey(newKey).build()); + tester.wsClient().projects().updateKey(new UpdateKeyRequest().setFrom(initialKey).setTo(newKey)); } private Projects.CreateWsResponse.Project createProject(Organizations.Organization organization, String key, String name) { - CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build(); + CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey()); return tester.wsClient().projects().create(createRequest).getProject(); } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java index ddb5803da22..7e9842c4400 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java @@ -29,15 +29,15 @@ import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; import org.sonarqube.qa.util.Tester; -import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Components; +import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.components.SearchProjectsRequest; -import org.sonarqube.ws.client.project.CreateRequest; -import org.sonarqube.ws.client.project.SearchRequest; +import org.sonarqube.ws.client.projects.CreateRequest; +import org.sonarqube.ws.client.projects.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -92,7 +92,7 @@ public class ProjectProvisioningTest { } private Project createProject(Organizations.Organization organization, String key, String name) { - CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build(); + CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey()); return tester.wsClient().projects().create(createRequest).getProject(); } @@ -101,7 +101,7 @@ public class ProjectProvisioningTest { */ private boolean isInProjectsSearch(Organizations.Organization organization, String name) { Projects.SearchWsResponse response = tester.wsClient().projects().search( - SearchRequest.builder().setOrganization(organization.getKey()).setQuery(name).setQualifiers(singletonList("TRK")).build()); + new SearchRequest().setOrganization(organization.getKey()).setQ(name).setQualifiers(singletonList("TRK"))); return response.getComponentsCount() > 0; } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectSearchTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectSearchTest.java index 12508573f70..d29f9eb8771 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectSearchTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectSearchTest.java @@ -32,7 +32,7 @@ import org.sonarqube.ws.Projects.CreateWsResponse; import org.sonarqube.ws.Projects.SearchWsResponse; import org.sonarqube.ws.Projects.SearchWsResponse.Component; import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.project.SearchRequest; +import org.sonarqube.ws.client.projects.SearchRequest; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; @@ -59,10 +59,10 @@ public class ProjectSearchTest { analyzeProject(oldProject.getKey(), moreThanOneYearAgo, organization.getKey()); analyzeProject(recentProject.getKey(), now, organization.getKey()); - SearchWsResponse result = tester.wsClient().projects().search(SearchRequest.builder() + SearchWsResponse result = tester.wsClient().projects().search(new SearchRequest() .setOrganization(organization.getKey()) .setQualifiers(singletonList("TRK")) - .setAnalyzedBefore(formatDate(oneYearAgo)).build()); + .setAnalyzedBefore(formatDate(oneYearAgo))); assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(oldProject.getKey()); } @@ -70,19 +70,18 @@ public class ProjectSearchTest { @Test public void search_on_key_query_partial_match_case_insensitive() { Organizations.Organization organization = tester.organizations().generate(); - CreateWsResponse.Project lowerCaseProject = tester.projects().provision(organization, p -> p.setKey("project-key")); - CreateWsResponse.Project upperCaseProject = tester.projects().provision(organization, p -> p.setKey("PROJECT-KEY")); - CreateWsResponse.Project anotherProject = tester.projects().provision(organization, p -> p.setKey("another-project")); + CreateWsResponse.Project lowerCaseProject = tester.projects().provision(organization, p -> p.setProject("project-key")); + CreateWsResponse.Project upperCaseProject = tester.projects().provision(organization, p -> p.setProject("PROJECT-KEY")); + CreateWsResponse.Project anotherProject = tester.projects().provision(organization, p -> p.setProject("another-project")); analyzeProject(lowerCaseProject.getKey(), organization.getKey()); analyzeProject(upperCaseProject.getKey(), organization.getKey()); analyzeProject(anotherProject.getKey(), organization.getKey()); - SearchWsResponse result = tester.wsClient().projects().search(SearchRequest.builder() + SearchWsResponse result = tester.wsClient().projects().search(new SearchRequest() .setOrganization(organization.getKey()) .setQualifiers(singletonList("TRK")) - .setQuery("JeCt-K") - .build()); + .setQ("JeCt-K")); assertThat(result.getComponentsList()).extracting(Component::getKey) .containsExactlyInAnyOrder(lowerCaseProject.getKey(), upperCaseProject.getKey()) @@ -101,10 +100,10 @@ public class ProjectSearchTest { String result = tester.wsClient().wsConnector().call(new GetRequest("api/projects/provisioned") .setParam("organization", organization.getKey())) .failIfNotSuccessful().content(); - SearchWsResponse searchResult = tester.wsClient().projects().search(SearchRequest.builder() + SearchWsResponse searchResult = tester.wsClient().projects().search(new SearchRequest() .setQualifiers(singletonList("TRK")) .setOrganization(organization.getKey()) - .setOnProvisionedOnly(true).build()); + .setOnProvisionedOnly("true")); assertThat(result).contains(firstProvisionedProject.getKey(), secondProvisionedProject.getKey()).doesNotContain(analyzedProject.getKey()); assertThat(searchResult.getComponentsList()).extracting(Component::getKey) diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java index 5607dc8fad0..55ed2134a6a 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java @@ -30,7 +30,7 @@ import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage; import org.sonarqube.ws.Components; import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.permissions.RemoveGroupRequest; -import org.sonarqube.ws.client.project.UpdateVisibilityRequest; +import org.sonarqube.ws.client.projects.UpdateVisibilityRequest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; @@ -54,7 +54,7 @@ public class ProjectVisibilityPageTest { public void return_all_projects_even_when_no_permission() throws Exception { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample1")); orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample2")); - tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("sample2").setVisibility("private").build()); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample2").setVisibility("private")); // Remove 'Admin' permission for admin group on project 2 -> No one can access or admin this project, expect System Admin tester.wsClient().permissions().removeGroup(new RemoveGroupRequest().setProjectKey("sample2").setGroupName("sonar-administrators").setPermission("admin")); diff --git a/tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java b/tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java index 8e6f6cba821..48f32a7dac1 100644 --- a/tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java @@ -20,15 +20,15 @@ package org.sonarqube.tests.ui; import com.sonar.orchestrator.Orchestrator; -import org.sonarqube.tests.Category4Suite; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.openqa.selenium.By; import org.sonarqube.qa.util.Tester; +import org.sonarqube.tests.Category4Suite; import org.sonarqube.ws.Projects; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.project.CreateRequest; +import org.sonarqube.ws.client.projects.CreateRequest; import util.ItUtils; import util.selenium.Selenese; @@ -107,9 +107,8 @@ public class UiExtensionsTest { private Projects.CreateWsResponse.Project createSampleProject() { String projectKey = ItUtils.newProjectKey(); - return tester.wsClient().projects().create(CreateRequest.builder() - .setKey(projectKey) - .setName("Name of " + projectKey) - .build()).getProject(); + return tester.wsClient().projects().create(new CreateRequest() + .setProject(projectKey) + .setName("Name of " + projectKey)).getProject(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java index b88d64da715..8c5d8b3b0cb 100644 --- a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java @@ -21,7 +21,6 @@ package org.sonarqube.tests.webhook; import com.sonar.orchestrator.Orchestrator; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -36,7 +35,7 @@ import org.sonarqube.tests.Category3Suite; import org.sonarqube.ws.Webhooks; import org.sonarqube.ws.client.HttpException; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.project.DeleteRequest; +import org.sonarqube.ws.client.projects.DeleteRequest; import org.sonarqube.ws.client.settings.ResetRequest; import org.sonarqube.ws.client.settings.SetRequest; import org.sonarqube.ws.client.webhooks.DeliveriesRequest; @@ -75,7 +74,7 @@ public class WebhooksTest { disableGlobalWebhooks(); try { // delete project and related properties/webhook deliveries - adminWs.projects().delete(DeleteRequest.builder().setKey(PROJECT_KEY).build()); + adminWs.projects().delete(new DeleteRequest().setProject(PROJECT_KEY)); } catch (HttpException e) { // ignore because project may not exist } -- 2.39.5