use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method sort_by_assignee.
@Test
public void sort_by_assignee() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setAssignee("steph"), IssueDocTesting.newDoc("ISSUE2", file).setAssignee("simon"));
IssueQuery.Builder query = IssueQuery.builder().sort(IssueQuery.SORT_BY_ASSIGNEE).asc(true);
SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).assignee()).isEqualTo("simon");
assertThat(result.getDocs().get(1).assignee()).isEqualTo("steph");
query = IssueQuery.builder().sort(IssueQuery.SORT_BY_ASSIGNEE).asc(false);
result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).assignee()).isEqualTo("steph");
assertThat(result.getDocs().get(1).assignee()).isEqualTo("simon");
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_assignees.
@Test
public void filter_by_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(null));
assertThat(underTest.search(IssueQuery.builder().assignees(newArrayList("steph")).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().assignees(newArrayList("steph", "simon")).build(), new SearchOptions()).getDocs()).hasSize(2);
assertThat(underTest.search(IssueQuery.builder().assignees(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_modules.
@Test
public void filter_by_modules() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto module = ComponentTesting.newModuleDto(project);
ComponentDto subModule = ComponentTesting.newModuleDto(module);
ComponentDto file = newFileDto(subModule, null);
indexIssues(IssueDocTesting.newDoc("ISSUE3", module), IssueDocTesting.newDoc("ISSUE5", subModule), IssueDocTesting.newDoc("ISSUE2", file));
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(file.uuid())).build(), new SearchOptions()).getDocs()).isEmpty();
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2);
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).isEmpty();
assertThat(underTest.search(IssueQuery.builder().projectUuids(newArrayList(project.uuid())).moduleUuids(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_resolved.
@Test
public void filter_by_resolved() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED), IssueDocTesting.newDoc("ISSUE2", file).setStatus(Issue.STATUS_OPEN).setResolution(null), IssueDocTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_OPEN).setResolution(null));
assertThat(underTest.search(IssueQuery.builder().resolved(true).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().resolved(false).build(), new SearchOptions()).getDocs()).hasSize(2);
assertThat(underTest.search(IssueQuery.builder().resolved(null).build(), new SearchOptions()).getDocs()).hasSize(3);
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facet_on_created_at_with_less_than_20_days.
@Test
public void facet_on_created_at_with_less_than_20_days() {
SearchOptions options = fixtureForCreatedAtFacet();
IssueQuery query = IssueQuery.builder().createdAfter(parseDateTime("2014-09-01T00:00:00+0100")).createdBefore(parseDateTime("2014-09-08T00:00:00+0100")).checkAuthorization(false).build();
SearchResult<IssueDoc> result = underTest.search(query, options);
Map<String, Long> buckets = result.getFacets().get("createdAt");
assertThat(buckets).containsOnly(entry("2014-08-31T01:00:00+0000", 0L), entry("2014-09-01T01:00:00+0000", 2L), entry("2014-09-02T01:00:00+0000", 1L), entry("2014-09-03T01:00:00+0000", 0L), entry("2014-09-04T01:00:00+0000", 0L), entry("2014-09-05T01:00:00+0000", 1L), entry("2014-09-06T01:00:00+0000", 0L), entry("2014-09-07T01:00:00+0000", 0L));
}
Aggregations