use of org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES in project sonarqube by SonarSource.
the class SearchActionFacetsTest method display_zero_valued_facets_for_selected_items_having_no_issue.
@Test
public void display_zero_valued_facets_for_selected_items_having_no_issue() {
ComponentDto project1 = db.components().insertPublicProject();
ComponentDto module1 = db.components().insertComponent(newModuleDto(project1));
ComponentDto module2 = db.components().insertComponent(newModuleDto(project1));
ComponentDto project2 = db.components().insertPublicProject();
ComponentDto file1 = db.components().insertComponent(newFileDto(module1));
ComponentDto file2 = db.components().insertComponent(newFileDto(module1));
RuleDefinitionDto rule1 = db.rules().insertIssueRule();
RuleDefinitionDto rule2 = db.rules().insertIssueRule();
UserDto user1 = db.users().insertUser();
UserDto user2 = db.users().insertUser();
db.issues().insertIssue(rule1, project1, file1, i -> i.setSeverity("MAJOR").setStatus("OPEN").setResolution(null).setType(RuleType.CODE_SMELL).setEffort(10L).setAssigneeUuid(user1.getUuid()));
indexPermissions();
indexIssues();
SearchWsResponse response = ws.newRequest().setParam(PARAM_PROJECTS, project1.getKey() + "," + project2.getKey()).setParam(PARAM_FILES, file1.path() + "," + file2.path()).setParam("rules", rule1.getKey().toString() + "," + rule2.getKey().toString()).setParam("severities", "MAJOR,MINOR").setParam("languages", rule1.getLanguage() + "," + rule2.getLanguage()).setParam("assignees", user1.getLogin() + "," + user2.getLogin()).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(rule1.getKey().toString(), 1L, rule2.getKey().toString(), 0L)), tuple("types", of("CODE_SMELL", 1L, "BUG", 0L, "VULNERABILITY", 0L)), tuple("languages", of(rule1.getLanguage(), 1L, rule2.getLanguage(), 0L)), tuple("projects", of(project1.getKey(), 1L, project2.getKey(), 0L)), tuple("moduleUuids", of(module1.uuid(), 1L)), tuple("files", of(file1.path(), 1L, file2.path(), 0L)), tuple("assignees", of("", 0L, user1.getLogin(), 1L, user2.getLogin(), 0L)));
}
use of org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES 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