private static final String PROJECT_KEY2 = "com.sonarsource.it.samples:multi-modules-sample2";
private static int DEFAULT_PAGINATED_RESULTS = 100;
- private static int TOTAL_NB_ISSUES = 273;
+ private static int TOTAL_NB_ISSUES = 272;
@BeforeClass
public static void prepareData() {
// Resolve a issue to test search by status and by resolution
adminIssueClient().doTransition(searchRandomIssue().key(), "resolve");
-
- // Create a manual issue to test search by reporter
- createManualRule();
- adminIssueClient().create(
- NewIssue.create().component("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo")
- .rule("manual:invalidclassname")
- .line(3)
- .severity("CRITICAL")
- .message("The name of the class is invalid"));
}
@After
@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(83);
- assertThat(search(IssueQuery.create().componentRoots("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1")).list()).hasSize(37);
+ 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);
assertThat(search(IssueQuery.create().componentRoots("unknown")).list()).isEmpty();
}
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(35);
+ .hasSize(34);
assertThat(search(IssueQuery.create().components("unknown")).list()).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(9);
+ 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);
assertThat(search(IssueQuery.create().assigned(false)).paging().total()).isEqualTo(TOTAL_NB_ISSUES - 1);
}
- @Test
- public void search_issues_by_reporters() {
- assertThat(search(IssueQuery.create().reporters("admin")).list()).hasSize(1);
- assertThat(search(IssueQuery.create().reporters("unknown")).list()).isEmpty();
- }
-
@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);
- assertThat(search(IssueQuery.create().rules("manual:invalidclassname")).list()).hasSize(1);
try {
assertThat(search(IssueQuery.create().rules("unknown")).list()).isEmpty();
ORCHESTRATOR.getServer().adminWsClient().post("/api/rules/create", ImmutableMap.<String, Object>of(
"manual_key", "invalidclassname",
"name", "InvalidClassName",
- "markdown_description", "Invalid class name"
- ));
+ "markdown_description", "Invalid class name"));
}
}
private final Collection<String> files;
private final Collection<String> views;
private final Collection<RuleKey> rules;
- private final Collection<String> reporters;
private final Collection<String> assignees;
private final Collection<String> authors;
private final Collection<String> languages;
this.files = defaultCollection(builder.files);
this.views = defaultCollection(builder.views);
this.rules = defaultCollection(builder.rules);
- this.reporters = defaultCollection(builder.reporters);
this.assignees = defaultCollection(builder.assignees);
this.authors = defaultCollection(builder.authors);
this.languages = defaultCollection(builder.languages);
return rules;
}
- public Collection<String> reporters() {
- return reporters;
- }
-
public Collection<String> assignees() {
return assignees;
}
private Collection<String> files;
private Collection<String> views;
private Collection<RuleKey> rules;
- private Collection<String> reporters;
private Collection<String> assignees;
private Collection<String> authors;
private Collection<String> languages;
return this;
}
- public Builder reporters(@Nullable Collection<String> l) {
- this.reporters = l;
- return this;
- }
-
public Builder assignees(@Nullable Collection<String> l) {
this.assignees = l;
return this;
.resolutions(RubyUtils.toStrings(params.get(IssueFilterParameters.RESOLUTIONS)))
.resolved(RubyUtils.toBoolean(params.get(IssueFilterParameters.RESOLVED)))
.rules(toRules(params.get(IssueFilterParameters.RULES)))
- .reporters(RubyUtils.toStrings(params.get(IssueFilterParameters.REPORTERS)))
.assignees(buildAssignees(RubyUtils.toStrings(params.get(IssueFilterParameters.ASSIGNEES))))
.languages(RubyUtils.toStrings(params.get(IssueFilterParameters.LANGUAGES)))
.tags(RubyUtils.toStrings(params.get(IssueFilterParameters.TAGS)))
.resolutions(request.getResolutions())
.resolved(request.getResolved())
.rules(stringsToRules(request.getRules()))
- .reporters(request.getReporters())
.assignees(buildAssignees(request.getAssignees()))
.languages(request.getLanguages())
.tags(request.getTags())
LANGUAGES,
TAGS,
TYPES,
- CREATED_AT);
+ CREATED_AT
+ );
+
// TODO to be documented
// TODO move to Facets ?
filters.put(IssueIndexDefinition.FIELD_ISSUE_TAGS, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_TAGS, query.tags()));
filters.put(IssueIndexDefinition.FIELD_ISSUE_TYPE, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_TYPE, query.types()));
filters.put(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION, query.resolutions()));
- filters.put(IssueIndexDefinition.FIELD_ISSUE_REPORTER, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_REPORTER, query.reporters()));
filters.put(IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors()));
filters.put(IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules()));
filters.put(IssueIndexDefinition.FIELD_ISSUE_SEVERITY, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_SEVERITY, query.severities()));
LANGUAGES, IssueIndexDefinition.FIELD_ISSUE_LANGUAGE, query.languages().toArray());
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
RULES, IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules().toArray());
- addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
- REPORTERS, IssueIndexDefinition.FIELD_ISSUE_REPORTER);
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
AUTHORS, IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors().toArray());
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECTS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECT_KEYS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECT_UUIDS;
-import static org.sonarqube.ws.client.issue.IssueFilterParameters.REPORTERS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RESOLUTIONS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RESOLVED;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RULES;
.setDescription(
"Search for issues. Requires Browse permission on project(s).<br/>" +
"Since 5.5, response field 'debt' has been renamed to 'effort'.<br/>" +
- "Since 5.5, response field 'actionPlan' has been removed")
+ "Since 5.5, response field 'actionPlan' has been removed.<br/>" +
+ "Since 5.5, response field 'reporter' has been removed, as manual issue feature has been dropped")
.setSince("3.6")
.setResponseExample(Resources.getResource(this.getClass(), "example-search.json"));
action.addPagingParams(100, MAX_LIMIT);
action.createParam(Param.FACETS)
.setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.<br/>" +
- "Since 5.5, facet 'actionPlans' is deprecated.")
+ "Since 5.5, facet 'actionPlans' is deprecated.<br/>" +
+ "Since 5.5, facet 'reporters' is deprecated.")
.setPossibleValues(IssueIndex.SUPPORTED_FACETS);
action.createParam(FACET_MODE)
.setDefaultValue(FACET_MODE_COUNT)
.setDescription("Since 5.5 this parameter is no more used, as action plan feature has been dropped")
.setDeprecatedSince("5.5")
.setBooleanPossibleValues();
- action.createParam(REPORTERS)
- .setDescription("Comma-separated list of reporter logins")
- .setExampleValue("admin");
+ action.createParam("reporters")
+ .setDescription("Since 5.5 this parameter is no more used, as manual issue feature has been dropped")
+ .setExampleValue("admin")
+ .setDeprecatedSince("5.5");
action.createParam(AUTHORS)
.setDescription("Comma-separated list of SCM accounts")
.setExampleValue("torvalds@linux-foundation.org");
}
addMandatoryValuesToFacet(facets, ASSIGNEES, assignees);
addMandatoryValuesToFacet(facets, FACET_ASSIGNED_TO_ME, singletonList(userSession.getLogin()));
- addMandatoryValuesToFacet(facets, REPORTERS, request.getReporters());
addMandatoryValuesToFacet(facets, RULES, request.getRules());
addMandatoryValuesToFacet(facets, LANGUAGES, request.getLanguages());
addMandatoryValuesToFacet(facets, TAGS, request.getTags());
collector.addComponentUuids(facets.getBucketKeys(FILE_UUIDS));
collector.addComponentUuids(facets.getBucketKeys(MODULE_UUIDS));
collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(ASSIGNEES));
- collector.addAll(SearchAdditionalField.USERS, facets.getBucketKeys(REPORTERS));
}
private void collectRequestParams(SearchResponseLoader.Collector collector, SearchWsRequest request) {
collector.addComponentUuids(request.getModuleUuids());
collector.addComponentUuids(request.getComponentRootUuids());
collector.addAll(SearchAdditionalField.USERS, request.getAssignees());
- collector.addAll(SearchAdditionalField.USERS, request.getReporters());
}
private static SearchWsRequest toSearchWsRequest(Request request) {
.setProjectKeys(request.paramAsStrings(PROJECT_KEYS))
.setProjectUuids(request.paramAsStrings(PROJECT_UUIDS))
.setProjects(request.paramAsStrings(PROJECTS))
- .setReporters(request.paramAsStrings(REPORTERS))
.setResolutions(request.paramAsStrings(RESOLUTIONS))
.setResolved(request.paramAsBoolean(RESOLVED))
.setRules(request.paramAsStrings(RULES))
}
public Issues.SearchWsResponse formatSearch(Set<SearchAdditionalField> fields, SearchResponseData data,
- Paging paging, @Nullable Facets facets) {
+ Paging paging, @Nullable Facets facets) {
Issues.SearchWsResponse.Builder response = Issues.SearchWsResponse.newBuilder();
formatPaging(paging, response);
if (!Strings.isNullOrEmpty(dto.getAssignee())) {
issueBuilder.setAssignee(dto.getAssignee());
}
- if (!Strings.isNullOrEmpty(dto.getReporter())) {
- issueBuilder.setReporter(dto.getReporter());
- }
if (!Strings.isNullOrEmpty(dto.getResolution())) {
issueBuilder.setResolution(dto.getResolution());
}
componentUuids.add(issue.getComponentUuid());
projectUuids.add(issue.getProjectUuid());
add(RULES, issue.getRuleKey());
- add(USERS, issue.getReporter());
add(USERS, issue.getAssignee());
collectComponentsFromIssueLocations(issue);
}
assertThat(query.projectUuids()).containsOnly("ABCD");
assertThat(query.moduleUuids()).containsOnly("BCDE");
assertThat(query.fileUuids()).containsOnly("CDEF");
- assertThat(query.reporters()).containsOnly("marilyn");
assertThat(query.assignees()).containsOnly("joanna");
assertThat(query.languages()).containsOnly("xoo");
assertThat(query.tags()).containsOnly("tag1", "tag2");
.setSinceLeakPeriod(true)
.setComponentUuids(Collections.singletonList("component-uuid"))
.setProjectUuids(Collections.singletonList("project-uuid"))
- );
+ );
}
}
.componentUuids(newArrayList("org/struts/Action.java"))
.moduleUuids(newArrayList("org.struts:core"))
.rules(newArrayList(RuleKey.of("squid", "AvoidCycle")))
- .reporters(newArrayList("crunky"))
.assignees(newArrayList("gargantua"))
.languages(newArrayList("xoo"))
.tags(newArrayList("tag1", "tag2"))
assertThat(query.resolutions()).containsOnly(Issue.RESOLUTION_FALSE_POSITIVE);
assertThat(query.componentUuids()).containsOnly("org/struts/Action.java");
assertThat(query.moduleUuids()).containsOnly("org.struts:core");
- assertThat(query.reporters()).containsOnly("crunky");
assertThat(query.assignees()).containsOnly("gargantua");
assertThat(query.languages()).containsOnly("xoo");
assertThat(query.tags()).containsOnly("tag1", "tag2");
.moduleUuids(null)
.statuses(null)
.assignees(null)
- .reporters(null)
.resolutions(null)
.rules(null)
.severities(null)
assertThat(query.moduleUuids()).isEmpty();
assertThat(query.statuses()).isEmpty();
assertThat(query.assignees()).isEmpty();
- assertThat(query.reporters()).isEmpty();
assertThat(query.resolutions()).isEmpty();
assertThat(query.rules()).isEmpty();
assertThat(query.severities()).isEmpty();
assertThat(query.moduleUuids()).isEmpty();
assertThat(query.statuses()).isEmpty();
assertThat(query.assignees()).isEmpty();
- assertThat(query.reporters()).isEmpty();
assertThat(query.resolutions()).isEmpty();
assertThat(query.rules()).isEmpty();
assertThat(query.severities()).isEmpty();
assertThat(
index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(file.uuid())).build(), new SearchOptions()).getDocs())
- .isEmpty();
+ .isEmpty();
assertThat(
index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs())
- .hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
- .getDocs())
- .hasSize(2);
+ .hasSize(1);
+ assertThat(
+ index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
+ .getDocs())
+ .hasSize(2);
assertThat(
index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs())
- .isEmpty();
+ .isEmpty();
assertThat(
index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs())
- .isEmpty();
+ .isEmpty();
}
@Test
assertThat(
index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE, Issue.RESOLUTION_FIXED)).build(), new SearchOptions()).getDocs())
- .hasSize(2);
+ .hasSize(2);
assertThat(index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE)).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_REMOVED)).build(), new SearchOptions()).getDocs()).isEmpty();
}
assertThat(index.search(IssueQuery.builder(userSessionRule).assigned(null).build(), new SearchOptions()).getDocs()).hasSize(3);
}
- @Test
- public void filter_by_reporters() {
- ComponentDto project = ComponentTesting.newProjectDto();
- ComponentDto file = ComponentTesting.newFileDto(project);
-
- indexIssues(
- IssueTesting.newDoc("ISSUE1", file).setReporter("fabrice"),
- IssueTesting.newDoc("ISSUE2", file).setReporter("stephane"));
-
- assertThat(index.search(IssueQuery.builder(userSessionRule).reporters(newArrayList("fabrice", "stephane")).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).reporters(newArrayList("fabrice")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).reporters(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
- }
-
@Test
public void filter_by_authors() {
ComponentDto project = ComponentTesting.newProjectDto();
IssueTesting.newDoc("F1_1", file1).setLine(null),
IssueTesting.newDoc("F1_3", file1).setLine(25),
- // file F2
+ // file F2
IssueTesting.newDoc("F2_1", file2).setLine(9),
IssueTesting.newDoc("F2_2", file2).setLine(109),
// two issues on the same line -> sort by key
.setSeverity("MAJOR")
.setAuthorLogin("John")
.setAssignee("simon")
- .setReporter("fabrice")
.setTags(asList("bug", "owasp"))
.setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100"))
.setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project)
.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")
.setAuthorLogin("John")
- .setAssignee("simon")
- .setReporter("fabrice");
+ .setAssignee("simon");
db.issueDao().insert(session, issue);
session.commit();
tester.get(IssueIndexer.class).indexAll();
{
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"assignee": "simon",
- "reporter": "fabrice",
"actions": [
"comment", "assign", "set_tags", "set_type", "assign_to_me"
],
}
],
"users": [
- {
- "login": "fabrice",
- "name": "Fabrice",
- "email": "fabrice@email.com",
- "active": true
- },
{
"login": "simon",
"name": "Simon",
"message": "the message",
"effort": "10min",
"assignee": "simon",
- "reporter": "fabrice",
"author": "John",
"tags": [
"bug",
*/
@Deprecated
public static final String DEPRECATED_ACTION_PLANS = "actionPlans";
+
+ /**
+ * @deprecated since 5.5, manual issue feature has been dropped.
+ */
+ @Deprecated
public static final String REPORTERS = "reporters";
public static final String ASSIGNEES = "assignees";
public static final String AUTHORS = "authors";
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECTS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECT_KEYS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.PROJECT_UUIDS;
-import static org.sonarqube.ws.client.issue.IssueFilterParameters.REPORTERS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RESOLUTIONS;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RESOLVED;
import static org.sonarqube.ws.client.issue.IssueFilterParameters.RULES;
.setParam(PROJECT_KEYS, inlineMultipleParamValue(request.getProjectKeys()))
.setParam(PROJECT_UUIDS, inlineMultipleParamValue(request.getProjectUuids()))
.setParam(PROJECTS, inlineMultipleParamValue(request.getProjects()))
- .setParam(REPORTERS, inlineMultipleParamValue(request.getReporters()))
.setParam(RESOLUTIONS, inlineMultipleParamValue(request.getResolutions()))
.setParam(RESOLVED, request.getResolved())
.setParam(RULES, inlineMultipleParamValue(request.getRules()))
private List<String> projectKeys;
private List<String> projectUuids;
private List<String> projects;
- private List<String> reporters;
private List<String> resolutions;
private Boolean resolved;
private List<String> rules;
return this;
}
- @CheckForNull
- public List<String> getReporters() {
- return reporters;
- }
-
- public SearchWsRequest setReporters(@Nullable List<String> reporters) {
- this.reporters = reporters;
- return this;
- }
-
@CheckForNull
public List<String> getResolutions() {
return resolutions;
assertThat(underTest.getProjects()).isSameAs(LIST_OF_STRINGS);
}
- @Test
- public void getReporters_returns_null_when_SearchWsRequest_has_just_been_instantiated() {
- assertThat(underTest.getReporters()).isNull();
- }
-
- @Test
- public void setReporters_accepts_null() {
- underTest.setReporters(null);
- }
-
- @Test
- public void getReporters_returns_object_from_setReporters() {
- underTest.setReporters(LIST_OF_STRINGS);
- assertThat(underTest.getReporters()).isSameAs(LIST_OF_STRINGS);
- }
-
@Test
public void getResolutions_returns_null_when_SearchWsRequest_has_just_been_instantiated() {
assertThat(underTest.getResolutions()).isNull();