From 2d211ab5fd27358de3d07990f3dc1b487d29c994 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Thu, 30 Nov 2017 18:39:25 +0100 Subject: [PATCH] Remove legacy sonar-ws code for components --- .../sonarqube/ws/client/DefaultWsClient.java | 7 - .../org/sonarqube/ws/client/WsClient.java | 6 - .../client/component/ComponentsService.java | 114 ----------- .../component/SearchProjectsRequest.java | 160 --------------- .../ws/client/component/SearchRequest.java | 94 --------- .../ws/client/component/ShowRequest.java | 59 ------ .../client/component/SuggestionsRequest.java | 95 --------- .../ws/client/component/TreeRequest.java | 163 --------------- .../ws/client/component/package-info.java | 24 --- .../ws/client/issues/IssuesService.java | 78 +++---- sonar-ws/src/main/protobuf/ws-issues.proto | 57 +++++- .../component/ComponentsServiceTest.java | 190 ------------------ .../component/SearchProjectsRequestTest.java | 91 --------- .../analysis/AnalysisEsResilienceTest.java | 54 +++-- .../tests/analysis/FileExclusionsTest.java | 4 +- .../sonarqube/tests/analysis/ScannerTest.java | 4 +- .../authorization/PermissionTemplateTest.java | 8 +- .../tests/component/ComponentsWsTest.java | 15 +- .../org/sonarqube/tests/lite/LiteTest.java | 6 +- .../tests/organization/OrganizationTest.java | 23 +-- .../project/ProjectBulkDeletionPageTest.java | 4 +- .../tests/project/ProjectDeletionTest.java | 6 +- .../tests/project/ProjectFilterTest.java | 28 +-- .../tests/project/ProjectKeyUpdateTest.java | 16 +- .../project/ProjectProvisioningTest.java | 6 +- .../project/ProjectVisibilityPageTest.java | 7 +- tests/src/test/java/util/ItUtils.java | 4 +- 27 files changed, 176 insertions(+), 1147 deletions(-) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchProjectsRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/TreeRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/component/package-info.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/component/SearchProjectsRequestTest.java 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 81b23171f15..272371378cc 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 @@ -56,7 +56,6 @@ class DefaultWsClient implements WsClient { private final OrganizationsService organizations; private final org.sonarqube.ws.client.permission.PermissionsService permissionsOld; private final PermissionsService permissions; - private final org.sonarqube.ws.client.component.ComponentsService componentsOld; private final ComponentsService components; private final FavoritesService favoritesService; private final QualityProfilesService qualityProfilesOld; @@ -87,7 +86,6 @@ class DefaultWsClient implements WsClient { this.organizations = new OrganizationsService(wsConnector); this.permissionsOld = new org.sonarqube.ws.client.permission.PermissionsService(wsConnector); this.permissions = new PermissionsService(wsConnector); - this.componentsOld = new org.sonarqube.ws.client.component.ComponentsService(wsConnector); this.components = new ComponentsService(wsConnector); this.favoritesService = new FavoritesService(wsConnector); this.qualityProfilesOld = new QualityProfilesService(wsConnector); @@ -134,11 +132,6 @@ class DefaultWsClient implements WsClient { return permissions; } - @Override - public org.sonarqube.ws.client.component.ComponentsService componentsOld() { - return componentsOld; - } - @Override public ComponentsService components() { return components; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 33eb13f191c..ad4ad79e3a1 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -66,12 +66,6 @@ public interface WsClient { OrganizationsService organizations(); - /** - * @deprecated since 7.0 use {@link #components()} instead - */ - @Deprecated - org.sonarqube.ws.client.component.ComponentsService componentsOld(); - ComponentsService components(); FavoritesService favorites(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java deleted file mode 100644 index acb55db838b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java +++ /dev/null @@ -1,114 +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.component; - -import com.google.common.base.Joiner; -import java.util.List; -import java.util.stream.Collectors; -import org.sonarqube.ws.Components.SearchProjectsWsResponse; -import org.sonarqube.ws.Components.SearchWsResponse; -import org.sonarqube.ws.Components.ShowWsResponse; -import org.sonarqube.ws.Components.TreeWsResponse; -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.WsConnector; -import org.sonarqube.ws.client.WsResponse; - -import static org.sonar.api.server.ws.WebService.Param; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH_PROJECTS; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SHOW; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SUGGESTIONS; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.CONTROLLER_COMPONENTS; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT_ID; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_FILTER; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_STRATEGY; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.components.ComponentsService} instead - */ -@Deprecated -public class ComponentsService extends BaseService { - - public ComponentsService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER_COMPONENTS); - } - - 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.PAGE, request.getPage()) - .setParam(Param.PAGE_SIZE, request.getPageSize()) - .setParam(Param.TEXT_QUERY, request.getQuery()); - return call(get, SearchWsResponse.parser()); - } - - public TreeWsResponse tree(TreeRequest request) { - GetRequest get = new GetRequest(path(ACTION_TREE)) - .setParam(PARAM_COMPONENT_ID, request.getBaseComponentId()) - .setParam("baseComponentKey", request.getBaseComponentKey()) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers())) - .setParam(PARAM_STRATEGY, request.getStrategy()) - .setParam(Param.PAGE, request.getPage()) - .setParam(Param.PAGE_SIZE, request.getPageSize()) - .setParam(Param.TEXT_QUERY, request.getQuery()) - .setParam(Param.SORT, inlineMultipleParamValue(request.getSort())); - return call(get, TreeWsResponse.parser()); - } - - public ShowWsResponse show(ShowRequest request) { - GetRequest get = new GetRequest(path(ACTION_SHOW)) - .setParam(PARAM_COMPONENT_ID, request.getId()) - .setParam(PARAM_COMPONENT, request.getKey()) - .setParam(PARAM_BRANCH, request.getBranch()); - return call(get, ShowWsResponse.parser()); - } - - public SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) { - List additionalFields = request.getAdditionalFields(); - List facets = request.getFacets(); - GetRequest get = new GetRequest(path(ACTION_SEARCH_PROJECTS)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_FILTER, request.getFilter()) - .setParam(Param.FACETS, !facets.isEmpty() ? inlineMultipleParamValue(facets) : null) - .setParam(Param.SORT, request.getSort()) - .setParam(Param.ASCENDING, request.getAsc()) - .setParam(Param.PAGE, request.getPage()) - .setParam(Param.PAGE_SIZE, request.getPageSize()) - .setParam(Param.FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null); - return call(get, SearchProjectsWsResponse.parser()); - } - - public WsResponse suggestions(SuggestionsRequest request) { - GetRequest get = new GetRequest(path(ACTION_SUGGESTIONS)) - .setParam("more", request.getMore() == null ? null : request.getMore().toString()) - .setParam("recentlyBrowsed", request.getRecentlyBrowsed().stream().collect(Collectors.joining(","))) - .setParam("s", request.getS()); - return call(get); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchProjectsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchProjectsRequest.java deleted file mode 100644 index a2e249a866b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchProjectsRequest.java +++ /dev/null @@ -1,160 +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.component; - -import java.util.ArrayList; -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -public class SearchProjectsRequest { - - public static final int MAX_PAGE_SIZE = 500; - public static final int DEFAULT_PAGE_SIZE = 100; - - private final int page; - private final int pageSize; - private final String organization; - private final String filter; - private final List facets; - private final String sort; - private final Boolean asc; - private final List additionalFields; - - private SearchProjectsRequest(Builder builder) { - this.page = builder.page; - this.pageSize = builder.pageSize; - this.organization = builder.organization; - this.filter = builder.filter; - this.facets = builder.facets; - this.sort = builder.sort; - this.asc = builder.asc; - this.additionalFields = builder.additionalFields; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - @CheckForNull - public String getFilter() { - return filter; - } - - public List getFacets() { - return facets; - } - - @CheckForNull - public String getSort() { - return sort; - } - - public int getPageSize() { - return pageSize; - } - - public int getPage() { - return page; - } - - @CheckForNull - public Boolean getAsc() { - return asc; - } - - public List getAdditionalFields() { - return additionalFields; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private Integer page; - private Integer pageSize; - private String filter; - private List facets = new ArrayList<>(); - private String sort; - private Boolean asc; - private List additionalFields = new ArrayList<>(); - - private Builder() { - // enforce static factory method - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setFilter(@Nullable String filter) { - this.filter = filter; - return this; - } - - public Builder setFacets(List facets) { - this.facets = requireNonNull(facets); - return this; - } - - public Builder setPage(int page) { - this.page = page; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public Builder setSort(@Nullable String sort) { - this.sort = sort; - return this; - } - - public Builder setAsc(boolean asc) { - this.asc = asc; - return this; - } - - public Builder setAdditionalFields(List additionalFields) { - this.additionalFields = requireNonNull(additionalFields, "additional fields cannot be null"); - return this; - } - - public SearchProjectsRequest build() { - if (page == null) { - page = 1; - } - if (pageSize == null) { - pageSize = DEFAULT_PAGE_SIZE; - } - checkArgument(pageSize <= MAX_PAGE_SIZE, "Page size must not be greater than %s", MAX_PAGE_SIZE); - return new SearchProjectsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchRequest.java deleted file mode 100644 index efe91f239d8..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SearchRequest.java +++ /dev/null @@ -1,94 +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.component; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static java.util.Objects.requireNonNull; - -public class SearchRequest { - private String organization; - private List qualifiers; - private Integer page; - private Integer pageSize; - private String query; - private String language; - - @CheckForNull - public String getOrganization() { - return organization; - } - - public SearchRequest setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public List getQualifiers() { - return qualifiers; - } - - public SearchRequest setQualifiers(List qualifiers) { - this.qualifiers = requireNonNull(qualifiers); - return this; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - public SearchRequest setPage(int page) { - this.page = page; - return this; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public SearchRequest setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public SearchRequest setQuery(@Nullable String query) { - this.query = query; - return this; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - public SearchRequest setLanguage(@Nullable String language) { - this.language = language; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowRequest.java deleted file mode 100644 index 2377e7dfea3..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowRequest.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.component; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ShowRequest { - private String id; - private String key; - private String branch; - - @CheckForNull - public String getId() { - return id; - } - - public ShowRequest setId(@Nullable String id) { - this.id = id; - return this; - } - - @CheckForNull - public String getKey() { - return key; - } - - public ShowRequest setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ShowRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsRequest.java deleted file mode 100644 index 1f28b21db1b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsRequest.java +++ /dev/null @@ -1,95 +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.component; - -import java.util.Collections; -import java.util.List; - -public class SuggestionsRequest { - - public static final int MAX_PAGE_SIZE = 500; - public static final int DEFAULT_PAGE_SIZE = 100; - - public enum More { - VW, - SVW, - APP, - TRK, - BRC, - FIL, - UTS - } - - private final More more; - private final List recentlyBrowsed; - private final String s; - - private SuggestionsRequest(Builder builder) { - this.more = builder.more; - this.recentlyBrowsed = builder.recentlyBrowsed; - this.s = builder.s; - } - - public More getMore() { - return more; - } - - public List getRecentlyBrowsed() { - return recentlyBrowsed; - } - - public String getS() { - return s; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private More more; - private List recentlyBrowsed = Collections.emptyList(); - private String s; - - private Builder() { - // enforce static factory method - } - - public Builder setMore(More more) { - this.more = more; - return this; - } - - public Builder setRecentlyBrowsed(List recentlyBrowsed) { - this.recentlyBrowsed = recentlyBrowsed; - return this; - } - - public Builder setS(String s) { - this.s = s; - return this; - } - - public SuggestionsRequest build() { - return new SuggestionsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/TreeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/TreeRequest.java deleted file mode 100644 index 569e44ad686..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/TreeRequest.java +++ /dev/null @@ -1,163 +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.component; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class TreeRequest { - private String baseComponentId; - private String baseComponentKey; - private String component; - private String branch; - private String strategy; - private List qualifiers; - private String query; - private List sort; - private Boolean asc; - private Integer page; - private Integer pageSize; - - /** - * @deprecated since 6.4, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getBaseComponentId() { - return baseComponentId; - } - - /** - * @deprecated since 6.4, please use {@link #setComponent(String)} instead - */ - @Deprecated - public TreeRequest setBaseComponentId(@Nullable String baseComponentId) { - this.baseComponentId = baseComponentId; - return this; - } - - /** - * @deprecated since 6.4, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getBaseComponentKey() { - return baseComponentKey; - } - - /** - * @deprecated since 6.4, please use {@link #setComponent(String)} instead - */ - @Deprecated - public TreeRequest setBaseComponentKey(@Nullable String baseComponentKey) { - this.baseComponentKey = baseComponentKey; - return this; - } - - public TreeRequest setComponent(@Nullable String component) { - this.component = component; - return this; - } - - @CheckForNull - public String getComponent() { - return component; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public TreeRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - @CheckForNull - public String getStrategy() { - return strategy; - } - - public TreeRequest setStrategy(@Nullable String strategy) { - this.strategy = strategy; - return this; - } - - @CheckForNull - public List getQualifiers() { - return qualifiers; - } - - public TreeRequest setQualifiers(@Nullable List qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public TreeRequest setQuery(@Nullable String query) { - this.query = query; - return this; - } - - @CheckForNull - public List getSort() { - return sort; - } - - public TreeRequest setSort(@Nullable List sort) { - this.sort = sort; - return this; - } - - public Boolean getAsc() { - return asc; - } - - public TreeRequest setAsc(@Nullable Boolean asc) { - this.asc = asc; - return this; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - public TreeRequest setPage(@Nullable Integer page) { - this.page = page; - return this; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public TreeRequest setPageSize(@Nullable Integer pageSize) { - this.pageSize = pageSize; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/package-info.java deleted file mode 100644 index 913f8c738d8..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/package-info.java +++ /dev/null @@ -1,24 +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.component; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java index 2ca4e8be540..6ead62cc9cc 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java @@ -21,14 +21,23 @@ package org.sonarqube.ws.client.issues; import java.util.stream.Collectors; import javax.annotation.Generated; +import org.sonarqube.ws.Issues.AddCommentResponse; +import org.sonarqube.ws.Issues.AssignResponse; +import org.sonarqube.ws.Issues.AuthorsResponse; +import org.sonarqube.ws.Issues.BulkChangeWsResponse; +import org.sonarqube.ws.Issues.ChangelogWsResponse; +import org.sonarqube.ws.Issues.DeleteCommentResponse; +import org.sonarqube.ws.Issues.DoTransitionResponse; +import org.sonarqube.ws.Issues.SearchWsResponse; +import org.sonarqube.ws.Issues.SetSeverityResponse; +import org.sonarqube.ws.Issues.SetTagsResponse; +import org.sonarqube.ws.Issues.SetTypeResponse; +import org.sonarqube.ws.Issues.TagsResponse; import org.sonarqube.ws.MediaTypes; import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsConnector; -import org.sonarqube.ws.Issues.BulkChangeWsResponse; -import org.sonarqube.ws.Issues.ChangelogWsResponse; -import org.sonarqube.ws.Issues.SearchWsResponse; /** * @see Further information about this web service online @@ -47,13 +56,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 3.6 */ - public String addComment(AddCommentRequest request) { + public AddCommentResponse addComment(AddCommentRequest request) { return call( new PostRequest(path("add_comment")) .setParam("issue", request.getIssue()) - .setParam("text", request.getText()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("text", request.getText()), + AddCommentResponse.parser()); } /** @@ -63,14 +71,13 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 3.6 */ - public String assign(AssignRequest request) { + public AssignResponse assign(AssignRequest request) { return call( new PostRequest(path("assign")) .setParam("assignee", request.getAssignee()) .setParam("issue", request.getIssue()) - .setParam("me", request.getMe()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("me", request.getMe()), + AssignResponse.parser()); } /** @@ -80,13 +87,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 5.1 */ - public String authors(AuthorsRequest request) { + public AuthorsResponse authors(AuthorsRequest request) { return call( new GetRequest(path("authors")) .setParam("ps", request.getPs()) - .setParam("q", request.getQ()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("q", request.getQ()), + AuthorsResponse.parser()); } /** @@ -150,12 +156,11 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 3.6 */ - public String deleteComment(DeleteCommentRequest request) { + public DeleteCommentResponse deleteComment(DeleteCommentRequest request) { return call( new PostRequest(path("delete_comment")) - .setParam("comment", request.getComment()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("comment", request.getComment()), + DeleteCommentResponse.parser()); } /** @@ -165,13 +170,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 3.6 */ - public String doTransition(DoTransitionRequest request) { + public DoTransitionResponse doTransition(DoTransitionRequest request) { return call( new PostRequest(path("do_transition")) .setParam("issue", request.getIssue()) - .setParam("transition", request.getTransition()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("transition", request.getTransition()), + DoTransitionResponse.parser()); } /** @@ -247,13 +251,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 3.6 */ - public String setSeverity(SetSeverityRequest request) { + public SetSeverityResponse setSeverity(SetSeverityRequest request) { return call( new PostRequest(path("set_severity")) .setParam("issue", request.getIssue()) - .setParam("severity", request.getSeverity()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("severity", request.getSeverity()), + SetSeverityResponse.parser()); } /** @@ -263,13 +266,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 5.1 */ - public String setTags(SetTagsRequest request) { + public SetTagsResponse setTags(SetTagsRequest request) { return call( new PostRequest(path("set_tags")) .setParam("issue", request.getIssue()) - .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))), + SetTagsResponse.parser()); } /** @@ -279,13 +281,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 5.5 */ - public String setType(SetTypeRequest request) { + public SetTypeResponse setType(SetTypeRequest request) { return call( new PostRequest(path("set_type")) .setParam("issue", request.getIssue()) - .setParam("type", request.getType()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("type", request.getType()), + SetTypeResponse.parser()); } /** @@ -295,13 +296,12 @@ public class IssuesService extends BaseService { * @see Further information about this action online (including a response example) * @since 5.1 */ - public String tags(TagsRequest request) { + public TagsResponse tags(TagsRequest request) { return call( new GetRequest(path("tags")) .setParam("organization", request.getOrganization()) .setParam("ps", request.getPs()) - .setParam("q", request.getQ()) - .setMediaType(MediaTypes.JSON) - ).content(); + .setParam("q", request.getQ()), + TagsResponse.parser()); } } diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index a1309679f58..8d58b8b935b 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -49,14 +49,65 @@ message SearchWsResponse { optional sonarqube.ws.commons.Facets facets = 12; } -// Response of most of POST/issues/{operation}, for instance assign, add_comment and set_severity message Operation { optional Issue issue = 1; repeated Component components = 2; repeated sonarqube.ws.commons.Rule rules = 3; repeated Users.User users = 4; - // Deprecated since 5.5, action plan has been removed - repeated ActionPlan unusedActionPlans = 5; +} +message AddCommentResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message AssignResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message AuthorsResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message DeleteCommentResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message DoTransitionResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message SetSeverityResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message SetTagsResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message SetTypeResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; +} +message TagsResponse { + optional Issue issue = 1; + repeated Component components = 2; + repeated sonarqube.ws.commons.Rule rules = 3; + repeated Users.User users = 4; } message Issue { diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java deleted file mode 100644 index 86f01cbc370..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/ComponentsServiceTest.java +++ /dev/null @@ -1,190 +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.component; - -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.Components; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.sonar.api.server.ws.WebService.Param.ASCENDING; -import static org.sonar.api.server.ws.WebService.Param.FACETS; -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.SORT; -import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_FILTER; - -public class ComponentsServiceTest { - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new ComponentsService(mock(WsConnector.class))); - - private ComponentsService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void search_projects() { - underTest.searchProjects(SearchProjectsRequest.builder() - .setFilter("ncloc > 10") - .setFacets(asList("ncloc", "duplicated_lines_density")) - .setSort("coverage") - .setAsc(true) - .setPage(3) - .setPageSize(10) - .setAdditionalFields(singletonList("analysisDate")) - .build()); - - assertThat(serviceTester.getGetParser()).isSameAs(Components.SearchProjectsWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("search_projects") - .hasParam(PARAM_FILTER, "ncloc > 10") - .hasParam(FACETS, "ncloc,duplicated_lines_density") - .hasParam(SORT, "coverage") - .hasParam(ASCENDING, true) - .hasParam(PAGE, 3) - .hasParam(PAGE_SIZE, 10) - .hasParam(FIELDS, "analysisDate") - .andNoOtherParam(); - } - - @Test - public void search_projects_without_sort() { - underTest.searchProjects(SearchProjectsRequest.builder() - .setFilter("ncloc > 10") - .setFacets(singletonList("ncloc")) - .setPage(3) - .setPageSize(10) - .build()); - - assertThat(serviceTester.getGetParser()).isSameAs(Components.SearchProjectsWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("search_projects") - .hasParam(PARAM_FILTER, "ncloc > 10") - .hasParam(FACETS, singletonList("ncloc")) - .hasParam(PAGE, 3) - .hasParam(PAGE_SIZE, 10) - .andNoOtherParam(); - } - - @Test - public void show() { - String key = randomAlphanumeric(20); - String id = randomAlphanumeric(20); - underTest.show(new ShowRequest() - .setKey(key) - .setId(id) - .setBranch("my_branch")); - - assertThat(serviceTester.getGetParser()).isSameAs(Components.ShowWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("show") - .hasParam("component", key) - .hasParam("componentId", id) - .hasParam("branch", "my_branch") - .andNoOtherParam(); - } - - @Test - public void suggestions() { - SuggestionsRequest.More more = SuggestionsRequest.More.BRC; - String s = randomAlphanumeric(20); - underTest.suggestions(SuggestionsRequest.builder() - .setMore(more) - .setS(s) - .setRecentlyBrowsed(asList("key-1", "key-2")) - .build()); - - // in this case no protobuf parser is used - assertThat(serviceTester.getGetParser()).isNull(); - - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("suggestions") - .hasParam("more", more.toString()) - .hasParam("s", s) - .hasParam("recentlyBrowsed", "key-1,key-2") - .andNoOtherParam(); - } - - @Test - public void search() { - String organization = randomAlphanumeric(20); - int page = 17; - int pageSize = 39; - String textQuery = randomAlphanumeric(20); - underTest.search(new SearchRequest() - .setOrganization(organization) - .setQualifiers(asList("q1", "q2")) - .setPage(page) - .setPageSize(pageSize) - .setQuery(textQuery)); - - assertThat(serviceTester.getGetParser()).isSameAs(Components.SearchWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("search") - .hasParam("organization", organization) - .hasParam("qualifiers", "q1,q2") - .hasParam("p", page) - .hasParam("ps", pageSize) - .hasParam("q", textQuery) - .andNoOtherParam(); - } - - @Test - public void tree() { - String componentId = randomAlphanumeric(20); - String componentKey = randomAlphanumeric(20); - String strategy = randomAlphanumeric(20); - int page = 17; - int pageSize = 39; - String query = randomAlphanumeric(20); - underTest.tree(new TreeRequest() - .setBaseComponentId(componentId) - .setBaseComponentKey(componentKey) - .setComponent(componentKey) - .setBranch("my_branch") - .setQualifiers(asList("q1", "q2")) - .setStrategy(strategy) - .setPage(page) - .setPageSize(pageSize) - .setQuery(query) - .setSort(asList("sort1", "sort2"))); - - assertThat(serviceTester.getGetParser()).isSameAs(Components.TreeWsResponse.parser()); - serviceTester.assertThat(serviceTester.getGetRequest()) - .hasPath("tree") - .hasParam("componentId", componentId) - .hasParam("baseComponentKey", componentKey) - .hasParam("component", componentKey) - .hasParam("branch", "my_branch") - .hasParam("qualifiers", "q1,q2") - .hasParam("strategy", strategy) - .hasParam("p", page) - .hasParam("ps", pageSize) - .hasParam("q", query) - .hasParam("s", "sort1,sort2") - .andNoOtherParam(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/SearchProjectsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/component/SearchProjectsRequestTest.java deleted file mode 100644 index 9b4fcad25cc..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/component/SearchProjectsRequestTest.java +++ /dev/null @@ -1,91 +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.component; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - -public class SearchProjectsRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - SearchProjectsRequest.Builder underTest = SearchProjectsRequest.builder(); - - @Test - public void filter_parameter() throws Exception { - SearchProjectsRequest result = underTest - .setFilter("ncloc > 10") - .build(); - - assertThat(result.getFilter()).isEqualTo("ncloc > 10"); - } - - @Test - public void set_facets() throws Exception { - SearchProjectsRequest result = underTest - .setFacets(singletonList("ncloc")) - .build(); - - assertThat(result.getFacets()).containsOnly("ncloc"); - } - - @Test - public void facets_are_empty_by_default() throws Exception { - SearchProjectsRequest result = underTest.build(); - - assertThat(result.getFacets()).isEmpty(); - } - - @Test - public void fail_if_facets_is_null() { - expectedException.expect(NullPointerException.class); - - underTest.setFacets(null); - } - - @Test - public void default_page_values() { - SearchProjectsRequest result = underTest.build(); - - assertThat(result.getPage()).isEqualTo(1); - assertThat(result.getPageSize()).isEqualTo(100); - } - - @Test - public void handle_paging_limit_values() { - SearchProjectsRequest result = underTest.setPageSize(500).build(); - - assertThat(result.getPage()).isEqualTo(1); - assertThat(result.getPageSize()).isEqualTo(500); - } - - @Test - public void fail_if_page_size_greater_than_500() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Page size must not be greater than 500"); - - underTest.setPageSize(501).build(); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java index 46b49e6eb67..e207bc33ba6 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java @@ -27,9 +27,7 @@ import java.net.InetAddress; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nullable; import org.junit.After; import org.junit.ClassRule; @@ -39,13 +37,15 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.tests.Byteman; import org.sonarqube.ws.Ce; import org.sonarqube.ws.Common; +import org.sonarqube.ws.Components; +import org.sonarqube.ws.Components.SuggestionsWsResponse.Suggestion; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Projects; +import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.ce.TaskRequest; -import org.sonarqube.ws.client.component.SuggestionsRequest; +import org.sonarqube.ws.client.components.SuggestionsRequest; import org.sonarqube.ws.client.issue.SearchRequest; import util.ItUtils; @@ -98,9 +98,9 @@ public class AnalysisEsResilienceTest { .assignQProfileToProject(profile, project); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v1", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty(); - assertThat(searchFile(file3Key, organization)).isEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty(); + assertThat(searchFile(file3Key)).isEmpty(); Issues.SearchWsResponse issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -108,9 +108,9 @@ public class AnalysisEsResilienceTest { byteman.activateScript("resilience/making_ce_indexation_failing.btm"); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v2", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty();// inconsistency: in DB there is also file2Key - assertThat(searchFile(file3Key, organization)).isEmpty();// inconsistency: in DB there is also file3Key + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty();// inconsistency: in DB there is also file2Key + assertThat(searchFile(file3Key)).isEmpty();// inconsistency: in DB there is also file3Key issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -118,9 +118,9 @@ public class AnalysisEsResilienceTest { byteman.deactivateAllRules(); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v3", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty(); - assertThat(searchFile(file3Key, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty(); + assertThat(searchFile(file3Key)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent, Issues.Issue::getStatus) @@ -144,7 +144,7 @@ public class AnalysisEsResilienceTest { .assignQProfileToProject(profile, project); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-purge", "2000-01-01"); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); Issues.SearchWsResponse issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -166,7 +166,7 @@ public class AnalysisEsResilienceTest { .contains("Caused by: java.lang.IllegalStateException: Unrecoverable indexation failures"); // The issue must be present with status CLOSED in database - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent, Issues.Issue::getStatus) @@ -189,7 +189,7 @@ public class AnalysisEsResilienceTest { // Second analysis must fix the issue, // The purge will delete the "old" issue executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-purge", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .isEmpty(); @@ -232,18 +232,16 @@ public class AnalysisEsResilienceTest { return tester.wsClient().issuesOld().search(request); } - private List searchFile(String key, Organization organization) { - SuggestionsRequest query = SuggestionsRequest.builder() - .setS(key) - .build(); - Map response = ItUtils.jsonToMap( - tester.wsClient().componentsOld().suggestions(query).content() - ); - List results = (List) response.get("results"); - Map trkResult = (Map) results.stream().filter(result -> "FIL".equals(((Map) result).get("q"))).findAny().get(); - List items = (List) trkResult.get("items"); - Stream x = items.stream().map(item -> (String) ((Map) item).get("key")); - return x.collect(Collectors.toList()); + private List searchFile(String key) { + SuggestionsRequest query = new SuggestionsRequest().setS(key); + + Components.SuggestionsWsResponse response = tester.wsClient().components().suggestions(query); + + return response + .getResultsList().stream().filter(result -> "FIL".equals(result.getQ())).findAny().get() + .getItemsList().stream() + .map(Suggestion::getKey) + .collect(Collectors.toList()); } private String executeAnalysis(String projectKey, Organization organization, User orgAdministrator, String projectPath, @Nullable String date) { diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java index 75cffdb3e11..a1716492c52 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.Components.Component; -import org.sonarqube.ws.client.component.TreeRequest; +import org.sonarqube.ws.client.components.TreeRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -134,6 +134,6 @@ public class FileExclusionsTest { } public static List getComponents(String qualifier) { - return newWsClient(orchestrator).componentsOld().tree(new TreeRequest().setBaseComponentKey(PROJECT).setQualifiers(singletonList(qualifier))).getComponentsList(); + return newWsClient(orchestrator).components().tree(new TreeRequest().setComponent(PROJECT).setQualifiers(singletonList(qualifier))).getComponentsList(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java index fa7261ced8b..15b20555741 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonarqube.qa.util.Tester; import org.sonarqube.tests.Category3Suite; -import org.sonarqube.ws.client.component.SearchRequest; +import org.sonarqube.ws.client.components.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -68,7 +68,7 @@ public class ScannerTest { scan("shared/xoo-multi-modules-sample"); scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x"); - assertThat(tester.wsClient().componentsOld().search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList()).hasSize(2); + assertThat(tester.wsClient().components().search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList()).hasSize(2); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample").getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample"); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample:branch/0.x").getName()) .isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x"); diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java index ad7898a3ab7..6379e36a30a 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java @@ -29,15 +29,15 @@ import org.junit.Test; import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; -import org.sonarqube.tests.Category6Suite; import org.sonarqube.qa.util.Tester; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Permissions; import org.sonarqube.ws.Permissions.CreateTemplateWsResponse; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.Users.CreateWsResponse; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.permission.AddUserToTemplateRequest; import org.sonarqube.ws.client.permission.ApplyTemplateRequest; import org.sonarqube.ws.client.permission.BulkApplyTemplateRequest; @@ -191,9 +191,9 @@ public class PermissionTemplateTest { } private boolean userHasAccessToIndexedProject(CreateWsResponse.User user, Organization organization, Project project) { - SearchProjectsRequest request = SearchProjectsRequest.builder().setOrganization(organization.getKey()).build(); + SearchProjectsRequest request = new SearchProjectsRequest().setOrganization(organization.getKey()); WsClient userSession = tester.as(user.getLogin()).wsClient(); - return userSession.componentsOld().searchProjects(request) + return userSession.components().searchProjects(request) .getComponentsList().stream() .anyMatch(c -> c.getKey().equals(project.getKey())); } diff --git a/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java b/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java index dbd32671196..d978ad8c32f 100644 --- a/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java @@ -27,10 +27,8 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Components; -import org.sonarqube.ws.client.component.SearchRequest; -import org.sonarqube.ws.client.component.ShowRequest; +import org.sonarqube.ws.client.components.ShowRequest; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; @@ -53,19 +51,10 @@ public class ComponentsWsTest { @Test public void show() { - Components.ShowWsResponse response = tester.wsClient().componentsOld().show(new ShowRequest().setKey(FILE_KEY)); + Components.ShowWsResponse response = tester.wsClient().components().show(new ShowRequest().setComponent(FILE_KEY)); assertThat(response).isNotNull(); assertThat(response.getComponent().getKey()).isEqualTo(FILE_KEY); assertThat(response.getAncestorsList()).isNotEmpty(); } - - @Test - public void search() { - Components.SearchWsResponse response = tester.wsClient().componentsOld().search(new SearchRequest() - .setQualifiers(singletonList("FIL"))); - - assertThat(response).isNotNull(); - assertThat(response.getComponents(0).getKey()).isEqualTo(FILE_KEY); - } } diff --git a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java index 30ace8285e1..1404a396b78 100644 --- a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java +++ b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java @@ -28,7 +28,7 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Components; import org.sonarqube.ws.Measures; -import org.sonarqube.ws.client.component.TreeRequest; +import org.sonarqube.ws.client.components.TreeRequest; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.issue.SearchRequest; import org.sonarqube.ws.client.measure.ComponentTreeRequest; @@ -75,8 +75,8 @@ public class LiteTest { @Test public void call_components_ws() { // files in project - Components.TreeWsResponse tree = tester.wsClient().componentsOld().tree(new TreeRequest() - .setBaseComponentKey(PROJECT_KEY) + Components.TreeWsResponse tree = tester.wsClient().components().tree(new TreeRequest() + .setComponent(PROJECT_KEY) .setQualifiers(singletonList("FIL"))); assertThat(tree.getComponentsCount()).isEqualTo(4); tree.getComponentsList().forEach(c -> { diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java index 5b72379ff63..dd40c775f24 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java @@ -36,7 +36,6 @@ import org.sonarqube.ws.Rules; import org.sonarqube.ws.UserGroups.Group; import org.sonarqube.ws.Users; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.organizations.AddMemberRequest; import org.sonarqube.ws.client.organizations.CreateRequest; import org.sonarqube.ws.client.organizations.DeleteRequest; @@ -203,8 +202,7 @@ public class OrganizationTest { "sonar.organization", organization.getKey(), "sonar.login", user.getLogin(), "sonar.password", user.getLogin()); - ComponentsService componentsService = tester.as(user.getLogin()).wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); } @Test @@ -219,8 +217,7 @@ public class OrganizationTest { assertThat(e.getResult().getLogs()).contains("Insufficient privileges"); } - ComponentsService componentsService = tester.wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsCount()).isEqualTo(0); + assertThat(searchSampleProject(organization.getKey()).getComponentsCount()).isEqualTo(0); } @Test @@ -229,8 +226,7 @@ public class OrganizationTest { runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", organization.getKey(), "sonar.login", "admin", "sonar.password", "admin"); - ComponentsService componentsService = tester.asAnonymous().wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); } private void addPermissionsToUser(String orgKeyAndName, String login, String permission, String... otherPermissions) { @@ -249,12 +245,11 @@ public class OrganizationTest { "sonar.organization", organization.getKey(), "sonar.login", "admin", "sonar.password", "admin"); - ComponentsService componentsService = tester.wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); tester.organizations().service().delete(new DeleteRequest().setOrganization(organization.getKey())); - expectNotFoundError(() -> searchSampleProject(organization.getKey(), componentsService)); + expectNotFoundError(() -> searchSampleProject(organization.getKey())); assertThatOrganizationDoesNotExit(organization); } @@ -297,12 +292,12 @@ public class OrganizationTest { .hasSize(1); } - private Components.SearchWsResponse searchSampleProject(String organizationKey, ComponentsService componentsService) { - return componentsService - .search(new org.sonarqube.ws.client.component.SearchRequest() + private Components.SearchWsResponse searchSampleProject(String organizationKey) { + return tester.wsClient().components() + .search(new org.sonarqube.ws.client.components.SearchRequest() .setOrganization(organizationKey) .setQualifiers(singletonList("TRK")) - .setQuery("sample")); + .setQ("sample")); } private void assertThatOrganizationDoesNotExit(Organization org) { diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java index 6b5a48383a4..8fecbb8eb6f 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Condition.visible; @@ -68,7 +68,7 @@ public class ProjectBulkDeletionPageTest { $(".modal button").click(); $("#projects-management-page").shouldNotHave(text(project1.getName())).shouldNotHave(text(project3.getName())); - assertThat(tester.wsClient().componentsOld().searchProjects(SearchProjectsRequest.builder().build()) + assertThat(tester.wsClient().components().searchProjects(new SearchProjectsRequest()) .getComponentsCount()).isEqualTo(1); } } 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 8216d8897da..9f679c9b20a 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java @@ -40,7 +40,7 @@ import org.sonarqube.ws.Users; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +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; @@ -202,8 +202,8 @@ public class ProjectDeletionTest { * Projects page - api/components/search_projects - uses ES + DB */ private boolean isInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); return response.getComponentsCount() > 0; } 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 3972f771c78..02af1ddf6a0 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java @@ -34,7 +34,7 @@ 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.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.project.CreateRequest; import static java.util.Arrays.asList; @@ -90,7 +90,7 @@ public class ProjectFilterTest { String projectKey = newProjectKey(); tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).build()); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).build()); + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey())); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(projectKey); } @@ -110,7 +110,7 @@ public class ProjectFilterTest { tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey3).setName(projectKey3).setOrganization(organization.getKey()).build()); SearchProjectsWsResponse response = searchProjects( - SearchProjectsRequest.builder().setAdditionalFields(singletonList("leakPeriodDate")).setOrganization(organization.getKey()).build()); + new SearchProjectsRequest().setF(singletonList("leakPeriodDate")).setOrganization(organization.getKey())); assertThat(response.getComponentsList()).extracting(Component::getKey, Component::hasLeakPeriodDate) .containsOnly( @@ -137,18 +137,18 @@ public class ProjectFilterTest { assertThat(searchProjects("query = \"unknown\"").getComponentsList()).isEmpty(); // Search by metric criteria and text query - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"pAch\" AND ncloc > 50").build()).getComponentsList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"pAch\" AND ncloc > 50")).getComponentsList()) .extracting(Component::getKey).containsExactly("project3"); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"nd\" AND ncloc > 50").build()).getComponentsList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"nd\" AND ncloc > 50")).getComponentsList()) .extracting(Component::getKey).containsExactly("project3", "project4"); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"unknown\" AND ncloc > 50").build()).getComponentsList()).isEmpty(); + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"unknown\" AND ncloc > 50")).getComponentsList()).isEmpty(); ; // Check facets - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"apache\"").setFacets(singletonList("ncloc")).build()).getFacets().getFacets(0).getValuesList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"apache\"").setFacets(singletonList("ncloc"))).getFacets().getFacets(0).getValuesList()) .extracting(Common.FacetValue::getVal, Common.FacetValue::getCount) .containsOnly(tuple("*-1000.0", 3L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 0L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 0L)); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"unknown\"").setFacets(singletonList("ncloc")).build()).getFacets().getFacets(0) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"unknown\"").setFacets(singletonList("ncloc"))).getFacets().getFacets(0) .getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount) .containsOnly(tuple("*-1000.0", 0L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 0L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 0L)); } @@ -158,7 +158,7 @@ public class ProjectFilterTest { analyzeProject(newProjectKey(), "shared/xoo-sample"); analyzeProject(newProjectKey(), "shared/xoo-multi-modules-sample"); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFacets(asList( + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFacets(asList( "alert_status", "coverage", "duplicated_lines_density", @@ -167,7 +167,7 @@ public class ProjectFilterTest { "reliability_rating", "security_rating", "sqale_rating", - "tags")).build()); + "tags"))); checkFacet(response, "alert_status", tuple("OK", 2L), @@ -228,8 +228,8 @@ public class ProjectFilterTest { analyzeProject(projectKey2, "projectSearch/xoo-history-v1", "sonar.projectDate", "2016-12-31"); analyzeProject(projectKey2, "projectSearch/xoo-history-v2"); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFacets(asList( - "new_reliability_rating", "new_security_rating", "new_maintainability_rating", "new_coverage", "new_duplicated_lines_density", "new_lines")).build()); + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFacets(asList( + "new_reliability_rating", "new_security_rating", "new_maintainability_rating", "new_coverage", "new_duplicated_lines_density", "new_lines"))); checkFacet(response, "new_reliability_rating", tuple("1", 2L), @@ -287,11 +287,11 @@ public class ProjectFilterTest { } private SearchProjectsWsResponse searchProjects(String filter) throws IOException { - return searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFilter(filter).build()); + return searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFilter(filter)); } private SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) throws IOException { - return tester.wsClient().componentsOld().searchProjects(request); + return tester.wsClient().components().searchProjects(request); } private void verifyFilterMatches(String projectKey, String filter) throws IOException { 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 2ab5e74158d..d42e850af28 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java @@ -39,8 +39,8 @@ import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; -import org.sonarqube.ws.client.component.ShowRequest; +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; @@ -71,7 +71,7 @@ public class ProjectKeyUpdateTest { public void update_key() { analyzeXooSample(); String newProjectKey = "another_project_key"; - Components.Component project = tester.wsClient().componentsOld().show(new ShowRequest().setKey(PROJECT_KEY)).getComponent(); + 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() @@ -79,14 +79,14 @@ public class ProjectKeyUpdateTest { .setNewKey(newProjectKey) .build()); - assertThat(tester.wsClient().componentsOld().show(new ShowRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); + 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().componentsOld().show(new ShowRequest().setKey(PROJECT_KEY)).getComponent(); + 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() @@ -95,7 +95,7 @@ public class ProjectKeyUpdateTest { .setTo(newProjectKey) .build()); - assertThat(tester.wsClient().componentsOld().show(new ShowRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(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) @@ -254,8 +254,8 @@ public class ProjectKeyUpdateTest { */ @CheckForNull private String keyInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); if (response.getComponentsCount() > 0) { return response.getComponents(0).getKey(); } 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 1faa8d031e3..ddb5803da22 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java @@ -35,7 +35,7 @@ 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.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.project.SearchRequest; import util.ItUtils; @@ -109,8 +109,8 @@ public class ProjectProvisioningTest { * Projects page - api/components/search_projects - uses ES + DB */ private boolean isInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); return response.getComponentsCount() > 0; } 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 0f9c90fb04e..926212d90fc 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java @@ -28,12 +28,11 @@ import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage; import org.sonarqube.ws.Components; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.permission.RemoveGroupRequest; import org.sonarqube.ws.client.project.UpdateVisibilityRequest; import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; public class ProjectVisibilityPageTest { @@ -84,8 +83,8 @@ public class ProjectVisibilityPageTest { .createProject("foo", "foo", visibility) .shouldHaveProjectsCount(1); - Components.SearchProjectsWsResponse response = newAdminWsClient(orchestrator).componentsOld().searchProjects( - SearchProjectsRequest.builder().build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest()); assertThat(response.getComponentsCount()).isEqualTo(1); assertThat(response.getComponents(0).getKey()).isEqualTo("foo"); assertThat(response.getComponents(0).getName()).isEqualTo("foo"); diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java index 6ac8775f635..c1dfd54f86e 100644 --- a/tests/src/test/java/util/ItUtils.java +++ b/tests/src/test/java/util/ItUtils.java @@ -70,7 +70,7 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; -import org.sonarqube.ws.client.component.ShowRequest; +import org.sonarqube.ws.client.components.ShowRequest; import org.sonarqube.ws.client.measure.ComponentRequest; import org.sonarqube.ws.client.qualityprofile.RestoreRequest; import org.sonarqube.ws.client.settings.ResetRequest; @@ -373,7 +373,7 @@ public class ItUtils { @CheckForNull public static Component getComponent(Orchestrator orchestrator, String componentKey) { try { - return newWsClient(orchestrator).componentsOld().show(new ShowRequest().setKey((componentKey))).getComponent(); + return newWsClient(orchestrator).components().show(new ShowRequest().setComponent((componentKey))).getComponent(); } catch (org.sonarqube.ws.client.HttpException e) { if (e.code() == 404) { return null; -- 2.39.5