use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_directories.
@Test
public void facets_on_directories() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file1 = ComponentTesting.newFileDto(project, null).setPath("src/main/xoo/F1.xoo");
ComponentDto file2 = ComponentTesting.newFileDto(project, null).setPath("F2.xoo");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"), IssueDocTesting.newDoc("ISSUE2", file2).setDirectoryPath("/"));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("directories")));
assertThat(result.getFacets().getNames()).containsOnly("directories", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("directories")).containsOnly(entry("/src/main/xoo", 10L), entry("/", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 20L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facet_on_created_at.
@Test
public void facet_on_created_at() {
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
Map<String, Long> createdAt = index.search(newQueryBuilder().createdBefore(DateUtils.parseDateTime("2016-01-01T00:00:00+0100")).build(), SearchOptions).getFacets().get("createdAt");
assertThat(createdAt).containsOnly(entry("2011-01-01T00:00:00+0000", 10L), entry("2012-01-01T00:00:00+0000", 0L), entry("2013-01-01T00:00:00+0000", 0L), entry("2014-01-01T00:00:00+0000", 50L), entry("2015-01-01T00:00:00+0000", 10L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_statuses.
@Test
public void facets_on_statuses() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.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 = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("statuses")));
assertThat(result.getFacets().getNames()).containsOnly("statuses", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("statuses")).containsOnly(entry("CLOSED", 20L), entry("OPEN", 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 IssueIndexDebtTest method facets_on_resolutions.
@Test
public void facets_on_resolutions() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE), IssueDocTesting.newDoc("ISSUE2", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE), IssueDocTesting.newDoc("ISSUE3", file).setResolution(Issue.RESOLUTION_FIXED));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("resolutions")));
assertThat(result.getFacets().getNames()).containsOnly("resolutions", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("resolutions")).containsOnly(entry("FALSE-POSITIVE", 20L), entry("FIXED", 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 filter_by_created_after_and_before.
@Test
public void filter_by_created_after_and_before() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")), IssueDocTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDate("2014-09-23")));
// 19 < createdAt < 25
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-19")).createdBefore(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).hasSize(2);
// 20 < createdAt < 25: excludes first issue
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).hasSize(2);
// 21 < createdAt < 25
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).hasSize(1);
// 21 < createdAt < 24
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-24")).build(), new SearchOptions()).getDocs()).hasSize(1);
// 21 < createdAt < 23: excludes second issue
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-23")).build(), new SearchOptions()).getDocs()).isEmpty();
// 19 < createdAt < 21: only first issue
assertThat(underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-19")).createdBefore(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1);
// 20 < createdAt < 20: exception
expectedException.expect(IllegalArgumentException.class);
underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs();
}
Aggregations