use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method authorized_issues_on_user.
@Test
public void authorized_issues_on_user() {
OrganizationDto org = newOrganizationDto();
ComponentDto project1 = newProjectDto(org);
ComponentDto project2 = newProjectDto(org);
ComponentDto project3 = newProjectDto(org);
ComponentDto file1 = newFileDto(project1, null);
ComponentDto file2 = newFileDto(project2, null);
ComponentDto file3 = newFileDto(project3, null);
UserDto user1 = newUserDto();
UserDto user2 = newUserDto();
// project1 can be seen by john, project2 by max, project3 cannot be seen by anyone
indexIssue(IssueDocTesting.newDoc("ISSUE1", file1));
authorizationIndexerTester.allowOnlyUser(project1, user1);
indexIssue(IssueDocTesting.newDoc("ISSUE2", file2));
authorizationIndexerTester.allowOnlyUser(project2, user2);
indexIssue(IssueDocTesting.newDoc("ISSUE3", file3));
userSessionRule.logIn(user1);
assertThat(underTest.search(IssueQuery.builder().build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project3.key())).build(), new SearchOptions()).getDocs()).hasSize(0);
userSessionRule.logIn(user2);
assertThat(underTest.search(IssueQuery.builder().build(), new SearchOptions()).getDocs()).hasSize(1);
// another user
userSessionRule.logIn(newUserDto());
assertThat(underTest.search(IssueQuery.builder().build(), new SearchOptions()).getDocs()).hasSize(0);
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facets_on_directories.
@Test
public void facets_on_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("/"));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().build(), new SearchOptions().addFacets(newArrayList("directories")));
assertThat(result.getFacets().getNames()).containsOnly("directories");
assertThat(result.getFacets().get("directories")).containsOnly(entry("/src/main/xoo", 1L), entry("/", 1L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facets_on_assignees_supports_dashes.
@Test
public void facets_on_assignees_supports_dashes() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setAssignee("j-b"), IssueDocTesting.newDoc("ISSUE2", file).setAssignee("simon"), IssueDocTesting.newDoc("ISSUE3", file).setAssignee("simon"), IssueDocTesting.newDoc("ISSUE4", file).setAssignee(null));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().assignees(Arrays.asList("j-b")).build(), new SearchOptions().addFacets(newArrayList("assignees")));
assertThat(result.getFacets().getNames()).containsOnly("assignees");
assertThat(result.getFacets().get("assignees")).containsOnly(entry("j-b", 1L), entry("simon", 2L), entry("", 1L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_projects.
@Test
public void filter_by_projects() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
indexIssues(IssueDocTesting.newDoc("ISSUE1", project), IssueDocTesting.newDoc("ISSUE2", newFileDto(project, null)), IssueDocTesting.newDoc("ISSUE3", module), IssueDocTesting.newDoc("ISSUE4", newFileDto(module, null)), IssueDocTesting.newDoc("ISSUE5", subModule), IssueDocTesting.newDoc("ISSUE6", newFileDto(subModule, null)));
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).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 facets_on_assignees.
@Test
public void facets_on_assignees() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setAssignee("steph"), IssueDocTesting.newDoc("ISSUE2", file).setAssignee("simon"), IssueDocTesting.newDoc("ISSUE3", file).setAssignee("simon"), IssueDocTesting.newDoc("ISSUE4", file).setAssignee(null));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().build(), new SearchOptions().addFacets(newArrayList("assignees")));
assertThat(result.getFacets().getNames()).containsOnly("assignees");
assertThat(result.getFacets().get("assignees")).containsOnly(entry("steph", 1L), entry("simon", 2L), entry("", 1L));
}
Aggregations