Browse Source

SONAR-19934 Rename ws param componentKeys to components

tags/10.2.0.77647
Eric Giffon 10 months ago
parent
commit
efd1e3f1d2

+ 2
- 2
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java View File

@@ -73,7 +73,7 @@ import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime;
import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
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_IN_LAST;
@@ -251,7 +251,7 @@ public class IssueQueryFactory {
boolean effectiveOnComponentOnly = false;

checkArgument(atMostOneNonNullElement(componentKeys, componentUuids),
"At most one of the following parameters can be provided: %s and %s", PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS);
"At most one of the following parameters can be provided: %s and %s", PARAM_COMPONENTS, PARAM_COMPONENT_UUIDS);

if (componentKeys != null) {
allComponents.addAll(getComponentsFromKeys(session, componentKeys, branch, pullRequest));

+ 1
- 1
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java View File

@@ -284,7 +284,7 @@ public class IssueQueryFactoryTest {

assertThatThrownBy(() -> underTest.create(request))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("At most one of the following parameters can be provided: componentKeys and componentUuids");
.hasMessageContaining("At most one of the following parameters can be provided: components and componentUuids");
}

@Test

+ 22
- 22
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java View File

@@ -75,7 +75,7 @@ import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DIRECTORIES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
@@ -169,7 +169,7 @@ public class SearchActionComponentsIT {
indexIssues();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.execute()
.assertJson(this.getClass(), "search_since_leak_period.json");
@@ -209,12 +209,12 @@ public class SearchActionComponentsIT {
indexIssues();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, file.getKey())
.setParam(PARAM_COMPONENTS, file.getKey())
.execute()
.assertJson(this.getClass(), "search_by_file_key.json");

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, unitTest.getKey())
.setParam(PARAM_COMPONENTS, unitTest.getKey())
.execute()
.assertJson(this.getClass(), "search_by_test_key.json");
}
@@ -231,7 +231,7 @@ public class SearchActionComponentsIT {
indexIssues();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, directory.getKey())
.setParam(PARAM_COMPONENTS, directory.getKey())
.execute()
.assertJson(this.getClass(), "search_by_file_uuid.json");

@@ -266,7 +266,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, view.getKey())
.setParam(PARAM_COMPONENTS, view.getKey())
.execute()
.assertJson(this.getClass(), "search_by_view_uuid.json");
}
@@ -286,7 +286,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, subView.getKey())
.setParam(PARAM_COMPONENTS, subView.getKey())
.execute()
.assertJson(this.getClass(), "search_by_view_uuid.json");
}
@@ -306,7 +306,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, subView.getKey())
.setParam(PARAM_COMPONENTS, subView.getKey())
.execute()
.assertJson(this.getClass(), "no_issue.json");
}
@@ -330,7 +330,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.executeProtobuf(SearchWsResponse.class);

assertThat(result.getIssuesList()).extracting(Issue::getKey)
@@ -373,7 +373,7 @@ public class SearchActionComponentsIT {

// All issues on applicationBranch1
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, applicationBranch1.getKey())
.setParam(PARAM_COMPONENTS, applicationBranch1.getKey())
.setParam(PARAM_BRANCH, appBranch1)
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getProject, Issue::getBranch, Issue::hasBranch)
@@ -384,7 +384,7 @@ public class SearchActionComponentsIT {

// Issues on project1Branch1
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, applicationBranch1.getKey())
.setParam(PARAM_COMPONENTS, applicationBranch1.getKey())
.setParam(PARAM_PROJECTS, project1.getKey())
.setParam(PARAM_BRANCH, appBranch1)
.executeProtobuf(SearchWsResponse.class).getIssuesList())
@@ -406,7 +406,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.executeProtobuf(SearchWsResponse.class);

assertThat(result.getIssuesList()).isEmpty();
@@ -424,7 +424,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.executeProtobuf(SearchWsResponse.class);

assertThat(result.getIssuesList()).isEmpty();
@@ -456,7 +456,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);

@@ -483,7 +483,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.setParam(PARAM_PROJECTS, project1.getKey())
.executeProtobuf(SearchWsResponse.class);

@@ -518,7 +518,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.setParam(PARAM_PROJECTS, project1.getKey())
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);
@@ -554,7 +554,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getKey())
.setParam(PARAM_COMPONENTS, application.getKey())
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);

@@ -580,7 +580,7 @@ public class SearchActionComponentsIT {

// On component key + branch
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(PARAM_BRANCH, branchName)
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
@@ -595,7 +595,7 @@ public class SearchActionComponentsIT {
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchName));
// On file key + branch
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, branchFile.getKey())
.setParam(PARAM_COMPONENTS, branchFile.getKey())
.setParam(PARAM_BRANCH, branchName)
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
@@ -617,7 +617,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, branch.getKey())
.setParam(PARAM_COMPONENTS, branch.getKey())
.setParam(PARAM_BRANCH, branchName)
.executeProtobuf(SearchWsResponse.class);

@@ -644,7 +644,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, pullRequest.getKey())
.setParam(PARAM_COMPONENTS, pullRequest.getKey())
.setParam(PARAM_PULL_REQUEST, pullRequestKey)
.executeProtobuf(SearchWsResponse.class);

@@ -669,7 +669,7 @@ public class SearchActionComponentsIT {
indexIssuesAndViews();

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
.executeProtobuf(SearchWsResponse.class);


+ 5
- 5
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java View File

@@ -62,7 +62,7 @@ import static org.sonar.api.server.ws.WebService.Param.FACETS;
import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.server.tester.UserSessionRule.standalone;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS;

@@ -106,7 +106,7 @@ public class SearchActionFacetsIT {
indexIssues();

SearchWsResponse response = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(FACETS, "severities,statuses,resolutions,rules,types,languages,projects,files,assignees")
.executeProtobuf(SearchWsResponse.class);

@@ -183,7 +183,7 @@ public class SearchActionFacetsIT {

SearchWsResponse response = ws.newRequest()
.setParam("resolved", "false")
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(WebService.Param.FACETS, "directories")
.executeProtobuf(SearchWsResponse.class);

@@ -224,7 +224,7 @@ public class SearchActionFacetsIT {
indexIssues();

SearchWsResponse response = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(PARAM_FILES, file1.path())
.setParam(WebService.Param.FACETS, "files")
.executeProtobuf(SearchWsResponse.class);
@@ -284,7 +284,7 @@ public class SearchActionFacetsIT {
indexIssues();

SearchWsResponse response = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_COMPONENTS, project.getKey())
.setParam(FACETS, "files,directories,statuses,resolutions,severities,types,rules,languages,assignees")
.executeProtobuf(SearchWsResponse.class);


+ 7
- 7
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java View File

@@ -120,7 +120,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_TAGS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ADDITIONAL_FIELDS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CODE_VARIANTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_HIDE_COMMENTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
@@ -620,7 +620,7 @@ public class SearchActionIT {
session.commit();
indexIssues();

ws.newRequest().setParam(PARAM_COMPONENT_KEYS, file.getKey()).execute()
ws.newRequest().setParam(PARAM_COMPONENTS, file.getKey()).execute()
.assertJson(this.getClass(), "apply_paging_with_one_component.json");
}

@@ -711,7 +711,7 @@ public class SearchActionIT {

ws.newRequest()
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
.setParam(PARAM_COMPONENTS, "PROJECT_KEY")
.execute()
.assertJson(this.getClass(), "filter_by_leak_period.json");

@@ -759,7 +759,7 @@ public class SearchActionIT {
userSession.logIn(john);

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
.setParam(PARAM_COMPONENTS, "PROJECT_KEY")
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.execute()
.assertJson(this.getClass(), "empty_result.json");
@@ -804,7 +804,7 @@ public class SearchActionIT {
userSession.logIn(john);

ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
.setParam(PARAM_COMPONENTS, "PROJECT_KEY")
.setParam(PARAM_PULL_REQUEST, "pr")
.setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
.execute()
@@ -1749,7 +1749,7 @@ public class SearchActionIT {
public void empty_search_with_unknown_branch() {
SearchWsResponse response = ws.newRequest()
.setParam("onComponentOnly", "true")
.setParam("componentKeys", "foo")
.setParam("components", "foo")
.setParam("branch", "bar")
.executeProtobuf(SearchWsResponse.class);

@@ -1787,7 +1787,7 @@ public class SearchActionIT {
assertThat(def.responseExampleAsString()).isNotEmpty();

assertThat(def.params()).extracting("key").containsExactlyInAnyOrder(
"additionalFields", "asc", "assigned", "assignees", "author", "componentKeys", "branch", "pullRequest", "createdAfter", "createdAt",
"additionalFields", "asc", "assigned", "assignees", "author", "components", "branch", "pullRequest", "createdAfter", "createdAt",
"createdBefore", "createdInLast", "directories", "facets", "files", "issues", "scopes", "languages", "onComponentOnly",
"p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "statuses", "tags", "types", "pciDss-3.2", "pciDss-4.0", "owaspAsvs-4.0",
"owaspAsvsLevel", "owaspTop10",

+ 5
- 2
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java View File

@@ -95,6 +95,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_AUTHOR;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CODE_VARIANTS;
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_CREATED_AFTER;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AT;
@@ -193,6 +194,7 @@ public class SearchAction implements IssuesWsAction {
+ "<br/>When issue indexation is in progress returns 503 service unavailable HTTP code.")
.setSince("3.6")
.setChangelog(
new Change("10.2", format("Parameter '%s' renamed to '%s'", PARAM_COMPONENT_KEYS, PARAM_COMPONENTS)),
new Change("10.1", "Add the 'codeVariants' parameter, facet and response field"),
new Change("10.0", "Parameter 'sansTop25' is deprecated"),
new Change("10.0", "The value 'sansTop25' for the parameter 'facets' has been deprecated"),
@@ -370,7 +372,8 @@ public class SearchAction implements IssuesWsAction {
.setBooleanPossibleValues()
.setDefaultValue("false");

action.createParam(PARAM_COMPONENT_KEYS)
action.createParam(PARAM_COMPONENTS)
.setDeprecatedKey(PARAM_COMPONENT_KEYS, "10.2")
.setDescription("Comma-separated list of component keys. Retrieve issues associated to a specific list of components (and all its descendants). " +
"A component can be a portfolio, project, module, directory or file.")
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
@@ -549,7 +552,7 @@ public class SearchAction implements IssuesWsAction {
.setAssigned(request.paramAsBoolean(PARAM_ASSIGNED))
.setAssigneesUuid(getLogins(dbSession, request.paramAsStrings(PARAM_ASSIGNEES)))
.setAuthors(request.multiParam(PARAM_AUTHOR))
.setComponentKeys(request.paramAsStrings(PARAM_COMPONENT_KEYS))
.setComponentKeys(request.paramAsStrings(PARAM_COMPONENTS))
.setCreatedAfter(request.param(PARAM_CREATED_AFTER))
.setCreatedAt(request.param(PARAM_CREATED_AT))
.setCreatedBefore(request.param(PARAM_CREATED_BEFORE))

+ 1
- 0
sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java View File

@@ -56,6 +56,7 @@ public class IssuesWsParameters {
public static final String PARAM_STATUSES = "statuses";
public static final String PARAM_RESOLUTIONS = "resolutions";
public static final String PARAM_RESOLVED = "resolved";
public static final String PARAM_COMPONENTS = "components";
public static final String PARAM_COMPONENT_KEYS = "componentKeys";
public static final String PARAM_COMPONENT_UUIDS = "componentUuids";
public static final String PARAM_PROJECTS = "projects";

+ 1
- 1
sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java View File

@@ -221,7 +221,7 @@ public class IssuesService extends BaseService {
.setParam("assignees", request.getAssignees() == null ? null : request.getAssignees().stream().collect(Collectors.joining(",")))
.setParam("author", request.getAuthor())
.setParam("branch", request.getBranch())
.setParam("componentKeys", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
.setParam("components", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
.setParam("createdAfter", request.getCreatedAfter())
.setParam("createdAt", request.getCreatedAt())
.setParam("createdBefore", request.getCreatedBefore())

Loading…
Cancel
Save