use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_components.
@Test
public void facets_on_components() {
ComponentDto project = ComponentTesting.newPrivateProjectDto("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("I1", project).setEffort(10L), IssueDocTesting.newDoc("I2", file1).setEffort(10L), IssueDocTesting.newDoc("I3", file2).setEffort(10L), IssueDocTesting.newDoc("I4", file2).setEffort(10L), IssueDocTesting.newDoc("I5", file3).setEffort(10L));
Facets facets = search("files");
assertThat(facets.getNames()).containsOnly("files", FACET_MODE_EFFORT);
assertThat(facets.get("files")).containsOnly(entry(file1.path(), 10L), entry(file2.path(), 20L), entry(file3.path(), 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 50L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_projects.
@Test
public void facets_on_projects() {
ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD");
ComponentDto project2 = ComponentTesting.newPrivateProjectDto("EFGH");
indexIssues(IssueDocTesting.newDoc("I1", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("I2", ComponentTesting.newFileDto(project, null)).setEffort(10L), IssueDocTesting.newDoc("I3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
Facets facets = search("projects");
assertThat(facets.getNames()).containsOnly("projects", FACET_MODE_EFFORT);
assertThat(facets.get("projects")).containsOnly(entry("ABCD", 20L), entry("EFGH", 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_assignees.
@Test
public void facets_on_assignees() {
ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("I1", file).setAssigneeUuid("uuid-steph").setEffort(10L), IssueDocTesting.newDoc("I2", file).setAssigneeUuid("uuid-simon").setEffort(10L), IssueDocTesting.newDoc("I3", file).setAssigneeUuid("uuid-simon").setEffort(10L), IssueDocTesting.newDoc("I4", file).setAssigneeUuid(null).setEffort(10L));
Facets facets = new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(singletonList("assignees"))), system2.getDefaultTimeZone().toZoneId());
assertThat(facets.getNames()).containsOnly("assignees", FACET_MODE_EFFORT);
assertThat(facets.get("assignees")).containsOnly(entry("uuid-steph", 10L), entry("uuid-simon", 20L), entry("", 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_languages.
@Test
public void facets_on_languages() {
ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto file = ComponentTesting.newFileDto(project, null);
indexIssues(IssueDocTesting.newDoc("I1", file).setLanguage("xoo").setEffort(10L));
Facets facets = search("languages");
assertThat(facets.getNames()).containsOnly("languages", FACET_MODE_EFFORT);
assertThat(facets.get("languages")).containsOnly(entry("xoo", 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 10L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class IssueIndexFacetsTest method assertThatFacetHasExactly.
@SafeVarargs
private final void assertThatFacetHasExactly(IssueQuery.Builder query, String facet, Map.Entry<String, Long>... expectedEntries) {
SearchResponse result = underTest.search(query.build(), new SearchOptions().addFacets(singletonList(facet)));
Facets facets = new Facets(result, system2.getDefaultTimeZone().toZoneId());
assertThat(facets.getNames()).containsOnly(facet, "effort");
assertThat(facets.get(facet)).containsExactly(expectedEntries);
}
Aggregations