use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_assignees.
@Test
public void facets_on_assignees() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.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 = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("assignees")));
assertThat(result.getFacets().getNames()).containsOnly("assignees", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("assignees")).containsOnly(entry("steph", 10L), entry("simon", 20L), entry("", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_components.
@Test
public void facets_on_components() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto(), "A");
ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD");
ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE");
ComponentDto file3 = ComponentTesting.newFileDto(project, null, "CDEF");
indexIssues(IssueDocTesting.newDoc("ISSUE1", project), IssueDocTesting.newDoc("ISSUE2", file1), IssueDocTesting.newDoc("ISSUE3", file2), IssueDocTesting.newDoc("ISSUE4", file2), IssueDocTesting.newDoc("ISSUE5", file3));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("fileUuids")));
assertThat(result.getFacets().getNames()).containsOnly("fileUuids", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("fileUuids")).containsOnly(entry("A", 10L), entry("ABCD", 10L), entry("BCDE", 20L), entry("CDEF", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 50L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_projects.
@Test
public void facets_on_projects() {
OrganizationDto organizationDto = newOrganizationDto();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD");
ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH");
indexIssues(IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
assertThat(result.getFacets().getNames()).containsOnly("projectUuids", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 20L), entry("EFGH", 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_authors.
@Test
public void facets_on_authors() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setAuthorLogin("steph"), IssueDocTesting.newDoc("ISSUE2", file).setAuthorLogin("simon"), IssueDocTesting.newDoc("ISSUE3", file).setAuthorLogin("simon"), IssueDocTesting.newDoc("ISSUE4", file).setAuthorLogin(null));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("authors")));
assertThat(result.getFacets().getNames()).containsOnly("authors", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("authors")).containsOnly(entry("steph", 10L), entry("simon", 20L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class IssueIndexDebtTest method deprecated_debt_facets.
@Test
public void deprecated_debt_facets() {
OrganizationDto organizationDto = newOrganizationDto();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, "ABCD");
ComponentDto project2 = ComponentTesting.newProjectDto(organizationDto, "EFGH");
indexIssues(IssueDocTesting.newDoc("ISSUE1", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
SearchResult<IssueDoc> result = index.search(IssueQuery.builder().facetMode(DEPRECATED_FACET_MODE_DEBT).build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
assertThat(result.getFacets().getNames()).containsOnly("projectUuids", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 20L), entry("EFGH", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L));
}
Aggregations