use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_directories.
@Test
public void filter_by_directories() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file1 = newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
ComponentDto file2 = newFileDto(project, null).setPath("F2.xoo");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"), IssueDocTesting.newDoc("ISSUE2", file2).setDirectoryPath("/"));
assertThat(underTest.search(IssueQuery.builder().directories(newArrayList("/src/main/xoo")).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().directories(newArrayList("/")).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().directories(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_components_on_contextualized_search.
@Test
public void filter_by_components_on_contextualized_search() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
ComponentDto file1 = newFileDto(project, null);
ComponentDto file2 = newFileDto(module, null);
ComponentDto file3 = newFileDto(subModule, null);
String view = "ABCD";
indexView(view, newArrayList(project.uuid()));
indexIssues(IssueDocTesting.newDoc("ISSUE1", project), IssueDocTesting.newDoc("ISSUE2", file1), IssueDocTesting.newDoc("ISSUE3", module), IssueDocTesting.newDoc("ISSUE4", file2), IssueDocTesting.newDoc("ISSUE5", subModule), IssueDocTesting.newDoc("ISSUE6", file3));
assertThat(underTest.search(IssueQuery.builder().fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions()).getDocs()).hasSize(3);
assertThat(underTest.search(IssueQuery.builder().fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().moduleRootUuids(newArrayList(subModule.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2);
assertThat(underTest.search(IssueQuery.builder().moduleRootUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs()).hasSize(4);
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
assertThat(underTest.search(IssueQuery.builder().viewUuids(newArrayList(view)).build(), new SearchOptions()).getDocs()).hasSize(6);
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_rules.
@Test
public void filter_by_rules() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()));
assertThat(underTest.search(IssueQuery.builder().rules(newArrayList(ruleKey)).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().rules(newArrayList(RuleKey.of("rule", "without issue"))).build(), new SearchOptions()).getDocs()).isEmpty();
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facets_on_statuses.
@Test
public void facets_on_statuses() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED), IssueDocTesting.newDoc("ISSUE2", file).setStatus(Issue.STATUS_CLOSED), IssueDocTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_OPEN));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().build(), new SearchOptions().addFacets(newArrayList("statuses")));
assertThat(result.getFacets().getNames()).containsOnly("statuses");
assertThat(result.getFacets().get("statuses")).containsOnly(entry("CLOSED", 2L), entry("OPEN", 1L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method root_user_is_authorized_to_access_all_issues.
@Test
public void root_user_is_authorized_to_access_all_issues() {
ComponentDto project = newProjectDto(newOrganizationDto());
indexIssue(IssueDocTesting.newDoc("I1", project));
userSessionRule.logIn().setRoot();
assertThat(underTest.search(IssueQuery.builder().build(), new SearchOptions()).getDocs()).hasSize(1);
}
Aggregations