diff options
Diffstat (limited to 'sonar-ws')
25 files changed, 2 insertions, 2397 deletions
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); @@ -129,11 +126,6 @@ class DefaultWsClient implements WsClient { } @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<String> params; - private final String key; - private final Optional<Boolean> reset; - private final String ruleKey; - private final Optional<Severity> severity; - private final Optional<String> 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<String> getParams() { - return params; - } - - public String getKey() { - return key; - } - - public Optional<Boolean> getReset() { - return reset; - } - - public String getRuleKey() { - return ruleKey; - } - - public Optional<Severity> getSeverity() { - return severity; - } - - public Optional<String> getOrganization() { - return organization; - } - - public static class Builder { - private Optional<String> organization = Optional.empty(); - private Optional<String> params = Optional.empty(); - private String key; - private Optional<Boolean> reset = Optional.empty(); - private String ruleKey; - private Optional<Severity> 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<String> 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<String> 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<String> 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<String> organization; - - private RestoreRequest(Builder builder) { - backup = requireNonNull(builder.backup); - organization = requireNonNull(builder.organization); - } - - public File getBackup() { - return backup; - } - - public Optional<String> getOrganization() { - return organization; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private File backup; - private Optional<String> 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 <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualityprofiles/copy">Further information about this action online (including a response example)</a> * @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<QualityProfilesService> 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"); - } - -} |