use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facet_on_created_at_with_bounds_outside_of_data.
@Test
public void facet_on_created_at_with_bounds_outside_of_data() {
SearchOptions options = fixtureForCreatedAtFacet();
Map<String, Long> createdAt = underTest.search(IssueQuery.builder().createdAfter(parseDateTime("2009-01-01T00:00:00+0100")).createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(), options).getFacets().get("createdAt");
assertThat(createdAt).containsOnly(entry("2008-01-01T01:00:00+0000", 0L), entry("2009-01-01T01:00:00+0000", 0L), entry("2010-01-01T01:00:00+0000", 0L), entry("2011-01-01T01:00:00+0000", 1L), entry("2012-01-01T01:00:00+0000", 0L), entry("2013-01-01T01:00:00+0000", 0L), entry("2014-01-01T01:00:00+0000", 5L), entry("2015-01-01T01:00:00+0000", 1L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method paging.
@Test
public void paging() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
for (int i = 0; i < 12; i++) {
indexIssues(IssueDocTesting.newDoc("ISSUE" + i, file));
}
IssueQuery.Builder query = IssueQuery.builder();
// There are 12 issues in total, with 10 issues per page, the page 2 should only contain 2 elements
SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions().setPage(2, 10));
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getTotal()).isEqualTo(12);
result = underTest.search(IssueQuery.builder().build(), new SearchOptions().setOffset(0).setLimit(5));
assertThat(result.getDocs()).hasSize(5);
assertThat(result.getTotal()).isEqualTo(12);
result = underTest.search(IssueQuery.builder().build(), new SearchOptions().setOffset(2).setLimit(0));
assertThat(result.getDocs()).hasSize(10);
assertThat(result.getTotal()).isEqualTo(12);
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_severities.
@Test
public void facets_on_severities() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setSeverity(Severity.INFO), IssueDocTesting.newDoc("ISSUE2", file).setSeverity(Severity.INFO), IssueDocTesting.newDoc("ISSUE3", file).setSeverity(Severity.MAJOR));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("severities")));
assertThat(result.getFacets().getNames()).containsOnly("severities", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("severities")).containsOnly(entry("INFO", 20L), entry("MAJOR", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facet_on_created_at_with_more_than_20_months.
@Test
public void facet_on_created_at_with_more_than_20_months() {
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
Map<String, Long> createdAt = underTest.search(IssueQuery.builder().createdAfter(parseDateTime("2011-01-01T00:00:00+0100")).createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(), SearchOptions).getFacets().get("createdAt");
assertThat(createdAt).containsOnly(entry("2010-01-01T01:00:00+0000", 0L), entry("2011-01-01T01:00:00+0000", 1L), entry("2012-01-01T01:00:00+0000", 0L), entry("2013-01-01T01:00:00+0000", 0L), entry("2014-01-01T01:00:00+0000", 5L), entry("2015-01-01T01:00:00+0000", 1L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexTest method facets_on_projects.
@Test
public void facets_on_projects() {
OrganizationDto organizationDto = newOrganizationDto();
ComponentDto project = newProjectDto(organizationDto, "ABCD");
ComponentDto project2 = newProjectDto(organizationDto, "EFGH");
indexIssues(IssueDocTesting.newDoc("ISSUE1", newFileDto(project, null)), IssueDocTesting.newDoc("ISSUE2", newFileDto(project, null)), IssueDocTesting.newDoc("ISSUE3", newFileDto(project2, null)));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
assertThat(result.getFacets().getNames()).containsOnly("projectUuids");
assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 2L), entry("EFGH", 1L));
}
Aggregations