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;
this.dbClient = dbClient;
}
- private static void writeResponse(Response response, List<String> 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")
int pageSize = request.mandatoryParamAsInt("ps");
OrganizationDto organization = getOrganization(request.param(PARAM_ORGANIZATION));
List<String> 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<String> listTags(@Nullable OrganizationDto organization, @Nullable String textQuery, int pageSize) {
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;
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);
return qualityprofiles;
}
- @Override
- public org.sonarqube.ws.client.issue.IssuesService issuesOld() {
- return issuesOld;
- }
-
@Override
public IssuesService issues() {
return issues;
FavoritesService favorites();
- /**
- * @deprecated since 7.0 use {@link #issues()} instead
- */
- @Deprecated
- org.sonarqube.ws.client.issue.IssuesService issuesOld();
-
IssuesService issues();
NotificationsService notifications();
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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<String> issues;
- private final String assign;
- private final String setSeverity;
- private final String setType;
- private final String doTransition;
- private final List<String> addTags;
- private final List<String> 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<String> 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<String> getAddTags() {
- return addTags;
- }
-
- public List<String> 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<String> issues;
- private String assign;
- private String setSeverity;
- private String setType;
- private String doTransition;
- private List<String> addTags = newArrayList();
- private List<String> removeTags = newArrayList();
- private String comment;
- private Boolean sendNotifications;
-
- public Builder setIssues(List<String> 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<String> addTags) {
- this.addTags = requireNonNull(addTags);
- return this;
- }
-
- public Builder setRemoveTags(List<String> 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);
- }
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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)
- );
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.issue;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class SearchRequest {
- private List<String> actionPlans;
- private List<String> additionalFields;
- private Boolean asc;
- private Boolean assigned;
- private List<String> assignees;
- private List<String> authors;
- private List<String> componentKeys;
- private List<String> componentRootUuids;
- private List<String> componentRoots;
- private List<String> componentUuids;
- private List<String> components;
- private String createdAfter;
- private String createdAt;
- private String createdBefore;
- private String createdInLast;
- private List<String> directories;
- private String facetMode;
- private List<String> facets;
- private List<String> fileUuids;
- private List<String> issues;
- private List<String> languages;
- private List<String> moduleUuids;
- private Boolean onComponentOnly;
- private String branch;
- private String organization;
- private Integer page;
- private Integer pageSize;
- private List<String> projectKeys;
- private List<String> projectUuids;
- private List<String> projects;
- private List<String> resolutions;
- private Boolean resolved;
- private List<String> rules;
- private Boolean sinceLeakPeriod;
- private String sort;
- private List<String> severities;
- private List<String> statuses;
- private List<String> tags;
- private List<String> types;
-
- @CheckForNull
- public List<String> getActionPlans() {
- return actionPlans;
- }
-
- public SearchRequest setActionPlans(@Nullable List<String> actionPlans) {
- this.actionPlans = actionPlans;
- return this;
- }
-
- @CheckForNull
- public List<String> getAdditionalFields() {
- return additionalFields;
- }
-
- public SearchRequest setAdditionalFields(@Nullable List<String> 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<String> getAssignees() {
- return assignees;
- }
-
- public SearchRequest setAssignees(@Nullable List<String> assignees) {
- this.assignees = assignees;
- return this;
- }
-
- @CheckForNull
- public List<String> getAuthors() {
- return authors;
- }
-
- public SearchRequest setAuthors(@Nullable List<String> authors) {
- this.authors = authors;
- return this;
- }
-
- @CheckForNull
- public List<String> getComponentKeys() {
- return componentKeys;
- }
-
- public SearchRequest setComponentKeys(@Nullable List<String> componentKeys) {
- this.componentKeys = componentKeys;
- return this;
- }
-
- @CheckForNull
- public List<String> getComponentUuids() {
- return componentUuids;
- }
-
- public SearchRequest setComponentUuids(@Nullable List<String> 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<String> getDirectories() {
- return directories;
- }
-
- public SearchRequest setDirectories(@Nullable List<String> 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<String> getFacets() {
- return facets;
- }
-
- public SearchRequest setFacets(@Nullable List<String> facets) {
- this.facets = facets;
- return this;
- }
-
- @CheckForNull
- public List<String> getFileUuids() {
- return fileUuids;
- }
-
- public SearchRequest setFileUuids(@Nullable List<String> fileUuids) {
- this.fileUuids = fileUuids;
- return this;
- }
-
- @CheckForNull
- public List<String> getIssues() {
- return issues;
- }
-
- public SearchRequest setIssues(@Nullable List<String> issues) {
- this.issues = issues;
- return this;
- }
-
- @CheckForNull
- public List<String> getLanguages() {
- return languages;
- }
-
- public SearchRequest setLanguages(@Nullable List<String> languages) {
- this.languages = languages;
- return this;
- }
-
- @CheckForNull
- public List<String> getModuleUuids() {
- return moduleUuids;
- }
-
- public SearchRequest setModuleUuids(@Nullable List<String> 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<String> getProjectKeys() {
- return projectKeys;
- }
-
- public SearchRequest setProjectKeys(@Nullable List<String> projectKeys) {
- this.projectKeys = projectKeys;
- return this;
- }
-
- @CheckForNull
- public List<String> getProjectUuids() {
- return projectUuids;
- }
-
- public SearchRequest setProjectUuids(@Nullable List<String> projectUuids) {
- this.projectUuids = projectUuids;
- return this;
- }
-
- @CheckForNull
- public List<String> getResolutions() {
- return resolutions;
- }
-
- public SearchRequest setResolutions(@Nullable List<String> 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<String> getRules() {
- return rules;
- }
-
- public SearchRequest setRules(@Nullable List<String> 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<String> getSeverities() {
- return severities;
- }
-
- public SearchRequest setSeverities(@Nullable List<String> severities) {
- this.severities = severities;
- return this;
- }
-
- @CheckForNull
- public List<String> getStatuses() {
- return statuses;
- }
-
- public SearchRequest setStatuses(@Nullable List<String> statuses) {
- this.statuses = statuses;
- return this;
- }
-
- @CheckForNull
- public List<String> getTags() {
- return tags;
- }
-
- public SearchRequest setTags(@Nullable List<String> tags) {
- this.tags = tags;
- return this;
- }
-
- @CheckForNull
- public List<String> getTypes() {
- return types;
- }
-
- public SearchRequest setTypes(@Nullable List<String> types) {
- this.types = types;
- return this;
- }
-
- @CheckForNull
- public List<String> getComponentRootUuids() {
- return componentRootUuids;
- }
-
- public SearchRequest setComponentRootUuids(List<String> componentRootUuids) {
- this.componentRootUuids = componentRootUuids;
- return this;
- }
-
- @CheckForNull
- public List<String> getComponentRoots() {
- return componentRoots;
- }
-
- public SearchRequest setComponentRoots(@Nullable List<String> componentRoots) {
- this.componentRoots = componentRoots;
- return this;
- }
-
- @CheckForNull
- public List<String> getComponents() {
- return components;
- }
-
- public SearchRequest setComponents(@Nullable List<String> components) {
- this.components = components;
- return this;
- }
-
- @CheckForNull
- public List<String> getProjects() {
- return projects;
- }
-
- public SearchRequest setProjects(@Nullable List<String> projects) {
- this.projects = projects;
- return this;
- }
-
- @CheckForNull
- public String getBranch() {
- return branch;
- }
-
- public SearchRequest setBranch(@Nullable String branch) {
- this.branch = branch;
- return this;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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;
- }
-}
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 {
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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<IssuesService> 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();
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.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<String> 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);
- }
-
-}
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;
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<String> searchFile(String key) {
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;
}
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) {
}
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));
}
}
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;
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;
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;
}
private List<Issue> 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();
}
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;
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 {
@ClassRule
public static final IssueRule issueRule = IssueRule.from(ORCHESTRATOR);
+ @Rule
+ public Tester tester = new Tester(ORCHESTRATOR);
+
private ProjectAnalysis projectAnalysis;
private IssuesService issuesService;
this.projectAnalysis = projectAnalysisRule.newProjectAnalysis(projectKey).withQualityProfile(qualityProfileKey);
this.projectAnalysis.run();
- this.issuesService = newAdminWsClient(ORCHESTRATOR).issuesOld();
+ this.issuesService = tester.wsClient().issues();
this.randomIssue = issueRule.getRandomIssue();
}
@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 <strong>comment</strong>");
assertThat(comment.getLogin()).isEqualTo("admin");
@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);
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 <strong>comment</strong>");
-
- // reload issue
- Issue reloaded = issueRule.getByKey(randomIssue.getKey());
- assertThat(reloaded.getComments().getCommentsList()).hasSize(1);
- assertThat(reloaded.getComments().getComments(0).getHtmlText()).isEqualTo("new <strong>comment</strong>");
- }
-
- @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
*/
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);
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();
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();
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);
}
private static List<Issue> 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();
}
}
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
@Rule
public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR);
+ @Rule
+ public Tester tester = new Tester(ORCHESTRATOR);
+
private IssuesService issuesService;
private ProjectAnalysis xooSampleLittleIssuesAnalysis;
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
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)) {
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)) {
try {
issuesService.bulkChange(createBulkChangeSeverityOfIssuesQuery(issueKeys, newSeverity));
} catch (Exception e) {
- assertHttpException(e, 401);
+ assertThat(e).isInstanceOf(HttpException.class);
+ assertThat(((HttpException) e).status()).isEqualTo(401);
}
}
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);
}
}
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;
}
}
- 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) {
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;
}
private static Issues.ChangelogWsResponse changelog(String issueKey) {
- return adminClient.issuesOld().changelog(issueKey);
+ return adminClient.issues().changelog(new ChangelogRequest().setIssue(issueKey));
}
}
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;
}
private List<Issues.Issue> 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<Issues.Issue> findAllIssues() {
- return adminWsClient.issuesOld().search(new SearchRequest()).getIssuesList();
+ return adminWsClient.issues().search(new SearchRequest()).getIssuesList();
}
}
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;
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);
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
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;
@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");
}
}
// 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");
}
-
}
/**
*/
@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<Issue> 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.Issue> 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);
}
/**
*/
@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<org.sonarqube.ws.Issues.Issue> 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<org.sonarqube.ws.Issues.Issue> 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<?, ? extends List<? extends org.sonarqube.ws.Issues.Issue>, org.sonarqube.ws.Issues.Issue> assertSearch(Consumer<SearchRequest>... consumers) {
+ return assertThat(searchResponse(consumers).getIssuesList());
}
+ @SafeVarargs
+ private final SearchWsResponse searchResponse(Consumer<SearchRequest>... consumers) {
+ SearchRequest request = new SearchRequest();
+ Arrays.stream(consumers).forEach(c -> c.accept(request));
+ return newAdminWsClient(ORCHESTRATOR).issues().search(request);
+ }
}
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;
.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"};
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) {
private void assertTags(@Nullable String userLogin, @Nullable String organization, String... expectedTags) {
assertThat(
- (List<String>) 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) {
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;
"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");
}
private List<Issue> 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() {
}
private static SearchWsResponse searchIssues(SearchRequest request) {
- return adminClient.issuesOld().search(request);
+ return adminClient.issues().search(request);
}
}
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 {
@Rule
public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR);
+ @Rule
+ public Tester tester = new Tester(ORCHESTRATOR);
+
@ClassRule
public static final IssueRule issueRule = IssueRule.from(ORCHESTRATOR);
@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);
@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");
// 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");
@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");
// 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");
@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();
@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");
@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");
@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");
@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");
@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");
@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");
@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();
}
private Issues.SearchWsResponse searchIssues(SearchRequest request) {
- return newAdminWsClient(ORCHESTRATOR).issuesOld().search(request);
+ return tester.wsClient().issues().search(request);
}
}
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;
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;
provisionAndAnalyseProject("sample2", org2.getKey());
List<String> 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);
}
.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()));
}
}
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;
@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);
}
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;
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<Issues.ChangelogWsResponse.Changelog> changes = changelog(firstIssue.getKey()).getChangelogList();
assertThat(changes).hasSize(1);
}
private Issues.ChangelogWsResponse changelog(String issueKey) {
- return tester.wsClient().issuesOld().changelog(issueKey);
+ return tester.wsClient().issues().changelog(new ChangelogRequest().setIssue(issueKey));
}
}
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;
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
// All the issues should have a technical debt
- List<Issues.Issue> issues = tester.wsClient().issuesOld().search(new SearchRequest()).getIssuesList();
+ List<Issues.Issue> issues = tester.wsClient().issues().search(new SearchRequest()).getIssuesList();
assertThat(issues).isNotEmpty();
for (Issues.Issue issue : issues) {
assertThat(issue.getDebt()).isEqualTo("1min");
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;
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<String> logLevelsOf(File webLogs) {
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;
}
public SearchWsResponse search(SearchRequest request) {
- return adminWsClient().issuesOld().search(request);
+ return adminWsClient().issues().search(request);
}
public Issue getRandomIssue() {