use of org.sonarqube.ws.Common.FacetValue 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)));
}
use of org.sonarqube.ws.Common.FacetValue in project sonarqube by SonarSource.
the class SearchActionFacetsTest method display_directory_facet_using_project.
@Test
public void display_directory_facet_using_project() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto directory = db.components().insertComponent(newDirectory(project, "src/main/java/dir"));
ComponentDto file = db.components().insertComponent(newFileDto(project, directory));
RuleDefinitionDto rule = db.rules().insertIssueRule();
db.issues().insertIssue(rule, project, file);
indexPermissions();
indexIssues();
SearchWsResponse response = ws.newRequest().setParam("resolved", "false").setParam(PARAM_COMPONENT_KEYS, project.getKey()).setParam(WebService.Param.FACETS, "directories").executeProtobuf(SearchWsResponse.class);
assertThat(response.getFacets().getFacetsList()).extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))).containsExactlyInAnyOrder(tuple("directories", of(directory.path(), 1L)));
}
use of org.sonarqube.ws.Common.FacetValue in project sonarqube by SonarSource.
the class SearchActionFacetsTest method display_files_facet_with_project.
@Test
public void display_files_facet_with_project() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto file1 = db.components().insertComponent(newFileDto(project));
ComponentDto file2 = db.components().insertComponent(newFileDto(project));
ComponentDto file3 = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = db.rules().insertIssueRule();
db.issues().insertIssue(rule, project, file1);
db.issues().insertIssue(rule, project, file2);
indexPermissions();
indexIssues();
SearchWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT_KEYS, project.getKey()).setParam(PARAM_FILES, file1.path()).setParam(WebService.Param.FACETS, "files").executeProtobuf(SearchWsResponse.class);
assertThat(response.getFacets().getFacetsList()).extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))).containsExactlyInAnyOrder(tuple("files", of(file1.path(), 1L, file2.path(), 1L)));
}
Aggregations