use of org.sonar.api.server.ws.WebService.Param.FACETS in project sonarqube by SonarSource.
the class SearchActionFacetsTest method display_all_facets.
@Test
public void display_all_facets() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto module = db.components().insertComponent(newModuleDto(project));
ComponentDto file = db.components().insertComponent(newFileDto(module));
RuleDefinitionDto rule = db.rules().insertIssueRule();
UserDto user = db.users().insertUser();
db.issues().insertIssue(rule, project, file, i -> i.setSeverity("MAJOR").setStatus("OPEN").setType(RuleType.CODE_SMELL).setEffort(10L).setAssigneeUuid(user.getUuid()));
indexPermissions();
indexIssues();
SearchWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT_KEYS, project.getKey()).setParam(FACETS, "severities,statuses,resolutions,rules,types,languages,projects,moduleUuids,files,assignees").executeProtobuf(SearchWsResponse.class);
Map<String, Number> expectedStatuses = ImmutableMap.<String, Number>builder().put("OPEN", 1L).put("CONFIRMED", 0L).put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).build();
assertThat(response.getFacets().getFacetsList()).extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))).containsExactlyInAnyOrder(tuple("severities", of("INFO", 0L, "MINOR", 0L, "MAJOR", 1L, "CRITICAL", 0L, "BLOCKER", 0L)), tuple("statuses", expectedStatuses), tuple("resolutions", of("", 1L, "FALSE-POSITIVE", 0L, "FIXED", 0L, "REMOVED", 0L, "WONTFIX", 0L)), tuple("rules", of(rule.getKey().toString(), 1L)), tuple("types", of("CODE_SMELL", 1L, "BUG", 0L, "VULNERABILITY", 0L)), tuple("languages", of(rule.getLanguage(), 1L)), tuple("projects", of(project.getKey(), 1L)), tuple("moduleUuids", of(module.uuid(), 1L)), tuple("files", of(file.path(), 1L)), tuple("assignees", of("", 0L, user.getLogin(), 1L)));
}
Aggregations