Browse Source

SONAR-13398 clean api/issues/search WS from deprecated code

tags/8.4.0.35506
Jacek 4 years ago
parent
commit
52dea5983f

+ 0
- 44
server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java View File

@@ -33,9 +33,6 @@ public class SearchRequest {
private Boolean assigned;
private List<String> assigneesUuid;
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;
@@ -55,7 +52,6 @@ public class SearchRequest {
private String organization;
private int page;
private int pageSize;
private List<String> projectKeys;
private List<String> projects;
private List<String> resolutions;
private Boolean resolved;
@@ -131,16 +127,6 @@ public class SearchRequest {
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;
@@ -299,16 +285,6 @@ public class SearchRequest {
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> getResolutions() {
return resolutions;
@@ -439,26 +415,6 @@ public class SearchRequest {
return this;
}

@CheckForNull
public List<String> getComponentRootUuids() {
return componentRootUuids;
}

public SearchRequest setComponentRootUuids(@Nullable 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;

+ 10
- 5
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java View File

@@ -20,11 +20,10 @@
package org.sonar.server.issue.index;

import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.project.ProjectDto;
import org.sonar.server.es.EsIndexSyncInProgressException;

public class IssueIndexSyncProgressChecker {
@@ -52,8 +51,14 @@ public class IssueIndexSyncProgressChecker {
/**
* Checks if project issue index sync is in progress, if it is, method throws exception org.sonar.server.es.EsIndexSyncInProgressException
*/
public void checkIfProjectIssueSyncInProgress(DbSession dbSession, ProjectDto projectDto) throws EsIndexSyncInProgressException {
if (doProjectNeedIssueSync(dbSession, projectDto.getUuid())) {
public void checkIfProjectIssueSyncInProgress(DbSession dbSession, String projectUuid) throws EsIndexSyncInProgressException {
if (doProjectNeedIssueSync(dbSession, projectUuid)) {
throw new EsIndexSyncInProgressException(IssueIndexDefinition.TYPE_ISSUE.getMainType());
}
}

public void checkIfAnyProjectIssueSyncInProgress(DbSession dbSession, Collection<String> projectUuids) throws EsIndexSyncInProgressException {
if (!findProjectUuidsWithIssuesSyncNeed(dbSession, projectUuids).isEmpty()) {
throw new EsIndexSyncInProgressException(IssueIndexDefinition.TYPE_ISSUE.getMainType());
}
}
@@ -66,7 +71,7 @@ public class IssueIndexSyncProgressChecker {
return !findProjectUuidsWithIssuesSyncNeed(dbSession, Sets.newHashSet(projectUuid)).isEmpty();
}

public List<String> findProjectUuidsWithIssuesSyncNeed(DbSession dbSession, Set<String> projectUuids) {
public List<String> findProjectUuidsWithIssuesSyncNeed(DbSession dbSession, Collection<String> projectUuids) {
return dbClient.branchDao().selectProjectUuidsWithIssuesNeedSync(dbSession, projectUuids);
}
}

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

@@ -195,30 +195,20 @@ public class IssueQueryFactory {
Boolean onComponentOnly = request.getOnComponentOnly();
Collection<String> components = request.getComponents();
Collection<String> componentUuids = request.getComponentUuids();
Collection<String> componentKeys = request.getComponentKeys();
Collection<String> componentRootUuids = request.getComponentRootUuids();
Collection<String> componentRoots = request.getComponentRoots();
String branch = request.getBranch();
String pullRequest = request.getPullRequest();

boolean effectiveOnComponentOnly = false;

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

if (componentRootUuids != null) {
allComponents.addAll(getComponentsFromUuids(session, componentRootUuids));
} else if (componentRoots != null) {
allComponents.addAll(getComponentsFromKeys(session, componentRoots, branch, pullRequest));
} else if (components != null) {
if (components != null) {
allComponents.addAll(getComponentsFromKeys(session, components, branch, pullRequest));
effectiveOnComponentOnly = true;
effectiveOnComponentOnly = BooleanUtils.isTrue(onComponentOnly);
} else if (componentUuids != null) {
allComponents.addAll(getComponentsFromUuids(session, componentUuids));
effectiveOnComponentOnly = BooleanUtils.isTrue(onComponentOnly);
} else if (componentKeys != null) {
allComponents.addAll(getComponentsFromKeys(session, componentKeys, branch, pullRequest));
effectiveOnComponentOnly = BooleanUtils.isTrue(onComponentOnly);
}

return effectiveOnComponentOnly;
@@ -238,7 +228,7 @@ public class IssueQueryFactory {
return;
}

List<String> projectKeys = request.getProjectKeys();
List<String> projectKeys = request.getProjects();
if (projectKeys != null) {
List<ComponentDto> projects = getComponentsFromKeys(session, projectKeys, request.getBranch(), request.getPullRequest());
builder.projectUuids(projects.stream().map(IssueQueryFactory::toProjectUuid).collect(toList()));
@@ -293,7 +283,7 @@ public class IssueQueryFactory {
}

private void addProjectUuidsForApplication(IssueQuery.Builder builder, DbSession session, SearchRequest request) {
List<String> projectKeys = request.getProjectKeys();
List<String> projectKeys = request.getProjects();
if (projectKeys != null) {
// On application, branch should only be applied on the application, not on projects
List<ComponentDto> projects = getComponentsFromKeys(session, projectKeys, null, null);

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

@@ -89,7 +89,7 @@ public class IssueQueryFactoryTest {
.setStatuses(asList("CLOSED"))
.setResolutions(asList("FALSE-POSITIVE"))
.setResolved(true)
.setProjectKeys(asList(project.getDbKey()))
.setProjects(asList(project.getDbKey()))
.setModuleUuids(asList(module.uuid()))
.setDirectories(asList("aDirPath"))
.setFileUuids(asList(file.uuid()))
@@ -187,7 +187,7 @@ public class IssueQueryFactoryTest {
@Test
public void add_unknown_when_no_component_found() {
SearchRequest request = new SearchRequest()
.setComponentKeys(asList("does_not_exist"));
.setComponents(asList("does_not_exist"));

IssueQuery query = underTest.create(request);

@@ -214,7 +214,7 @@ public class IssueQueryFactoryTest {
@Test
public void fail_if_components_and_components_uuid_params_are_set_at_the_same_time() {
SearchRequest request = new SearchRequest()
.setComponentKeys(singletonList("foo"))
.setComponents(singletonList("foo"))
.setComponentUuids(singletonList("bar"));

expectedException.expect(IllegalArgumentException.class);
@@ -224,35 +224,10 @@ public class IssueQueryFactoryTest {
}

@Test
public void fail_if_both_componentRoots_and_componentRootUuids_params_are_set() {
SearchRequest request = new SearchRequest()
.setComponentRoots(singletonList("foo"))
.setComponentRootUuids(singletonList("bar"));

expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("At most one of the following parameters can be provided: componentKeys and componentUuids");

underTest.create(request);
}

@Test
public void fail_if_componentRoots_references_components_with_different_qualifier() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
SearchRequest request = new SearchRequest()
.setComponentRoots(asList(project.getDbKey(), file.getDbKey()));

expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("All components must have the same qualifier, found FIL,TRK");

underTest.create(request);
}

@Test
public void param_componentRootUuids_enables_search_in_view_tree_if_user_has_permission_on_view() {
public void param_componentUuids_enables_search_in_view_tree_if_user_has_permission_on_view() {
ComponentDto view = db.components().insertView();
SearchRequest request = new SearchRequest()
.setComponentRootUuids(asList(view.uuid()));
.setComponentUuids(asList(view.uuid()));
userSession.registerComponents(view);

IssueQuery query = underTest.create(request);
@@ -305,7 +280,7 @@ public class IssueQueryFactoryTest {
ComponentDto view = db.components().insertView();
ComponentDto subView = db.components().insertComponent(newSubView(view));
SearchRequest request = new SearchRequest()
.setComponentRootUuids(asList(subView.uuid()));
.setComponentUuids(asList(subView.uuid()));

IssueQuery query = underTest.create(request);

@@ -327,7 +302,7 @@ public class IssueQueryFactoryTest {
public void onComponentOnly_restricts_search_to_specified_componentKeys() {
ComponentDto project = db.components().insertPrivateProject();
SearchRequest request = new SearchRequest()
.setComponentKeys(asList(project.getDbKey()))
.setComponents(asList(project.getDbKey()))
.setOnComponentOnly(true);

IssueQuery query = underTest.create(request);
@@ -393,16 +368,16 @@ public class IssueQueryFactoryTest {
ComponentDto branch = db.components().insertProjectBranch(project);

assertThat(underTest.create(new SearchRequest()
.setProjectKeys(singletonList(branch.getKey()))
.setProjects(singletonList(branch.getKey()))
.setBranch(branch.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(project.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(project.uuid()), false);

assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(branch.getKey()))
.setComponents(singletonList(branch.getKey()))
.setBranch(branch.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(project.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(project.uuid()), false);
}

@Test
@@ -412,24 +387,24 @@ public class IssueQueryFactoryTest {
ComponentDto file = db.components().insertComponent(newFileDto(branch));

assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(file.getKey()))
.setComponents(singletonList(file.getKey()))
.setBranch(branch.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);

assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(branch.getKey()))
.setComponents(singletonList(branch.getKey()))
.setFileUuids(singletonList(file.uuid()))
.setBranch(branch.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);

assertThat(underTest.create(new SearchRequest()
.setProjectKeys(singletonList(branch.getKey()))
.setProjects(singletonList(branch.getKey()))
.setFileUuids(singletonList(file.uuid()))
.setBranch(branch.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.fileUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
}

@Test
@@ -439,11 +414,11 @@ public class IssueQueryFactoryTest {
ComponentDto file = db.components().insertComponent(newFileDto(branch));

assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(file.getKey()))
.setComponents(singletonList(file.getKey()))
.setBranch(branch.getBranch())
.setOnComponentOnly(true)))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.componentUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.componentUuids()), IssueQuery::isMainBranch)
.containsOnly(branch.uuid(), singletonList(file.uuid()), false);
}

@Test
@@ -452,15 +427,15 @@ public class IssueQueryFactoryTest {
ComponentDto branch = db.components().insertProjectBranch(project);

assertThat(underTest.create(new SearchRequest()
.setProjectKeys(singletonList(project.getKey()))
.setProjects(singletonList(project.getKey()))
.setBranch("master")))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(project.uuid(), singletonList(project.uuid()), true);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(project.uuid(), singletonList(project.uuid()), true);
assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(project.getKey()))
.setComponents(singletonList(project.getKey()))
.setBranch("master")))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(project.uuid(), singletonList(project.uuid()), true);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(project.uuid(), singletonList(project.uuid()), true);
}

@Test
@@ -473,7 +448,7 @@ public class IssueQueryFactoryTest {
userSession.addProjectPermission(USER, application);

assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(application.getKey())))
.setComponents(singletonList(application.getKey())))
.viewUuids()).containsExactly(application.uuid());
}

@@ -493,18 +468,18 @@ public class IssueQueryFactoryTest {

// Search on applicationBranch1
assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(applicationBranch1.getKey()))
.setComponents(singletonList(applicationBranch1.getKey()))
.setBranch(applicationBranch1.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(applicationBranch1.uuid(), Collections.emptyList(), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(applicationBranch1.uuid(), Collections.emptyList(), false);

// Search on project1Branch1
assertThat(underTest.create(new SearchRequest()
.setComponentKeys(singletonList(applicationBranch1.getKey()))
.setProjectKeys(singletonList(project1.getKey()))
.setComponents(singletonList(applicationBranch1.getKey()))
.setProjects(singletonList(project1.getKey()))
.setBranch(applicationBranch1.getBranch())))
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(applicationBranch1.uuid(), singletonList(project1.uuid()), false);
.extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
.containsOnly(applicationBranch1.uuid(), singletonList(project1.uuid()), false);
}

@Test
@@ -561,7 +536,7 @@ public class IssueQueryFactoryTest {

underTest.create(new SearchRequest()
.setSinceLeakPeriod(true)
.setComponentKeys(asList(project1.getKey(), project2.getKey())));
.setComponents(asList(project1.getKey(), project2.getKey())));
}

@Test

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

@@ -101,7 +101,6 @@ 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_COMPONENT_KEYS;
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;
@@ -116,7 +115,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ON_COMPONEN
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_10;
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_PULL_REQUEST;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLUTIONS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLVED;
@@ -167,8 +165,8 @@ public class SearchAction implements IssuesWsAction {
private final System2 system2;
private final DbClient dbClient;

public SearchAction(UserSession userSession, IssueIndex issueIndex, IssueQueryFactory issueQueryFactory, SearchResponseLoader searchResponseLoader,
SearchResponseFormat searchResponseFormat, System2 system2, DbClient dbClient) {
public SearchAction(UserSession userSession, IssueIndex issueIndex, IssueQueryFactory issueQueryFactory,
SearchResponseLoader searchResponseLoader, SearchResponseFormat searchResponseFormat, System2 system2, DbClient dbClient) {
this.userSession = userSession;
this.issueIndex = issueIndex;
this.issueQueryFactory = issueQueryFactory;
@@ -183,13 +181,10 @@ public class SearchAction implements IssuesWsAction {
WebService.NewAction action = controller
.createAction(ACTION_SEARCH)
.setHandler(this)
.setDescription(
"Search for issues.<br>" +
"At most one of the following parameters can be provided at the same time: %s and %s.<br>" +
"Requires the 'Browse' permission on the specified project(s).",
PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS)
.setDescription("Search for issues.<br>Requires the 'Browse' permission on the specified project(s).")
.setSince("3.6")
.setChangelog(
new Change("8.4", "parameters 'componentUuids', 'projectKeys' has been dropped."),
new Change("8.2", "'REVIEWED', 'TO_REVIEW' status param values are no longer supported"),
new Change("8.2", "Security hotspots are no longer returned as type 'SECURITY_HOTSPOT' is not supported anymore, use dedicated api/hotspots"),
new Change("8.2", "response field 'fromHotspot' has been deprecated and is no more populated"),
@@ -324,18 +319,10 @@ public class SearchAction implements IssuesWsAction {
"A component can be a portfolio, project, module, directory or file.")
.setExampleValue(KEY_PROJECT_EXAMPLE_001);

action.createParam(PARAM_COMPONENT_UUIDS)
.setDescription("To retrieve issues associated to a specific list of components their sub-components (comma-separated list of component IDs). " +
INTERNAL_PARAMETER_DISCLAIMER +
"A component can be a project, module, directory or file.")
.setDeprecatedSince("6.5")
.setExampleValue("584a89f2-8037-4f7b-b82c-8b45d2d63fb2");

action.createParam(PARAM_PROJECTS)
.setDescription("To retrieve issues associated to a specific list of projects (comma-separated list of project keys). " +
INTERNAL_PARAMETER_DISCLAIMER +
"If this parameter is set, projectUuids must not be set.")
.setDeprecatedKey(PARAM_PROJECT_KEYS, "6.5")
.setInternal(true)
.setExampleValue(KEY_PROJECT_EXAMPLE_001);

@@ -448,7 +435,6 @@ public class SearchAction implements IssuesWsAction {
addMandatoryValuesToFacet(facets, FACET_PROJECTS, query.projectUuids());
addMandatoryValuesToFacet(facets, PARAM_MODULE_UUIDS, query.moduleUuids());
addMandatoryValuesToFacet(facets, PARAM_FILE_UUIDS, query.fileUuids());
addMandatoryValuesToFacet(facets, PARAM_COMPONENT_UUIDS, request.getComponentUuids());

List<String> assignees = Lists.newArrayList("");
List<String> assigneesFromRequest = request.getAssigneeUuids();
@@ -499,7 +485,6 @@ public class SearchAction implements IssuesWsAction {
collector.addProjectUuids(facets.getBucketKeys(FACET_PROJECTS));
collector.addComponentUuids(facets.getBucketKeys(PARAM_MODULE_UUIDS));
collector.addComponentUuids(facets.getBucketKeys(PARAM_FILE_UUIDS));
collector.addComponentUuids(facets.getBucketKeys(PARAM_COMPONENT_UUIDS));
collector.addRuleIds(facets.getBucketKeys(PARAM_RULES));
collector.addUserUuids(facets.getBucketKeys(PARAM_ASSIGNEES));
}
@@ -507,7 +492,6 @@ public class SearchAction implements IssuesWsAction {
private static void collectRequestParams(SearchResponseLoader.Collector collector, SearchRequest request) {
collector.addComponentUuids(request.getFileUuids());
collector.addComponentUuids(request.getModuleUuids());
collector.addComponentUuids(request.getComponentRootUuids());
collector.addUserUuids(request.getAssigneeUuids());
}

@@ -518,8 +502,7 @@ public class SearchAction implements IssuesWsAction {
.setAssigned(request.paramAsBoolean(PARAM_ASSIGNED))
.setAssigneesUuid(getLogins(dbSession, request.paramAsStrings(PARAM_ASSIGNEES)))
.setAuthors(request.hasParam(PARAM_AUTHOR) ? request.multiParam(PARAM_AUTHOR) : request.paramAsStrings(DEPRECATED_PARAM_AUTHORS))
.setComponentKeys(request.paramAsStrings(PARAM_COMPONENT_KEYS))
.setComponentUuids(request.paramAsStrings(PARAM_COMPONENT_UUIDS))
.setComponents(request.paramAsStrings(PARAM_COMPONENT_KEYS))
.setCreatedAfter(request.param(PARAM_CREATED_AFTER))
.setCreatedAt(request.param(PARAM_CREATED_AT))
.setCreatedBefore(request.param(PARAM_CREATED_BEFORE))
@@ -537,7 +520,6 @@ public class SearchAction implements IssuesWsAction {
.setOrganization(request.param(PARAM_ORGANIZATION))
.setPage(request.mandatoryParamAsInt(Param.PAGE))
.setPageSize(request.mandatoryParamAsInt(Param.PAGE_SIZE))
.setProjectKeys(request.paramAsStrings(PARAM_PROJECTS))
.setProjects(request.paramAsStrings(PARAM_PROJECTS))
.setResolutions(request.paramAsStrings(PARAM_RESOLUTIONS))
.setResolved(request.paramAsBoolean(PARAM_RESOLVED))

+ 22
- 34
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java View File

@@ -75,12 +75,10 @@ import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.db.component.ComponentTesting.newView;
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_COMPONENT_UUIDS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DIRECTORIES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILE_UUIDS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_MODULE_UUIDS;
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_PULL_REQUEST;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD;

@@ -168,12 +166,12 @@ public class SearchActionComponentsTest {
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, module1.getKey())
.executeProtobuf(SearchWsResponse.class).getIssuesList()).extracting(Issue::getKey)
.containsExactlyInAnyOrder(issue1.getKey());
.containsExactlyInAnyOrder(issue1.getKey());

assertThat(ws.newRequest()
.setParam(PARAM_MODULE_UUIDS, module1.uuid())
.executeProtobuf(SearchWsResponse.class).getIssuesList()).extracting(Issue::getKey)
.containsExactlyInAnyOrder(issue1.getKey());
.containsExactlyInAnyOrder(issue1.getKey());
}

@Test
@@ -216,7 +214,7 @@ public class SearchActionComponentsTest {
indexIssues();

ws.newRequest()
.setParam(PARAM_COMPONENT_UUIDS, project.uuid())
.setParam(PARAM_COMPONENT_KEYS, project.getDbKey())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.execute()
.assertJson(this.getClass(), "search_since_leak_period.json");
@@ -239,7 +237,7 @@ public class SearchActionComponentsTest {
indexIssues();

ws.newRequest()
.setParam(PARAM_COMPONENT_UUIDS, project.uuid())
.setParam(PARAM_COMPONENT_KEYS, project.getDbKey())
.setParam(PARAM_FILE_UUIDS, file.uuid())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.execute()
@@ -264,16 +262,6 @@ public class SearchActionComponentsTest {
.setParam(PARAM_FILE_UUIDS, "unknown")
.execute()
.assertJson(this.getClass(), "no_issue.json");

ws.newRequest()
.setParam(PARAM_COMPONENT_UUIDS, file.uuid())
.execute()
.assertJson(this.getClass(), "search_by_file_uuid.json");

ws.newRequest()
.setParam(PARAM_COMPONENT_UUIDS, "unknown")
.execute()
.assertJson(this.getClass(), "no_issue.json");
}

@Test
@@ -484,11 +472,11 @@ public class SearchActionComponentsTest {
.setParam(PARAM_COMPONENT_KEYS, applicationBranch1.getKey())
.setParam(PARAM_BRANCH, applicationBranch1.getBranch())
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getProject, Issue::getBranch, Issue::hasBranch)
.containsExactlyInAnyOrder(
tuple(issueOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch(), true),
tuple(issueOnFileOnProject1Branch1.getKey(), fileOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch(), true),
tuple(issueOnProject2.getKey(), project2.getKey(), project2.getKey(), "", false));
.extracting(Issue::getKey, Issue::getComponent, Issue::getProject, Issue::getBranch, Issue::hasBranch)
.containsExactlyInAnyOrder(
tuple(issueOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch(), true),
tuple(issueOnFileOnProject1Branch1.getKey(), fileOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch(), true),
tuple(issueOnProject2.getKey(), project2.getKey(), project2.getKey(), "", false));

// Issues on project1Branch1
assertThat(ws.newRequest()
@@ -496,10 +484,10 @@ public class SearchActionComponentsTest {
.setParam(PARAM_PROJECTS, project1.getKey())
.setParam(PARAM_BRANCH, applicationBranch1.getBranch())
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(
tuple(issueOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch()),
tuple(issueOnFileOnProject1Branch1.getKey(), fileOnProject1Branch1.getKey(), project1Branch1.getBranch()));
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(
tuple(issueOnProject1Branch1.getKey(), project1Branch1.getKey(), project1Branch1.getBranch()),
tuple(issueOnFileOnProject1Branch1.getKey(), fileOnProject1Branch1.getKey(), project1Branch1.getBranch()));
}

@Test
@@ -581,7 +569,7 @@ public class SearchActionComponentsTest {

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

assertThat(result.getIssuesList()).extracting(Issue::getKey)
@@ -612,7 +600,7 @@ public class SearchActionComponentsTest {

SearchWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, application.getDbKey())
.setParam(PARAM_PROJECT_KEYS, project1.getDbKey())
.setParam(PARAM_PROJECTS, project1.getDbKey())
.setParam(PARAM_SINCE_LEAK_PERIOD, "true")
.executeProtobuf(SearchWsResponse.class);

@@ -670,24 +658,24 @@ public class SearchActionComponentsTest {
.setParam(PARAM_COMPONENT_KEYS, project.getKey())
.setParam(PARAM_BRANCH, branch.getBranch())
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));

// On project key + branch
assertThat(ws.newRequest()
.setParam(PARAM_PROJECT_KEYS, project.getKey())
.setParam(PARAM_PROJECTS, project.getKey())
.setParam(PARAM_BRANCH, branch.getBranch())
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));

// On file key + branch
assertThat(ws.newRequest()
.setParam(PARAM_COMPONENT_KEYS, branchFile.getKey())
.setParam(PARAM_BRANCH, branch.getBranch())
.executeProtobuf(SearchWsResponse.class).getIssuesList())
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));
.extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
.containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchFile.getBranch()));
}

@Test

+ 1
- 1
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java View File

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

assertThat(def.params()).extracting("key").containsExactlyInAnyOrder(
"additionalFields", "asc", "assigned", "assignees", "authors", "author", "componentKeys", "componentUuids", "branch",
"additionalFields", "asc", "assigned", "assignees", "authors", "author", "componentKeys", "branch",
"pullRequest", "organization",
"createdAfter", "createdAt", "createdBefore", "createdInLast", "directories", "facetMode", "facets", "fileUuids", "issues", "languages", "moduleUuids", "onComponentOnly",
"p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "sinceLeakPeriod",

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

@@ -45,6 +45,7 @@ public class IssuesWsParameters {
public static final String PARAM_ASSIGNEE = "assignee";
public static final String PARAM_TRANSITION = "transition";
public static final String PARAM_SEVERITY = "severity";
public static final String PARAM_COMPONENT = "component";
public static final String PARAM_COMPONENT_UUID = "componentUuid";
public static final String PARAM_TYPE = "type";
public static final String PARAM_ISSUES = "issues";
@@ -56,7 +57,6 @@ public class IssuesWsParameters {
public static final String PARAM_COMPONENT_UUIDS = "componentUuids";
public static final String PARAM_MODULE_UUIDS = "moduleUuids";
public static final String PARAM_PROJECTS = "projects";
public static final String PARAM_PROJECT_KEYS = "projectKeys";
public static final String PARAM_DIRECTORIES = "directories";
public static final String PARAM_FILE_UUIDS = "fileUuids";
public static final String PARAM_ON_COMPONENT_ONLY = "onComponentOnly";

Loading…
Cancel
Save