Search in sources :

Example 26 with TestRequest

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

the class AddProjectActionTest method executeRequest.

private void executeRequest(ComponentDto project, QualityProfileDto qualityProfile) {
    TestRequest request = ws.newRequest().setParam("projectUuid", project.uuid()).setParam("profileKey", qualityProfile.getKey());
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 27 with TestRequest

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

the class RuleQueryFactoryTest method execute.

private RuleQuery execute(String... paramsKeyAndValue) {
    WsActionTester ws = new WsActionTester(fakeAction);
    TestRequest request = ws.newRequest();
    for (int i = 0; i < paramsKeyAndValue.length; i += 2) {
        request.setParam(paramsKeyAndValue[i], paramsKeyAndValue[i + 1]);
    }
    request.execute();
    return fakeAction.getRuleQuery();
}
Also used : WsActionTester(org.sonar.server.ws.WsActionTester) TestRequest(org.sonar.server.ws.TestRequest)

Example 28 with TestRequest

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

the class SearchActionTest method call.

private SearchWsResponse call(SearchWsRequest wsRequest) {
    TestRequest request = ws.newRequest().setMediaType(PROTOBUF);
    setNullable(wsRequest.getOrganization(), p -> request.setParam(PARAM_ORGANIZATION, p));
    setNullable(wsRequest.getLanguage(), p -> request.setParam(PARAM_LANGUAGE, p));
    setNullable(wsRequest.getQualifiers(), p -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p)));
    setNullable(wsRequest.getQuery(), p -> request.setParam(TEXT_QUERY, p));
    setNullable(wsRequest.getPage(), page -> request.setParam(PAGE, String.valueOf(page)));
    setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize)));
    try {
        return SearchWsResponse.parseFrom(request.execute().getInputStream());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 29 with TestRequest

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

the class SearchProjectsActionTest method call.

private SearchProjectsWsResponse call(SearchProjectsRequest.Builder requestBuilder) {
    SearchProjectsRequest wsRequest = requestBuilder.build();
    TestRequest httpRequest = ws.newRequest().setMediaType(MediaTypes.PROTOBUF);
    ofNullable(wsRequest.getOrganization()).ifPresent(organization -> httpRequest.setParam(PARAM_ORGANIZATION, organization));
    ofNullable(wsRequest.getFilter()).ifPresent(filter -> httpRequest.setParam(PARAM_FILTER, filter));
    ofNullable(wsRequest.getSort()).ifPresent(sort -> httpRequest.setParam(SORT, sort));
    ofNullable(wsRequest.getAsc()).ifPresent(asc -> httpRequest.setParam(ASCENDING, Boolean.toString(asc)));
    httpRequest.setParam(PAGE, String.valueOf(wsRequest.getPage()));
    httpRequest.setParam(PAGE_SIZE, String.valueOf(wsRequest.getPageSize()));
    httpRequest.setParam(FACETS, Joiner.on(",").join(wsRequest.getFacets()));
    httpRequest.setParam(FIELDS, Joiner.on(",").join(wsRequest.getAdditionalFields()));
    try {
        return SearchProjectsWsResponse.parseFrom(httpRequest.execute().getInputStream());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : SearchProjectsRequest(org.sonarqube.ws.client.component.SearchProjectsRequest) IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 30 with TestRequest

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

the class EditCommentActionTest method call.

private TestResponse call(@Nullable String commentKey, @Nullable String commentText) {
    TestRequest request = tester.newRequest();
    setNullable(commentKey, comment -> request.setParam("comment", comment));
    setNullable(commentText, comment -> request.setParam("text", 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