Search in sources :

Example 36 with TestRequest

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

the class CreateActionTest method executeRequest.

private CreateWsResponse executeRequest(@Nullable String name, @Nullable String key, @Nullable String description, @Nullable String url, @Nullable String avatar) {
    TestRequest request = wsTester.newRequest().setMediaType(MediaTypes.PROTOBUF);
    populateRequest(name, key, description, url, avatar, request);
    try {
        return CreateWsResponse.parseFrom(request.execute().getInputStream());
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 37 with TestRequest

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

the class UpdateActionTest method executeRequest.

private Organizations.UpdateWsResponse executeRequest(@Nullable String key, @Nullable String name, @Nullable String description, @Nullable String url, @Nullable String avatar) {
    TestRequest request = wsTester.newRequest().setMediaType(MediaTypes.PROTOBUF);
    setParam(request, "key", key);
    setParam(request, "name", name);
    setParam(request, "description", description);
    setParam(request, "url", url);
    setParam(request, "avatar", avatar);
    try {
        return Organizations.UpdateWsResponse.parseFrom(request.execute().getInputStream());
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 38 with TestRequest

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

the class AddUserActionTest method executeRequest.

private void executeRequest(UserDto userDto, String permission, @Nullable OrganizationDto organizationDto) throws Exception {
    TestRequest request = newRequest().setParam(PARAM_USER_LOGIN, userDto.getLogin()).setParam(PARAM_PERMISSION, permission);
    if (organizationDto != null) {
        request.setParam(PARAM_ORGANIZATION, organizationDto.getKey());
    }
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 39 with TestRequest

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

the class CreateActionTest method call.

private CreateWsResponse call(CreateRequest request) {
    TestRequest httpRequest = ws.newRequest().setMethod(POST.name()).setMediaType(MediaTypes.PROTOBUF);
    setNullable(request.getOrganization(), e -> httpRequest.setParam("organization", e));
    setNullable(request.getKey(), e -> httpRequest.setParam("project", e));
    setNullable(request.getName(), e -> httpRequest.setParam("name", e));
    setNullable(request.getBranch(), e -> httpRequest.setParam("branch", e));
    try {
        return CreateWsResponse.parseFrom(httpRequest.execute().getInputStream());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 40 with TestRequest

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

the class UpdateEventActionTest method call.

private UpdateEventResponse call(@Nullable String eventUuid, @Nullable String name) {
    TestRequest request = ws.newRequest().setMethod(POST.name()).setMediaType(MediaTypes.PROTOBUF);
    setNullable(eventUuid, e -> request.setParam(PARAM_EVENT, e));
    setNullable(name, n -> request.setParam(PARAM_NAME, n));
    try {
        return UpdateEventResponse.parseFrom(request.execute().getInputStream());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : IOException(java.io.IOException) 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