Search in sources :

Example 6 with TestRequest

use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.

the class SearchActionTest method call.

private SearchResponse call(@Nullable Integer page, @Nullable Integer pageSize) {
    TestRequest request = ws.newRequest().setMediaType(MediaTypes.PROTOBUF).setMethod(POST.name());
    setNullable(page, p -> request.setParam(Param.PAGE, p.toString()));
    setNullable(pageSize, ps -> request.setParam(Param.PAGE_SIZE, ps.toString()));
    InputStream response = request.execute().getInputStream();
    try {
        return SearchResponse.parseFrom(response);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 7 with TestRequest

use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.

the class SendActionTest method executeRequest.

private void executeRequest(@Nullable String to, @Nullable String subject, @Nullable String message) {
    TestRequest request = ws.newRequest();
    if (to != null) {
        request.setParam("to", to);
    }
    if (subject != null) {
        request.setParam("subject", subject);
    }
    if (message != null) {
        request.setParam("message", message);
    }
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 8 with TestRequest

use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.

the class AddCommentActionTest method call.

private TestResponse call(@Nullable String issueKey, @Nullable String commentText) {
    TestRequest request = tester.newRequest();
    setNullable(issueKey, issue -> request.setParam("issue", issue));
    setNullable(commentText, text -> request.setParam("text", text));
    return request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 9 with TestRequest

use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.

the class BulkChangeActionTest method call.

private BulkChangeWsResponse call(BulkChangeRequest bulkChangeRequest) {
    TestRequest request = tester.newRequest().setMediaType(MediaTypes.PROTOBUF);
    setNullable(bulkChangeRequest.getIssues(), value -> request.setParam("issues", String.join(",", value)));
    setNullable(bulkChangeRequest.getAssign(), value -> request.setParam("assign", value));
    setNullable(bulkChangeRequest.getSetSeverity(), value -> request.setParam("set_severity", value));
    setNullable(bulkChangeRequest.getSetType(), value -> request.setParam("set_type", value));
    setNullable(bulkChangeRequest.getDoTransition(), value -> request.setParam("do_transition", value));
    setNullable(bulkChangeRequest.getComment(), value -> request.setParam("comment", value));
    setNullable(bulkChangeRequest.getSendNotifications(), value -> request.setParam("sendNotifications", value != null ? value ? "true" : "false" : null));
    if (!bulkChangeRequest.getAddTags().isEmpty()) {
        request.setParam("add_tags", String.join(",", bulkChangeRequest.getAddTags()));
    }
    if (!bulkChangeRequest.getRemoveTags().isEmpty()) {
        request.setParam("remove_tags", String.join(",", bulkChangeRequest.getRemoveTags()));
    }
    try {
        return BulkChangeWsResponse.parseFrom(request.execute().getInputStream());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 10 with TestRequest

use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.

the class DeleteCommentActionTest method call.

private TestResponse call(@Nullable String commentKey) {
    TestRequest request = tester.newRequest();
    setNullable(commentKey, comment -> request.setParam("comment", comment));
    return request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Aggregations

TestRequest (org.sonar.server.ws.TestRequest)48 IOException (java.io.IOException)19 Test (org.junit.Test)4 InputStream (java.io.InputStream)3 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 AddRequest (org.sonarqube.ws.client.notification.AddRequest)2 DbSession (org.sonar.db.DbSession)1 CoveredFileDoc (org.sonar.server.test.index.CoveredFileDoc)1 TestDoc (org.sonar.server.test.index.TestDoc)1 TestResponse (org.sonar.server.ws.TestResponse)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 SearchProjectsRequest (org.sonarqube.ws.client.component.SearchProjectsRequest)1 SearchHistoryRequest (org.sonarqube.ws.client.measure.SearchHistoryRequest)1 CreateEventRequest (org.sonarqube.ws.client.projectanalysis.CreateEventRequest)1