Search in sources :

Example 1 with TestRequest

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

the class GenerateActionTest method newRequest.

private GenerateWsResponse newRequest(@Nullable String login, String name) {
    TestRequest testRequest = ws.newRequest().setMediaType(MediaTypes.PROTOBUF).setParam(PARAM_NAME, name);
    if (login != null) {
        testRequest.setParam(PARAM_LOGIN, login);
    }
    InputStream responseStream = testRequest.execute().getInputStream();
    try {
        return GenerateWsResponse.parseFrom(responseStream);
    } catch (IOException e) {
        throw propagate(e);
    }
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 2 with TestRequest

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

the class CreateActionTest method executeJsonRequest.

private String executeJsonRequest(@Nullable String name, @Nullable String key, @Nullable String description, @Nullable String url, @Nullable String avatar) {
    TestRequest request = wsTester.newRequest().setMediaType(MediaTypes.JSON);
    populateRequest(name, key, description, url, avatar, request);
    return request.execute().getInput();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 3 with TestRequest

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

the class RemoveActionTest method call.

private TestResponse call(AddRequest.Builder wsRequestBuilder) {
    AddRequest wsRequest = wsRequestBuilder.build();
    TestRequest request = ws.newRequest();
    request.setParam(PARAM_TYPE, wsRequest.getType());
    setNullable(wsRequest.getChannel(), channel -> request.setParam(PARAM_CHANNEL, channel));
    setNullable(wsRequest.getProject(), project -> request.setParam(PARAM_PROJECT, project));
    return request.execute();
}
Also used : AddRequest(org.sonarqube.ws.client.notification.AddRequest) TestRequest(org.sonar.server.ws.TestRequest)

Example 4 with TestRequest

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

the class SearchActionTest method executeRequest.

private List<Organization> executeRequest(@Nullable Integer page, @Nullable Integer pageSize, String... keys) {
    TestRequest request = wsTester.newRequest().setMediaType(MediaTypes.PROTOBUF);
    populateRequest(request, page, pageSize, keys);
    try {
        return Organizations.SearchWsResponse.parseFrom(request.execute().getInputStream()).getOrganizationsList();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Example 5 with TestRequest

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

the class SearchActionTest method executeJsonRequest.

private String executeJsonRequest(@Nullable Integer page, @Nullable Integer pageSize, String... keys) {
    TestRequest request = wsTester.newRequest().setMediaType(MediaTypes.JSON);
    populateRequest(request, page, pageSize, keys);
    return request.execute().getInput();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Aggregations

TestRequest (org.sonar.server.ws.TestRequest)375 Test (org.junit.Test)309 UserDto (org.sonar.db.user.UserDto)82 ComponentDto (org.sonar.db.component.ComponentDto)61 NotFoundException (org.sonar.server.exceptions.NotFoundException)59 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)41 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)29 IssueDto (org.sonar.db.issue.IssueDto)21 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)21 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)20 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)15 IOException (java.io.IOException)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (org.sonar.server.exceptions.BadRequestException)11 ProjectDto (org.sonar.db.project.ProjectDto)10 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)9 TestResponse (org.sonar.server.ws.TestResponse)9 WsActionTester (org.sonar.server.ws.WsActionTester)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 Mockito.mock (org.mockito.Mockito.mock)8