From ba4329be29c76d61cafedd0fb642117fc75b2a4c Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Fri, 1 Dec 2017 17:25:43 +0100 Subject: [PATCH] Remove legacy sonar-ws code for issues --- .../org/sonar/server/issue/ws/TagsAction.java | 16 +- .../sonarqube/ws/client/DefaultWsClient.java | 7 - .../org/sonarqube/ws/client/WsClient.java | 6 - .../ws/client/issue/AddCommentRequest.java | 41 -- .../ws/client/issue/AssignRequest.java | 45 -- .../ws/client/issue/BulkChangeRequest.java | 161 ----- .../ws/client/issue/DoTransitionRequest.java | 41 -- .../ws/client/issue/EditCommentRequest.java | 41 -- .../ws/client/issue/IssuesService.java | 236 ------- .../ws/client/issue/SearchRequest.java | 456 -------------- .../ws/client/issue/SetSeverityRequest.java | 41 -- .../ws/client/issue/SetTypeRequest.java | 41 -- sonar-ws/src/main/protobuf/ws-issues.proto | 5 +- .../ws/client/issue/IssuesServiceTest.java | 164 ----- .../ws/client/issue/SearchRequestTest.java | 588 ------------------ .../analysis/AnalysisEsResilienceTest.java | 6 +- .../authorization/IssuePermissionTest.java | 15 +- .../CrossProjectDuplicationsTest.java | 2 +- .../tests/duplication/DuplicationsTest.java | 2 +- .../tests/issue/CommonRulesTest.java | 6 +- .../tests/issue/IssueActionTest.java | 51 +- .../tests/issue/IssueBulkChangeTest.java | 56 +- .../tests/issue/IssueChangelogTest.java | 3 +- .../issue/IssueFilterOnCommonRulesTest.java | 8 +- .../tests/issue/IssueNotificationsTest.java | 30 +- .../tests/issue/IssueSearchTest.java | 176 +++--- .../sonarqube/tests/issue/IssueTagsTest.java | 32 +- .../tests/issue/IssueTrackingTest.java | 8 +- .../tests/issue/IssueWorkflowTest.java | 39 +- .../issue/OrganizationIssueAssignTest.java | 22 +- .../org/sonarqube/tests/lite/LiteTest.java | 8 +- .../TechnicalDebtInIssueChangelogTest.java | 7 +- .../tests/qualityModel/TechnicalDebtTest.java | 4 +- .../tests/serverSystem/LogsTest.java | 6 +- tests/src/test/java/util/issue/IssueRule.java | 4 +- 35 files changed, 246 insertions(+), 2128 deletions(-) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AssignRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/BulkChangeRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/DoTransitionRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetSeverityRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetTypeRequest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/issue/SearchRequestTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/TagsAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/TagsAction.java index f208ca97812..de2f6ba3f98 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/TagsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/TagsAction.java @@ -38,7 +38,10 @@ import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; import org.sonar.server.issue.index.IssueIndex; import org.sonar.server.rule.index.RuleIndex; +import org.sonar.server.ws.WsUtils; +import org.sonarqube.ws.Issues; +import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION; @@ -58,14 +61,6 @@ public class TagsAction implements IssuesWsAction { this.dbClient = dbClient; } - private static void writeResponse(Response response, List tags) { - try (JsonWriter json = response.newJsonWriter()) { - json.beginObject().name("tags").beginArray(); - tags.forEach(json::value); - json.endArray().endObject(); - } - } - @Override public void define(WebService.NewController controller) { NewAction action = controller.createAction("tags") @@ -89,7 +84,10 @@ public class TagsAction implements IssuesWsAction { int pageSize = request.mandatoryParamAsInt("ps"); OrganizationDto organization = getOrganization(request.param(PARAM_ORGANIZATION)); List tags = listTags(organization, query, pageSize == 0 ? Integer.MAX_VALUE : pageSize); - writeResponse(response, tags); + + Issues.TagsResponse.Builder tagsResponseBuilder = Issues.TagsResponse.newBuilder(); + tags.forEach(tagsResponseBuilder::addTags); + writeProtobuf(tagsResponseBuilder.build(), request, response); } private List listTags(@Nullable OrganizationDto organization, @Nullable String textQuery, int pageSize) { 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 272371378cc..6c3aea44441 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 @@ -60,7 +60,6 @@ class DefaultWsClient implements WsClient { private final FavoritesService favoritesService; private final QualityProfilesService qualityProfilesOld; private final QualityprofilesService qualityprofiles; - private final org.sonarqube.ws.client.issue.IssuesService issuesOld; private final IssuesService issues; private final UsersService usersService; private final UserGroupsService userGroupsService; @@ -90,7 +89,6 @@ class DefaultWsClient implements WsClient { this.favoritesService = new FavoritesService(wsConnector); this.qualityProfilesOld = new QualityProfilesService(wsConnector); this.qualityprofiles = new QualityprofilesService(wsConnector); - this.issuesOld = new org.sonarqube.ws.client.issue.IssuesService(wsConnector); this.issues = new IssuesService(wsConnector); this.usersService = new UsersService(wsConnector); this.userGroupsService = new UserGroupsService(wsConnector); @@ -152,11 +150,6 @@ class DefaultWsClient implements WsClient { return qualityprofiles; } - @Override - public org.sonarqube.ws.client.issue.IssuesService issuesOld() { - return issuesOld; - } - @Override public IssuesService issues() { return issues; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index ad4ad79e3a1..505c15111cc 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -70,12 +70,6 @@ public interface WsClient { FavoritesService favorites(); - /** - * @deprecated since 7.0 use {@link #issues()} instead - */ - @Deprecated - org.sonarqube.ws.client.issue.IssuesService issuesOld(); - IssuesService issues(); NotificationsService notifications(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java deleted file mode 100644 index cc6a862d5b4..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.ws.client.issue; - -import static java.util.Objects.requireNonNull; - -public class AddCommentRequest { - - private final String issue; - private final String text; - - public AddCommentRequest(String issue, String text) { - this.issue = requireNonNull(issue, "Issue key cannot be null"); - this.text = requireNonNull(text, "Text cannot be null"); - } - - public String getIssue() { - return issue; - } - - public String getText() { - return text; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AssignRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AssignRequest.java deleted file mode 100644 index 2434267df5a..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AssignRequest.java +++ /dev/null @@ -1,45 +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.issue; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static java.util.Objects.requireNonNull; - -public class AssignRequest { - - private final String issue; - private final String assignee; - - public AssignRequest(String issue, @Nullable String assignee) { - this.issue = requireNonNull(issue, "Issue key cannot be null"); - this.assignee = assignee; - } - - public String getIssue() { - return issue; - } - - @CheckForNull - public String getAssignee() { - return assignee; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/BulkChangeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/BulkChangeRequest.java deleted file mode 100644 index a6ec273c3f3..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/BulkChangeRequest.java +++ /dev/null @@ -1,161 +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.issue; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Lists.newArrayList; -import static java.util.Objects.requireNonNull; - -public class BulkChangeRequest { - - private final List issues; - private final String assign; - private final String setSeverity; - private final String setType; - private final String doTransition; - private final List addTags; - private final List removeTags; - private final String comment; - private final Boolean sendNotifications; - - private BulkChangeRequest(Builder builder) { - this.issues = builder.issues; - this.assign = builder.assign; - this.setSeverity = builder.setSeverity; - this.setType = builder.setType; - this.doTransition = builder.doTransition; - this.addTags = builder.addTags; - this.removeTags = builder.removeTags; - this.comment = builder.comment; - this.sendNotifications = builder.sendNotifications; - } - - public List getIssues() { - return issues; - } - - @CheckForNull - public String getAssign() { - return assign; - } - - @CheckForNull - public String getSetSeverity() { - return setSeverity; - } - - @CheckForNull - public String getSetType() { - return setType; - } - - @CheckForNull - public String getDoTransition() { - return doTransition; - } - - public List getAddTags() { - return addTags; - } - - public List getRemoveTags() { - return removeTags; - } - - @CheckForNull - public String getComment() { - return comment; - } - - @CheckForNull - public Boolean getSendNotifications() { - return sendNotifications; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private List issues; - private String assign; - private String setSeverity; - private String setType; - private String doTransition; - private List addTags = newArrayList(); - private List removeTags = newArrayList(); - private String comment; - private Boolean sendNotifications; - - public Builder setIssues(List issues) { - this.issues = issues; - return this; - } - - public Builder setAssign(@Nullable String assign) { - this.assign = assign; - return this; - } - - public Builder setSetSeverity(@Nullable String setSeverity) { - this.setSeverity = setSeverity; - return this; - } - - public Builder setSetType(@Nullable String setType) { - this.setType = setType; - return this; - } - - public Builder setDoTransition(@Nullable String doTransition) { - this.doTransition = doTransition; - return this; - } - - public Builder setAddTags(List addTags) { - this.addTags = requireNonNull(addTags); - return this; - } - - public Builder setRemoveTags(List removeTags) { - this.removeTags = requireNonNull(removeTags); - return this; - } - - public Builder setComment(@Nullable String comment) { - this.comment = comment; - return this; - } - - public Builder setSendNotifications(@Nullable Boolean sendNotifications) { - this.sendNotifications = sendNotifications; - return this; - } - - public BulkChangeRequest build() { - checkArgument(issues != null && !issues.isEmpty(), "Issue keys must be provided"); - return new BulkChangeRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/DoTransitionRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/DoTransitionRequest.java deleted file mode 100644 index 26a372cab5f..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/DoTransitionRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.ws.client.issue; - -import static java.util.Objects.requireNonNull; - -public class DoTransitionRequest { - - private final String issue; - private final String transition; - - public DoTransitionRequest(String issue, String transition) { - this.issue = requireNonNull(issue, "Issue key cannot be null"); - this.transition = requireNonNull(transition, "Transition cannot be null"); - } - - public String getIssue() { - return issue; - } - - public String getTransition() { - return transition; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java deleted file mode 100644 index 0254a35d180..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.ws.client.issue; - -import static java.util.Objects.requireNonNull; - -public class EditCommentRequest { - - private final String comment; - private final String text; - - public EditCommentRequest(String comment, String text) { - this.comment = requireNonNull(comment, "Comment key cannot be null"); - this.text = requireNonNull(text, "Text cannot be null"); - } - - public String getComment() { - return comment; - } - - public String getText() { - return text; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java deleted file mode 100644 index 4cc625cbd23..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java +++ /dev/null @@ -1,236 +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.issue; - -import java.util.Arrays; -import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.sonarqube.ws.Issues; -import org.sonarqube.ws.Issues.ChangelogWsResponse; -import org.sonarqube.ws.Issues.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 org.sonarqube.ws.client.WsResponse; - -import static org.sonar.api.server.ws.WebService.Param.FACETS; -import static org.sonar.api.server.ws.WebService.Param.PAGE; -import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; -import static org.sonar.api.server.ws.WebService.Param.SORT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_ADD_COMMENT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_ASSIGN; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_BULK_CHANGE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_CHANGELOG; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_DELETE_COMMENT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_DO_TRANSITION; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_EDIT_COMMENT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SEARCH; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_SEVERITY; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_TAGS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_TYPE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_TAGS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.CONTROLLER_ISSUES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.DEPRECATED_PARAM_ACTION_PLANS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.FACET_MODE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ADDITIONAL_FIELDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ADD_TAGS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASC; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGN; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNED; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_AUTHORS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMMENT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_ROOTS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_ROOT_UUIDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_UUIDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_BEFORE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_IN_LAST; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DIRECTORIES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DO_TRANSITION; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILE_UUIDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_LANGUAGES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_MODULE_UUIDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ON_COMPONENT_ONLY; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ORGANIZATION; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECT_KEYS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECT_UUIDS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_REMOVE_TAGS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLUTIONS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLVED; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEND_NOTIFICATIONS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SET_SEVERITY; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SET_TYPE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITIES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITY; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TAGS; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TEXT; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TRANSITION; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TYPE; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TYPES; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.issues.IssuesService} instead - */ -@Deprecated -public class IssuesService extends BaseService { - - public IssuesService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER_ISSUES); - } - - public Issues.Operation addComment(AddCommentRequest request) { - return call(new PostRequest(path(ACTION_ADD_COMMENT)) - .setParam(PARAM_ISSUE, request.getIssue()) - .setParam(PARAM_TEXT, request.getText()), - Issues.Operation.parser()); - } - - public Issues.Operation assign(AssignRequest request) { - return call(new PostRequest(path(ACTION_ASSIGN)) - .setParam(PARAM_ISSUE, request.getIssue()) - .setParam(PARAM_ASSIGNEE, request.getAssignee()), - Issues.Operation.parser()); - } - - public Issues.BulkChangeWsResponse bulkChange(BulkChangeRequest request) { - return call(new PostRequest(path(ACTION_BULK_CHANGE)) - .setParam(PARAM_ISSUES, inlineMultipleParamValue(request.getIssues())) - .setParam(PARAM_ASSIGN, request.getAssign()) - .setParam(PARAM_SET_SEVERITY, request.getSetSeverity()) - .setParam(PARAM_SET_TYPE, request.getSetType()) - .setParam(PARAM_DO_TRANSITION, request.getDoTransition()) - .setParam(PARAM_ADD_TAGS, inlineMultipleParamValue(request.getAddTags())) - .setParam(PARAM_REMOVE_TAGS, inlineMultipleParamValue(request.getRemoveTags())) - .setParam(PARAM_COMMENT, request.getComment()) - .setParam(PARAM_SEND_NOTIFICATIONS, request.getSendNotifications()), - Issues.BulkChangeWsResponse.parser()); - } - - public ChangelogWsResponse changelog(String issueKey) { - return call(new GetRequest(path(ACTION_CHANGELOG)) - .setParam(PARAM_ISSUE, issueKey), - ChangelogWsResponse.parser()); - } - - public Issues.Operation doTransition(DoTransitionRequest request) { - return call(new PostRequest(path(ACTION_DO_TRANSITION)) - .setParam(PARAM_ISSUE, request.getIssue()) - .setParam(PARAM_TRANSITION, request.getTransition()), - Issues.Operation.parser()); - } - - public Issues.Operation deleteComment(String commentKey) { - return call(new PostRequest(path(ACTION_DELETE_COMMENT)) - .setParam(PARAM_COMMENT, commentKey), - Issues.Operation.parser()); - } - - public Issues.Operation editComment(EditCommentRequest request) { - return call(new PostRequest(path(ACTION_EDIT_COMMENT)) - .setParam(PARAM_COMMENT, request.getComment()) - .setParam(PARAM_TEXT, request.getText()), - Issues.Operation.parser()); - } - - public SearchWsResponse search(SearchRequest request) { - return call( - new GetRequest(path(ACTION_SEARCH)) - .setParam(DEPRECATED_PARAM_ACTION_PLANS, inlineMultipleParamValue(request.getActionPlans())) - .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields())) - .setParam(PARAM_ASC, request.getAsc()) - .setParam(PARAM_ASSIGNED, request.getAssigned()) - .setParam(PARAM_ASSIGNEES, inlineMultipleParamValue(request.getAssignees())) - .setParam(PARAM_AUTHORS, inlineMultipleParamValue(request.getAuthors())) - .setParam(PARAM_COMPONENT_KEYS, inlineMultipleParamValue(request.getComponentKeys())) - .setParam(PARAM_COMPONENT_ROOT_UUIDS, inlineMultipleParamValue(request.getComponentRootUuids())) - .setParam(PARAM_COMPONENT_ROOTS, inlineMultipleParamValue(request.getComponentRoots())) - .setParam(PARAM_COMPONENT_UUIDS, inlineMultipleParamValue(request.getComponentUuids())) - .setParam(PARAM_COMPONENTS, inlineMultipleParamValue(request.getComponents())) - .setParam(PARAM_CREATED_AFTER, request.getCreatedAfter()) - .setParam(PARAM_CREATED_AT, request.getCreatedAt()) - .setParam(PARAM_CREATED_BEFORE, request.getCreatedBefore()) - .setParam(PARAM_CREATED_IN_LAST, request.getCreatedInLast()) - .setParam(PARAM_DIRECTORIES, inlineMultipleParamValue(request.getDirectories())) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(FACET_MODE, request.getFacetMode()) - .setParam(FACETS, inlineMultipleParamValue(request.getFacets())) - .setParam(PARAM_FILE_UUIDS, inlineMultipleParamValue(request.getFileUuids())) - .setParam(PARAM_ISSUES, inlineMultipleParamValue(request.getIssues())) - .setParam(PARAM_LANGUAGES, inlineMultipleParamValue(request.getLanguages())) - .setParam(PARAM_MODULE_UUIDS, inlineMultipleParamValue(request.getModuleUuids())) - .setParam(PARAM_ON_COMPONENT_ONLY, request.getOnComponentOnly()) - .setParam(PAGE, request.getPage()) - .setParam(PAGE_SIZE, request.getPageSize()) - .setParam(PARAM_PROJECT_KEYS, inlineMultipleParamValue(request.getProjectKeys())) - .setParam(PARAM_PROJECT_UUIDS, inlineMultipleParamValue(request.getProjectUuids())) - .setParam(PARAM_PROJECTS, inlineMultipleParamValue(request.getProjects())) - .setParam(PARAM_RESOLUTIONS, inlineMultipleParamValue(request.getResolutions())) - .setParam(PARAM_RESOLVED, request.getResolved()) - .setParam(PARAM_RULES, inlineMultipleParamValue(request.getRules())) - .setParam(SORT, request.getSort()) - .setParam(PARAM_SEVERITIES, inlineMultipleParamValue(request.getSeverities())) - .setParam(PARAM_SINCE_LEAK_PERIOD, request.getSinceLeakPeriod()) - .setParam(PARAM_STATUSES, inlineMultipleParamValue(request.getStatuses())) - .setParam(PARAM_TAGS, inlineMultipleParamValue(request.getTags())) - .setParam(PARAM_TYPES, inlineMultipleParamValue(request.getTypes())), - SearchWsResponse.parser()); - } - - public Issues.Operation setSeverity(SetSeverityRequest request) { - return call(new PostRequest(path(ACTION_SET_SEVERITY)) - .setParam(PARAM_ISSUE, request.getIssue()) - .setParam(PARAM_SEVERITY, request.getSeverity()), - Issues.Operation.parser()); - } - - public Issues.Operation setType(SetTypeRequest request) { - return call(new PostRequest(path(ACTION_SET_TYPE)) - .setParam(PARAM_ISSUE, request.getIssue()) - .setParam(PARAM_TYPE, request.getType()), - Issues.Operation.parser()); - } - - - public Issues.Operation setTags(String issue, String... tags) { - return call(new PostRequest(path(ACTION_SET_TAGS)) - .setParam(PARAM_ISSUE, issue) - .setParam(PARAM_TAGS, Arrays.stream(tags).collect(Collectors.joining(","))), - Issues.Operation.parser()); - } - - public WsResponse getTags(@Nullable String organization) { - return call(new PostRequest(path(ACTION_TAGS)) - .setParam(PARAM_ORGANIZATION, organization) - ); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SearchRequest.java deleted file mode 100644 index 841e00791da..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SearchRequest.java +++ /dev/null @@ -1,456 +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.issue; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SearchRequest { - private List actionPlans; - private List additionalFields; - private Boolean asc; - private Boolean assigned; - private List assignees; - private List authors; - private List componentKeys; - private List componentRootUuids; - private List componentRoots; - private List componentUuids; - private List components; - private String createdAfter; - private String createdAt; - private String createdBefore; - private String createdInLast; - private List directories; - private String facetMode; - private List facets; - private List fileUuids; - private List issues; - private List languages; - private List moduleUuids; - private Boolean onComponentOnly; - private String branch; - private String organization; - private Integer page; - private Integer pageSize; - private List projectKeys; - private List projectUuids; - private List projects; - private List resolutions; - private Boolean resolved; - private List rules; - private Boolean sinceLeakPeriod; - private String sort; - private List severities; - private List statuses; - private List tags; - private List types; - - @CheckForNull - public List getActionPlans() { - return actionPlans; - } - - public SearchRequest setActionPlans(@Nullable List actionPlans) { - this.actionPlans = actionPlans; - return this; - } - - @CheckForNull - public List getAdditionalFields() { - return additionalFields; - } - - public SearchRequest setAdditionalFields(@Nullable List additionalFields) { - this.additionalFields = additionalFields; - return this; - } - - @CheckForNull - public Boolean getAsc() { - return asc; - } - - public SearchRequest setAsc(boolean asc) { - this.asc = asc; - return this; - } - - @CheckForNull - public Boolean getAssigned() { - return assigned; - } - - public SearchRequest setAssigned(@Nullable Boolean assigned) { - this.assigned = assigned; - return this; - } - - @CheckForNull - public List getAssignees() { - return assignees; - } - - public SearchRequest setAssignees(@Nullable List assignees) { - this.assignees = assignees; - return this; - } - - @CheckForNull - public List getAuthors() { - return authors; - } - - public SearchRequest setAuthors(@Nullable List authors) { - this.authors = authors; - return this; - } - - @CheckForNull - public List getComponentKeys() { - return componentKeys; - } - - public SearchRequest setComponentKeys(@Nullable List componentKeys) { - this.componentKeys = componentKeys; - return this; - } - - @CheckForNull - public List getComponentUuids() { - return componentUuids; - } - - public SearchRequest setComponentUuids(@Nullable List componentUuids) { - this.componentUuids = componentUuids; - return this; - } - - @CheckForNull - public String getCreatedAfter() { - return createdAfter; - } - - public SearchRequest setCreatedAfter(@Nullable String createdAfter) { - this.createdAfter = createdAfter; - return this; - } - - @CheckForNull - public String getCreatedAt() { - return createdAt; - } - - public SearchRequest setCreatedAt(@Nullable String createdAt) { - this.createdAt = createdAt; - return this; - } - - @CheckForNull - public String getCreatedBefore() { - return createdBefore; - } - - public SearchRequest setCreatedBefore(@Nullable String createdBefore) { - this.createdBefore = createdBefore; - return this; - } - - @CheckForNull - public String getCreatedInLast() { - return createdInLast; - } - - public SearchRequest setCreatedInLast(@Nullable String createdInLast) { - this.createdInLast = createdInLast; - return this; - } - - @CheckForNull - public List getDirectories() { - return directories; - } - - public SearchRequest setDirectories(@Nullable List directories) { - this.directories = directories; - return this; - } - - @CheckForNull - public String getFacetMode() { - return facetMode; - } - - public SearchRequest setFacetMode(@Nullable String facetMode) { - this.facetMode = facetMode; - return this; - } - - @CheckForNull - public List getFacets() { - return facets; - } - - public SearchRequest setFacets(@Nullable List facets) { - this.facets = facets; - return this; - } - - @CheckForNull - public List getFileUuids() { - return fileUuids; - } - - public SearchRequest setFileUuids(@Nullable List fileUuids) { - this.fileUuids = fileUuids; - return this; - } - - @CheckForNull - public List getIssues() { - return issues; - } - - public SearchRequest setIssues(@Nullable List issues) { - this.issues = issues; - return this; - } - - @CheckForNull - public List getLanguages() { - return languages; - } - - public SearchRequest setLanguages(@Nullable List languages) { - this.languages = languages; - return this; - } - - @CheckForNull - public List getModuleUuids() { - return moduleUuids; - } - - public SearchRequest setModuleUuids(@Nullable List moduleUuids) { - this.moduleUuids = moduleUuids; - return this; - } - - @CheckForNull - public Boolean getOnComponentOnly() { - return onComponentOnly; - } - - public SearchRequest setOnComponentOnly(Boolean onComponentOnly) { - this.onComponentOnly = onComponentOnly; - return this; - } - - @CheckForNull - public String getOrganization() { - return organization; - } - - public SearchRequest setOrganization(@Nullable String s) { - this.organization = s; - return this; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - public SearchRequest setPage(int page) { - this.page = page; - return this; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public SearchRequest setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @CheckForNull - public List getProjectKeys() { - return projectKeys; - } - - public SearchRequest setProjectKeys(@Nullable List projectKeys) { - this.projectKeys = projectKeys; - return this; - } - - @CheckForNull - public List getProjectUuids() { - return projectUuids; - } - - public SearchRequest setProjectUuids(@Nullable List projectUuids) { - this.projectUuids = projectUuids; - return this; - } - - @CheckForNull - public List getResolutions() { - return resolutions; - } - - public SearchRequest setResolutions(@Nullable List resolutions) { - this.resolutions = resolutions; - return this; - } - - @CheckForNull - public Boolean getResolved() { - return resolved; - } - - public SearchRequest setResolved(@Nullable Boolean resolved) { - this.resolved = resolved; - return this; - } - - @CheckForNull - public List getRules() { - return rules; - } - - public SearchRequest setRules(@Nullable List rules) { - this.rules = rules; - return this; - } - - @CheckForNull - public Boolean getSinceLeakPeriod() { - return sinceLeakPeriod; - } - - public SearchRequest setSinceLeakPeriod(@Nullable Boolean sinceLeakPeriod) { - this.sinceLeakPeriod = sinceLeakPeriod; - return this; - } - - @CheckForNull - public String getSort() { - return sort; - } - - public SearchRequest setSort(@Nullable String sort) { - this.sort = sort; - return this; - } - - @CheckForNull - public List getSeverities() { - return severities; - } - - public SearchRequest setSeverities(@Nullable List severities) { - this.severities = severities; - return this; - } - - @CheckForNull - public List getStatuses() { - return statuses; - } - - public SearchRequest setStatuses(@Nullable List statuses) { - this.statuses = statuses; - return this; - } - - @CheckForNull - public List getTags() { - return tags; - } - - public SearchRequest setTags(@Nullable List tags) { - this.tags = tags; - return this; - } - - @CheckForNull - public List getTypes() { - return types; - } - - public SearchRequest setTypes(@Nullable List types) { - this.types = types; - return this; - } - - @CheckForNull - public List getComponentRootUuids() { - return componentRootUuids; - } - - public SearchRequest setComponentRootUuids(List componentRootUuids) { - this.componentRootUuids = componentRootUuids; - return this; - } - - @CheckForNull - public List getComponentRoots() { - return componentRoots; - } - - public SearchRequest setComponentRoots(@Nullable List componentRoots) { - this.componentRoots = componentRoots; - return this; - } - - @CheckForNull - public List getComponents() { - return components; - } - - public SearchRequest setComponents(@Nullable List components) { - this.components = components; - return this; - } - - @CheckForNull - public List getProjects() { - return projects; - } - - public SearchRequest setProjects(@Nullable List projects) { - this.projects = projects; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public SearchRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetSeverityRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetSeverityRequest.java deleted file mode 100644 index e65a4503c48..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetSeverityRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.ws.client.issue; - -import static java.util.Objects.requireNonNull; - -public class SetSeverityRequest { - - private final String issue; - private final String severity; - - public SetSeverityRequest(String issue, String severity) { - this.issue = requireNonNull(issue, "Issue key cannot be null"); - this.severity = requireNonNull(severity, "Severity cannot be null"); - } - - public String getIssue() { - return issue; - } - - public String getSeverity() { - return severity; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetTypeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetTypeRequest.java deleted file mode 100644 index a7035f3063f..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/SetTypeRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.ws.client.issue; - -import static java.util.Objects.requireNonNull; - -public class SetTypeRequest { - - private final String issue; - private final String type; - - public SetTypeRequest(String issue, String type) { - this.issue = requireNonNull(issue, "Issue key cannot be null"); - this.type = requireNonNull(type, "Type cannot be null"); - } - - public String getIssue() { - return issue; - } - - public String getType() { - return type; - } -} diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index 8d58b8b935b..c869c9c1ff3 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -104,10 +104,7 @@ message SetTypeResponse { repeated Users.User users = 4; } message TagsResponse { - optional Issue issue = 1; - repeated Component components = 2; - repeated sonarqube.ws.commons.Rule rules = 3; - repeated Users.User users = 4; + repeated string tags = 1; } message Issue { diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java deleted file mode 100644 index 069c6223536..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java +++ /dev/null @@ -1,164 +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.issue; - -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.Issues; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class IssuesServiceTest { - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new IssuesService(mock(WsConnector.class))); - - private IssuesService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void add_comment() { - underTest.addComment(new AddCommentRequest("ABCD", "Please help me to fix this issue")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("issue", "ABCD") - .hasParam("text", "Please help me to fix this issue") - .andNoOtherParam(); - } - - @Test - public void assign() { - underTest.assign(new AssignRequest("ABCD", "teryk")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("issue", "ABCD") - .hasParam("assignee", "teryk") - .andNoOtherParam(); - } - - @Test - public void bulk_change() { - underTest.bulkChange(BulkChangeRequest.builder() - .setIssues(asList("ABCD", "EFGH")) - .setAssign("john") - .setSetSeverity("MAJOR") - .setSetType("bugs") - .setDoTransition("confirm") - .setAddTags(asList("tag1", "tag2")) - .setRemoveTags(asList("tag3", "tag4")) - .setComment("some comment") - .setSendNotifications(true) - .build()); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.BulkChangeWsResponse.parser()); - serviceTester.assertThat(request) - .hasParam("issues", "ABCD,EFGH") - .hasParam("assign", "john") - .hasParam("set_severity", "MAJOR") - .hasParam("set_type", "bugs") - .hasParam("do_transition", "confirm") - .hasParam("add_tags", "tag1,tag2") - .hasParam("remove_tags", "tag3,tag4") - .hasParam("comment", "some comment") - .hasParam("sendNotifications", "true") - .andNoOtherParam(); - } - - @Test - public void changelog() { - underTest.changelog("ABCD"); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(Issues.ChangelogWsResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam("issue", "ABCD") - .andNoOtherParam(); - } - - @Test - public void do_transition() { - underTest.doTransition(new DoTransitionRequest("ABCD", "confirm")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("issue", "ABCD") - .hasParam("transition", "confirm") - .andNoOtherParam(); - } - - @Test - public void delete_comment() { - underTest.deleteComment("ABCD"); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("comment", "ABCD") - .andNoOtherParam(); - } - - @Test - public void edit_comment() { - underTest.editComment(new EditCommentRequest("ABCD", "Please help me to fix this issue")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("comment", "ABCD") - .hasParam("text", "Please help me to fix this issue") - .andNoOtherParam(); - } - - @Test - public void set_severity() { - underTest.setSeverity(new SetSeverityRequest("ABCD", "confirm")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("issue", "ABCD") - .hasParam("severity", "confirm") - .andNoOtherParam(); - } - - @Test - public void set_type() { - underTest.setType(new SetTypeRequest("ABCD", "bugs")); - PostRequest request = serviceTester.getPostRequest(); - - assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser()); - serviceTester.assertThat(request) - .hasParam("issue", "ABCD") - .hasParam("type", "bugs") - .andNoOtherParam(); - } - -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/SearchRequestTest.java deleted file mode 100644 index b4228376693..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/SearchRequestTest.java +++ /dev/null @@ -1,588 +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.issue; - -import com.google.common.collect.ImmutableList; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SearchRequestTest { - private static final ImmutableList LIST_OF_STRINGS = ImmutableList.of("A", "B"); - private static final String SOME_STRING = "some string"; - public static final int SOME_INT = 894352; - - private SearchRequest underTest = new SearchRequest(); - - @Test - public void getActionPlans_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getActionPlans()).isNull(); - } - - @Test - public void setActionPlans_accepts_null() { - underTest.setActionPlans(null); - } - - @Test - public void getActionPlans_returns_object_from_setActionPlans() { - underTest.setActionPlans(LIST_OF_STRINGS); - - assertThat(underTest.getActionPlans()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getAdditionalFields_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getAdditionalFields()).isNull(); - } - - @Test - public void setAdditionalFields_accepts_null() { - underTest.setAdditionalFields(null); - } - - @Test - public void getAdditionalFields_returns_object_from_setAdditionalFields() { - underTest.setAdditionalFields(LIST_OF_STRINGS); - assertThat(underTest.getAdditionalFields()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getAssignees_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getAssignees()).isNull(); - } - - @Test - public void setAssignees_accepts_null() { - underTest.setAssignees(null); - } - - @Test - public void getAssignees_returns_object_from_setAssignees() { - underTest.setAssignees(LIST_OF_STRINGS); - assertThat(underTest.getAssignees()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getAuthors_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getAuthors()).isNull(); - } - - @Test - public void setAuthors_accepts_null() { - underTest.setAuthors(null); - } - - @Test - public void getAuthors_returns_object_from_setAuthors() { - underTest.setAuthors(LIST_OF_STRINGS); - assertThat(underTest.getAuthors()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getComponentKeys_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getComponentKeys()).isNull(); - } - - @Test - public void setComponentKeys_accepts_null() { - underTest.setComponentKeys(null); - } - - @Test - public void getComponentKeys_returns_object_from_setComponentKeys() { - underTest.setComponentKeys(LIST_OF_STRINGS); - assertThat(underTest.getComponentKeys()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getComponentRootUuids_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getComponentRootUuids()).isNull(); - } - - @Test - public void setComponentRootUuids_accepts_null() { - underTest.setComponentRootUuids(null); - } - - @Test - public void getComponentRootUuids_returns_object_from_setComponentRootUuids() { - underTest.setComponentRootUuids(LIST_OF_STRINGS); - assertThat(underTest.getComponentRootUuids()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getComponentRoots_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getComponentRoots()).isNull(); - } - - @Test - public void setComponentRoots_accepts_null() { - underTest.setComponentRoots(null); - } - - @Test - public void getComponentRoots_returns_object_from_setComponentRoots() { - underTest.setComponentRoots(LIST_OF_STRINGS); - assertThat(underTest.getComponentRoots()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getComponentUuids_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getComponentUuids()).isNull(); - } - - @Test - public void setComponentUuids_accepts_null() { - underTest.setComponentUuids(null); - } - - @Test - public void getComponentUuids_returns_object_from_setComponentUuids() { - underTest.setComponentUuids(LIST_OF_STRINGS); - assertThat(underTest.getComponentUuids()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getComponents_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getComponents()).isNull(); - } - - @Test - public void setComponents_accepts_null() { - underTest.setComponents(null); - } - - @Test - public void getComponents_returns_object_from_setComponents() { - underTest.setComponents(LIST_OF_STRINGS); - assertThat(underTest.getComponents()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getDirectories_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getDirectories()).isNull(); - } - - @Test - public void setDirectories_accepts_null() { - underTest.setDirectories(null); - } - - @Test - public void getDirectories_returns_object_from_setDirectories() { - underTest.setDirectories(LIST_OF_STRINGS); - assertThat(underTest.getDirectories()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getFacets_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getFacets()).isNull(); - } - - @Test - public void setFacets_accepts_null() { - underTest.setFacets(null); - } - - @Test - public void getFacets_returns_object_from_setFacets() { - underTest.setFacets(LIST_OF_STRINGS); - assertThat(underTest.getFacets()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getFileUuids_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getFileUuids()).isNull(); - } - - @Test - public void setFileUuids_accepts_null() { - underTest.setFileUuids(null); - } - - @Test - public void getFileUuids_returns_object_from_setFileUuids() { - underTest.setFileUuids(LIST_OF_STRINGS); - assertThat(underTest.getFileUuids()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getIssues_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getIssues()).isNull(); - } - - @Test - public void setIssues_accepts_null() { - underTest.setIssues(null); - } - - @Test - public void getIssues_returns_object_from_setIssues() { - underTest.setIssues(LIST_OF_STRINGS); - assertThat(underTest.getIssues()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getLanguages_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getLanguages()).isNull(); - } - - @Test - public void setLanguages_accepts_null() { - underTest.setLanguages(null); - } - - @Test - public void getLanguages_returns_object_from_setLanguages() { - underTest.setLanguages(LIST_OF_STRINGS); - assertThat(underTest.getLanguages()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getModuleUuids_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getModuleUuids()).isNull(); - } - - @Test - public void setModuleUuids_accepts_null() { - underTest.setModuleUuids(null); - } - - @Test - public void getModuleUuids_returns_object_from_setModuleUuids() { - underTest.setModuleUuids(LIST_OF_STRINGS); - assertThat(underTest.getModuleUuids()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getProjectKeys_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getProjectKeys()).isNull(); - } - - @Test - public void setProjectKeys_accepts_null() { - underTest.setProjectKeys(null); - } - - @Test - public void getProjectKeys_returns_object_from_setProjectKeys() { - underTest.setProjectKeys(LIST_OF_STRINGS); - assertThat(underTest.getProjectKeys()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getProjectUuids_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getProjectUuids()).isNull(); - } - - @Test - public void setProjectUuids_accepts_null() { - underTest.setProjectUuids(null); - } - - @Test - public void getProjectUuids_returns_object_from_setProjectUuids() { - underTest.setProjectUuids(LIST_OF_STRINGS); - assertThat(underTest.getProjectUuids()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getProjects_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getProjects()).isNull(); - } - - @Test - public void setProjects_accepts_null() { - underTest.setProjects(null); - } - - @Test - public void getProjects_returns_object_from_setProjects() { - underTest.setProjects(LIST_OF_STRINGS); - assertThat(underTest.getProjects()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getResolutions_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getResolutions()).isNull(); - } - - @Test - public void setResolutions_accepts_null() { - underTest.setResolutions(null); - } - - @Test - public void getResolutions_returns_object_from_setResolutions() { - underTest.setResolutions(LIST_OF_STRINGS); - assertThat(underTest.getResolutions()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getRules_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getRules()).isNull(); - } - - @Test - public void setRules_accepts_null() { - underTest.setRules(null); - } - - @Test - public void getRules_returns_object_from_setRules() { - underTest.setRules(LIST_OF_STRINGS); - assertThat(underTest.getRules()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getSeverities_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getSeverities()).isNull(); - } - - @Test - public void setSeverities_accepts_null() { - underTest.setSeverities(null); - } - - @Test - public void getSeverities_returns_object_from_setSeverities() { - underTest.setSeverities(LIST_OF_STRINGS); - assertThat(underTest.getSeverities()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getStatuses_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getStatuses()).isNull(); - } - - @Test - public void setStatuses_accepts_null() { - underTest.setStatuses(null); - } - - @Test - public void getStatuses_returns_object_from_setStatuses() { - underTest.setStatuses(LIST_OF_STRINGS); - assertThat(underTest.getStatuses()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getTags_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getTags()).isNull(); - } - - @Test - public void setTags_accepts_null() { - underTest.setTags(null); - } - - @Test - public void getTags_returns_object_from_setTags() { - underTest.setTags(LIST_OF_STRINGS); - assertThat(underTest.getTags()).isSameAs(LIST_OF_STRINGS); - } - - @Test - public void getAsc_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getAsc()).isNull(); - } - - @Test - public void getAsc_returns_boolean_from_setTags() { - underTest.setAsc(true); - assertThat(underTest.getAsc()).isTrue(); - underTest.setAsc(false); - assertThat(underTest.getAsc()).isFalse(); - } - - @Test - public void getAssigned_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getAssigned()).isNull(); - } - - @Test - public void setAssigned_accepts_null() { - underTest.setAssigned(null); - } - - @Test - public void getAssigned_returns_boolean_from_setTags() { - underTest.setAssigned(true); - assertThat(underTest.getAssigned()).isTrue(); - underTest.setAssigned(false); - assertThat(underTest.getAssigned()).isFalse(); - } - - @Test - public void getOnComponentOnly_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getOnComponentOnly()).isNull(); - } - - @Test - public void setOnComponentOnly_accepts_null() { - underTest.setOnComponentOnly(null); - } - - @Test - public void getOnComponentOnly_returns_boolean_from_setOnComponentOnly() { - underTest.setOnComponentOnly(true); - assertThat(underTest.getOnComponentOnly()).isTrue(); - underTest.setOnComponentOnly(false); - assertThat(underTest.getOnComponentOnly()).isFalse(); - } - - @Test - public void getResolved_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getResolved()).isNull(); - } - - @Test - public void setResolved_accepts_null() { - underTest.setResolved(null); - } - - @Test - public void getResolved_returns_boolean_from_setResolved() { - underTest.setResolved(true); - assertThat(underTest.getResolved()).isTrue(); - underTest.setResolved(false); - assertThat(underTest.getResolved()).isFalse(); - } - - @Test - public void getCreatedAfter_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getCreatedAfter()).isNull(); - } - - @Test - public void setCreatedAfter_accepts_null() { - underTest.setCreatedAfter(null); - } - - @Test - public void getCreatedAfter_returns_object_from_setCreatedAfter() { - underTest.setCreatedAfter(SOME_STRING); - assertThat(underTest.getCreatedAfter()).isEqualTo(SOME_STRING); - } - - @Test - public void getCreatedAt_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getCreatedAt()).isNull(); - } - - @Test - public void setCreatedAt_accepts_null() { - underTest.setCreatedAt(null); - } - - @Test - public void getCreatedAt_returns_object_from_setCreatedAt() { - underTest.setCreatedAt(SOME_STRING); - assertThat(underTest.getCreatedAt()).isEqualTo(SOME_STRING); - } - - @Test - public void getCreatedBefore_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getCreatedBefore()).isNull(); - } - - @Test - public void setCreatedBefore_accepts_null() { - underTest.setCreatedBefore(null); - } - - @Test - public void getCreatedBefore_returns_object_from_setCreatedBefore() { - underTest.setCreatedBefore(SOME_STRING); - assertThat(underTest.getCreatedBefore()).isEqualTo(SOME_STRING); - } - - @Test - public void getCreatedInLast_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getCreatedInLast()).isNull(); - } - - @Test - public void setCreatedInLast_accepts_null() { - underTest.setCreatedInLast(null); - } - - @Test - public void getCreatedInLast_returns_object_from_setCreatedInLast() { - underTest.setCreatedInLast(SOME_STRING); - assertThat(underTest.getCreatedInLast()).isEqualTo(SOME_STRING); - } - - @Test - public void getFacetMode_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getFacetMode()).isNull(); - } - - @Test - public void setFacetMode_accepts_null() { - underTest.setFacetMode(null); - } - - @Test - public void getFacetMode_returns_object_from_setFacetMode() { - underTest.setFacetMode(SOME_STRING); - assertThat(underTest.getFacetMode()).isEqualTo(SOME_STRING); - } - - @Test - public void getSort_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getSort()).isNull(); - } - - @Test - public void setSort_accepts_null() { - underTest.setSort(null); - } - - @Test - public void getSort_returns_object_from_setSort() { - underTest.setSort(SOME_STRING); - assertThat(underTest.getSort()).isEqualTo(SOME_STRING); - } - - @Test - public void getPage_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getPage()).isNull(); - } - - @Test - public void getPage_returns_object_from_setPage() { - underTest.setPage(SOME_INT); - assertThat(underTest.getPage()).isEqualTo(SOME_INT); - } - - @Test - public void getPageSize_returns_null_when_SearchWsRequest_has_just_been_instantiated() { - assertThat(underTest.getPageSize()).isNull(); - } - - @Test - public void getPageSize_returns_object_from_setPageSize() { - underTest.setPageSize(SOME_INT); - assertThat(underTest.getPageSize()).isEqualTo(SOME_INT); - } - -} diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java index e207bc33ba6..bd6bd272a42 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java @@ -46,7 +46,7 @@ import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.ce.TaskRequest; import org.sonarqube.ws.client.components.SuggestionsRequest; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -227,9 +227,9 @@ public class AnalysisEsResilienceTest { private Issues.SearchWsResponse searchIssues(String projectKey) { SearchRequest request = new SearchRequest() - .setProjectKeys(Collections.singletonList(projectKey)) + .setProjects(Collections.singletonList(projectKey)) .setFacets(Collections.singletonList("statuses")); - return tester.wsClient().issuesOld().search(request); + return tester.wsClient().issues().search(request); } private List searchFile(String key) { diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java index 94cccebeba6..a77453f643f 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/IssuePermissionTest.java @@ -32,12 +32,14 @@ import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.user.UserParameters; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; -import org.sonarqube.ws.client.issue.BulkChangeRequest; +import org.sonarqube.ws.client.issues.BulkChangeRequest; +import org.sonarqube.ws.client.issues.ChangelogRequest; import org.sonarqube.ws.client.permission.AddUserRequest; import org.sonarqube.ws.client.project.UpdateVisibilityRequest; import util.ItUtils; import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static junit.framework.TestCase.fail; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newUserWsClient; @@ -256,11 +258,10 @@ public class IssuePermissionTest { } private Issues.BulkChangeWsResponse makeBlockerAndFalsePositive(String user, Issue issueOnPrivateProject, Issue issueOnPublicProject) { - return newUserWsClient(orchestrator, user, "password").issuesOld() - .bulkChange(BulkChangeRequest.builder().setIssues(asList(issueOnPrivateProject.key(), issueOnPublicProject.key())) - .setSetSeverity("BLOCKER") - .setDoTransition("falsepositive") - .build()); + return newUserWsClient(orchestrator, user, "password").issues() + .bulkChange(new BulkChangeRequest().setIssues(asList(issueOnPrivateProject.key(), issueOnPublicProject.key())) + .setSetSeverity(singletonList("BLOCKER")) + .setDoTransition("falsepositive")); } private void addUserPermission(String login, String projectKey, String permission) { @@ -272,6 +273,6 @@ public class IssuePermissionTest { } private static Issues.ChangelogWsResponse changelog(String issueKey, String login, String password) { - return newUserWsClient(orchestrator, login, password).issuesOld().changelog(issueKey); + return newUserWsClient(orchestrator, login, password).issues().changelog(new ChangelogRequest().setIssue(issueKey)); } } diff --git a/tests/src/test/java/org/sonarqube/tests/duplication/CrossProjectDuplicationsTest.java b/tests/src/test/java/org/sonarqube/tests/duplication/CrossProjectDuplicationsTest.java index 934b045de47..683c0220d8a 100644 --- a/tests/src/test/java/org/sonarqube/tests/duplication/CrossProjectDuplicationsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/duplication/CrossProjectDuplicationsTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import util.issue.IssueRule; diff --git a/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java b/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java index 0efe0c0837b..0bbf0426686 100644 --- a/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java @@ -30,7 +30,7 @@ import org.junit.rules.RuleChain; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import util.issue.IssueRule; diff --git a/tests/src/test/java/org/sonarqube/tests/issue/CommonRulesTest.java b/tests/src/test/java/org/sonarqube/tests/issue/CommonRulesTest.java index a18c02e6795..9d5c661c55b 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/CommonRulesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/CommonRulesTest.java @@ -24,7 +24,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -86,9 +86,9 @@ public class CommonRulesTest extends AbstractIssueTest { } private List findIssues(String componentKey, String ruleKey) { - return adminWsClient.issuesOld().search( + return adminWsClient.issues().search( new SearchRequest() - .setComponents(singletonList(componentKey)) + .setComponentKeys(singletonList(componentKey)) .setRules(singletonList(ruleKey))) .getIssuesList(); } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueActionTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueActionTest.java index f4a1a4bc3e0..cfde3901bb6 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueActionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueActionTest.java @@ -24,14 +24,10 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; +import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.Issue; -import org.sonarqube.ws.client.issue.AddCommentRequest; -import org.sonarqube.ws.client.issue.AssignRequest; -import org.sonarqube.ws.client.issue.EditCommentRequest; -import org.sonarqube.ws.client.issue.IssuesService; -import org.sonarqube.ws.client.issue.SearchRequest; -import org.sonarqube.ws.client.issue.SetSeverityRequest; +import org.sonarqube.ws.client.issues.*; import util.ProjectAnalysis; import util.ProjectAnalysisRule; import util.issue.IssueRule; @@ -40,7 +36,6 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.sonarqube.ws.Common.Severity.BLOCKER; -import static util.ItUtils.newAdminWsClient; import static util.ItUtils.toDatetime; public class IssueActionTest extends AbstractIssueTest { @@ -51,6 +46,9 @@ public class IssueActionTest extends AbstractIssueTest { @ClassRule public static final IssueRule issueRule = IssueRule.from(ORCHESTRATOR); + @Rule + public Tester tester = new Tester(ORCHESTRATOR); + private ProjectAnalysis projectAnalysis; private IssuesService issuesService; @@ -63,7 +61,7 @@ public class IssueActionTest extends AbstractIssueTest { this.projectAnalysis = projectAnalysisRule.newProjectAnalysis(projectKey).withQualityProfile(qualityProfileKey); this.projectAnalysis.run(); - this.issuesService = newAdminWsClient(ORCHESTRATOR).issuesOld(); + this.issuesService = tester.wsClient().issues(); this.randomIssue = issueRule.getRandomIssue(); } @@ -74,7 +72,7 @@ public class IssueActionTest extends AbstractIssueTest { @Test public void add_comment() throws Exception { - Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0); + Issues.Comment comment = issuesService.addComment(new AddCommentRequest().setIssue(randomIssue.getKey()).setText("this is my *comment*")).getIssue().getComments().getComments(0); assertThat(comment.getKey()).isNotNull(); assertThat(comment.getHtmlText()).isEqualTo("this is my comment"); assertThat(comment.getLogin()).isEqualTo("admin"); @@ -94,7 +92,7 @@ public class IssueActionTest extends AbstractIssueTest { @Test public void should_reject_blank_comment() throws Exception { try { - issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), " ")); + issuesService.addComment(new AddCommentRequest().setIssue(randomIssue.getKey()).setText(" ")); fail(); } catch (org.sonarqube.ws.client.HttpException ex) { assertThat(ex.code()).isEqualTo(400); @@ -104,29 +102,6 @@ public class IssueActionTest extends AbstractIssueTest { assertThat(reloaded.getComments().getCommentsList()).isEmpty(); } - @Test - public void edit_comment() throws Exception { - Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0); - Issues.Comment editedComment = issuesService.editComment(new EditCommentRequest(comment.getKey(), "new *comment*")).getIssue().getComments().getComments(0); - assertThat(editedComment.getHtmlText()).isEqualTo("new comment"); - - // reload issue - Issue reloaded = issueRule.getByKey(randomIssue.getKey()); - assertThat(reloaded.getComments().getCommentsList()).hasSize(1); - assertThat(reloaded.getComments().getComments(0).getHtmlText()).isEqualTo("new comment"); - } - - @Test - public void delete_comment() throws Exception { - Issues.Comment comment = issuesService.addComment(new AddCommentRequest(randomIssue.getKey(), "this is my *comment*")).getIssue().getComments().getComments(0); - Issue issue = issuesService.deleteComment(comment.getKey()).getIssue(); - assertThat(issue.getComments().getCommentsList()).isEmpty(); - - // reload issue - Issue reloaded = issueRule.getByKey(randomIssue.getKey()); - assertThat(reloaded.getComments().getCommentsList()).isEmpty(); - } - /** * SONAR-4352 */ @@ -138,7 +113,7 @@ public class IssueActionTest extends AbstractIssueTest { assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).isEmpty(); // increase the severity of an issue - issuesService.setSeverity(new SetSeverityRequest(randomIssue.getKey(), "BLOCKER")); + issuesService.setSeverity(new SetSeverityRequest().setIssue(randomIssue.getKey()).setSeverity("BLOCKER")); assertThat(searchIssuesBySeverities(componentKey, "BLOCKER")).hasSize(1); @@ -160,7 +135,7 @@ public class IssueActionTest extends AbstractIssueTest { Issues.SearchWsResponse response = issueRule.search(new SearchRequest().setIssues(singletonList(randomIssue.getKey()))); assertThat(response.getUsers().getUsersList()).isEmpty(); - issuesService.assign(new AssignRequest(randomIssue.getKey(), "admin")); + issuesService.assign(new AssignRequest().setIssue(randomIssue.getKey()).setAssignee("admin")); assertThat(issueRule.search(new SearchRequest().setAssignees(singletonList("admin"))).getIssuesList()).hasSize(1); projectAnalysis.run(); @@ -173,7 +148,7 @@ public class IssueActionTest extends AbstractIssueTest { assertThat(response.getUsers().getUsersList().stream().filter(user -> "Administrator".equals(user.getName())).findFirst()).isPresent(); // unassign - issuesService.assign(new AssignRequest(randomIssue.getKey(), null)); + issuesService.assign(new AssignRequest().setIssue(randomIssue.getKey()).setAssignee(null)); reloaded = issueRule.getByKey(randomIssue.getKey()); assertThat(reloaded.hasAssignee()).isFalse(); assertThat(issueRule.search(new SearchRequest().setAssignees(singletonList("admin"))).getIssuesList()).isEmpty(); @@ -186,7 +161,7 @@ public class IssueActionTest extends AbstractIssueTest { public void fail_assign_if_assignee_does_not_exist() { assertThat(randomIssue.hasAssignee()).isFalse(); try { - issuesService.assign(new AssignRequest(randomIssue.getKey(), "unknown")); + issuesService.assign(new AssignRequest().setIssue(randomIssue.getKey()).setAssignee("unknown")); fail(); } catch (org.sonarqube.ws.client.HttpException ex) { assertThat(ex.code()).isEqualTo(404); @@ -194,7 +169,7 @@ public class IssueActionTest extends AbstractIssueTest { } private static List searchIssuesBySeverities(String projectKey, String severity) { - return issueRule.search(new SearchRequest().setProjectKeys(singletonList(projectKey)).setSeverities(singletonList(severity))).getIssuesList(); + return issueRule.search(new SearchRequest().setProjects(singletonList(projectKey)).setSeverities(singletonList(severity))).getIssuesList(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueBulkChangeTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueBulkChangeTest.java index ab9fee0b3f6..32fc233bb4d 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueBulkChangeTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueBulkChangeTest.java @@ -27,20 +27,21 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.wsclient.base.HttpException; +import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.BulkChangeWsResponse; -import org.sonarqube.ws.client.issue.BulkChangeRequest; -import org.sonarqube.ws.client.issue.IssuesService; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.BulkChangeRequest; +import org.sonarqube.ws.client.issues.IssuesService; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ProjectAnalysis; import util.ProjectAnalysisRule; import util.issue.IssueRule; import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.sonarqube.ws.Common.Severity.BLOCKER; import static org.sonarqube.ws.Issues.Issue; -import static util.ItUtils.newAdminWsClient; /** * SONAR-4421 @@ -60,6 +61,9 @@ public class IssueBulkChangeTest extends AbstractIssueTest { @Rule public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR); + @Rule + public Tester tester = new Tester(ORCHESTRATOR); + private IssuesService issuesService; private ProjectAnalysis xooSampleLittleIssuesAnalysis; @@ -69,7 +73,7 @@ public class IssueBulkChangeTest extends AbstractIssueTest { String projectKey = projectAnalysisRule.registerProject("shared/xoo-sample"); this.xooSampleLittleIssuesAnalysis = projectAnalysisRule.newProjectAnalysis(projectKey) .withQualityProfile(qualityProfileKey); - this.issuesService = newAdminWsClient(ORCHESTRATOR).issuesOld(); + this.issuesService = tester.wsClient().issues(); } @Test @@ -114,11 +118,10 @@ public class IssueBulkChangeTest extends AbstractIssueTest { String newSeverity = "BLOCKER"; String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT); - BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder() + BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(new BulkChangeRequest() .setIssues(asList(issueKeys)) - .setSetSeverity(newSeverity) - .setComment(COMMENT_AS_MARKDOWN) - .build()); + .setSetSeverity(singletonList(newSeverity)) + .setComment(singletonList(COMMENT_AS_MARKDOWN))); assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT); for (Issue issue : issueRule.getByKeys(issueKeys)) { @@ -132,13 +135,12 @@ public class IssueBulkChangeTest extends AbstractIssueTest { xooSampleLittleIssuesAnalysis.run(); String[] issueKeys = searchIssueKeys(BULK_EDITED_ISSUE_COUNT); - BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder() + BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(new BulkChangeRequest() .setIssues(asList(issueKeys)) .setDoTransition("confirm") - .setAssign("admin") - .setSetSeverity("BLOCKER") - .setComment(COMMENT_AS_MARKDOWN) - .build()); + .setAssign(singletonList("admin")) + .setSetSeverity(singletonList("BLOCKER")) + .setComment(singletonList(COMMENT_AS_MARKDOWN))); assertThat(bulkChangeResponse.getSuccess()).isEqualTo(BULK_EDITED_ISSUE_COUNT); for (Issue issue : issueRule.getByKeys(issueKeys)) { @@ -160,7 +162,8 @@ public class IssueBulkChangeTest extends AbstractIssueTest { try { issuesService.bulkChange(createBulkChangeSeverityOfIssuesQuery(issueKeys, newSeverity)); } catch (Exception e) { - assertHttpException(e, 401); + assertThat(e).isInstanceOf(HttpException.class); + assertThat(((HttpException) e).status()).isEqualTo(401); } } @@ -188,9 +191,10 @@ public class IssueBulkChangeTest extends AbstractIssueTest { try { int limit = BULK_EDITED_ISSUE_COUNT; String[] issueKeys = searchIssueKeys(limit); - issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).build()); + issuesService.bulkChange(new BulkChangeRequest().setIssues(asList(issueKeys))); } catch (Exception e) { - assertHttpException(e, 400); + assertThat(e).isInstanceOf(org.sonarqube.ws.client.HttpException.class); + assertThat(((org.sonarqube.ws.client.HttpException) e).code()).isEqualTo(400); } } @@ -204,10 +208,9 @@ public class IssueBulkChangeTest extends AbstractIssueTest { adminIssueClient().doTransition(searchIssues().iterator().next().key(), "confirm"); // Apply a bulk change on unconfirm transition - BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)) + BulkChangeWsResponse bulkChangeResponse = issuesService.bulkChange(new BulkChangeRequest().setIssues(asList(issueKeys)) .setDoTransition("unconfirm") - .setComment("this is my comment") - .build()); + .setComment(singletonList("this is my comment"))); assertThat(bulkChangeResponse.getSuccess()).isEqualTo(1); int nbIssuesWithComment = 0; @@ -232,30 +235,25 @@ public class IssueBulkChangeTest extends AbstractIssueTest { } } - private static void assertHttpException(Exception e, int expectedCode) { - assertThat(e).isInstanceOf(HttpException.class); - assertThat(((HttpException) e).status()).isEqualTo(expectedCode); - } - private BulkChangeWsResponse bulkChangeSeverityOfIssues(String[] issueKeys, String newSeverity) { BulkChangeRequest bulkChangeQuery = createBulkChangeSeverityOfIssuesQuery(issueKeys, newSeverity); return issuesService.bulkChange(bulkChangeQuery); } private static BulkChangeRequest createBulkChangeSeverityOfIssuesQuery(String[] issueKeys, String newSeverity) { - BulkChangeRequest.Builder request = BulkChangeRequest.builder().setSetSeverity(newSeverity); + BulkChangeRequest request = new BulkChangeRequest().setSetSeverity(singletonList(newSeverity)); if (issueKeys != null && issueKeys.length > 0) { request.setIssues(asList(issueKeys)); } - return request.build(); + return request; } private BulkChangeWsResponse bulkTransitionStatusOfIssues(String[] issueKeys, String newSeverity) { - return issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setDoTransition(newSeverity).build()); + return issuesService.bulkChange(new BulkChangeRequest().setIssues(asList(issueKeys)).setDoTransition(newSeverity)); } private BulkChangeWsResponse buldChangeAssigneeOfIssues(String[] issueKeys, String newAssignee) { - return issuesService.bulkChange(BulkChangeRequest.builder().setIssues(asList(issueKeys)).setAssign(newAssignee).build()); + return issuesService.bulkChange(new BulkChangeRequest().setIssues(asList(issueKeys)).setAssign(singletonList(newAssignee))); } private static String[] searchIssueKeys(int limit) { diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueChangelogTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueChangelogTest.java index cb5a08fd89c..5a806f95a2b 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueChangelogTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueChangelogTest.java @@ -26,6 +26,7 @@ import org.sonar.wsclient.issue.Issue; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.ChangelogWsResponse.Changelog; import org.sonarqube.ws.client.WsClient; +import org.sonarqube.ws.client.issues.ChangelogRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -118,7 +119,7 @@ public class IssueChangelogTest extends AbstractIssueTest { } private static Issues.ChangelogWsResponse changelog(String issueKey) { - return adminClient.issuesOld().changelog(issueKey); + return adminClient.issues().changelog(new ChangelogRequest().setIssue(issueKey)); } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueFilterOnCommonRulesTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueFilterOnCommonRulesTest.java index 88bc4569dbd..88da7e40470 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueFilterOnCommonRulesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueFilterOnCommonRulesTest.java @@ -25,7 +25,7 @@ import org.junit.Before; import org.junit.Test; import org.sonarqube.ws.Issues; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -112,15 +112,15 @@ public class IssueFilterOnCommonRulesTest extends AbstractIssueTest { } private List findIssuesByRuleKey(String ruleKey) { - return adminWsClient.issuesOld().search( + return adminWsClient.issues().search( new SearchRequest() - .setComponents(singletonList(FILE_KEY)) + .setComponentKeys(singletonList(FILE_KEY)) .setRules(singletonList(ruleKey))) .getIssuesList(); } private List findAllIssues() { - return adminWsClient.issuesOld().search(new SearchRequest()).getIssuesList(); + return adminWsClient.issues().search(new SearchRequest()).getIssuesList(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java index fc38ee73cef..14f02c2b65d 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueNotificationsTest.java @@ -39,20 +39,20 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.sonarqube.tests.Category6Suite; import org.sonarqube.qa.util.Tester; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.Issues.SearchWsResponse; import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.ws.Qualityprofiles; import org.sonarqube.ws.Projects.CreateWsResponse.Project; +import org.sonarqube.ws.Qualityprofiles; import org.sonarqube.ws.Users; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.AssignRequest; -import org.sonarqube.ws.client.issue.BulkChangeRequest; -import org.sonarqube.ws.client.issue.SearchRequest; +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.permission.AddUserRequest; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; @@ -174,9 +174,9 @@ public class IssueNotificationsTest { clearSmtpMessages(); // Change assignee - SearchWsResponse issues = tester.wsClient().issuesOld().search(new SearchRequest().setProjectKeys(singletonList(PROJECT_KEY))); + SearchWsResponse issues = tester.wsClient().issues().search(new SearchRequest().setProjects(singletonList(PROJECT_KEY))); Issue issue = issues.getIssuesList().get(0); - tester.wsClient().issuesOld().assign(new AssignRequest(issue.getKey(), userWithUserRole.getLogin())); + tester.wsClient().issues().assign(new AssignRequest().setIssue(issue.getKey()).setAssignee(userWithUserRole.getLogin())); // Only the assignee should receive the email waitUntilAllNotificationsAreDelivered(1); @@ -245,22 +245,20 @@ public class IssueNotificationsTest { assertThat(smtpServer.getMessages()).hasSize(privateProject ? 2 : 3); clearSmtpMessages(); - SearchWsResponse issues = tester.wsClient().issuesOld().search(new SearchRequest().setProjectKeys(singletonList(PROJECT_KEY))); + SearchWsResponse issues = tester.wsClient().issues().search(new SearchRequest().setProjects(singletonList(PROJECT_KEY))); Issue issue = issues.getIssuesList().get(0); // bulk change without notification by default - tester.wsClient().issuesOld().bulkChange(BulkChangeRequest.builder() + tester.wsClient().issues().bulkChange(new BulkChangeRequest() .setIssues(singletonList(issue.getKey())) - .setAssign(userWithUserRole.getLogin()) - .setSetSeverity("MINOR") - .build()); + .setAssign(singletonList(userWithUserRole.getLogin())) + .setSetSeverity(singletonList("MINOR"))); // bulk change with notification - tester.wsClient().issuesOld().bulkChange(BulkChangeRequest.builder() + tester.wsClient().issues().bulkChange(new BulkChangeRequest() .setIssues(singletonList(issue.getKey())) - .setSetSeverity("BLOCKER") - .setSendNotifications(true) - .build()); + .setSetSeverity(singletonList("BLOCKER")) + .setSendNotifications("true")); // We are waiting for a single notification for userWithUserRole // for a change on MyIssues diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueSearchTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueSearchTest.java index 0a4e7fbea19..075803fa162 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueSearchTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueSearchTest.java @@ -20,27 +20,29 @@ package org.sonarqube.tests.issue; import java.io.IOException; +import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.Date; import java.util.List; -import org.apache.commons.lang.time.DateUtils; +import org.assertj.core.api.AbstractListAssert; import org.assertj.core.api.Fail; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.sonar.wsclient.base.HttpException; -import org.sonar.wsclient.base.Paging; -import org.sonar.wsclient.issue.Issue; import org.sonar.wsclient.issue.IssueQuery; -import org.sonar.wsclient.issue.Issues; import org.sonarqube.ws.Common; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.Issues; +import org.sonarqube.ws.client.HttpException; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; +import util.selenium.Consumer; -import static java.util.Arrays.asList; import static java.util.Collections.singletonList; +import static org.apache.commons.lang.time.DateUtils.addSeconds; import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.wsclient.internal.EncodingUtils.toQueryParam; import static org.sonarqube.ws.Issues.SearchWsResponse; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.runProjectAnalysis; @@ -84,68 +86,66 @@ public class IssueSearchTest extends AbstractIssueTest { @Test public void search_all_issues() { - assertThat(search(IssueQuery.create()).list()).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch().hasSize(DEFAULT_PAGINATED_RESULTS); } @Test public void search_issues_by_component_roots() { - assertThat(search(IssueQuery.create().componentRoots("com.sonarsource.it.samples:multi-modules-sample")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().componentRoots("com.sonarsource.it.samples:multi-modules-sample:module_a")).list()).hasSize(82); - assertThat(search(IssueQuery.create().componentRoots("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1")).list()).hasSize(36); + assertSearch(r -> r.setComponentRoots("com.sonarsource.it.samples:multi-modules-sample")).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setComponentRoots("com.sonarsource.it.samples:multi-modules-sample:module_a")).hasSize(82); + assertSearch(r -> r.setComponentRoots("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1")).hasSize(36); assertThat(search(IssueQuery.create().componentRoots("unknown")).list()).isEmpty(); } @Test public void search_issues_by_components() { - assertThat( - search(IssueQuery.create().components("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo")).list()) - .hasSize(34); - assertThat(search(IssueQuery.create().components("unknown")).list()).isEmpty(); + assertSearch(r -> r.setComponents("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo")).hasSize(34); + assertSearch(r -> r.setComponents("unknown")).isEmpty(); } @Test public void search_issues_by_severities() { - assertThat(search(IssueQuery.create().severities("BLOCKER")).list()).hasSize(8); - assertThat(search(IssueQuery.create().severities("CRITICAL")).list()).hasSize(8); - assertThat(search(IssueQuery.create().severities("MAJOR")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().severities("MINOR")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().severities("INFO")).list()).hasSize(4); + assertSearch(r -> r.setSeverities(singletonList("BLOCKER"))).hasSize(8); + assertSearch(r -> r.setSeverities(singletonList("CRITICAL"))).hasSize(8); + assertSearch(r -> r.setSeverities(singletonList("MAJOR"))).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setSeverities(singletonList("MINOR"))).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setSeverities(singletonList("INFO"))).hasSize(4); } @Test public void search_issues_by_statuses() { - assertThat(search(IssueQuery.create().statuses("OPEN")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().statuses("RESOLVED")).list()).hasSize(1); - assertThat(search(IssueQuery.create().statuses("CLOSED")).list()).isEmpty(); + assertSearch(r -> r.setStatuses(singletonList("OPEN"))).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setStatuses(singletonList("RESOLVED"))).hasSize(1); + assertSearch(r -> r.setStatuses(singletonList("CLOSED"))).isEmpty(); } @Test public void search_issues_by_resolutions() { - assertThat(search(IssueQuery.create().resolutions("FIXED")).list()).hasSize(1); - assertThat(search(IssueQuery.create().resolutions("FALSE-POSITIVE")).list()).isEmpty(); - assertThat(search(IssueQuery.create().resolved(true)).list()).hasSize(1); - assertThat(search(IssueQuery.create().resolved(false)).paging().total()).isEqualTo(TOTAL_NB_ISSUES - 1); + assertSearch(r -> r.setResolutions(singletonList("FIXED"))).hasSize(1); + assertSearch(r -> r.setResolutions(singletonList("FALSE-POSITIVE"))).isEmpty(); + assertSearch(r -> r.setResolved("true")).hasSize(1); + assertThat(searchResponse(r -> r.setResolved("false")).getPaging().getTotal()).isEqualTo(TOTAL_NB_ISSUES - 1); } @Test public void search_issues_by_assignees() { - assertThat(search(IssueQuery.create().assignees("admin")).list()).hasSize(1); - assertThat(search(IssueQuery.create().assignees("unknown")).list()).isEmpty(); - assertThat(search(IssueQuery.create().assigned(true)).list()).hasSize(1); - assertThat(search(IssueQuery.create().assigned(false)).paging().total()).isEqualTo(TOTAL_NB_ISSUES - 1); + assertSearch(r -> r.setAssignees(singletonList("admin"))).hasSize(1); + assertSearch(r -> r.setAssignees(singletonList("unknown"))).isEmpty(); + assertSearch(r -> r.setAssigned("true")).hasSize(1); + assertThat(searchResponse(r -> r.setAssigned("false")).getPaging().getTotal()).isEqualTo(TOTAL_NB_ISSUES - 1); } @Test public void search_issues_by_rules() { - assertThat(search(IssueQuery.create().rules("xoo:OneIssuePerLine")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().rules("xoo:OneIssuePerFile")).list()).hasSize(8); + assertSearch(r -> r.setRules(singletonList("xoo:OneIssuePerLine"))).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setRules(singletonList("xoo:OneIssuePerFile"))).hasSize(8); try { - search(IssueQuery.create().rules("unknown")); + searchResponse(r -> r.setRules(singletonList("unknown"))); Assert.fail(); - } catch (org.sonar.wsclient.base.HttpException e) { - assertThat(e.status()).isEqualTo(400); + } catch (HttpException e) { + assertThat(e.getMessage()).contains("Invalid rule key: unknown"); } } @@ -161,31 +161,30 @@ public class IssueSearchTest extends AbstractIssueTest { // createdAfter in the future => bad request try { - search(IssueQuery.create().createdAfter(future)).list(); + searchResponse(r -> r.setCreatedAfter(toDateString(future))); Fail.fail("Expecting 400 from issues search WS"); } catch (HttpException exception) { assertThat(exception.getMessage()).contains("Start bound cannot be in the future"); } // after date - assertThat(search(IssueQuery.create().createdAfter(today)).list().size()).isGreaterThan(0); - assertThat(search(IssueQuery.create().createdAfter(past)).list().size()).isGreaterThan(0); + assertSearch(r -> r.setCreatedAfter(toDateString(today))).isNotEmpty(); + assertSearch(r -> r.setCreatedAfter(toDateString(past))).isNotEmpty(); // before - assertThat(search(IssueQuery.create().createdBefore(future)).list().size()).isGreaterThan(0); - assertThat(search(IssueQuery.create().createdBefore(past)).list()).isEmpty(); + assertSearch(r -> r.setCreatedBefore(toDateString(future))).isNotEmpty(); + assertSearch(r -> r.setCreatedBefore(toDateString(past))).isEmpty(); // before and after - assertThat(search(IssueQuery.create().createdBefore(future).createdAfter(past)).list().size()).isGreaterThan(0); + assertSearch(r -> r.setCreatedBefore(toDateString(future)).setCreatedAfter(toDateString(past))).isNotEmpty(); // createdAfter > createdBefore => bad request try { - search(IssueQuery.create().createdBefore(past).createdAfter(today)).list(); + searchResponse(r -> r.setCreatedBefore(toDateString(past)).setCreatedAfter(toDateString(today))); Fail.fail("Expecting 400 from issues search WS"); } catch (HttpException exception) { assertThat(exception.getMessage()).contains("Start bound cannot be larger or equal to end bound"); } - } /** @@ -193,32 +192,32 @@ public class IssueSearchTest extends AbstractIssueTest { */ @Test public void search_issues_by_languages() { - assertThat(search(IssueQuery.create().languages("xoo")).list()).hasSize(DEFAULT_PAGINATED_RESULTS); - assertThat(search(IssueQuery.create().languages("foo")).list()).isEmpty(); + assertSearch(r -> r.setLanguages(singletonList("xoo"))).hasSize(DEFAULT_PAGINATED_RESULTS); + assertSearch(r -> r.setLanguages(singletonList("foo"))).isEmpty(); } @Test public void paginate_results() { - Issues issues = search(IssueQuery.create().pageSize(20).pageIndex(2)); + SearchWsResponse issues = searchResponse(r -> r.setPs("20").setP("2")); - assertThat(issues.list()).hasSize(20); - Paging paging = issues.paging(); - assertThat(paging.pageIndex()).isEqualTo(2); - assertThat(paging.pageSize()).isEqualTo(20); - assertThat(paging.total()).isEqualTo(TOTAL_NB_ISSUES); + assertThat(issues.getIssuesList()).hasSize(20); + Common.Paging paging = issues.getPaging(); + assertThat(paging.getPageIndex()).isEqualTo(2); + assertThat(paging.getPageSize()).isEqualTo(20); + assertThat(paging.getTotal()).isEqualTo(TOTAL_NB_ISSUES); // SONAR-3257 // return max page size results when using negative page size value - assertThat(search(IssueQuery.create().pageSize(0)).list()).hasSize(TOTAL_NB_ISSUES); - assertThat(search(IssueQuery.create().pageSize(-1)).list()).hasSize(TOTAL_NB_ISSUES); + assertSearch(r -> r.setPs("0")).hasSize(TOTAL_NB_ISSUES); + assertSearch(r -> r.setPs("-1")).hasSize(TOTAL_NB_ISSUES); } @Test public void sort_results() { - List issues = search(IssueQuery.create().sort("SEVERITY").asc(false)).list(); - assertThat(issues.get(0).severity()).isEqualTo("BLOCKER"); - assertThat(issues.get(8).severity()).isEqualTo("CRITICAL"); - assertThat(issues.get(17).severity()).isEqualTo("MAJOR"); + List issues = searchResponse(r -> r.setS("SEVERITY").setAsc("false")).getIssuesList(); + assertThat(issues.get(0).getSeverity()).isEqualTo(Common.Severity.BLOCKER); + assertThat(issues.get(8).getSeverity()).isEqualTo(Common.Severity.CRITICAL); + assertThat(issues.get(17).getSeverity()).isEqualTo(Common.Severity.MAJOR); } /** @@ -226,52 +225,67 @@ public class IssueSearchTest extends AbstractIssueTest { */ @Test public void search_by_exact_creation_date() { - final Issue issue = search(IssueQuery.create()).list().get(0); - assertThat(issue.creationDate()).isNotNull(); + Issues.Issue issue = searchResponse().getIssues(0); + assertThat(issue.getCreationDate()).isNotNull(); // search the issue key with the same date - assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(issue.creationDate())).list()).hasSize(1); + assertSearch(r -> r.setIssues(singletonList(issue.getKey())).setCreatedAt(issue.getCreationDate())).hasSize(1); // search issue key with 1 second more and less should return nothing - assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(DateUtils.addSeconds(issue.creationDate(), 1))).size()).isEqualTo(0); - assertThat(search(IssueQuery.create().issues().issues(issue.key()).createdAt(DateUtils.addSeconds(issue.creationDate(), -1))).size()).isEqualTo(0); + assertSearch(r -> r.setIssues(singletonList(issue.getKey())).setCreatedAt(toDateString(addSeconds(parse(issue.getCreationDate()), 1)))).isEmpty(); + assertSearch(r -> r.setIssues(singletonList(issue.getKey())).setCreatedAt(toDateString(addSeconds(parse(issue.getCreationDate()), -1)))).isEmpty(); // search with future and past dates that do not match any issues - assertThat(search(IssueQuery.create().createdAt(toDate("2020-01-01"))).size()).isEqualTo(0); - assertThat(search(IssueQuery.create().createdAt(toDate("2010-01-01"))).size()).isEqualTo(0); + assertSearch(r -> r.setCreatedAt(toDateString(toDate("2020-01-01")))).isEmpty(); + assertSearch(r -> r.setCreatedAt(toDateString(toDate("2010-01-01")))).isEmpty(); } @Test public void return_issue_type() throws Exception { - List issues = searchByRuleKey("xoo:OneBugIssuePerLine"); - assertThat(issues).isNotEmpty(); - org.sonarqube.ws.Issues.Issue issue = issues.get(0); + SearchWsResponse issues = searchResponse(r -> r.setRules(singletonList("xoo:OneBugIssuePerLine"))); + assertThat(issues.getIssuesList()).isNotEmpty(); + org.sonarqube.ws.Issues.Issue issue = issues.getIssues(0); assertThat(issue.getType()).isEqualTo(Common.RuleType.BUG); - issues = searchByRuleKey("xoo:OneVulnerabilityIssuePerModule"); - assertThat(issues).isNotEmpty(); - issue = issues.get(0); + issues = searchResponse(r -> r.setRules(singletonList("xoo:OneVulnerabilityIssuePerModule"))); + assertThat(issues.getIssuesList()).isNotEmpty(); + issue = issues.getIssues(0); assertThat(issue.getType()).isEqualTo(Common.RuleType.VULNERABILITY); - issues = searchByRuleKey("xoo:OneIssuePerLine"); - assertThat(issues).isNotEmpty(); - issue = issues.get(0); + issues = searchResponse(r -> r.setRules(singletonList("xoo:OneIssuePerLine"))); + assertThat(issues.getIssuesList()).isNotEmpty(); + issue = issues.getIssues(0); assertThat(issue.getType()).isEqualTo(Common.RuleType.CODE_SMELL); } @Test public void search_issues_by_types() throws IOException { - assertThat(searchIssues(new SearchRequest().setTypes(singletonList("CODE_SMELL"))).getPaging().getTotal()).isEqualTo(142); - assertThat(searchIssues(new SearchRequest().setTypes(singletonList("BUG"))).getPaging().getTotal()).isEqualTo(122); - assertThat(searchIssues(new SearchRequest().setTypes(singletonList("VULNERABILITY"))).getPaging().getTotal()).isEqualTo(8); + assertThat(searchResponse(r -> r.setTypes(singletonList("CODE_SMELL"))).getPaging().getTotal()).isEqualTo(142); + assertThat(searchResponse(r -> r.setTypes(singletonList("BUG"))).getPaging().getTotal()).isEqualTo(122); + assertThat(searchResponse(r -> r.setTypes(singletonList("VULNERABILITY"))).getPaging().getTotal()).isEqualTo(8); + } + + private Date parse(String date) { + try { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(date); + } catch (ParseException e) { + throw new IllegalStateException(e); + } } - private List searchByRuleKey(String... ruleKey) throws IOException { - return searchIssues(new SearchRequest().setRules(asList(ruleKey))).getIssuesList(); + private String toDateString(Date future) { + return toQueryParam(future, true); } - private SearchWsResponse searchIssues(SearchRequest request) throws IOException { - return newAdminWsClient(ORCHESTRATOR).issuesOld().search(request); + @SafeVarargs + private final AbstractListAssert, org.sonarqube.ws.Issues.Issue> assertSearch(Consumer... consumers) { + return assertThat(searchResponse(consumers).getIssuesList()); } + @SafeVarargs + private final SearchWsResponse searchResponse(Consumer... consumers) { + SearchRequest request = new SearchRequest(); + Arrays.stream(consumers).forEach(c -> c.accept(request)); + return newAdminWsClient(ORCHESTRATOR).issues().search(request); + } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java index 7b655eecb99..f34e3be7589 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java @@ -33,7 +33,9 @@ import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Projects.CreateWsResponse; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; +import org.sonarqube.ws.client.issues.SetTagsRequest; +import org.sonarqube.ws.client.issues.TagsRequest; import org.sonarqube.ws.client.organizations.AddMemberRequest; import org.sonarqube.ws.client.permission.AddUserRequest; import org.sonarqube.ws.client.project.CreateRequest; @@ -78,8 +80,8 @@ public class IssueTagsTest { .build()); analyzeProject(organization.getKey(), projectKey); - String issue = tester.wsClient().issuesOld().search(new SearchRequest()).getIssues(0).getKey(); - tester.wsClient().issuesOld().setTags(issue, "bla", "blubb"); + String issue = tester.wsClient().issues().search(new SearchRequest()).getIssues(0).getKey(); + tester.wsClient().issues().setTags(new SetTagsRequest().setIssue(issue).setTags(asList("bla", "blubb"))); String[] publicTags = {"bad-practice", "convention", "pitfall"}; String[] privateTags = {"bad-practice", "bla", "blubb", "convention", "pitfall"}; @@ -119,12 +121,12 @@ public class IssueTagsTest { CreateWsResponse.Project anotherProject = tester.projects().provision(anotherOrganization); analyzeProject(organization.getKey(), project.getKey()); analyzeProject(anotherOrganization.getKey(), anotherProject.getKey()); - String issue = tester.wsClient().issues().search(new SearchRequest().setProjectKeys(singletonList(project.getKey()))).getIssues(0).getKey(); - String anotherIssue = tester.wsClient().issues().search(new SearchRequest().setProjectKeys(singletonList(anotherProject.getKey()))).getIssues(0).getKey(); - tester.wsClient().issues().setTags(issue, "first-tag"); - tester.wsClient().issues().setTags(anotherIssue, "another-tag"); + String issue = tester.wsClient().issues().search(new SearchRequest().setProjects(singletonList(project.getKey()))).getIssues(0).getKey(); + String anotherIssue = tester.wsClient().issues().search(new SearchRequest().setProjects(singletonList(anotherProject.getKey()))).getIssues(0).getKey(); + tester.wsClient().issues().setTags(new SetTagsRequest().setIssue(issue).setTags(singletonList("first-tag"))); + tester.wsClient().issues().setTags(new SetTagsRequest().setIssue(anotherIssue).setTags(singletonList("another-tag"))); - assertThat(tester.wsClient().issues().getTags(null).content()).contains("first-tag", "another-tag"); + assertThat(tester.wsClient().issues().tags(new TagsRequest().setOrganization(null)).getTagsList()).contains("first-tag", "another-tag"); } private void addMemberToOrganization(User member) { @@ -141,14 +143,12 @@ public class IssueTagsTest { private void assertTags(@Nullable String userLogin, @Nullable String organization, String... expectedTags) { assertThat( - (List) ItUtils.jsonToMap( - tester.as(userLogin) - .wsClient() - .issuesOld() - .getTags(organization) - .content()) - .get("tags")).containsExactly( - expectedTags); + tester.as(userLogin) + .wsClient() + .issues() + .tags(new TagsRequest().setOrganization(organization)) + .getTagsList()) + .containsExactly(expectedTags); } private void analyzeProject(String organizationKey, String projectKey) { diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueTrackingTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueTrackingTest.java index 97e78cff64f..6ec13ac8ba8 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueTrackingTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueTrackingTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.Issues.SearchWsResponse; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -71,7 +71,7 @@ public class IssueTrackingTest extends AbstractIssueTest { "sonar.projectDate", NEW_DATE_STR, "sonar.exclusions", "**/*.xoo"); - issues = searchIssues(new SearchRequest().setProjectKeys(singletonList("sample"))).getIssuesList(); + issues = searchIssues(new SearchRequest().setProjects(singletonList("sample"))).getIssuesList(); assertThat(issues).hasSize(1); assertThat(issues.get(0).getStatus()).isEqualTo("CLOSED"); assertThat(issues.get(0).getResolution()).isEqualTo("FIXED"); @@ -200,7 +200,7 @@ public class IssueTrackingTest extends AbstractIssueTest { } private List searchUnresolvedIssuesByComponent(String componentKey) { - return searchIssues(new SearchRequest().setComponentKeys(singletonList(componentKey)).setResolved(false)).getIssuesList(); + return searchIssues(new SearchRequest().setComponentKeys(singletonList(componentKey)).setResolved("false")).getIssuesList(); } private static Issue getRandomIssue() { @@ -214,7 +214,7 @@ public class IssueTrackingTest extends AbstractIssueTest { } private static SearchWsResponse searchIssues(SearchRequest request) { - return adminClient.issuesOld().search(request); + return adminClient.issues().search(request); } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueWorkflowTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueWorkflowTest.java index 6344124f029..c8c8d3221a8 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueWorkflowTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueWorkflowTest.java @@ -24,18 +24,18 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; +import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.Issue; -import org.sonarqube.ws.client.issue.DoTransitionRequest; -import org.sonarqube.ws.client.issue.IssuesService; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.IssuesService; +import org.sonarqube.ws.client.issues.DoTransitionRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ProjectAnalysis; import util.ProjectAnalysisRule; import util.issue.IssueRule; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.newAdminWsClient; import static util.ItUtils.toDatetime; public class IssueWorkflowTest extends AbstractIssueTest { @@ -43,6 +43,9 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Rule public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR); + @Rule + public Tester tester = new Tester(ORCHESTRATOR); + @ClassRule public static final IssueRule issueRule = IssueRule.from(ORCHESTRATOR); @@ -54,7 +57,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Before public void before() { - issuesService = newAdminWsClient(ORCHESTRATOR).issuesOld(); + issuesService = tester.wsClient().issues(); String oneIssuePerFileProfileKey = projectAnalysisRule.registerProfile("/issue/IssueWorkflowTest/xoo-one-issue-per-line-profile.xml"); String analyzedProjectKey = projectAnalysisRule.registerProject("issue/workflow"); analysisWithIssues = projectAnalysisRule.newProjectAnalysis(analyzedProjectKey).withQualityProfile(oneIssuePerFileProfileKey); @@ -90,7 +93,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void user_should_confirm_issue() { // mark as confirmed - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "confirm")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("confirm")); Issue confirmed = issueRule.getByKey(issue.getKey()); assertThat(confirmed.getStatus()).isEqualTo("CONFIRMED"); @@ -99,7 +102,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { // user unconfirm the issue assertThat(transitions(confirmed.getKey())).contains("unconfirm"); - issuesService.doTransition(new DoTransitionRequest(confirmed.getKey(), "unconfirm")); + issuesService.doTransition(new DoTransitionRequest().setIssue(confirmed.getKey()).setTransition("unconfirm")); Issue unconfirmed = issueRule.getByKey(issue.getKey()); assertThat(unconfirmed.getStatus()).isEqualTo("REOPENED"); @@ -113,7 +116,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void user_should_mark_as_false_positive_confirmed_issue() { // mark as confirmed - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "confirm")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("confirm")); Issue confirmed = issueRule.getByKey(issue.getKey()); assertThat(confirmed.getStatus()).isEqualTo("CONFIRMED"); @@ -122,7 +125,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { // user mark the issue as false-positive assertThat(transitions(confirmed.getKey())).contains("falsepositive"); - issuesService.doTransition(new DoTransitionRequest(confirmed.getKey(), "falsepositive")); + issuesService.doTransition(new DoTransitionRequest().setIssue(confirmed.getKey()).setTransition("falsepositive")); Issue falsePositive = issueRule.getByKey(issue.getKey()); assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED"); @@ -136,7 +139,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void scan_should_close_no_more_existing_confirmed() { // mark as confirmed - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "confirm")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("confirm")); Issue falsePositive = issueRule.getByKey(issue.getKey()); assertThat(falsePositive.getStatus()).isEqualTo("CONFIRMED"); assertThat(falsePositive.hasResolution()).isFalse(); @@ -156,7 +159,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void scan_should_reopen_unresolved_issue_but_marked_as_resolved() { // mark as resolved - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("resolve")); Issue resolvedIssue = issueRule.getByKey(issue.getKey()); assertThat(resolvedIssue.getStatus()).isEqualTo("RESOLVED"); assertThat(resolvedIssue.getResolution()).isEqualTo("FIXED"); @@ -181,7 +184,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void scan_should_close_resolved_issue() { // mark as resolved - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("resolve")); Issue resolvedIssue = issueRule.getByKey(issue.getKey()); assertThat(resolvedIssue.getStatus()).isEqualTo("RESOLVED"); assertThat(resolvedIssue.getResolution()).isEqualTo("FIXED"); @@ -207,7 +210,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void user_should_reopen_issue_marked_as_resolved() { // user marks issue as resolved - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("resolve")); Issue resolved = issueRule.getByKey(issue.getKey()); assertThat(resolved.getStatus()).isEqualTo("RESOLVED"); assertThat(resolved.getResolution()).isEqualTo("FIXED"); @@ -229,7 +232,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void scan_should_not_reopen_or_close_false_positives() { // user marks issue as false-positive - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "falsepositive")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("falsepositive")); Issue falsePositive = issueRule.getByKey(issue.getKey()); assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED"); @@ -253,7 +256,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void scan_should_close_no_more_existing_false_positive() { // user marks as false-positive - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "falsepositive")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("falsepositive")); Issue falsePositive = issueRule.getByKey(issue.getKey()); assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED"); assertThat(falsePositive.getResolution()).isEqualTo("FALSE-POSITIVE"); @@ -273,7 +276,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void user_should_reopen_false_positive() { // user marks as false-positive - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "falsepositive")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("falsepositive")); Issue falsePositive = issueRule.getByKey(issue.getKey()); assertThat(falsePositive.getStatus()).isEqualTo("RESOLVED"); @@ -292,7 +295,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { @Test public void user_should_not_reopen_closed_issue() { - issuesService.doTransition(new DoTransitionRequest(issue.getKey(), "resolve")); + issuesService.doTransition(new DoTransitionRequest().setIssue(issue.getKey()).setTransition("resolve")); // re-execute scan without rules -> the issue is closed analysisWithoutIssues.run(); @@ -308,7 +311,7 @@ public class IssueWorkflowTest extends AbstractIssueTest { } private Issues.SearchWsResponse searchIssues(SearchRequest request) { - return newAdminWsClient(ORCHESTRATOR).issuesOld().search(request); + return tester.wsClient().issues().search(request); } } diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java index d6a9389ecd8..4bd683f3277 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -21,7 +21,6 @@ package org.sonarqube.tests.issue; import com.sonar.orchestrator.Orchestrator; -import org.sonarqube.tests.Category6Suite; import java.util.List; import java.util.stream.Collectors; import org.junit.Before; @@ -29,16 +28,17 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; +import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.issue.AssignRequest; -import org.sonarqube.ws.client.issue.BulkChangeRequest; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.AssignRequest; +import org.sonarqube.ws.client.issues.BulkChangeRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; import util.issue.IssueRule; import static java.lang.String.format; @@ -127,13 +127,13 @@ public class OrganizationIssueAssignTest { provisionAndAnalyseProject("sample2", org2.getKey()); List issues = issueRule.search(new SearchRequest()).getIssuesList().stream().map(Issue::getKey).collect(Collectors.toList()); - Issues.BulkChangeWsResponse response = tester.wsClient().issuesOld() - .bulkChange(BulkChangeRequest.builder().setIssues(issues).setAssign(user.getLogin()).build()); + Issues.BulkChangeWsResponse response = tester.wsClient().issues() + .bulkChange(new BulkChangeRequest().setIssues(issues).setAssign(singletonList(user.getLogin()))); assertThat(response.getIgnored()).isGreaterThan(0); - assertThat(issueRule.search(new SearchRequest().setProjectKeys(singletonList("sample"))).getIssuesList()).extracting(Issue::getAssignee) + assertThat(issueRule.search(new SearchRequest().setProjects(singletonList("sample"))).getIssuesList()).extracting(Issue::getAssignee) .containsOnly(user.getLogin()); - assertThat(issueRule.search(new SearchRequest().setProjectKeys(singletonList("sample2"))).getIssuesList()).extracting(Issue::hasAssignee) + assertThat(issueRule.search(new SearchRequest().setProjects(singletonList("sample2"))).getIssuesList()).extracting(Issue::hasAssignee) .containsOnly(false); } @@ -213,7 +213,7 @@ public class OrganizationIssueAssignTest { .build()); } - private Issues.Operation assignIssueTo(Issue issue, User u) { - return tester.wsClient().issuesOld().assign(new AssignRequest(issue.getKey(), u.getLogin())); + private Issues.AssignResponse assignIssueTo(Issue issue, User u) { + return tester.wsClient().issues().assign(new AssignRequest().setIssue(issue.getKey()).setAssignee(u.getLogin())); } } diff --git a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java index 1404a396b78..f8230246a8e 100644 --- a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java +++ b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java @@ -29,8 +29,8 @@ import org.sonarqube.ws.Issues; import org.sonarqube.ws.Components; import org.sonarqube.ws.Measures; import org.sonarqube.ws.client.components.TreeRequest; -import org.sonarqube.ws.client.issue.IssuesService; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.IssuesService; +import org.sonarqube.ws.client.issues.SearchRequest; import org.sonarqube.ws.client.measure.ComponentTreeRequest; import org.sonarqube.ws.client.measure.ComponentRequest; import org.sonarqube.ws.client.measure.MeasuresService; @@ -63,12 +63,12 @@ public class LiteTest { @Test public void call_issues_ws() { // all issues - IssuesService issuesService = tester.wsClient().issuesOld(); + IssuesService issuesService = tester.wsClient().issues(); Issues.SearchWsResponse response = issuesService.search(new SearchRequest()); assertThat(response.getIssuesCount()).isGreaterThan(0); // project issues - response = issuesService.search(new SearchRequest().setProjectKeys(singletonList(PROJECT_KEY))); + response = issuesService.search(new SearchRequest().setProjects(singletonList(PROJECT_KEY))); assertThat(response.getIssuesCount()).isGreaterThan(0); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtInIssueChangelogTest.java b/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtInIssueChangelogTest.java index 3ecb8d97e70..248c3498318 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtInIssueChangelogTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtInIssueChangelogTest.java @@ -27,7 +27,8 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.ChangelogRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -58,7 +59,7 @@ public class TechnicalDebtInIssueChangelogTest { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")) .setProperties("sonar.oneIssuePerFile.effortToFix", "10")); - Issues.Issue firstIssue = tester.wsClient().issuesOld().search(new SearchRequest()).getIssues(0); + Issues.Issue firstIssue = tester.wsClient().issues().search(new SearchRequest()).getIssues(0); List changes = changelog(firstIssue.getKey()).getChangelogList(); assertThat(changes).hasSize(1); @@ -68,7 +69,7 @@ public class TechnicalDebtInIssueChangelogTest { } private Issues.ChangelogWsResponse changelog(String issueKey) { - return tester.wsClient().issuesOld().changelog(issueKey); + return tester.wsClient().issues().changelog(new ChangelogRequest().setIssue(issueKey)); } } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtTest.java b/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtTest.java index a941680436e..3b942e79885 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityModel/TechnicalDebtTest.java @@ -27,7 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -54,7 +54,7 @@ public class TechnicalDebtTest { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); // All the issues should have a technical debt - List issues = tester.wsClient().issuesOld().search(new SearchRequest()).getIssuesList(); + List issues = tester.wsClient().issues().search(new SearchRequest()).getIssuesList(); assertThat(issues).isNotEmpty(); for (Issues.Issue issue : issues) { assertThat(issue.getDebt()).isEqualTo("1min"); diff --git a/tests/src/test/java/org/sonarqube/tests/serverSystem/LogsTest.java b/tests/src/test/java/org/sonarqube/tests/serverSystem/LogsTest.java index efea4d8615a..ca705c5211b 100644 --- a/tests/src/test/java/org/sonarqube/tests/serverSystem/LogsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/serverSystem/LogsTest.java @@ -36,7 +36,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import util.ItUtils; import static java.lang.String.format; @@ -116,8 +116,8 @@ public class LogsTest { private void generateSqlAndEsLogsInWebAndCe() { orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); - ItUtils.newAdminWsClient(orchestrator).issuesOld().search(new SearchRequest() - .setProjectKeys(Collections.singletonList("sample"))); + ItUtils.newAdminWsClient(orchestrator).issues().search(new SearchRequest() + .setProjects(Collections.singletonList("sample"))); } private Collection logLevelsOf(File webLogs) { diff --git a/tests/src/test/java/util/issue/IssueRule.java b/tests/src/test/java/util/issue/IssueRule.java index 0d1b750b7f3..36580c8bde3 100644 --- a/tests/src/test/java/util/issue/IssueRule.java +++ b/tests/src/test/java/util/issue/IssueRule.java @@ -25,7 +25,7 @@ import org.junit.rules.ExternalResource; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.Issues.SearchWsResponse; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.issue.SearchRequest; +import org.sonarqube.ws.client.issues.SearchRequest; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -48,7 +48,7 @@ public class IssueRule extends ExternalResource { } public SearchWsResponse search(SearchRequest request) { - return adminWsClient().issuesOld().search(request); + return adminWsClient().issues().search(request); } public Issue getRandomIssue() { -- 2.39.5