use of org.sonarqube.ws.Issues.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionComponentsMediumTest method do_not_return_module_key_on_single_module_projects.
@Test
public void do_not_return_module_key_on_single_module_projects() throws IOException {
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(defaultOrganization, "P1").setKey("PK1"));
setDefaultProjectPermission(project);
ComponentDto module = insertComponent(newModuleDto("M1", project).setKey("MK1"));
ComponentDto file = insertComponent(newFileDto(module, null, "F1").setKey("FK1"));
RuleDto newRule = newRule();
IssueDto issueInModule = IssueTesting.newDto(newRule, file, project).setKee("ISSUE_IN_MODULE");
IssueDto issueInRootModule = IssueTesting.newDto(newRule, project, project).setKee("ISSUE_IN_ROOT_MODULE");
db.issueDao().insert(session, issueInModule, issueInRootModule);
session.commit();
indexIssues();
WsActionTester actionTester = new WsActionTester(tester.get(SearchAction.class));
TestResponse response = actionTester.newRequest().setMediaType(MediaTypes.PROTOBUF).execute();
SearchWsResponse searchResponse = SearchWsResponse.parseFrom(response.getInputStream());
assertThat(searchResponse.getIssuesCount()).isEqualTo(2);
for (Issues.Issue issue : searchResponse.getIssuesList()) {
assertThat(issue.getProject()).isEqualTo("PK1");
if (issue.getKey().equals("ISSUE_IN_MODULE")) {
assertThat(issue.getSubProject()).isEqualTo("MK1");
} else if (issue.getKey().equals("ISSUE_IN_ROOT_MODULE")) {
assertThat(issue.hasSubProject()).isFalse();
}
}
}
use of org.sonarqube.ws.Issues.SearchWsResponse in project sonarqube by SonarSource.
the class IssueTrackingTest method getIssueByKey.
private static Issue getIssueByKey(String issueKey) {
SearchWsResponse search = searchIssues(new SearchWsRequest().setIssues(singletonList(issueKey)));
assertThat(search.getTotal()).isEqualTo(1);
return search.getIssues(0);
}
use of org.sonarqube.ws.Issues.SearchWsResponse in project sonarqube by SonarSource.
the class SearchAction method handle.
@Override
public final void handle(Request request, Response response) throws Exception {
SearchWsResponse searchWsResponse = doHandle(toSearchWsRequest(request), request);
writeProtobuf(searchWsResponse, request, response);
}
Aggregations