summaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-12-04 18:34:50 +0100
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-12-06 14:40:17 +0100
commit9bd3b8f3857e1434b97b73f39b9ffd88bdd703cc (patch)
tree134d6b2b916d10776ae8b1e141dee5f26b8932d2 /sonar-ws
parentad745fb92a0450298d89f01c21d1d6a439c3d19c (diff)
downloadsonarqube-9bd3b8f3857e1434b97b73f39b9ffd88bdd703cc.tar.gz
sonarqube-9bd3b8f3857e1434b97b73f39b9ffd88bdd703cc.zip
Remove legacy sonar-ws code for projects
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java2
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java113
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java113
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java59
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java140
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java72
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java179
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java88
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java66
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java184
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java81
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java49
12 files changed, 1 insertions, 1145 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 ecef12eecfd..daa1a503ce0 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
@@ -45,8 +45,8 @@ import org.sonarqube.ws.client.profiles.ProfilesService;
import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService;
import org.sonarqube.ws.client.projectbranches.ProjectBranchesService;
import org.sonarqube.ws.client.projectlinks.ProjectLinksService;
-import org.sonarqube.ws.client.projects.ProjectsService;
import org.sonarqube.ws.client.projecttags.ProjectTagsService;
+import org.sonarqube.ws.client.projects.ProjectsService;
import org.sonarqube.ws.client.properties.PropertiesService;
import org.sonarqube.ws.client.qualitygates.QualitygatesService;
import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java
deleted file mode 100644
index 980f6361f87..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/BulkUpdateKeyRequest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-@Immutable
-public class BulkUpdateKeyRequest {
- private final String id;
- private final String key;
- private final String from;
- private final String to;
- private final boolean dryRun;
-
- public BulkUpdateKeyRequest(Builder builder) {
- this.id = builder.id;
- this.key = builder.key;
- this.from = builder.from;
- this.to = builder.to;
- this.dryRun = builder.dryRun;
- }
-
- @CheckForNull
- public String getId() {
- return id;
- }
-
- @CheckForNull
- public String getKey() {
- return key;
- }
-
- public String getFrom() {
- return from;
- }
-
- public String getTo() {
- return to;
- }
-
- public boolean isDryRun() {
- return dryRun;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String id;
- private String key;
- private String from;
- private String to;
- private boolean dryRun;
-
- private Builder() {
- // enforce method constructor
- }
-
- public Builder setId(@Nullable String id) {
- this.id = id;
- return this;
- }
-
- public Builder setKey(@Nullable String key) {
- this.key = key;
- return this;
- }
-
- public Builder setFrom(String from) {
- this.from = from;
- return this;
- }
-
- public Builder setTo(String to) {
- this.to = to;
- return this;
- }
-
- public Builder setDryRun(boolean dryRun) {
- this.dryRun = dryRun;
- return this;
- }
-
- public BulkUpdateKeyRequest build() {
- checkArgument(from != null && !from.isEmpty(), "The string to match must not be empty");
- checkArgument(to != null && !to.isEmpty(), "The string replacement must not be empty");
- return new BulkUpdateKeyRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java
deleted file mode 100644
index 61c89eeabfc..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class CreateRequest {
-
- private final String organization;
- private final String key;
- private final String name;
- private final String branch;
- @CheckForNull
- private final String visibility;
-
- private CreateRequest(Builder builder) {
- this.organization = builder.organization;
- this.key = builder.key;
- this.name = builder.name;
- this.branch = builder.branch;
- this.visibility = builder.visibility;
- }
-
- @CheckForNull
- public String getOrganization() {
- return organization;
- }
-
- @CheckForNull
- public String getKey() {
- return key;
- }
-
- @CheckForNull
- public String getName() {
- return name;
- }
-
- @CheckForNull
- public String getBranch() {
- return branch;
- }
-
- @CheckForNull
- public String getVisibility() {
- return visibility;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String organization;
- private String key;
- private String name;
- private String branch;
- @CheckForNull
- private String visibility;
-
- private Builder() {
- }
-
- public Builder setOrganization(@Nullable String organization) {
- this.organization = organization;
- return this;
- }
-
- public Builder setKey(@Nullable String key) {
- this.key = key;
- return this;
- }
-
- public Builder setName(@Nullable String name) {
- this.name = name;
- return this;
- }
-
- public Builder setBranch(@Nullable String branch) {
- this.branch = branch;
- return this;
- }
-
- public Builder setVisibility(@Nullable String visibility) {
- this.visibility = visibility;
- return this;
- }
-
- public CreateRequest build() {
- return new CreateRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java
deleted file mode 100644
index 0d798bd54f2..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/DeleteRequest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class DeleteRequest {
-
- private final String key;
-
- private DeleteRequest(Builder builder) {
- this.key = builder.key;
- }
-
- @CheckForNull
- public String getKey() {
- return key;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String key;
-
- private Builder() {
- }
-
- public Builder setKey(@Nullable String key) {
- this.key = key;
- return this;
- }
-
- public DeleteRequest build() {
- return new DeleteRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java
deleted file mode 100644
index e169f4f96e1..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/ProjectsService.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import com.google.common.base.Joiner;
-import org.sonarqube.ws.Projects.BulkUpdateKeyWsResponse;
-import org.sonarqube.ws.Projects.CreateWsResponse;
-import org.sonarqube.ws.Projects.SearchWsResponse;
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-
-import static org.sonar.api.server.ws.WebService.Param.PAGE;
-import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_BULK_UPDATE_KEY;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_CREATE;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_SEARCH;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_KEY;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_VISIBILITY;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.CONTROLLER;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ANALYZED_BEFORE;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_BRANCH;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NAME;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ON_PROVISIONED_ONLY;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECTS;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_IDS;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_QUALIFIERS;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_VISIBILITY;
-
-/**
- * Maps web service {@code api/projects}.
- *
- * @since 5.5
- */
-public class ProjectsService extends BaseService {
-
- public ProjectsService(WsConnector wsConnector) {
- super(wsConnector, CONTROLLER);
- }
-
- /**
- * Provisions a new project.
- *
- * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx.
- */
- public CreateWsResponse create(CreateRequest project) {
- PostRequest request = new PostRequest(path(ACTION_CREATE))
- .setParam(PARAM_ORGANIZATION, project.getOrganization())
- .setParam(PARAM_PROJECT, project.getKey())
- .setParam(PARAM_NAME, project.getName())
- .setParam(PARAM_BRANCH, project.getBranch())
- .setParam(PARAM_VISIBILITY, project.getVisibility());
- return call(request, CreateWsResponse.parser());
- }
-
- /**
- * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx.
- */
- public void delete(DeleteRequest request) {
- call(new PostRequest(path("delete"))
- .setParam("project", request.getKey()));
- }
-
- public void bulkDelete(SearchRequest request) {
- PostRequest post = new PostRequest(path("bulk_delete"))
- .setParam(PARAM_ORGANIZATION, request.getOrganization())
- .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers()))
- .setParam(PARAM_ANALYZED_BEFORE, request.getAnalyzedBefore())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(PARAM_ON_PROVISIONED_ONLY, request.isOnProvisionedOnly())
- .setParam(PARAM_PROJECTS, inlineMultipleParamValue(request.getProjects()))
- .setParam(PARAM_PROJECT_IDS, inlineMultipleParamValue(request.getProjectIds()));
-
- call(post);
- }
-
- public void updateKey(UpdateKeyRequest request) {
- PostRequest post = new PostRequest(path(ACTION_UPDATE_KEY))
- .setParam(PARAM_PROJECT_ID, request.getId())
- .setParam(PARAM_FROM, request.getKey())
- .setParam(PARAM_TO, request.getNewKey());
-
- call(post);
- }
-
- public BulkUpdateKeyWsResponse bulkUpdateKey(BulkUpdateKeyRequest request) {
- PostRequest post = new PostRequest(path(ACTION_BULK_UPDATE_KEY))
- .setParam(PARAM_PROJECT_ID, request.getId())
- .setParam(PARAM_PROJECT, request.getKey())
- .setParam(ProjectsWsParameters.PARAM_FROM, request.getFrom())
- .setParam(ProjectsWsParameters.PARAM_TO, request.getTo());
-
- return call(post, BulkUpdateKeyWsResponse.parser());
- }
-
- public SearchWsResponse search(SearchRequest request) {
- GetRequest get = new GetRequest(path(ACTION_SEARCH))
- .setParam(PARAM_ORGANIZATION, request.getOrganization())
- .setParam(PARAM_QUALIFIERS, Joiner.on(",").join(request.getQualifiers()))
- .setParam(PARAM_ANALYZED_BEFORE, request.getAnalyzedBefore())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(PAGE, request.getPage())
- .setParam(PAGE_SIZE, request.getPageSize())
- .setParam(PARAM_ON_PROVISIONED_ONLY, request.isOnProvisionedOnly())
- .setParam(PARAM_PROJECTS, inlineMultipleParamValue(request.getProjects()))
- .setParam(PARAM_PROJECT_IDS, inlineMultipleParamValue(request.getProjectIds()));
- return call(get, SearchWsResponse.parser());
- }
-
- public void updateVisibility(UpdateVisibilityRequest request) {
- PostRequest post = new PostRequest(path(ACTION_UPDATE_VISIBILITY))
- .setParam(PARAM_PROJECT, request.getProject())
- .setParam(PARAM_VISIBILITY, request.getVisibility());
- call(post);
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java
deleted file mode 100644
index a0b6b3d80db..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchMyProjectsRequest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class SearchMyProjectsRequest {
- private final Integer page;
- private final Integer pageSize;
-
- private SearchMyProjectsRequest(Builder builder) {
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private Integer page;
- private Integer pageSize;
-
- private Builder() {
- // enforce method constructor
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public SearchMyProjectsRequest build() {
- return new SearchMyProjectsRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java
deleted file mode 100644
index 5cf2b559dc9..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/SearchRequest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.resources.Qualifiers;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Collections.singletonList;
-import static java.util.Objects.requireNonNull;
-import static org.sonarqube.ws.client.project.ProjectsWsParameters.MAX_PAGE_SIZE;
-
-public class SearchRequest {
-
- private final String organization;
- private final String query;
- private final List<String> qualifiers;
- private final String visibility;
- private final Integer page;
- private final Integer pageSize;
- private final String analyzedBefore;
- private final boolean onProvisionedOnly;
- private final List<String> projects;
- private final List<String> projectIds;
-
- public SearchRequest(Builder builder) {
- this.organization = builder.organization;
- this.query = builder.query;
- this.qualifiers = builder.qualifiers;
- this.visibility = builder.visibility;
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- this.analyzedBefore = builder.analyzedBefore;
- this.onProvisionedOnly = builder.onProvisionedOnly;
- this.projects = builder.projects;
- this.projectIds = builder.projectIds;
- }
-
- @CheckForNull
- public String getOrganization() {
- return organization;
- }
-
- public List<String> getQualifiers() {
- return qualifiers;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- @CheckForNull
- public String getQuery() {
- return query;
- }
-
- @CheckForNull
- public String getVisibility() {
- return visibility;
- }
-
- @CheckForNull
- public String getAnalyzedBefore() {
- return analyzedBefore;
- }
-
- public boolean isOnProvisionedOnly() {
- return onProvisionedOnly;
- }
-
- @CheckForNull
- public List<String> getProjects() {
- return projects;
- }
-
- @CheckForNull
- public List<String> getProjectIds() {
- return projectIds;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String organization;
- private List<String> qualifiers = singletonList(Qualifiers.PROJECT);
- private Integer page;
- private Integer pageSize;
- private String query;
- private String visibility;
- private String analyzedBefore;
- private boolean onProvisionedOnly = false;
- private List<String> projects;
- private List<String> projectIds;
-
- public Builder setOrganization(@Nullable String organization) {
- this.organization = organization;
- return this;
- }
-
- public Builder setQualifiers(List<String> qualifiers) {
- this.qualifiers = requireNonNull(qualifiers, "Qualifiers cannot be null");
- return this;
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public Builder setQuery(@Nullable String query) {
- this.query = query;
- return this;
- }
-
- public Builder setVisibility(@Nullable String visibility) {
- this.visibility = visibility;
- return this;
- }
-
- public Builder setAnalyzedBefore(@Nullable String lastAnalysisBefore) {
- this.analyzedBefore = lastAnalysisBefore;
- return this;
- }
-
- public Builder setOnProvisionedOnly(boolean onProvisionedOnly) {
- this.onProvisionedOnly = onProvisionedOnly;
- return this;
- }
-
- public Builder setProjects(@Nullable List<String> projects) {
- this.projects = projects;
- return this;
- }
-
- public Builder setProjectIds(@Nullable List<String> projectIds) {
- this.projectIds = projectIds;
- return this;
- }
-
- public SearchRequest build() {
- checkArgument(projects==null || !projects.isEmpty(), "Project key list must not be empty");
- checkArgument(projectIds==null || !projectIds.isEmpty(), "Project id list must not be empty");
- checkArgument(pageSize == null || pageSize <= MAX_PAGE_SIZE, "Page size must not be greater than %s", MAX_PAGE_SIZE);
- return new SearchRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java
deleted file mode 100644
index 0995a388c24..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateKeyRequest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-@Immutable
-public class UpdateKeyRequest {
- private final String id;
- private final String key;
- private final String newKey;
-
- public UpdateKeyRequest(Builder builder) {
- this.id = builder.id;
- this.key = builder.key;
- this.newKey = builder.newKey;
- }
-
- @CheckForNull
- public String getId() {
- return id;
- }
-
- @CheckForNull
- public String getKey() {
- return key;
- }
-
- public String getNewKey() {
- return newKey;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String id;
- private String key;
- private String newKey;
-
- private Builder() {
- // enforce method constructor
- }
-
- public Builder setId(@Nullable String id) {
- this.id = id;
- return this;
- }
-
- public Builder setKey(@Nullable String key) {
- this.key = key;
- return this;
- }
-
- public Builder setNewKey(String newKey) {
- this.newKey = newKey;
- return this;
- }
-
- public UpdateKeyRequest build() {
- checkArgument(newKey != null && !newKey.isEmpty(), "The new key must not be empty");
- return new UpdateKeyRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java
deleted file mode 100644
index 342b7a547b3..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/UpdateVisibilityRequest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class UpdateVisibilityRequest {
- private final String project;
- private final String visibility;
-
- public UpdateVisibilityRequest(Builder builder) {
- this.project = builder.project;
- this.visibility = builder.visibility;
- }
-
- @CheckForNull
- public String getProject() {
- return project;
- }
-
- @CheckForNull
- public String getVisibility() {
- return visibility;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String project;
- private String visibility;
-
- public Builder setProject(@Nullable String project) {
- this.project = project;
- return this;
- }
-
- public Builder setVisibility(@Nullable String visibility) {
- this.visibility = visibility;
- return this;
- }
-
- public UpdateVisibilityRequest build() {
- return new UpdateVisibilityRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java
deleted file mode 100644
index 9b8fbb04478..00000000000
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/ProjectsServiceTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import java.util.Arrays;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.Projects;
-import org.sonarqube.ws.client.ServiceTester;
-import org.sonarqube.ws.client.WsConnector;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.data.MapEntry.entry;
-import static org.mockito.Mockito.mock;
-import static org.sonar.api.server.ws.WebService.Param.PAGE;
-import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-
-public class ProjectsServiceTest {
-
- @Rule
- public ServiceTester<ProjectsService> serviceTester = new ServiceTester<>(new ProjectsService(mock(WsConnector.class)));
-
- private ProjectsService underTest = serviceTester.getInstanceUnderTest();
-
- @Test
- public void creates_project() {
- underTest.create(CreateRequest.builder()
- .setKey("project_key")
- .setName("Project Name")
- .build());
-
- assertThat(serviceTester.getPostParser()).isSameAs(Projects.CreateWsResponse.parser());
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("project", "project_key"),
- entry("name", "Project Name"));
- }
-
- @Test
- public void creates_project_on_organization() {
- underTest.create(CreateRequest.builder()
- .setOrganization("org_key")
- .setKey("project_key")
- .setName("Project Name")
- .build());
-
- assertThat(serviceTester.getPostParser()).isSameAs(Projects.CreateWsResponse.parser());
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("organization", "org_key"),
- entry("project", "project_key"),
- entry("name", "Project Name"));
- }
-
- @Test
- public void creates_project_on_branch() {
- underTest.create(CreateRequest.builder()
- .setKey("project_key")
- .setName("Project Name")
- .setBranch("the_branch")
- .build());
-
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("project", "project_key"),
- entry("name", "Project Name"),
- entry("branch", "the_branch"));
- }
-
- @Test
- public void creates_public_project() {
- underTest.create(CreateRequest.builder()
- .setKey("project_key")
- .setName("Project Name")
- .setVisibility("public")
- .build());
-
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("project", "project_key"),
- entry("name", "Project Name"),
- entry("visibility", "public"));
- }
-
- @Test
- public void creates_private_project() {
- underTest.create(CreateRequest.builder()
- .setKey("project_key")
- .setName("Project Name")
- .setVisibility("private")
- .build());
-
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/create");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("project", "project_key"),
- entry("name", "Project Name"),
- entry("visibility", "private"));
- }
-
- @Test
- public void delete() {
- underTest.delete(DeleteRequest.builder().setKey("P1").build());
-
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/delete");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(entry("project", "P1"));
- }
-
- @Test
- public void bulk_delete() {
- underTest.bulkDelete(SearchRequest.builder()
- .setOrganization("default")
- .setQuery("project")
- .setQualifiers(asList("TRK", "VW"))
- .setAnalyzedBefore("2017-09-01")
- .setProjects(Arrays.asList("P1", "P2"))
- .setOnProvisionedOnly(true)
- .build());
-
- serviceTester.assertThat(serviceTester.getPostRequest())
- .hasPath("bulk_delete")
- .hasParam("organization", "default")
- .hasParam("q", "project")
- .hasParam("analyzedBefore", "2017-09-01")
- .hasParam("qualifiers", "TRK,VW")
- .hasParam("onProvisionedOnly", "true")
- .hasParam("projects", "P1,P2")
- .andNoOtherParam();
- }
-
- @Test
- public void search() {
- underTest.search(SearchRequest.builder()
- .setOrganization("default")
- .setQuery("project")
- .setQualifiers(asList("TRK", "VW"))
- .setAnalyzedBefore("2017-09-01")
- .setOnProvisionedOnly(true)
- .setPage(3)
- .setPageSize(10)
- .build());
-
- serviceTester.assertThat(serviceTester.getGetRequest())
- .hasPath("search")
- .hasParam("organization", "default")
- .hasParam("q", "project")
- .hasParam("analyzedBefore", "2017-09-01")
- .hasParam("qualifiers", "TRK,VW")
- .hasParam("onProvisionedOnly", "true")
- .hasParam(PAGE, 3)
- .hasParam(PAGE_SIZE, 10)
- .andNoOtherParam();
- }
-
- @Test
- public void update_visibility() {
- underTest.updateVisibility(UpdateVisibilityRequest.builder()
- .setProject("project_key")
- .setVisibility("public")
- .build());
-
- assertThat(serviceTester.getPostRequest().getPath()).isEqualTo("api/projects/update_visibility");
- assertThat(serviceTester.getPostRequest().getParams()).containsOnly(
- entry("project", "project_key"),
- entry("visibility", "public"));
- }
-}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java
deleted file mode 100644
index ee64ad762ca..00000000000
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/SearchRequestTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.project;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SearchRequestTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void create_request() throws Exception {
- SearchRequest underTest = SearchRequest.builder()
- .setOrganization("orga")
- .setQuery("project")
- .setQualifiers(asList("TRK", "VW"))
- .setPage(5)
- .setPageSize(10)
- .build();
-
- assertThat(underTest.getOrganization()).isEqualTo("orga");
- assertThat(underTest.getQuery()).isEqualTo("project");
- assertThat(underTest.getQualifiers()).containsOnly("TRK", "VW");
- assertThat(underTest.getPage()).isEqualTo(5);
- assertThat(underTest.getPageSize()).isEqualTo(10);
- }
-
- @Test
- public void fail_when_page_size_is_greater_then_500() throws Exception {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Page size must not be greater than 500");
-
- SearchRequest.builder()
- .setPageSize(10000)
- .build();
- }
-
- @Test
- public void fail_if_project_key_list_is_empty() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Project key list must not be empty");
-
- SearchRequest.builder()
- .setProjects(emptyList())
- .build();
- }
-
- @Test
- public void fail_if_project_id_list_is_empty() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Project id list must not be empty");
-
- SearchRequest.builder()
- .setProjectIds(emptyList())
- .build();
- }
-}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java
deleted file mode 100644
index 7b99e955c7b..00000000000
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/project/UpdateKeyRequestTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonarqube.ws.client.project;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class UpdateKeyRequestTest {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- UpdateKeyRequest.Builder underTest = UpdateKeyRequest.builder();
-
- @Test
- public void fail_if_new_key_is_null() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The new key must not be empty");
-
- underTest.setNewKey(null).build();
- }
-
- @Test
- public void fail_if_new_key_is_empty() {
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The new key must not be empty");
-
- underTest.setNewKey("").build();
- }
-}