Search in sources :

Example 1 with SearchWsResponse

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();
        }
    }
}
Also used : RuleDto(org.sonar.db.rule.RuleDto) TestResponse(org.sonar.server.ws.TestResponse) Issues(org.sonarqube.ws.Issues) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse) WsActionTester(org.sonar.server.ws.WsActionTester) Test(org.junit.Test)

Example 2 with SearchWsResponse

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);
}
Also used : SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse)

Example 3 with SearchWsResponse

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);
}
Also used : SearchWsResponse(org.sonarqube.ws.Issues.SearchWsResponse)

Aggregations

SearchWsResponse (org.sonarqube.ws.Issues.SearchWsResponse)3 Test (org.junit.Test)1 ComponentDto (org.sonar.db.component.ComponentDto)1 IssueDto (org.sonar.db.issue.IssueDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 TestResponse (org.sonar.server.ws.TestResponse)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 Issues (org.sonarqube.ws.Issues)1 SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)1