From 460bb1a793ad325312c5d0644dbd3753d4835207 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Sat, 2 Dec 2017 16:17:48 +0100 Subject: [PATCH] Remove legacy sonar-ws code for qualityprofiles --- .../org/sonarqube/qa/util/QProfileTester.java | 37 +- .../sonarqube/ws/client/DefaultWsClient.java | 8 - .../org/sonarqube/ws/client/WsClient.java | 7 - .../qualityprofile/ActivateRuleRequest.java | 118 ------ .../qualityprofile/AddGroupRequest.java | 93 ----- .../qualityprofile/AddProjectRequest.java | 127 ------- .../client/qualityprofile/AddUserRequest.java | 93 ----- .../qualityprofile/ChangeParentRequest.java | 116 ------ .../qualityprofile/ChangelogRequest.java | 126 ------- .../ws/client/qualityprofile/CopyRequest.java | 41 --- .../client/qualityprofile/CreateRequest.java | 87 ----- .../QualityProfilesService.java | 269 -------------- .../qualityprofile/RemoveGroupRequest.java | 93 ----- .../qualityprofile/RemoveProjectRequest.java | 112 ------ .../qualityprofile/RemoveUserRequest.java | 93 ----- .../client/qualityprofile/RestoreRequest.java | 68 ---- .../qualityprofile/SearchGroupsRequest.java | 127 ------- .../client/qualityprofile/SearchRequest.java | 79 ----- .../qualityprofile/SearchUsersRequest.java | 127 ------- .../qualityprofile/SetDefaultRequest.java | 33 -- .../ws/client/qualityprofile/ShowRequest.java | 49 --- .../QualityprofilesService.java | 4 +- .../qualityprofile/AddProjectRequestTest.java | 68 ---- .../qualityprofile/CreateRequestTest.java | 58 --- .../QualityProfilesServiceTest.java | 335 ------------------ .../RemoveProjectRequestTest.java | 68 ---- .../tests/analysis/IssueExclusionsTest.java | 6 +- .../QualityProfileAdminPermissionTest.java | 7 +- .../issue/OrganizationIssueAssignTest.java | 11 +- .../tests/organization/OrganizationTest.java | 10 +- ...uiltInQualityProfilesNotificationTest.java | 8 +- .../BuiltInQualityProfilesTest.java | 41 ++- .../CustomQualityProfilesTest.java | 68 ++-- .../OrganizationQualityProfilesUiTest.java | 20 +- .../QualityProfilesEditTest.java | 82 ++--- .../qualityProfile/QualityProfilesUiTest.java | 23 +- .../qualityProfile/QualityProfilesWsTest.java | 29 +- .../org/sonarqube/tests/rule/RulesWsTest.java | 4 +- tests/src/test/java/util/ItUtils.java | 20 +- 39 files changed, 175 insertions(+), 2590 deletions(-) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddGroupRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddUserRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangelogRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CopyRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RestoreRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchUsersRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java index c28530f86de..312db3c9ed7 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java @@ -25,14 +25,15 @@ import java.util.function.Consumer; import org.assertj.core.api.Assertions; import org.sonarqube.ws.Common; import org.sonarqube.ws.Organizations.Organization; +import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Rules; -import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.client.HttpException; -import org.sonarqube.ws.client.qualityprofile.ActivateRuleRequest; -import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.ws.client.qualityprofile.CreateRequest; -import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; +import org.sonarqube.ws.client.qualityprofiles.ActivateRuleRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.CreateRequest; +import org.sonarqube.ws.client.qualityprofiles.DeactivateRuleRequest; +import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; import org.sonarqube.ws.client.rules.SearchRequest; import static java.util.Arrays.asList; @@ -49,19 +50,19 @@ public class QProfileTester { this.session = session; } - public QualityProfilesService service() { - return session.wsClient().qualityProfilesOld(); + public QualityprofilesService service() { + return session.wsClient().qualityprofiles(); } @SafeVarargs - public final QualityProfile createXooProfile(Organization organization, Consumer... populators) { + public final QualityProfile createXooProfile(Organization organization, Consumer... populators) { int id = ID_GENERATOR.getAndIncrement(); - CreateRequest.Builder request = CreateRequest.builder() - .setOrganizationKey(organization.getKey()) + CreateRequest request = new CreateRequest() + .setOrganization(organization.getKey()) .setLanguage("xoo") .setName("Profile" + id); stream(populators).forEach(p -> p.accept(request)); - return service().create(request.build()).getProfile(); + return service().create(request).getProfile(); } public QProfileTester activateRule(QualityProfile profile, String ruleKey) { @@ -69,24 +70,22 @@ public class QProfileTester { } public QProfileTester activateRule(String profileKey, String ruleKey) { - ActivateRuleRequest request = ActivateRuleRequest.builder() + ActivateRuleRequest request = new ActivateRuleRequest() .setKey(profileKey) - .setRuleKey(ruleKey) - .build(); + .setRule(ruleKey); service().activateRule(request); return this; } public QProfileTester deactivateRule(QualityProfile profile, String ruleKey) { - service().deactivateRule(profile.getKey(), ruleKey); + service().deactivateRule(new DeactivateRuleRequest().setKey(profile.getKey()).setRule(ruleKey)); return this; } public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) { - service().addProject(AddProjectRequest.builder() - .setProjectKey(project.getKey()) - .setKey(profile.getKey()) - .build()); + service().addProject(new AddProjectRequest() + .setProject(project.getKey()) + .setKey(profile.getKey())); return this; } 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 71d261c2718..3712426dd3a 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 @@ -32,7 +32,6 @@ 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.qualitygates.QualitygatesService; -import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; import org.sonarqube.ws.client.roots.RootsService; import org.sonarqube.ws.client.rules.RulesService; @@ -56,7 +55,6 @@ class DefaultWsClient implements WsClient { private final PermissionsService permissions; private final ComponentsService components; private final FavoritesService favoritesService; - private final QualityProfilesService qualityProfilesOld; private final QualityprofilesService qualityprofiles; private final IssuesService issues; private final UsersService usersService; @@ -82,7 +80,6 @@ class DefaultWsClient implements WsClient { this.permissions = new PermissionsService(wsConnector); this.components = new ComponentsService(wsConnector); this.favoritesService = new FavoritesService(wsConnector); - this.qualityProfilesOld = new QualityProfilesService(wsConnector); this.qualityprofiles = new QualityprofilesService(wsConnector); this.issues = new IssuesService(wsConnector); this.usersService = new UsersService(wsConnector); @@ -128,11 +125,6 @@ class DefaultWsClient implements WsClient { return favoritesService; } - @Override - public QualityProfilesService qualityProfilesOld() { - return qualityProfilesOld; - } - @Override public QualityprofilesService qualityProfiles() { return qualityprofiles; 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 75ac3a18e1c..88948a30469 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 @@ -32,7 +32,6 @@ 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.qualitygates.QualitygatesService; -import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; import org.sonarqube.ws.client.roots.RootsService; import org.sonarqube.ws.client.rules.RulesService; @@ -75,12 +74,6 @@ public interface WsClient { PermissionsService permissions(); - /** - * @deprecated since 7.0 use {@link #qualityProfiles()} instead - */ - @Deprecated - QualityProfilesService qualityProfilesOld(); - QualityprofilesService qualityProfiles(); UsersService users(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleRequest.java deleted file mode 100644 index 70499d87f41..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ActivateRuleRequest.java +++ /dev/null @@ -1,118 +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.qualityprofile; - -import java.util.Optional; -import javax.annotation.Nullable; -import org.sonarqube.ws.Common.Severity; - -import static java.util.Objects.requireNonNull; - -public class ActivateRuleRequest { - private final Optional params; - private final String key; - private final Optional reset; - private final String ruleKey; - private final Optional severity; - private final Optional organization; - - private ActivateRuleRequest(Builder builder) { - organization = requireNonNull(builder.organization); - params = requireNonNull(builder.params); - key = requireNonNull(builder.key); - reset = requireNonNull(builder.reset); - ruleKey = requireNonNull(builder.ruleKey); - severity = requireNonNull(builder.severity); - } - - public static ActivateRuleRequest.Builder builder() { - return new Builder(); - } - - public Optional getParams() { - return params; - } - - public String getKey() { - return key; - } - - public Optional getReset() { - return reset; - } - - public String getRuleKey() { - return ruleKey; - } - - public Optional getSeverity() { - return severity; - } - - public Optional getOrganization() { - return organization; - } - - public static class Builder { - private Optional organization = Optional.empty(); - private Optional params = Optional.empty(); - private String key; - private Optional reset = Optional.empty(); - private String ruleKey; - private Optional severity = Optional.empty(); - - private Builder() { - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = Optional.ofNullable(organization); - return this; - } - - public Builder setParams(@Nullable String params) { - this.params = Optional.ofNullable(params); - return this; - } - - public Builder setKey(String key) { - this.key = key; - return this; - } - - public Builder setReset(@Nullable Boolean reset) { - this.reset = Optional.ofNullable(reset); - return this; - } - - public Builder setRuleKey(String ruleKey) { - this.ruleKey = ruleKey; - return this; - } - - public Builder setSeverity(@Nullable Severity severity) { - this.severity = Optional.ofNullable(severity); - return this; - } - - public ActivateRuleRequest build() { - return new ActivateRuleRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddGroupRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddGroupRequest.java deleted file mode 100644 index 8fe5c8ac94d..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddGroupRequest.java +++ /dev/null @@ -1,93 +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.qualityprofile; - -import javax.annotation.concurrent.Immutable; - -@Immutable -public class AddGroupRequest { - - private final String organization; - private final String language; - private final String qualityProfile; - private final String group; - - private AddGroupRequest(Builder builder) { - this.language = builder.language; - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.group = builder.group; - } - - public String getLanguage() { - return language; - } - - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getGroup() { - return group; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String group; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setGroup(String group) { - this.group = group; - return this; - } - - public AddGroupRequest build() { - return new AddGroupRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java deleted file mode 100644 index fc852433d5c..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequest.java +++ /dev/null @@ -1,127 +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.qualityprofile; - -import java.util.Optional; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import static java.util.Objects.requireNonNull; - -@Immutable -public class AddProjectRequest { - - private final String language; - private final Optional organization; - private final String qualityProfile; - private final String key; - private final String projectKey; - private final String projectUuid; - - private AddProjectRequest(Builder builder) { - this.language = builder.language; - this.organization = requireNonNull(builder.organization); - this.qualityProfile = builder.qualityProfile; - this.key = builder.key; - this.projectKey = builder.projectKey; - this.projectUuid = builder.projectUuid; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - public Optional getOrganization() { - return organization; - } - - @CheckForNull - public String getQualityProfile() { - return qualityProfile; - } - - @CheckForNull - public String getKey() { - return key; - } - - @CheckForNull - public String getProjectKey() { - return projectKey; - } - - @CheckForNull - public String getProjectUuid() { - return projectUuid; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String language; - private Optional organization = Optional.empty(); - private String qualityProfile; - private String key; - private String projectKey; - private String projectUuid; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = Optional.ofNullable(organization); - return this; - } - - public Builder setQualityProfile(@Nullable String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public Builder setProjectKey(@Nullable String projectKey) { - this.projectKey = projectKey; - return this; - } - - public Builder setProjectUuid(@Nullable String projectUuid) { - this.projectUuid = projectUuid; - return this; - } - - public AddProjectRequest build() { - return new AddProjectRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddUserRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddUserRequest.java deleted file mode 100644 index db89c3d7c40..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/AddUserRequest.java +++ /dev/null @@ -1,93 +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.qualityprofile; - -import javax.annotation.concurrent.Immutable; - -@Immutable -public class AddUserRequest { - - private final String organization; - private final String language; - private final String qualityProfile; - private final String userLogin; - - private AddUserRequest(Builder builder) { - this.language = builder.language; - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.userLogin = builder.userLogin; - } - - public String getLanguage() { - return language; - } - - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getUserLogin() { - return userLogin; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String userLogin; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setUserLogin(String userLogin) { - this.userLogin = userLogin; - return this; - } - - public AddUserRequest build() { - return new AddUserRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java deleted file mode 100644 index 9b1b6a3ddca..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangeParentRequest.java +++ /dev/null @@ -1,116 +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.qualityprofile; - -import javax.annotation.Nullable; - -public class ChangeParentRequest { - private final String language; - private final String parentKey; - private final String parentQualityProfile; - private final String key; - private final String qualityProfile; - private final String organization; - - public ChangeParentRequest(Builder builder) { - this.language = builder.language; - this.parentKey = builder.parentKey; - this.parentQualityProfile = builder.parentName; - this.key = builder.profileKey; - this.qualityProfile = builder.profileName; - this.organization = builder.organization; - } - - public String getLanguage() { - return language; - } - - public String getParentKey() { - return parentKey; - } - - public String getParentQualityProfile() { - return parentQualityProfile; - } - - public String getKey() { - return key; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String language; - private String parentKey; - private String parentName; - private String profileKey; - private String profileName; - private String organization; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - public Builder setProfileName(@Nullable String profileName) { - this.profileName = profileName; - return this; - } - - public Builder setProfileKey(@Nullable String profileKey) { - this.profileKey = profileKey; - return this; - } - - public Builder setParentKey(@Nullable String parentKey) { - this.parentKey = parentKey; - return this; - } - - public Builder setParentName(@Nullable String parentName) { - this.parentName = parentName; - return this; - } - - public Builder setOrganization(@Nullable String s) { - this.organization = s; - return this; - } - - public ChangeParentRequest build() { - return new ChangeParentRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangelogRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangelogRequest.java deleted file mode 100644 index 5c74416c9bc..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ChangelogRequest.java +++ /dev/null @@ -1,126 +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.qualityprofile; - -public class ChangelogRequest { - - private final String language; - private final String organization; - private final Integer p; - private final Integer ps; - private final String qualityProfile; - private final String since; - private final String to; - - private ChangelogRequest(Builder builder) { - this.language = builder.language; - this.organization = builder.organization; - this.p = builder.p; - this.ps = builder.ps; - this.qualityProfile = builder.qualityProfile; - this.since = builder.since; - this.to = builder.to; - } - - public String getLanguage() { - return language; - } - - public String getOrganization() { - return organization; - } - - public Integer getP() { - return p; - } - - public Integer getPs() { - return ps; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getSince() { - return since; - } - - public String getTo() { - return to; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String language; - private String organization; - private Integer p; - private Integer ps; - private String qualityProfile; - private String since; - private String to; - - private Builder() { - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setP(Integer p) { - this.p = p; - return this; - } - - public Builder setPs(Integer ps) { - this.ps = ps; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setSince(String since) { - this.since = since; - return this; - } - - public Builder setTo(String to) { - this.to = to; - return this; - } - - public ChangelogRequest build() { - return new ChangelogRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CopyRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CopyRequest.java deleted file mode 100644 index 39fdb48a3c9..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CopyRequest.java +++ /dev/null @@ -1,41 +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.qualityprofile; - -import static java.util.Objects.requireNonNull; - -public class CopyRequest { - private final String fromKey; - private final String toName; - - public CopyRequest(String fromKey, String toName) { - this.fromKey = requireNonNull(fromKey); - this.toName = requireNonNull(toName); - } - - public String getFromKey() { - return fromKey; - } - - public String getToName() { - return toName; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java deleted file mode 100644 index abf35e1c171..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/CreateRequest.java +++ /dev/null @@ -1,87 +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.qualityprofile; - -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import static com.google.common.base.Preconditions.checkArgument; - -@Immutable -public class CreateRequest { - - private final String name; - private final String language; - private final String organizationKey; - - private CreateRequest(Builder builder) { - this.name = builder.name; - this.language = builder.language; - this.organizationKey = builder.organizationKey; - } - - public String getLanguage() { - return language; - } - - public String getName() { - return name; - } - - public String getOrganizationKey() { - return organizationKey; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String language; - private String name; - private String organizationKey; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - public Builder setName(@Nullable String profileName) { - this.name = profileName; - return this; - } - - public Builder setOrganizationKey(@Nullable String organizationKey) { - this.organizationKey = organizationKey; - return this; - } - - public CreateRequest build() { - checkArgument(language != null && !language.isEmpty(), "Language is mandatory and must not be empty."); - checkArgument(name != null && !name.isEmpty(), "Profile name is mandatory and must not be empty."); - checkArgument(organizationKey == null || !organizationKey.isEmpty(), "Organization key may be either null or not empty. Empty organization key is invalid."); - return new CreateRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java deleted file mode 100644 index aa00e4e3b45..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java +++ /dev/null @@ -1,269 +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.qualityprofile; - -import org.sonarqube.ws.MediaTypes; -import org.sonarqube.ws.Qualityprofiles; -import org.sonarqube.ws.Qualityprofiles.CopyWsResponse; -import org.sonarqube.ws.Qualityprofiles.CreateWsResponse; -import org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse; -import org.sonarqube.ws.Qualityprofiles.SearchUsersResponse; -import org.sonarqube.ws.Qualityprofiles.SearchWsResponse; -import org.sonarqube.ws.Qualityprofiles.ShowResponse; -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.SELECTED; -import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ADD_GROUP; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ADD_PROJECT; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ADD_USER; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CHANGE_PARENT; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_COPY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CREATE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DELETE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_GROUP; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_PROJECT; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_USER; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_RESTORE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH_GROUPS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH_USERS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SET_DEFAULT; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SHOW; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.CONTROLLER_QUALITY_PROFILES; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_GROUP; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LOGIN; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TO_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.RestoreActionParameters.PARAM_BACKUP; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.qualityprofiles.QualityprofilesService} instead - */ -@Deprecated -public class QualityProfilesService extends BaseService { - - public QualityProfilesService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER_QUALITY_PROFILES); - } - - public void activateRule(ActivateRuleRequest request) { - PostRequest httpRequest = new PostRequest(path(ACTION_ACTIVATE_RULE)); - httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)); - httpRequest.setParam(PARAM_PARAMS, request.getParams().orElse(null)); - httpRequest.setParam(PARAM_KEY, request.getKey()); - httpRequest.setParam(PARAM_RESET, request.getReset().orElse(null)); - httpRequest.setParam(PARAM_RULE, request.getRuleKey()); - httpRequest.setParam(PARAM_SEVERITY, request.getSeverity().map(Enum::name).orElse(null)); - call(httpRequest); - } - - public void deactivateRule(String profileKey, String ruleKey) { - PostRequest httpRequest = new PostRequest(path(ACTION_DEACTIVATE_RULE)); - httpRequest.setParam(PARAM_KEY, profileKey); - httpRequest.setParam(PARAM_RULE, ruleKey); - call(httpRequest); - } - - public void restoreProfile(RestoreRequest request) { - PostRequest httpRequest = new PostRequest(path(ACTION_RESTORE)); - httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)); - httpRequest.setPart(PARAM_BACKUP, new PostRequest.Part(MediaTypes.XML, request.getBackup())); - call(httpRequest); - } - - public SearchWsResponse search(SearchRequest request) { - return call( - new GetRequest(path(ACTION_SEARCH)) - .setParam(PARAM_DEFAULTS, request.getDefaults()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) - .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()), - SearchWsResponse.parser()); - } - - public Qualityprofiles.ShowResponse show(ShowRequest request) { - return call( - new GetRequest(path(ACTION_SHOW)) - .setParam(PARAM_KEY, request.getKey()) - .setParam(PARAM_COMPARE_TO_SONAR_WAY, request.getCompareToSonarWay()), - ShowResponse.parser()); - } - - public void addProject(AddProjectRequest request) { - call(new PostRequest(path(ACTION_ADD_PROJECT)) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null)) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) - .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) - .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); - } - - public void removeProject(RemoveProjectRequest request) { - call(new PostRequest(path(ACTION_REMOVE_PROJECT)) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()) - .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) - .setParam(PARAM_PROJECT_UUID, request.getProjectUuid())); - } - - public CreateWsResponse create(CreateRequest request) { - PostRequest postRequest = new PostRequest(path(ACTION_CREATE)) - .setParam(PARAM_ORGANIZATION, request.getOrganizationKey()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_NAME, request.getName()); - return call(postRequest, CreateWsResponse.parser()); - } - - public CopyWsResponse copy(CopyRequest request) { - PostRequest postRequest = new PostRequest(path(ACTION_COPY)) - .setParam(PARAM_FROM_KEY, request.getFromKey()) - .setParam(PARAM_TO_NAME, request.getToName()); - - return call(postRequest, CopyWsResponse.parser()); - } - - public void changeParent(ChangeParentRequest request) { - call(new PostRequest(path(ACTION_CHANGE_PARENT)) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_PARENT_KEY, request.getParentKey()) - .setParam(PARAM_PARENT_QUALITY_PROFILE, request.getParentQualityProfile()) - .setParam(PARAM_KEY, request.getKey()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_ORGANIZATION, request.getOrganization())); - } - - public void setDefault(SetDefaultRequest request) { - PostRequest postRequest = new PostRequest(path(ACTION_SET_DEFAULT)) - .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey()); - - call(postRequest); - } - - public void delete(String profileKey) { - PostRequest postRequest = new PostRequest(path(ACTION_DELETE)) - .setParam(QualityProfileWsParameters.PARAM_KEY, profileKey); - - call(postRequest); - } - - public void addUser(AddUserRequest request) { - call(new PostRequest(path(ACTION_ADD_USER)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_LOGIN, request.getUserLogin())); - } - - public void removeUser(RemoveUserRequest request) { - call(new PostRequest(path(ACTION_REMOVE_USER)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_LOGIN, request.getUserLogin())); - } - - public SearchUsersResponse searchUsers(SearchUsersRequest request) { - return call( - new GetRequest(path(ACTION_SEARCH_USERS)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(TEXT_QUERY, request.getQuery()) - .setParam(SELECTED, request.getSelected()) - .setParam(PAGE, request.getPage()) - .setParam(PAGE_SIZE, request.getPageSize()), - SearchUsersResponse.parser()); - } - - public void addGroup(AddGroupRequest request) { - call(new PostRequest(path(ACTION_ADD_GROUP)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_GROUP, request.getGroup())); - } - - public void removeGroup(RemoveGroupRequest request) { - call(new PostRequest(path(ACTION_REMOVE_GROUP)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(PARAM_GROUP, request.getGroup())); - } - - public SearchGroupsResponse searchGroups(SearchGroupsRequest request) { - return call( - new GetRequest(path(ACTION_SEARCH_GROUPS)) - .setParam(PARAM_ORGANIZATION, request.getOrganization()) - .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile()) - .setParam(PARAM_LANGUAGE, request.getLanguage()) - .setParam(TEXT_QUERY, request.getQuery()) - .setParam(SELECTED, request.getSelected()) - .setParam(PAGE, request.getPage()) - .setParam(PAGE_SIZE, request.getPageSize()), - SearchGroupsResponse.parser()); - } - - public String changelog(ChangelogRequest request) { - PostRequest postRequest = new PostRequest(path("changelog")) - .setParam("language", request.getLanguage()) - .setParam("organization", request.getOrganization()) - .setParam("qualityProfile", request.getQualityProfile()); - if (request.getP() != null) { - postRequest.setParam("p", request.getP()); - } - if (request.getPs() != null) { - postRequest.setParam("ps", request.getPs()); - } - if (request.getSince() != null) { - postRequest.setParam("since", request.getSince()); - } - if (request.getTo() != null) { - postRequest.setParam("to", request.getTo()); - } - return call(postRequest).content(); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java deleted file mode 100644 index 6bd43b8257b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveGroupRequest.java +++ /dev/null @@ -1,93 +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.qualityprofile; - -import javax.annotation.concurrent.Immutable; - -@Immutable -public class RemoveGroupRequest { - - private final String organization; - private final String language; - private final String qualityProfile; - private final String group; - - private RemoveGroupRequest(Builder builder) { - this.language = builder.language; - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.group = builder.group; - } - - public String getLanguage() { - return language; - } - - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getGroup() { - return group; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String group; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setGroup(String group) { - this.group = group; - return this; - } - - public RemoveGroupRequest build() { - return new RemoveGroupRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java deleted file mode 100644 index ccc35577b4b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequest.java +++ /dev/null @@ -1,112 +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.qualityprofile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -@Immutable -public class RemoveProjectRequest { - - private final String language; - private final String qualityProfile; - private final String key; - private final String projectKey; - private final String projectUuid; - - private RemoveProjectRequest(Builder builder) { - this.language = builder.language; - this.qualityProfile = builder.qualityProfile; - this.key = builder.key; - this.projectKey = builder.projectKey; - this.projectUuid = builder.projectUuid; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - @CheckForNull - public String getQualityProfile() { - return qualityProfile; - } - - @CheckForNull - public String getKey() { - return key; - } - - @CheckForNull - public String getProjectKey() { - return projectKey; - } - - @CheckForNull - public String getProjectUuid() { - return projectUuid; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String language; - private String qualityProfile; - private String key; - private String projectKey; - private String projectUuid; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - public Builder setQualityProfile(@Nullable String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setKey(@Nullable String key) { - this.key = key; - return this; - } - - public Builder setProjectKey(@Nullable String projectKey) { - this.projectKey = projectKey; - return this; - } - - public Builder setProjectUuid(@Nullable String projectUuid) { - this.projectUuid = projectUuid; - return this; - } - - public RemoveProjectRequest build() { - return new RemoveProjectRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java deleted file mode 100644 index 609ac00d562..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RemoveUserRequest.java +++ /dev/null @@ -1,93 +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.qualityprofile; - -import javax.annotation.concurrent.Immutable; - -@Immutable -public class RemoveUserRequest { - - private final String organization; - private final String language; - private final String qualityProfile; - private final String userLogin; - - private RemoveUserRequest(Builder builder) { - this.language = builder.language; - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.userLogin = builder.userLogin; - } - - public String getLanguage() { - return language; - } - - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getUserLogin() { - return userLogin; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String userLogin; - - private Builder() { - // enforce factory method use - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setUserLogin(String userLogin) { - this.userLogin = userLogin; - return this; - } - - public RemoveUserRequest build() { - return new RemoveUserRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RestoreRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RestoreRequest.java deleted file mode 100644 index c4cbdaec421..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/RestoreRequest.java +++ /dev/null @@ -1,68 +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.qualityprofile; - -import java.io.File; -import java.util.Optional; -import javax.annotation.Nullable; - -import static java.util.Objects.requireNonNull; - -public class RestoreRequest { - - private final File backup; - private final Optional organization; - - private RestoreRequest(Builder builder) { - backup = requireNonNull(builder.backup); - organization = requireNonNull(builder.organization); - } - - public File getBackup() { - return backup; - } - - public Optional getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private File backup; - private Optional organization = Optional.empty(); - - public Builder setBackup(File backup) { - this.backup = backup; - return this; - } - - public Builder setOrganization(@Nullable String organization) { - this.organization = Optional.ofNullable(organization); - return this; - } - - public RestoreRequest build() { - return new RestoreRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java deleted file mode 100644 index bf515ef724b..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java +++ /dev/null @@ -1,127 +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.qualityprofile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SearchGroupsRequest { - - private String organization; - private String qualityProfile; - private String language; - private String selected; - private String query; - private Integer page; - private Integer pageSize; - - private SearchGroupsRequest(Builder builder) { - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.language = builder.language; - this.selected = builder.selected; - this.query = builder.query; - this.page = builder.page; - this.pageSize = builder.pageSize; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getLanguage() { - return language; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public String getSelected() { - return selected; - } - - public Integer getPage() { - return page; - } - - public Integer getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String selected; - private String query; - private Integer page; - private Integer pageSize; - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setSelected(String selected) { - this.selected = selected; - return this; - } - - public Builder setQuery(@Nullable String query) { - this.query = query; - return this; - } - - public Builder setPage(Integer page) { - this.page = page; - return this; - } - - public Builder setPageSize(Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - public SearchGroupsRequest build() { - return new SearchGroupsRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchRequest.java deleted file mode 100644 index 1df9c059e6a..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchRequest.java +++ /dev/null @@ -1,79 +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.qualityprofile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SearchRequest { - private String organizationKey; - private boolean defaults; - private String language; - private String qualityProfile; - private String projectKey; - - public String getOrganizationKey() { - return organizationKey; - } - - public SearchRequest setOrganizationKey(String organizationKey) { - this.organizationKey = organizationKey; - return this; - } - - public boolean getDefaults() { - return defaults; - } - - public SearchRequest setDefaults(boolean defaults) { - this.defaults = defaults; - return this; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - public SearchRequest setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - @CheckForNull - public String getQualityProfile() { - return qualityProfile; - } - - public SearchRequest setQualityProfile(@Nullable String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - @CheckForNull - public String getProjectKey() { - return projectKey; - } - - public SearchRequest setProjectKey(@Nullable String projectKey) { - this.projectKey = projectKey; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchUsersRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchUsersRequest.java deleted file mode 100644 index 247efbdb20c..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchUsersRequest.java +++ /dev/null @@ -1,127 +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.qualityprofile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SearchUsersRequest { - - private String organization; - private String qualityProfile; - private String language; - private String selected; - private String query; - private Integer page; - private Integer pageSize; - - private SearchUsersRequest(Builder builder) { - this.organization = builder.organization; - this.qualityProfile = builder.qualityProfile; - this.language = builder.language; - this.selected = builder.selected; - this.query = builder.query; - this.page = builder.page; - this.pageSize = builder.pageSize; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public String getQualityProfile() { - return qualityProfile; - } - - public String getLanguage() { - return language; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public String getSelected() { - return selected; - } - - public Integer getPage() { - return page; - } - - public Integer getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String organization; - private String qualityProfile; - private String language; - private String selected; - private String query; - private Integer page; - private Integer pageSize; - - public Builder setOrganization(@Nullable String organization) { - this.organization = organization; - return this; - } - - public Builder setQualityProfile(String qualityProfile) { - this.qualityProfile = qualityProfile; - return this; - } - - public Builder setLanguage(String language) { - this.language = language; - return this; - } - - public Builder setSelected(String selected) { - this.selected = selected; - return this; - } - - public Builder setQuery(@Nullable String query) { - this.query = query; - return this; - } - - public Builder setPage(Integer page) { - this.page = page; - return this; - } - - public Builder setPageSize(Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - public SearchUsersRequest build() { - return new SearchUsersRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java deleted file mode 100644 index 57a7bd419bb..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SetDefaultRequest.java +++ /dev/null @@ -1,33 +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.qualityprofile; - -public class SetDefaultRequest { - private final String key; - - public SetDefaultRequest(String key) { - this.key = key; - } - - public String getKey() { - return key; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.java deleted file mode 100644 index 0e267e65e16..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/ShowRequest.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.qualityprofile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ShowRequest { - private String key; - private Boolean compareToSonarWay; - - @CheckForNull - public String getKey() { - return key; - } - - public ShowRequest setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public Boolean getCompareToSonarWay() { - return compareToSonarWay; - } - - public ShowRequest setCompareToSonarWay(@Nullable Boolean compareToSonarWay) { - this.compareToSonarWay = compareToSonarWay; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofiles/QualityprofilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofiles/QualityprofilesService.java index 31694161a17..b91e6ce4b2a 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofiles/QualityprofilesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofiles/QualityprofilesService.java @@ -237,8 +237,8 @@ public class QualityprofilesService extends BaseService { * @see Further information about this action online (including a response example) * @since 5.2 */ - public void copy(CopyRequest request) { - call( + public CopyWsResponse copy(CopyRequest request) { + return call( new PostRequest(path("copy")) .setParam("fromKey", request.getFromKey()) .setParam("toName", request.getToName()), diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java deleted file mode 100644 index 7f0fcde543f..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/AddProjectRequestTest.java +++ /dev/null @@ -1,68 +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.qualityprofile; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class AddProjectRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - AddProjectRequest.Builder underTest = AddProjectRequest.builder(); - - @Test - public void create_request_from_profile_key_and_project_key() { - AddProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); - - assertThat(result.getLanguage()).isNull(); - assertThat(result.getKey()).isEqualTo("SonarWay"); - assertThat(result.getQualityProfile()).isNull(); - assertThat(result.getProjectKey()).isEqualTo("sample"); - assertThat(result.getProjectUuid()).isNull(); - } - - @Test - public void create_request_from_profile_name_and_language_and_project_key() { - AddProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); - - assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getKey()).isNull(); - assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); - assertThat(result.getProjectKey()).isEqualTo("sample"); - assertThat(result.getProjectUuid()).isNull(); - } - - @Test - public void create_request_from_profile_key_and_project_uuid() { - AddProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); - - assertThat(result.getLanguage()).isNull(); - assertThat(result.getKey()).isEqualTo("SonarWay"); - assertThat(result.getQualityProfile()).isNull(); - assertThat(result.getProjectKey()).isNull(); - assertThat(result.getProjectUuid()).isEqualTo("123"); - } - -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java deleted file mode 100644 index 7aff1d888d5..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java +++ /dev/null @@ -1,58 +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.qualityprofile; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - CreateRequest.Builder underTest = CreateRequest.builder(); - - @Test - public void create_set_request() { - CreateRequest result = underTest - .setLanguage("java") - .setName("Sonar way") - .build(); - - assertThat(result.getLanguage()).isEqualTo("java"); - assertThat(result.getName()).isEqualTo("Sonar way"); - } - - @Test - public void fail_when_no_language() { - expectedException.expect(IllegalArgumentException.class); - underTest.setName("Sonar way").build(); - } - - @Test - public void fail_when_no_profile_name() { - expectedException.expect(IllegalArgumentException.class); - underTest.setLanguage("java").build(); - } - -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java deleted file mode 100644 index 2718136410c..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java +++ /dev/null @@ -1,335 +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.qualityprofile; - -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.Common.Severity; -import org.sonarqube.ws.Qualityprofiles; -import org.sonarqube.ws.Qualityprofiles.SearchWsResponse; -import org.sonarqube.ws.Qualityprofiles.ShowResponse; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -import static org.assertj.core.api.Assertions.assertThat; -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; -import static org.sonar.api.server.ws.WebService.Param.SELECTED; -import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_GROUP; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LOGIN; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY; -import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TO_NAME; - -public class QualityProfilesServiceTest { - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new QualityProfilesService(mock(WsConnector.class))); - - private QualityProfilesService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void search() { - underTest.search(new SearchRequest() - .setDefaults(true) - .setProjectKey("project") - .setLanguage("language") - .setQualityProfile("profile")); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser()); - serviceTester.assertThat(getRequest) - .hasPath("search") - .hasParam(PARAM_DEFAULTS, true) - .hasParam(PARAM_PROJECT_KEY, "project") - .hasParam(PARAM_LANGUAGE, "language") - .hasParam(PARAM_QUALITY_PROFILE, "profile") - .andNoOtherParam(); - } - - @Test - public void show() { - underTest.show(new ShowRequest() - .setKey("profile") - .setCompareToSonarWay(true)); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(ShowResponse.parser()); - serviceTester.assertThat(getRequest) - .hasPath("show") - .hasParam(PARAM_KEY, "profile") - .hasParam(PARAM_COMPARE_TO_SONAR_WAY, true) - .andNoOtherParam(); - } - - @Test - public void add_project() throws Exception { - underTest.addProject(AddProjectRequest.builder() - .setLanguage("xoo") - .setQualityProfile("Sonar Way") - .setProjectKey("sample") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("add_project") - .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") - .hasParam(PARAM_PROJECT_KEY, "sample") - .andNoOtherParam(); - } - - @Test - public void remove_project() throws Exception { - underTest.removeProject(RemoveProjectRequest.builder() - .setLanguage("xoo") - .setQualityProfile("Sonar Way") - .setProjectKey("sample") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("remove_project") - .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way") - .hasParam(PARAM_PROJECT_KEY, "sample") - .andNoOtherParam(); - } - - @Test - public void create() throws Exception { - underTest.create(CreateRequest.builder() - .setLanguage("xoo") - .setName("Sonar Way") - .build()); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("create") - .hasParam(PARAM_LANGUAGE, "xoo") - .hasParam(PARAM_NAME, "Sonar Way") - .andNoOtherParam(); - } - - @Test - public void copy() throws Exception { - underTest.copy(new CopyRequest("fromKey", "My Sonar Way")); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("copy") - .hasParam(PARAM_FROM_KEY, "fromKey") - .hasParam(PARAM_TO_NAME, "My Sonar Way") - .andNoOtherParam(); - } - - @Test - public void set_default() { - underTest.setDefault(new SetDefaultRequest("sample")); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("set_default") - .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") - .andNoOtherParam(); - } - - @Test - public void delete() { - underTest.delete("sample"); - - serviceTester.assertThat(serviceTester.getPostRequest()) - .hasPath("delete") - .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample") - .andNoOtherParam(); - } - - @Test - public void deactivate_rule() { - underTest.deactivateRule("P1", "R1"); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("deactivate_rule") - .hasParam(PARAM_KEY, "P1") - .hasParam(PARAM_RULE, "R1") - .andNoOtherParam(); - } - - @Test - public void activate_rule() { - underTest.activateRule(ActivateRuleRequest.builder() - .setRuleKey("R1") - .setKey("P1") - .setOrganization("O1") - .setParams("PS1") - .setSeverity(Severity.INFO) - .build()); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("activate_rule") - .hasParam(PARAM_KEY, "P1") - .hasParam(PARAM_RULE, "R1") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_PARAMS, "PS1") - .hasParam(PARAM_SEVERITY, Severity.INFO.toString()) - .andNoOtherParam(); - } - - @Test - public void add_user() { - underTest.addUser(AddUserRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setUserLogin("john") - .build()); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("add_user") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(PARAM_LOGIN, "john") - .andNoOtherParam(); - } - - @Test - public void remove_user() { - underTest.removeUser(RemoveUserRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setUserLogin("john") - .build()); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("remove_user") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(PARAM_LOGIN, "john") - .andNoOtherParam(); - } - - @Test - public void search_users() { - underTest.searchUsers(SearchUsersRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setQuery("john") - .setSelected("all") - .setPage(5) - .setPageSize(50) - .build() - ); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(Qualityprofiles.SearchUsersResponse.parser()); - serviceTester.assertThat(getRequest) - .hasPath("search_users") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(TEXT_QUERY, "john") - .hasParam(SELECTED, "all") - .hasParam(PAGE, 5) - .hasParam(PAGE_SIZE, 50) - .andNoOtherParam(); - } - - @Test - public void add_group() { - underTest.addGroup(AddGroupRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setGroup("users") - .build()); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("add_group") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(PARAM_GROUP, "users") - .andNoOtherParam(); - } - - @Test - public void remove_group() { - underTest.removeGroup(RemoveGroupRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setGroup("users") - .build()); - PostRequest request = serviceTester.getPostRequest(); - - serviceTester.assertThat(request) - .hasPath("remove_group") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(PARAM_GROUP, "users") - .andNoOtherParam(); - } - - @Test - public void search_groups() { - underTest.searchGroups(SearchGroupsRequest.builder() - .setOrganization("O1") - .setQualityProfile("P1") - .setLanguage("Xoo") - .setQuery("users") - .setSelected("all") - .setPage(5) - .setPageSize(50) - .build() - ); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(Qualityprofiles.SearchGroupsResponse.parser()); - serviceTester.assertThat(getRequest) - .hasPath("search_groups") - .hasParam(PARAM_ORGANIZATION, "O1") - .hasParam(PARAM_QUALITY_PROFILE, "P1") - .hasParam(PARAM_LANGUAGE, "Xoo") - .hasParam(TEXT_QUERY, "users") - .hasParam(SELECTED, "all") - .hasParam(PAGE, 5) - .hasParam(PAGE_SIZE, 50) - .andNoOtherParam(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java deleted file mode 100644 index e6735e2e271..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/RemoveProjectRequestTest.java +++ /dev/null @@ -1,68 +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.qualityprofile; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RemoveProjectRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - RemoveProjectRequest.Builder underTest = RemoveProjectRequest.builder(); - - @Test - public void create_request_from_profile_key_and_project_key() { - RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build(); - - assertThat(result.getLanguage()).isNull(); - assertThat(result.getKey()).isEqualTo("SonarWay"); - assertThat(result.getQualityProfile()).isNull(); - assertThat(result.getProjectKey()).isEqualTo("sample"); - assertThat(result.getProjectUuid()).isNull(); - } - - @Test - public void create_request_from_profile_name_and_language_and_project_key() { - RemoveProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build(); - - assertThat(result.getLanguage()).isEqualTo("xoo"); - assertThat(result.getKey()).isNull(); - assertThat(result.getQualityProfile()).isEqualTo("Sonar Way"); - assertThat(result.getProjectKey()).isEqualTo("sample"); - assertThat(result.getProjectUuid()).isNull(); - } - - @Test - public void create_request_from_profile_key_and_project_uuid() { - RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build(); - - assertThat(result.getLanguage()).isNull(); - assertThat(result.getKey()).isEqualTo("SonarWay"); - assertThat(result.getQualityProfile()).isNull(); - assertThat(result.getProjectKey()).isNull(); - assertThat(result.getProjectUuid()).isEqualTo("123"); - } - -} 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 ad68417e7c4..45b4a28a05d 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/IssueExclusionsTest.java @@ -28,7 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.tests.Category4Suite; -import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -239,8 +239,8 @@ public class IssueExclusionsTest { tester.projects().provision(p -> p .setKey("com.sonarsource.it.samples:multi-modules-exclusions") .setName("Sonar :: Integration Tests :: Multi-modules With Exclusions")); - tester.wsClient().qualityProfilesOld().addProject(AddProjectRequest.builder().setProjectKey("com.sonarsource.it.samples:multi-modules-exclusions") - .setLanguage("xoo").setQualityProfile("with-many-rules").build()); + tester.wsClient().qualityprofiles().addProject(new AddProjectRequest().setProject("com.sonarsource.it.samples:multi-modules-exclusions") + .setLanguage("xoo").setQualityProfile("with-many-rules")); SonarScanner scan = SonarScanner.create(ItUtils.projectDir(PROJECT_DIR)) .setProperty("sonar.cpd.exclusions", "**/*") diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/QualityProfileAdminPermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/QualityProfileAdminPermissionTest.java index 4bac6f1017e..647de95197f 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/QualityProfileAdminPermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/QualityProfileAdminPermissionTest.java @@ -25,7 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.client.permissions.AddUserRequest; -import org.sonarqube.ws.client.qualityprofile.CreateRequest; +import org.sonarqube.ws.client.qualityprofiles.CreateRequest; import util.selenium.Selenese; import static util.ItUtils.runProjectAnalysis; @@ -60,10 +60,9 @@ public class QualityProfileAdminPermissionTest { } private void createProfile(String language, String name) { - tester.wsClient().qualityProfilesOld().create(CreateRequest.builder() + tester.wsClient().qualityprofiles().create(new CreateRequest() .setLanguage(language) - .setName(name) - .build()); + .setName(name)); } } 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 4bd683f3277..79b0b20cd0f 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -38,7 +38,7 @@ 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.qualityprofile.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; import util.issue.IssueRule; import static java.lang.String.format; @@ -204,13 +204,12 @@ public class OrganizationIssueAssignTest { } private void addQualityProfileToProject(String organization, String projectKey) { - tester.wsClient().qualityProfilesOld().addProject( - AddProjectRequest.builder() - .setProjectKey(projectKey) + tester.wsClient().qualityprofiles().addProject( + new AddProjectRequest() + .setProject(projectKey) .setOrganization(organization) .setLanguage("xoo") - .setQualityProfile("one-issue-per-file-profile") - .build()); + .setQualityProfile("one-issue-per-file-profile")); } private Issues.AssignResponse assignIssueTo(Issue issue, User u) { 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 092c1f7d833..d6387035175 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java @@ -331,9 +331,9 @@ public class OrganizationTest { } private void assertThatBuiltInQualityProfilesExist(Organization org) { - org.sonarqube.ws.client.qualityprofile.SearchRequest profilesRequest = new org.sonarqube.ws.client.qualityprofile.SearchRequest() - .setOrganizationKey(org.getKey()); - Qualityprofiles.SearchWsResponse response = tester.wsClient().qualityProfilesOld().search(profilesRequest); + org.sonarqube.ws.client.qualityprofiles.SearchRequest profilesRequest = new org.sonarqube.ws.client.qualityprofiles.SearchRequest() + .setOrganization(org.getKey()); + Qualityprofiles.SearchWsResponse response = tester.wsClient().qualityprofiles().search(profilesRequest); assertThat(response.getProfilesCount()).isGreaterThan(0); response.getProfilesList().forEach(p -> { @@ -354,7 +354,7 @@ public class OrganizationTest { } private void assertThatQualityProfilesDoNotExist(Organization org) { - expectNotFoundError(() -> tester.wsClient().qualityProfilesOld().search( - new org.sonarqube.ws.client.qualityprofile.SearchRequest().setOrganizationKey(org.getKey()))); + expectNotFoundError(() -> tester.wsClient().qualityprofiles().search( + new org.sonarqube.ws.client.qualityprofiles.SearchRequest().setOrganization(org.getKey()))); } } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java index abaf407ee20..018de95aa1f 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java @@ -33,8 +33,8 @@ import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.permissions.AddGroupRequest; import org.sonarqube.ws.client.permissions.AddUserRequest; -import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; -import org.sonarqube.ws.client.qualityprofile.CreateRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangeParentRequest; +import org.sonarqube.ws.client.qualityprofiles.CreateRequest; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; import util.ItUtils; @@ -111,8 +111,8 @@ public class BuiltInQualityProfilesNotificationTest { Users.CreateWsResponse.User noProfileAdmin = userRule.generate(); // Create a child profile on the built-in profile => The notification should not take into account updates of this profile - wsClient.qualityProfilesOld().create(CreateRequest.builder().setLanguage("foo").setName("child").build()); - wsClient.qualityProfilesOld().changeParent(ChangeParentRequest.builder().setProfileName("child").setParentName("Basic").setLanguage("foo").build()); + wsClient.qualityprofiles().create(new CreateRequest().setLanguage("foo").setName("child")); + wsClient.qualityprofiles().changeParent(new ChangeParentRequest().setQualityProfile("child").setParentQualityProfile("Basic").setLanguage("foo")); // uninstall plugin V1 wsClient.wsConnector().call(new PostRequest("api/plugins/uninstall").setParam("key", "foo")).failIfNotSuccessful(); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesTest.java index be5eb2a3ee9..6994f1a8a95 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesTest.java @@ -24,20 +24,22 @@ import java.util.function.Predicate; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.tests.Category6Suite; -import org.sonarqube.qa.util.TesterSession; import org.sonarqube.qa.util.Tester; +import org.sonarqube.qa.util.TesterSession; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Qualityprofiles; import org.sonarqube.ws.Qualityprofiles.CreateWsResponse; import org.sonarqube.ws.Qualityprofiles.SearchWsResponse; import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; -import org.sonarqube.ws.client.qualityprofile.CopyRequest; -import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; -import org.sonarqube.ws.client.qualityprofile.SearchRequest; -import org.sonarqube.ws.client.qualityprofile.SetDefaultRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangeParentRequest; +import org.sonarqube.ws.client.qualityprofiles.CopyRequest; +import org.sonarqube.ws.client.qualityprofiles.DeactivateRuleRequest; +import org.sonarqube.ws.client.qualityprofiles.DeleteRequest; +import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; +import org.sonarqube.ws.client.qualityprofiles.SearchRequest; +import org.sonarqube.ws.client.qualityprofiles.SetDefaultRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; @@ -55,7 +57,7 @@ public class BuiltInQualityProfilesTest { @Test public void built_in_profiles_are_available_in_new_organization() { Organization org = tester.organizations().generate(); - SearchWsResponse result = tester.qProfiles().service().search(new SearchRequest().setOrganizationKey(org.getKey())); + SearchWsResponse result = tester.qProfiles().service().search(new SearchRequest().setOrganization(org.getKey())); assertThat(result.getProfilesList()) .extracting(QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault) @@ -70,7 +72,7 @@ public class BuiltInQualityProfilesTest { @Test public void built_in_profiles_are_available_in_default_organization() { - SearchWsResponse result = tester.qProfiles().service().search(new SearchRequest().setOrganizationKey("default-organization")); + SearchWsResponse result = tester.qProfiles().service().search(new SearchRequest().setOrganization("default-organization")); assertThat(result.getProfilesList()) .extracting(QualityProfile::getOrganization, QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault) @@ -89,9 +91,9 @@ public class BuiltInQualityProfilesTest { QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && p.getIsDefault() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage())); CreateWsResponse.QualityProfile profileInOrg = tester.qProfiles().createXooProfile(org); - tester.qProfiles().service().setDefault(new SetDefaultRequest(profileInOrg.getKey())); + tester.qProfiles().service().setDefault(new SetDefaultRequest().setKey(profileInOrg.getKey())); - expectBadRequestError(() -> tester.qProfiles().service().delete(builtInProfile.getKey())); + expectBadRequestError(() -> tester.qProfiles().service().delete(new DeleteRequest().setKey(builtInProfile.getKey()))); } @Test @@ -99,10 +101,11 @@ public class BuiltInQualityProfilesTest { Organization org = tester.organizations().generate(); QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && p.getIsDefault() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage())); - QualityProfilesService service = tester.qProfiles().service(); + QualityprofilesService service = tester.qProfiles().service(); expectBadRequestError(() -> tester.qProfiles().activateRule(builtInProfile.getKey(), RULE_ONE_BUG_PER_LINE)); - expectBadRequestError(() -> service.deactivateRule(builtInProfile.getKey(), RULE_ONE_BUG_PER_LINE)); - expectBadRequestError(() -> service.delete(builtInProfile.getKey())); + expectBadRequestError(() -> service.deactivateRule(new DeactivateRuleRequest() + .setKey(builtInProfile.getKey()).setRule(RULE_ONE_BUG_PER_LINE))); + expectBadRequestError(() -> service.delete(new DeleteRequest().setKey(builtInProfile.getKey()))); } @Test @@ -112,7 +115,7 @@ public class BuiltInQualityProfilesTest { QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage())); TesterSession adminSession = tester.as(administrator.getLogin()); - Qualityprofiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest(builtInProfile.getKey(), "My copy")); + Qualityprofiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest().setFromKey(builtInProfile.getKey()).setToName("My copy")); assertThat(copyResponse.getIsDefault()).isFalse(); assertThat(copyResponse.getKey()).isNotEmpty().isNotEqualTo(builtInProfile.getKey()); @@ -134,9 +137,9 @@ public class BuiltInQualityProfilesTest { QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage())); TesterSession adminSession = tester.as(administrator.getLogin()); - Qualityprofiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest(builtInProfile.getKey(), "My copy")); + Qualityprofiles.CopyWsResponse copyResponse = adminSession.qProfiles().service().copy(new CopyRequest().setFromKey(builtInProfile.getKey()).setToName("My copy")); adminSession.qProfiles().service().changeParent( - ChangeParentRequest.builder().setParentKey(builtInProfile.getKey()).setProfileKey(copyResponse.getKey()).build()); + new ChangeParentRequest().setParentKey(builtInProfile.getKey()).setKey(copyResponse.getKey())); QualityProfile inheritedQualityPropfile = getProfile(org, p -> p.getKey().equals(copyResponse.getKey())); @@ -145,7 +148,7 @@ public class BuiltInQualityProfilesTest { // Remove inheritance adminSession.qProfiles().service().changeParent( - new ChangeParentRequest(ChangeParentRequest.builder().setProfileKey(inheritedQualityPropfile.getKey()))); + new ChangeParentRequest().setKey(inheritedQualityPropfile.getKey())); inheritedQualityPropfile = getProfile(org, p -> p.getKey().equals(copyResponse.getKey())); @@ -155,7 +158,7 @@ public class BuiltInQualityProfilesTest { private QualityProfile getProfile(Organization organization, Predicate filter) { return tester.qProfiles().service().search(new SearchRequest() - .setOrganizationKey(organization.getKey())).getProfilesList() + .setOrganization(organization.getKey())).getProfilesList() .stream() .filter(filter) .findAny().orElseThrow(IllegalStateException::new); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java index c3866bb6c0f..0a11bd74203 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java @@ -21,7 +21,6 @@ package org.sonarqube.tests.qualityProfile; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category6Suite; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -29,8 +28,9 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.QProfileTester; -import org.sonarqube.qa.util.TesterSession; import org.sonarqube.qa.util.Tester; +import org.sonarqube.qa.util.TesterSession; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Qualityprofiles; import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; @@ -38,12 +38,12 @@ import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.organizations.DeleteRequest; -import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; -import org.sonarqube.ws.client.qualityprofile.CopyRequest; -import org.sonarqube.ws.client.qualityprofile.CreateRequest; -import org.sonarqube.ws.client.qualityprofile.SearchRequest; -import org.sonarqube.ws.client.qualityprofile.SetDefaultRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangeParentRequest; +import org.sonarqube.ws.client.qualityprofiles.CopyRequest; +import org.sonarqube.ws.client.qualityprofiles.CreateRequest; +import org.sonarqube.ws.client.qualityprofiles.SearchRequest; +import org.sonarqube.ws.client.qualityprofiles.SetDefaultRequest; import util.ItUtils; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; @@ -112,7 +112,7 @@ public class CustomQualityProfilesTest { .activateRule(profile, "xoo:OneIssuePerFile") .assertThatNumberOfActiveRulesEqualsTo(profile, 1); - adminSession.service().delete(profile.getKey()); + adminSession.service().delete(new org.sonarqube.ws.client.qualityprofiles.DeleteRequest().setKey(profile.getKey())); adminSession.assertThatNumberOfActiveRulesEqualsTo(profile, 0); } @@ -127,36 +127,34 @@ public class CustomQualityProfilesTest { // Copied profile Qualityprofiles.SearchWsResponse.QualityProfile builtInProfile = getProfile(org, p -> p.getIsBuiltIn() && "Basic".equals(p.getName()) && "xoo".equals(p.getLanguage())); - Qualityprofiles.CopyWsResponse copyResponse = adminSession.service().copy(new CopyRequest(builtInProfile.getKey(), "My copy")); + Qualityprofiles.CopyWsResponse copyResponse = adminSession.service().copy(new CopyRequest().setFromKey(builtInProfile.getKey()).setToName("My copy")); // Inherited profile from custom QualityProfile inheritedProfile1 = adminSession.service().create( - CreateRequest.builder() + new CreateRequest() .setLanguage(parentProfile.getLanguage()) - .setOrganizationKey(org.getKey()) - .setName("inherited_profile") - .build()) + .setOrganization(org.getKey()) + .setName("inherited_profile")) .getProfile(); adminSession.service().changeParent( - ChangeParentRequest.builder().setParentKey(parentProfile.getKey()).setProfileKey(inheritedProfile1.getKey()).build()); + new ChangeParentRequest().setParentKey(parentProfile.getKey()).setKey(inheritedProfile1.getKey())); // Inherited profile from builtIn QualityProfile inheritedProfile2 = adminSession.service().create( - CreateRequest.builder() + new CreateRequest() .setLanguage(parentProfile.getLanguage()) - .setOrganizationKey(org.getKey()) - .setName("inherited_profile2") - .build()) + .setOrganization(org.getKey()) + .setName("inherited_profile2")) .getProfile(); adminSession.service().changeParent( - ChangeParentRequest.builder().setParentKey(builtInProfile.getKey()).setProfileKey(inheritedProfile2.getKey()).build()); + new ChangeParentRequest().setParentKey(builtInProfile.getKey()).setKey(inheritedProfile2.getKey())); tester.organizations().service().delete(new DeleteRequest().setOrganization(org.getKey())); expectMissingError(() -> tester.qProfiles().service().search(new SearchRequest() - .setOrganizationKey(org.getKey()))); + .setOrganization(org.getKey()))); tester.qProfiles().service().search(new SearchRequest()).getProfilesList() .forEach(p -> { @@ -175,13 +173,13 @@ public class CustomQualityProfilesTest { QProfileTester adminSession = tester.as(adminOfOrg1.getLogin()).qProfiles(); expectForbiddenError(() -> adminSession.createXooProfile(org2)); - expectForbiddenError(() -> adminSession.service().delete(profileInOrg2.getKey())); + expectForbiddenError(() -> adminSession.service().delete(new org.sonarqube.ws.client.qualityprofiles.DeleteRequest().setKey(profileInOrg2.getKey()))); expectForbiddenError(() -> adminSession.activateRule(profileInOrg2, "xoo:OneIssuePerFile")); expectForbiddenError(() -> adminSession.deactivateRule(profileInOrg2, "xoo:OneIssuePerFile")); } private void delete(QualityProfile profile) { - tester.qProfiles().service().delete(profile.getKey()); + tester.qProfiles().service().delete(new org.sonarqube.ws.client.qualityprofiles.DeleteRequest().setKey(profile.getKey())); } @Test @@ -192,7 +190,7 @@ public class CustomQualityProfilesTest { TesterSession anonymousSession = tester.asAnonymous(); expectUnauthorizedError(() -> anonymousSession.qProfiles().createXooProfile(org)); - expectUnauthorizedError(() -> anonymousSession.qProfiles().service().delete(profile.getKey())); + expectUnauthorizedError(() -> anonymousSession.qProfiles().service().delete(new org.sonarqube.ws.client.qualityprofiles.DeleteRequest().setKey(profile.getKey()))); expectUnauthorizedError(() -> anonymousSession.qProfiles().activateRule(profile, "xoo:OneIssuePerFile")); expectUnauthorizedError(() -> anonymousSession.qProfiles().deactivateRule(profile, "xoo:OneIssuePerFile")); } @@ -209,7 +207,7 @@ public class CustomQualityProfilesTest { tester.qProfiles() .activateRule(profile, "xoo:OneIssuePerFile") .assertThatNumberOfActiveRulesEqualsTo(profile, 1); - tester.qProfiles().service().delete(profile.getKey()); + tester.qProfiles().service().delete(new org.sonarqube.ws.client.qualityprofiles.DeleteRequest().setKey(profile.getKey())); tester.qProfiles().assertThatNumberOfActiveRulesEqualsTo(profile, 0); } @@ -221,15 +219,14 @@ public class CustomQualityProfilesTest { TesterSession adminSession = tester.as(user.getLogin()); QualityProfile parentProfile = adminSession.qProfiles().createXooProfile(org); QualityProfile inheritedProfile = adminSession.qProfiles().service().create( - CreateRequest.builder() + new CreateRequest() .setLanguage(parentProfile.getLanguage()) - .setOrganizationKey(org.getKey()) - .setName("inherited_profile") - .build()) + .setOrganization(org.getKey()) + .setName("inherited_profile")) .getProfile(); adminSession.qProfiles().service().changeParent( - ChangeParentRequest.builder().setParentKey(parentProfile.getKey()).setProfileKey(inheritedProfile.getKey()).build()); + new ChangeParentRequest().setParentKey(parentProfile.getKey()).setKey(inheritedProfile.getKey())); Qualityprofiles.SearchWsResponse.QualityProfile inheritedQualityPropfile = getProfile(org, p -> p.getKey().equals(inheritedProfile.getKey())); @@ -238,7 +235,7 @@ public class CustomQualityProfilesTest { // Remove inheritance adminSession.qProfiles().service().changeParent( - new ChangeParentRequest(ChangeParentRequest.builder().setProfileKey(inheritedQualityPropfile.getKey()))); + new ChangeParentRequest().setKey(inheritedQualityPropfile.getKey())); inheritedQualityPropfile = getProfile(org, p -> p.getKey().equals(inheritedProfile.getKey())); @@ -268,7 +265,7 @@ public class CustomQualityProfilesTest { assertThatQualityProfileIsUsedFor(projectKey, defaultProfile.getKey()); QualityProfile newXooProfile = adminSession.qProfiles().createXooProfile(org); - adminSession.qProfiles().service().setDefault(new SetDefaultRequest(newXooProfile.getKey())); + adminSession.qProfiles().service().setDefault(new SetDefaultRequest().setKey(newXooProfile.getKey())); orchestrator.executeBuild( SonarScanner.create(projectDir("shared/xoo-sample"), @@ -295,10 +292,9 @@ public class CustomQualityProfilesTest { .setParam("name", projectName) .setParam("organization", org.getKey())); - adminSession.qProfiles().service().addProject(AddProjectRequest.builder() + adminSession.qProfiles().service().addProject(new AddProjectRequest() .setKey(newXooProfile.getKey()) - .setProjectKey(projectKey) - .build()); + .setProject(projectKey)); orchestrator.executeBuild( SonarScanner.create(projectDir("shared/xoo-sample"), @@ -321,7 +317,7 @@ public class CustomQualityProfilesTest { private Qualityprofiles.SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate filter) { return tester.qProfiles().service().search(new SearchRequest() - .setOrganizationKey(organization.getKey())).getProfilesList() + .setOrganization(organization.getKey())).getProfilesList() .stream() .filter(filter) .findAny().orElseThrow(IllegalStateException::new); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java index 83c7f9e7b51..bc1d4d6e87e 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -35,8 +35,8 @@ import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Qualityprofiles; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangeParentRequest; import util.selenium.Selenese; import static com.codeborne.selenide.Selenide.$; @@ -184,12 +184,11 @@ public class OrganizationQualityProfilesUiTest { } private void inheritProfile(String language, String name, String parentName) { - tester.wsClient().qualityProfilesOld().changeParent(ChangeParentRequest.builder() + tester.wsClient().qualityprofiles().changeParent(new ChangeParentRequest() .setLanguage(language) - .setProfileName(name) - .setParentName(parentName) - .setOrganization(organization.getKey()) - .build()); + .setQualityProfile(name) + .setParentQualityProfile(parentName) + .setOrganization(organization.getKey())); } private void analyzeProject(String path) { @@ -200,12 +199,11 @@ public class OrganizationQualityProfilesUiTest { } private void addProfileToProject(String language, String profileName, String projectKey) { - tester.wsClient().qualityProfilesOld().addProject(AddProjectRequest.builder() + tester.wsClient().qualityprofiles().addProject(new AddProjectRequest() .setLanguage(language) .setQualityProfile(profileName) - .setProjectKey(projectKey) - .setOrganization(organization.getKey()) - .build()); + .setProject(projectKey) + .setOrganization(organization.getKey())); } private void deleteProfile(String language, String name) { diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesEditTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesEditTest.java index 6ae433c2567..c5ba0483a4a 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesEditTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesEditTest.java @@ -36,13 +36,13 @@ import org.sonarqube.ws.UserGroups; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.permissions.AddUserRequest; -import org.sonarqube.ws.client.qualityprofile.AddGroupRequest; -import org.sonarqube.ws.client.qualityprofile.RemoveGroupRequest; -import org.sonarqube.ws.client.qualityprofile.RemoveUserRequest; -import org.sonarqube.ws.client.qualityprofile.SearchGroupsRequest; -import org.sonarqube.ws.client.qualityprofile.SearchUsersRequest; -import org.sonarqube.ws.client.qualityprofile.SearchRequest; -import org.sonarqube.ws.client.qualityprofile.ShowRequest; +import org.sonarqube.ws.client.qualityprofiles.AddGroupRequest; +import org.sonarqube.ws.client.qualityprofiles.RemoveGroupRequest; +import org.sonarqube.ws.client.qualityprofiles.RemoveUserRequest; +import org.sonarqube.ws.client.qualityprofiles.SearchGroupsRequest; +import org.sonarqube.ws.client.qualityprofiles.SearchRequest; +import org.sonarqube.ws.client.qualityprofiles.SearchUsersRequest; +import org.sonarqube.ws.client.qualityprofiles.ShowRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; @@ -66,12 +66,11 @@ public class QualityProfilesEditTest { CreateWsResponse.QualityProfile xooProfile = tester.qProfiles().createXooProfile(organization); addUserPermission(organization, user1, xooProfile); - SearchUsersResponse users = tester.qProfiles().service().searchUsers(SearchUsersRequest.builder() + SearchUsersResponse users = tester.qProfiles().service().searchUsers(new SearchUsersRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("all") - .build()); + .setSelected("all")); assertThat(users.getUsersList()) .extracting(SearchUsersResponse.User::getLogin, SearchUsersResponse.User::getName, SearchUsersResponse.User::getAvatar, SearchUsersResponse.User::getSelected) @@ -91,39 +90,35 @@ public class QualityProfilesEditTest { CreateWsResponse.QualityProfile xooProfile = tester.qProfiles().createXooProfile(organization); // No user added - assertThat(tester.qProfiles().service().searchUsers(SearchUsersRequest.builder() + assertThat(tester.qProfiles().service().searchUsers(new SearchUsersRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getUsersList()) + .setSelected("selected")).getUsersList()) .extracting(SearchUsersResponse.User::getLogin) .isEmpty(); // Add user 1 addUserPermission(organization, user1, xooProfile); - assertThat(tester.qProfiles().service().searchUsers(SearchUsersRequest.builder() + assertThat(tester.qProfiles().service().searchUsers(new SearchUsersRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getUsersList()) + .setSelected("selected")).getUsersList()) .extracting(SearchUsersResponse.User::getLogin) .containsExactlyInAnyOrder(user1.getLogin()); // Remove user 1 - tester.qProfiles().service().removeUser(RemoveUserRequest.builder() + tester.qProfiles().service().removeUser(new RemoveUserRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setUserLogin(user1.getLogin()) - .build()); - assertThat(tester.qProfiles().service().searchUsers(SearchUsersRequest.builder() + .setLogin(user1.getLogin())); + assertThat(tester.qProfiles().service().searchUsers(new SearchUsersRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getUsersList()) + .setSelected("selected")).getUsersList()) .extracting(SearchUsersResponse.User::getLogin) .isEmpty(); } @@ -138,11 +133,10 @@ public class QualityProfilesEditTest { addGroupPermission(organization, group1, xooProfile); addGroupPermission(organization, group2, xooProfile); - SearchGroupsResponse groups = tester.qProfiles().service().searchGroups(SearchGroupsRequest.builder() + SearchGroupsResponse groups = tester.qProfiles().service().searchGroups(new SearchGroupsRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) - .setLanguage(xooProfile.getLanguage()) - .build()); + .setLanguage(xooProfile.getLanguage())); assertThat(groups.getGroupsList()).extracting(Group::getName, Group::getDescription, Group::getSelected) .containsExactlyInAnyOrder( @@ -160,39 +154,35 @@ public class QualityProfilesEditTest { CreateWsResponse.QualityProfile xooProfile = tester.qProfiles().createXooProfile(organization); // No group added - assertThat(tester.qProfiles().service().searchGroups(SearchGroupsRequest.builder() + assertThat(tester.qProfiles().service().searchGroups(new SearchGroupsRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getGroupsList()) + .setSelected("selected")).getGroupsList()) .extracting(Group::getName) .isEmpty(); // Add group 1 addGroupPermission(organization, group1, xooProfile); - assertThat(tester.qProfiles().service().searchGroups(SearchGroupsRequest.builder() + assertThat(tester.qProfiles().service().searchGroups(new SearchGroupsRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getGroupsList()) + .setSelected("selected")).getGroupsList()) .extracting(Group::getName) .containsExactlyInAnyOrder(group1.getName()); // Remove group 1 - tester.qProfiles().service().removeGroup(RemoveGroupRequest.builder() + tester.qProfiles().service().removeGroup(new RemoveGroupRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setGroup(group1.getName()) - .build()); - assertThat(tester.qProfiles().service().searchGroups(SearchGroupsRequest.builder() + .setGroup(group1.getName())); + assertThat(tester.qProfiles().service().searchGroups(new SearchGroupsRequest() .setOrganization(organization.getKey()) .setQualityProfile(xooProfile.getName()) .setLanguage(xooProfile.getLanguage()) - .setSelected("selected") - .build()).getGroupsList()) + .setSelected("selected")).getGroupsList()) .extracting(Group::getName) .isEmpty(); } @@ -210,7 +200,7 @@ public class QualityProfilesEditTest { CreateWsResponse.QualityProfile xooProfile3 = tester.qProfiles().createXooProfile(organization); SearchWsResponse result = tester.as(user.getLogin()) - .qProfiles().service().search(new SearchRequest().setOrganizationKey(organization.getKey())); + .qProfiles().service().search(new SearchRequest().setOrganization(organization.getKey())); assertThat(result.getActions().getCreate()).isFalse(); assertThat(result.getProfilesList()) .extracting(SearchWsResponse.QualityProfile::getKey, qp -> qp.getActions().getEdit(), qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), @@ -229,7 +219,7 @@ public class QualityProfilesEditTest { tester.wsClient().permissions().addUser(new AddUserRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()).setPermission("profileadmin")); SearchWsResponse result = tester.as(user.getLogin()) - .qProfiles().service().search(new SearchRequest().setOrganizationKey(organization.getKey())); + .qProfiles().service().search(new SearchRequest().setOrganization(organization.getKey())); assertThat(result.getActions().getCreate()).isTrue(); assertThat(result.getProfilesList()) .extracting(SearchWsResponse.QualityProfile::getKey, qp -> qp.getActions().getEdit(), qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), @@ -263,31 +253,29 @@ public class QualityProfilesEditTest { .failIfNotSuccessful(); // Check that the profile has no missing rule from the Sonar way profile - assertThat(tester.qProfiles().service().show(new ShowRequest().setKey(xooProfile.getKey()).setCompareToSonarWay(true)).getCompareToSonarWay().getMissingRuleCount()) + assertThat(tester.qProfiles().service().show(new ShowRequest().setKey(xooProfile.getKey()).setCompareToSonarWay("true")).getCompareToSonarWay().getMissingRuleCount()) .isZero(); } private void addUserPermission(Organization organization, User user, CreateWsResponse.QualityProfile qProfile) { - tester.qProfiles().service().addUser(org.sonarqube.ws.client.qualityprofile.AddUserRequest.builder() + tester.qProfiles().service().addUser(new org.sonarqube.ws.client.qualityprofiles.AddUserRequest() .setOrganization(organization.getKey()) .setQualityProfile(qProfile.getName()) .setLanguage(qProfile.getLanguage()) - .setUserLogin(user.getLogin()) - .build()); + .setLogin(user.getLogin())); } private void addGroupPermission(Organization organization, UserGroups.Group group, CreateWsResponse.QualityProfile qProfile) { - tester.qProfiles().service().addGroup(AddGroupRequest.builder() + tester.qProfiles().service().addGroup(new AddGroupRequest() .setOrganization(organization.getKey()) .setQualityProfile(qProfile.getName()) .setLanguage(qProfile.getLanguage()) - .setGroup(group.getName()) - .build()); + .setGroup(group.getName())); } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate filter) { return tester.qProfiles().service().search(new SearchRequest() - .setOrganizationKey(organization.getKey())).getProfilesList() + .setOrganization(organization.getKey())).getProfilesList() .stream() .filter(filter) .findAny().orElseThrow(IllegalStateException::new); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java index 71ff0ad3755..3208f9e96a8 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java @@ -31,9 +31,9 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.tests.Category4Suite; import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; -import org.sonarqube.ws.client.qualityprofile.CreateRequest; +import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangeParentRequest; +import org.sonarqube.ws.client.qualityprofiles.CreateRequest; import util.selenium.Selenese; import util.user.UserRule; @@ -154,18 +154,16 @@ public class QualityProfilesUiTest { } private void createProfile(String language, String name) { - tester.wsClient().qualityProfilesOld().create(CreateRequest.builder() + tester.wsClient().qualityprofiles().create(new CreateRequest() .setLanguage(language) - .setName(name) - .build()); + .setName(name)); } private void inheritProfile(String language, String name, String parentName) { - tester.wsClient().qualityProfilesOld().changeParent(ChangeParentRequest.builder() + tester.wsClient().qualityprofiles().changeParent(new ChangeParentRequest() .setLanguage(language) - .setProfileName(name) - .setParentName(parentName) - .build()); + .setQualityProfile(name) + .setParentQualityProfile(parentName)); } private static void analyzeProject(String path) { @@ -173,11 +171,10 @@ public class QualityProfilesUiTest { } private void addProfileToProject(String language, String profileName, String projectKey) { - tester.wsClient().qualityProfilesOld().addProject(AddProjectRequest.builder() + tester.wsClient().qualityprofiles().addProject(new AddProjectRequest() .setLanguage(language) .setQualityProfile(profileName) - .setProjectKey(projectKey) - .build()); + .setProject(projectKey)); } private void deleteProfile(String language, String name) { diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java index e39af31e2c0..e880e3007ef 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesWsTest.java @@ -27,8 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; -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.Qualityprofiles.CreateWsResponse; import org.sonarqube.ws.Qualityprofiles.SearchWsResponse; @@ -38,9 +38,9 @@ import org.sonarqube.ws.Qualityprofiles.ShowResponse.QualityProfile; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.qualityprofile.ChangelogRequest; -import org.sonarqube.ws.client.qualityprofile.SearchRequest; -import org.sonarqube.ws.client.qualityprofile.ShowRequest; +import org.sonarqube.ws.client.qualityprofiles.ChangelogRequest; +import org.sonarqube.ws.client.qualityprofiles.SearchRequest; +import org.sonarqube.ws.client.qualityprofiles.ShowRequest; import static org.assertj.core.api.Assertions.assertThat; @@ -85,7 +85,7 @@ public class QualityProfilesWsTest { CompareToSonarWay result = tester.qProfiles().service().show(new ShowRequest() .setKey(xooProfile.getKey()) - .setCompareToSonarWay(true)).getCompareToSonarWay(); + .setCompareToSonarWay("true")).getCompareToSonarWay(); assertThat(result) .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) @@ -110,7 +110,7 @@ public class QualityProfilesWsTest { // Check that the profile has no missing rule from the Sonar way profile assertThat(tester.qProfiles().service().show(new ShowRequest() .setKey(xooProfile.getKey()) - .setCompareToSonarWay(true)).getCompareToSonarWay()) + .setCompareToSonarWay("true")).getCompareToSonarWay()) .extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount) .containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L); } @@ -133,35 +133,32 @@ public class QualityProfilesWsTest { Organization org = tester.organizations().generate(); CreateWsResponse.QualityProfile profile = tester.qProfiles().createXooProfile(org); - String changelog = tester.wsClient().qualityProfilesOld().changelog(ChangelogRequest.builder() + String changelog = tester.wsClient().qualityprofiles().changelog(new ChangelogRequest() .setOrganization(org.getKey()) .setLanguage(profile.getLanguage()) - .setQualityProfile(profile.getName()) - .build()); + .setQualityProfile(profile.getName())); JSONAssert.assertEquals(EXPECTED_CHANGELOG_EMPTY, changelog, JSONCompareMode.STRICT); tester.qProfiles().activateRule(profile, RULE_ONE_BUG_PER_LINE); tester.qProfiles().activateRule(profile, RULE_ONE_ISSUE_PER_LINE); - String changelog2 = tester.wsClient().qualityProfilesOld().changelog(ChangelogRequest.builder() + String changelog2 = tester.wsClient().qualityprofiles().changelog(new ChangelogRequest() .setOrganization(org.getKey()) .setLanguage(profile.getLanguage()) - .setQualityProfile(profile.getName()) - .build()); + .setQualityProfile(profile.getName())); JSONAssert.assertEquals(EXPECTED_CHANGELOG, changelog2, JSONCompareMode.LENIENT); - String changelog3 = tester.wsClient().qualityProfilesOld().changelog(ChangelogRequest.builder() + String changelog3 = tester.wsClient().qualityprofiles().changelog(new ChangelogRequest() .setOrganization(org.getKey()) .setLanguage(profile.getLanguage()) .setQualityProfile(profile.getName()) - .setSince("2999-12-31T23:59:59+0000") - .build()); + .setSince("2999-12-31T23:59:59+0000")); JSONAssert.assertEquals(EXPECTED_CHANGELOG_EMPTY, changelog3, JSONCompareMode.STRICT); } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate filter) { return tester.qProfiles().service().search(new SearchRequest() - .setOrganizationKey(organization.getKey())).getProfilesList() + .setOrganization(organization.getKey())).getProfilesList() .stream() .filter(filter) .findAny().orElseThrow(IllegalStateException::new); diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java index 31cef84c190..bac620bd151 100644 --- a/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java @@ -83,8 +83,8 @@ public class RulesWsTest { } private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate filter) { - return tester.qProfiles().service().search(new org.sonarqube.ws.client.qualityprofile.SearchRequest() - .setOrganizationKey(organization.getKey())).getProfilesList() + return tester.qProfiles().service().search(new org.sonarqube.ws.client.qualityprofiles.SearchRequest() + .setOrganization(organization.getKey())).getProfilesList() .stream() .filter(filter) .findAny().orElseThrow(IllegalStateException::new); diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java index 7700bf120f5..3c401d8cd8c 100644 --- a/tests/src/test/java/util/ItUtils.java +++ b/tests/src/test/java/util/ItUtils.java @@ -66,13 +66,14 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Components.Component; import org.sonarqube.ws.Measures; import org.sonarqube.ws.Measures.Measure; +import org.sonarqube.ws.MediaTypes; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.HttpConnector; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.components.ShowRequest; import org.sonarqube.ws.client.measures.ComponentRequest; -import org.sonarqube.ws.client.qualityprofile.RestoreRequest; import org.sonarqube.ws.client.settings.ResetRequest; import org.sonarqube.ws.client.settings.SetRequest; @@ -86,6 +87,8 @@ import static java.util.Locale.ENGLISH; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.RestoreActionParameters.PARAM_BACKUP; public class ItUtils { public static final Splitter LINE_SPLITTER = Splitter.on(System.getProperty("line.separator")); @@ -402,13 +405,14 @@ public class ItUtils { } catch (URISyntaxException e) { throw new IllegalArgumentException("Cannot find quality profile xml file '" + resource + "' in classpath"); } - newAdminWsClient(orchestrator) - .qualityProfilesOld() - .restoreProfile( - RestoreRequest.builder() - .setBackup(new File(uri)) - .setOrganization(organization) - .build()); + + PostRequest httpRequest = new PostRequest("api/qualityprofiles/restore") + .setParam(PARAM_ORGANIZATION, organization) + .setPart(PARAM_BACKUP, new PostRequest.Part(MediaTypes.XML, new File(uri))); + HttpConnector.newBuilder() + .url(orchestrator.getServer().getUrl()) + .credentials(ADMIN_LOGIN, ADMIN_PASSWORD) + .build().call(httpRequest); } public static String newOrganizationKey() { -- 2.39.5