import javax.annotation.Nullable;
import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Projects;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.DeleteRequest;
-import org.sonarqube.ws.client.project.ProjectsService;
-import org.sonarqube.ws.client.project.SearchRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
+import org.sonarqube.ws.client.projects.DeleteRequest;
+import org.sonarqube.ws.client.projects.ProjectsService;
+import org.sonarqube.ws.client.projects.SearchRequest;
import static java.util.Arrays.stream;
import static java.util.Collections.singletonList;
void deleteAll() {
ProjectsService service = session.wsClient().projects();
- service.search(SearchRequest.builder().setQualifiers(singletonList("TRK")).build()).getComponentsList().forEach(p ->
- service.delete(DeleteRequest.builder().setKey(p.getKey()).build()));
+ service.search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList().forEach(p ->
+ service.delete(new DeleteRequest().setProject(p.getKey())));
}
@SafeVarargs
- public final Projects.CreateWsResponse.Project provision(Consumer<CreateRequest.Builder>... populators) {
+ public final Projects.CreateWsResponse.Project provision(Consumer<CreateRequest>... populators) {
return provision(null, populators);
}
@SafeVarargs
- public final Projects.CreateWsResponse.Project provision(@Nullable Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) {
+ public final Projects.CreateWsResponse.Project provision(@Nullable Organizations.Organization organization, Consumer<CreateRequest>... populators) {
int id = ID_GENERATOR.getAndIncrement();
- CreateRequest.Builder request = CreateRequest.builder()
- .setKey("key" + id)
+ CreateRequest request = new CreateRequest()
+ .setProject("key" + id)
.setName("Name " + id)
.setOrganization(organization != null ? organization.getKey() : null);
stream(populators).forEach(p -> p.accept(request));
- return session.wsClient().projects().create(request.build()).getProject();
+ return session.wsClient().projects().create(request).getProject();
}
}
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;
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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"));
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
ItUtils.restoreProfile(orchestrator, getClass().getResource("/exclusions/IssueExclusionsTest/with-many-rules.xml"));
tester.projects().provision(p -> p
- .setKey("com.sonarsource.it.samples:multi-modules-exclusions")
+ .setProject("com.sonarsource.it.samples:multi-modules-exclusions")
.setName("Sonar :: Integration Tests :: Multi-modules With Exclusions"));
tester.wsClient().qualityprofiles().addProject(new AddProjectRequest().setProject("com.sonarsource.it.samples:multi-modules-exclusions")
.setLanguage("xoo").setQualityProfile("with-many-rules"));
import org.sonarqube.ws.client.permissions.AddGroupRequest;
import org.sonarqube.ws.client.permissions.AddProjectCreatorToTemplateRequest;
import org.sonarqube.ws.client.permissions.RemoveGroupRequest;
-import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
+import org.sonarqube.ws.client.projects.UpdateVisibilityRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
"You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.");
}
- tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(PROJECT_KEY).setVisibility("private").build());
+ tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(PROJECT_KEY).setVisibility("private"));
try {
// Execute anonymous analysis
executeAnonymousAnalysis();
executeAnonymousAnalysis();
// make project private
- tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("sample").setVisibility("private").build());
+ tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample").setVisibility("private"));
// still no error
executeAnonymousAnalysis();
import org.sonarqube.ws.client.issues.BulkChangeRequest;
import org.sonarqube.ws.client.issues.ChangelogRequest;
import org.sonarqube.ws.client.permissions.AddUserRequest;
-import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
+import org.sonarqube.ws.client.projects.UpdateVisibilityRequest;
import util.ItUtils;
import static java.util.Arrays.asList;
ItUtils.restoreProfile(orchestrator, getClass().getResource("/authorisation/one-issue-per-line-profile.xml"));
orchestrator.getServer().provisionProject("privateProject", "PrivateProject");
- tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("privateProject").setVisibility("private").build());
+ tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("privateProject").setVisibility("private"));
orchestrator.getServer().associateProjectToQualityProfile("privateProject", "xoo", "one-issue-per-line");
SonarScanner privateProject = SonarScanner.create(projectDir("shared/xoo-sample"))
.setProperty("sonar.projectKey", "privateProject")
import org.sonarqube.ws.client.permissions.AddUserRequest;
import org.sonarqube.ws.client.permissions.RemoveGroupRequest;
import org.sonarqube.ws.client.permissions.RemoveUserRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import util.ItUtils;
import static org.assertj.core.api.Assertions.assertThat;
final String newName = "New Project";
Project created = tester.as(USER_WITH_PROVISIONING, PASSWORD).wsClient().projects()
- .create(CreateRequest.builder().setKey(newKey).setName(newName).build())
+ .create(new CreateRequest().setProject(newKey).setName(newName))
.getProject();
assertThat(created).isNotNull();
public void user_cannot_provision_project_through_ws_if_he_does_not_have_provisioning_permission() {
ItUtils.expectForbiddenError(() -> {
tester.as(USER_WITHOUT_PROVISIONING, PASSWORD).wsClient().projects()
- .create(CreateRequest.builder().setKey("new-project").setName("New Project").build())
+ .create(new CreateRequest().setProject("new-project").setName("New Project"))
.getProject();
});
}
private void createSampleProject(String visibility) {
// Create project
Qualityprofiles.CreateWsResponse.QualityProfile profile = tester.qProfiles().createXooProfile(organization);
- Project project = tester.projects().provision(organization, p -> p.setKey(PROJECT_KEY)
+ Project project = tester.projects().provision(organization, p -> p.setProject(PROJECT_KEY)
.setName("Sample")
.setVisibility(visibility));
tester.qProfiles()
import org.sonarqube.ws.client.issues.TagsRequest;
import org.sonarqube.ws.client.organizations.AddMemberRequest;
import org.sonarqube.ws.client.permissions.AddUserRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
restoreProfile(orchestrator, IssueTagsTest.class.getResource("/issue/one-issue-per-line-profile.xml"), organization.getKey());
String projectKey = newProjectKey();
tester.wsClient().projects().create(
- CreateRequest.builder()
- .setKey(projectKey)
+ new CreateRequest()
+ .setProject(projectKey)
.setOrganization(organization.getKey())
.setName(randomAlphabetic(10))
- .setVisibility("private")
- .build());
+ .setVisibility("private"));
analyzeProject(organization.getKey(), projectKey);
String issue = tester.wsClient().issues().search(new SearchRequest()).getIssues(0).getKey();
import org.sonarqube.ws.client.issues.AssignRequest;
import org.sonarqube.ws.client.issues.BulkChangeRequest;
import org.sonarqube.ws.client.issues.SearchRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import util.issue.IssueRule;
import static java.lang.String.format;
private void provisionProject(String projectKey, String organization) {
tester.wsClient().projects().create(
- CreateRequest.builder()
- .setKey(projectKey)
+ new CreateRequest()
+ .setProject(projectKey)
.setName(projectKey)
- .setOrganization(organization)
- .build());
+ .setOrganization(organization));
}
private void analyseProject(String projectKey, String organization) {
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.ce.TaskRequest;
import org.sonarqube.ws.client.organizations.UpdateProjectVisibilityRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
+import org.sonarqube.ws.client.projects.UpdateVisibilityRequest;
import util.ItUtils;
import static java.lang.String.format;
String projectKey = createPublicProject();
tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
- tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build());
+ tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(projectKey).setVisibility("private"));
assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey), "\"visibility\":\"private\"");
}
expectHttpError(400,
format("Organization %s cannot use private project", organization.getKey()),
- () -> tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build()));
+ () -> tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject(projectKey).setVisibility("private")));
}
@Test
String projectKey = newProjectKey();
tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
- tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("public").build());
+ tester.wsClient().projects().create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("public"));
assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey), "\"visibility\":\"public\"");
}
expectHttpError(400,
format("Organization %s cannot use private project", organization.getKey()),
() -> tester.wsClient().projects()
- .create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("private").build()));
+ .create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey()).setVisibility("private")));
}
@Test
import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Projects.CreateWsResponse;
import org.sonarqube.ws.Projects.SearchWsResponse.Component;
-import org.sonarqube.ws.client.project.SearchRequest;
+import org.sonarqube.ws.client.projects.BulkDeleteRequest;
+import org.sonarqube.ws.client.projects.SearchRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.runProjectAnalysis;
@Test
public void delete_projects() {
Organizations.Organization organization = tester.organizations().generate();
- CreateWsResponse.Project firstProvisionedProject = tester.projects().provision(organization, p -> p.setKey("first-provisioned-project"));
- CreateWsResponse.Project secondProvisionedProject = tester.projects().provision(organization, p -> p.setKey("second-provisioned-project"));
+ CreateWsResponse.Project firstProvisionedProject = tester.projects().provision(organization, p -> p.setProject("first-provisioned-project"));
+ CreateWsResponse.Project secondProvisionedProject = tester.projects().provision(organization, p -> p.setProject("second-provisioned-project"));
CreateWsResponse.Project analyzedProject = tester.projects().provision(organization);
analyzeProject(analyzedProject.getKey(), organization.getKey());
- tester.wsClient().projects().bulkDelete(SearchRequest.builder()
+ tester.wsClient().projects().bulkDelete(new BulkDeleteRequest()
.setOrganization(organization.getKey())
- .setQuery("FIRST-PROVISIONED")
- .setOnProvisionedOnly(true).build());
+ .setQ("FIRST-PROVISIONED")
+ .setOnProvisionedOnly("true"));
- List<Component> projects = tester.wsClient().projects().search(SearchRequest.builder().setOrganization(organization.getKey()).build()).getComponentsList();
+ List<Component> projects = tester.wsClient().projects().search(new SearchRequest().setOrganization(organization.getKey())).getComponentsList();
assertThat(projects).extracting(Component::getKey)
.containsExactlyInAnyOrder(analyzedProject.getKey(), secondProvisionedProject.getKey())
.doesNotContain(firstProvisionedProject.getKey());
public void delete_more_than_50_projects_at_the_same_time() {
Organizations.Organization organization = tester.organizations().generate();
IntStream.range(0, 60).forEach(i -> tester.projects().provision(organization));
- SearchRequest request = SearchRequest.builder().setOrganization(organization.getKey()).build();
- assertThat(tester.wsClient().projects().search(request).getPaging().getTotal()).isEqualTo(60);
+ SearchRequest searchRequest = new SearchRequest().setOrganization(organization.getKey());
+ BulkDeleteRequest deleteRequest = new BulkDeleteRequest().setOrganization(organization.getKey());
+ assertThat(tester.wsClient().projects().search(searchRequest).getPaging().getTotal()).isEqualTo(60);
- tester.wsClient().projects().bulkDelete(request);
+ tester.wsClient().projects().bulkDelete(deleteRequest);
- assertThat(tester.wsClient().projects().search(request).getComponentsList()).isEmpty();
- assertThat(tester.wsClient().projects().search(request).getPaging().getTotal()).isEqualTo(0);
+ assertThat(tester.wsClient().projects().search(searchRequest).getComponentsList()).isEmpty();
+ assertThat(tester.wsClient().projects().search(searchRequest).getPaging().getTotal()).isEqualTo(0);
}
private void analyzeProject(String projectKey, String organizationKey) {
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Components;
+import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Projects;
import org.sonarqube.ws.Projects.CreateWsResponse.Project;
import org.sonarqube.ws.Users;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.components.SearchProjectsRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.DeleteRequest;
-import org.sonarqube.ws.client.project.SearchRequest;
+import org.sonarqube.ws.client.projects.BulkDeleteRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
+import org.sonarqube.ws.client.projects.DeleteRequest;
+import org.sonarqube.ws.client.projects.SearchRequest;
import util.ItUtils;
import static java.util.Collections.singletonList;
}
private void deleteProject(Project project) {
- tester.wsClient().projects().delete(DeleteRequest.builder().setKey(project.getKey()).build());
+ tester.wsClient().projects().delete(new DeleteRequest().setProject(project.getKey()));
}
private void bulkDeleteProjects(Organizations.Organization organization, Project... projects) {
- SearchRequest request = SearchRequest.builder()
+ BulkDeleteRequest request = new BulkDeleteRequest()
.setOrganization(organization.getKey())
- .setProjects(Arrays.stream(projects).map(Project::getKey).collect(Collectors.toList()))
- .build();
+ .setProjects(Arrays.stream(projects).map(Project::getKey).collect(Collectors.toList()));
tester.wsClient().projects().bulkDelete(request);
}
private Project createProject(Organizations.Organization organization, String key, String name) {
- CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build();
+ CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey());
return tester.wsClient().projects().create(createRequest).getProject();
}
*/
private boolean isInProjectsSearch(Organizations.Organization organization, String name) {
Projects.SearchWsResponse response = tester.wsClient().projects().search(
- SearchRequest.builder().setOrganization(organization.getKey()).setQuery(name).setQualifiers(singletonList("TRK")).build());
+ new SearchRequest().setOrganization(organization.getKey()).setQ(name).setQualifiers(singletonList("TRK")));
return response.getComponentsCount() > 0;
}
}
private static void executeDeleteRequest(WsClient wsClient, String key) {
- wsClient.projects().delete(DeleteRequest.builder().setKey(key).build());
+ wsClient.projects().delete(new DeleteRequest().setProject(key));
}
}
import org.junit.Test;
import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Common;
-import org.sonarqube.ws.Organizations.Organization;
import org.sonarqube.ws.Components.Component;
import org.sonarqube.ws.Components.SearchProjectsWsResponse;
+import org.sonarqube.ws.Organizations.Organization;
import org.sonarqube.ws.client.components.SearchProjectsRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
@Test
public void provisioned_projects_should_be_included_to_results() throws Exception {
String projectKey = newProjectKey();
- tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).build());
+ tester.wsClient().projects().create(new CreateRequest().setProject(projectKey).setName(projectKey).setOrganization(organization.getKey()));
SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()));
analyzeProject(projectKey2, "shared/xoo-sample");
// This project is provisioned, so has no leak period
String projectKey3 = newProjectKey();
- tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey3).setName(projectKey3).setOrganization(organization.getKey()).build());
+ tester.wsClient().projects().create(new CreateRequest().setProject(projectKey3).setName(projectKey3).setOrganization(organization.getKey()));
SearchProjectsWsResponse response = searchProjects(
new SearchProjectsRequest().setF(singletonList("leakPeriodDate")).setOrganization(organization.getKey()));
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.components.SearchProjectsRequest;
import org.sonarqube.ws.client.components.ShowRequest;
-import org.sonarqube.ws.client.project.BulkUpdateKeyRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.UpdateKeyRequest;
+import org.sonarqube.ws.client.projects.UpdateKeyRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import util.ItUtils;
import static org.assertj.core.api.Assertions.assertThat;
Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent();
assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
- tester.wsClient().projects().updateKey(UpdateKeyRequest.builder()
- .setKey(PROJECT_KEY)
- .setNewKey(newProjectKey)
- .build());
-
- assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
- }
-
- @Test
- public void bulk_update_key() {
- analyzeXooSample();
- String newProjectKey = "another_project_key";
- Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent();
- assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
-
- Projects.BulkUpdateKeyWsResponse result = tester.wsClient().projects().bulkUpdateKey(BulkUpdateKeyRequest.builder()
- .setKey(PROJECT_KEY)
+ tester.wsClient().projects().updateKey(new UpdateKeyRequest()
.setFrom(PROJECT_KEY)
- .setTo(newProjectKey)
- .build());
+ .setTo(newProjectKey));
assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
- assertThat(result.getKeysCount()).isEqualTo(1);
- assertThat(result.getKeys(0))
- .extracting(Projects.BulkUpdateKeyWsResponse.Key::getKey, Projects.BulkUpdateKeyWsResponse.Key::getNewKey, Projects.BulkUpdateKeyWsResponse.Key::getDuplicate)
- .containsOnlyOnce(PROJECT_KEY, newProjectKey, false);
}
@Test
}
private void updateKey(Projects.CreateWsResponse.Project project, String newKey) {
- tester.wsClient().projects().updateKey(UpdateKeyRequest.builder().setKey(project.getKey()).setNewKey(newKey).build());
+ tester.wsClient().projects().updateKey(new UpdateKeyRequest().setFrom(project.getKey()).setTo(newKey));
}
private void updateKey(String initialKey, String newKey) {
- tester.wsClient().projects().updateKey(UpdateKeyRequest.builder().setKey(initialKey).setNewKey(newKey).build());
+ tester.wsClient().projects().updateKey(new UpdateKeyRequest().setFrom(initialKey).setTo(newKey));
}
private Projects.CreateWsResponse.Project createProject(Organizations.Organization organization, String key, String name) {
- CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build();
+ CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey());
return tester.wsClient().projects().create(createRequest).getProject();
}
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Components;
+import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Projects;
import org.sonarqube.ws.Projects.CreateWsResponse.Project;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.components.SearchProjectsRequest;
-import org.sonarqube.ws.client.project.CreateRequest;
-import org.sonarqube.ws.client.project.SearchRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
+import org.sonarqube.ws.client.projects.SearchRequest;
import util.ItUtils;
import static java.util.Collections.singletonList;
}
private Project createProject(Organizations.Organization organization, String key, String name) {
- CreateRequest createRequest = CreateRequest.builder().setKey(key).setName(name).setOrganization(organization.getKey()).build();
+ CreateRequest createRequest = new CreateRequest().setProject(key).setName(name).setOrganization(organization.getKey());
return tester.wsClient().projects().create(createRequest).getProject();
}
*/
private boolean isInProjectsSearch(Organizations.Organization organization, String name) {
Projects.SearchWsResponse response = tester.wsClient().projects().search(
- SearchRequest.builder().setOrganization(organization.getKey()).setQuery(name).setQualifiers(singletonList("TRK")).build());
+ new SearchRequest().setOrganization(organization.getKey()).setQ(name).setQualifiers(singletonList("TRK")));
return response.getComponentsCount() > 0;
}
import org.sonarqube.ws.Projects.SearchWsResponse;
import org.sonarqube.ws.Projects.SearchWsResponse.Component;
import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.project.SearchRequest;
+import org.sonarqube.ws.client.projects.SearchRequest;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
analyzeProject(oldProject.getKey(), moreThanOneYearAgo, organization.getKey());
analyzeProject(recentProject.getKey(), now, organization.getKey());
- SearchWsResponse result = tester.wsClient().projects().search(SearchRequest.builder()
+ SearchWsResponse result = tester.wsClient().projects().search(new SearchRequest()
.setOrganization(organization.getKey())
.setQualifiers(singletonList("TRK"))
- .setAnalyzedBefore(formatDate(oneYearAgo)).build());
+ .setAnalyzedBefore(formatDate(oneYearAgo)));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(oldProject.getKey());
}
@Test
public void search_on_key_query_partial_match_case_insensitive() {
Organizations.Organization organization = tester.organizations().generate();
- CreateWsResponse.Project lowerCaseProject = tester.projects().provision(organization, p -> p.setKey("project-key"));
- CreateWsResponse.Project upperCaseProject = tester.projects().provision(organization, p -> p.setKey("PROJECT-KEY"));
- CreateWsResponse.Project anotherProject = tester.projects().provision(organization, p -> p.setKey("another-project"));
+ CreateWsResponse.Project lowerCaseProject = tester.projects().provision(organization, p -> p.setProject("project-key"));
+ CreateWsResponse.Project upperCaseProject = tester.projects().provision(organization, p -> p.setProject("PROJECT-KEY"));
+ CreateWsResponse.Project anotherProject = tester.projects().provision(organization, p -> p.setProject("another-project"));
analyzeProject(lowerCaseProject.getKey(), organization.getKey());
analyzeProject(upperCaseProject.getKey(), organization.getKey());
analyzeProject(anotherProject.getKey(), organization.getKey());
- SearchWsResponse result = tester.wsClient().projects().search(SearchRequest.builder()
+ SearchWsResponse result = tester.wsClient().projects().search(new SearchRequest()
.setOrganization(organization.getKey())
.setQualifiers(singletonList("TRK"))
- .setQuery("JeCt-K")
- .build());
+ .setQ("JeCt-K"));
assertThat(result.getComponentsList()).extracting(Component::getKey)
.containsExactlyInAnyOrder(lowerCaseProject.getKey(), upperCaseProject.getKey())
String result = tester.wsClient().wsConnector().call(new GetRequest("api/projects/provisioned")
.setParam("organization", organization.getKey()))
.failIfNotSuccessful().content();
- SearchWsResponse searchResult = tester.wsClient().projects().search(SearchRequest.builder()
+ SearchWsResponse searchResult = tester.wsClient().projects().search(new SearchRequest()
.setQualifiers(singletonList("TRK"))
.setOrganization(organization.getKey())
- .setOnProvisionedOnly(true).build());
+ .setOnProvisionedOnly("true"));
assertThat(result).contains(firstProvisionedProject.getKey(), secondProvisionedProject.getKey()).doesNotContain(analyzedProject.getKey());
assertThat(searchResult.getComponentsList()).extracting(Component::getKey)
import org.sonarqube.ws.Components;
import org.sonarqube.ws.client.components.SearchProjectsRequest;
import org.sonarqube.ws.client.permissions.RemoveGroupRequest;
-import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
+import org.sonarqube.ws.client.projects.UpdateVisibilityRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.projectDir;
public void return_all_projects_even_when_no_permission() throws Exception {
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample1"));
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample2"));
- tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject("sample2").setVisibility("private").build());
+ tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample2").setVisibility("private"));
// Remove 'Admin' permission for admin group on project 2 -> No one can access or admin this project, expect System Admin
tester.wsClient().permissions().removeGroup(new RemoveGroupRequest().setProjectKey("sample2").setGroupName("sonar-administrators").setPermission("admin"));
package org.sonarqube.tests.ui;
import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category4Suite;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Category4Suite;
import org.sonarqube.ws.Projects;
import org.sonarqube.ws.Users.CreateWsResponse.User;
-import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.projects.CreateRequest;
import util.ItUtils;
import util.selenium.Selenese;
private Projects.CreateWsResponse.Project createSampleProject() {
String projectKey = ItUtils.newProjectKey();
- return tester.wsClient().projects().create(CreateRequest.builder()
- .setKey(projectKey)
- .setName("Name of " + projectKey)
- .build()).getProject();
+ return tester.wsClient().projects().create(new CreateRequest()
+ .setProject(projectKey)
+ .setName("Name of " + projectKey)).getProject();
}
}
import com.sonar.orchestrator.Orchestrator;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.sonarqube.ws.Webhooks;
import org.sonarqube.ws.client.HttpException;
import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.ws.client.project.DeleteRequest;
+import org.sonarqube.ws.client.projects.DeleteRequest;
import org.sonarqube.ws.client.settings.ResetRequest;
import org.sonarqube.ws.client.settings.SetRequest;
import org.sonarqube.ws.client.webhooks.DeliveriesRequest;
disableGlobalWebhooks();
try {
// delete project and related properties/webhook deliveries
- adminWs.projects().delete(DeleteRequest.builder().setKey(PROJECT_KEY).build());
+ adminWs.projects().delete(new DeleteRequest().setProject(PROJECT_KEY));
} catch (HttpException e) {
// ignore because project may not exist
}