Search in sources :

Example 41 with TestRequest

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

the class DeleteEventActionTest method call.

private void call(@Nullable String event) {
    TestRequest request = ws.newRequest();
    if (event != null) {
        request.setParam(PARAM_EVENT, event);
    }
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 42 with TestRequest

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

the class GhostsActionTest method fail_with_NotFoundException_when_organization_with_specified_key_does_not_exist.

@Test
public void fail_with_NotFoundException_when_organization_with_specified_key_does_not_exist() {
    TestRequest request = underTest.newRequest().setParam("organization", "foo");
    userSessionRule.logIn();
    expectedException.expect(NotFoundException.class);
    expectedException.expectMessage("No organization for key 'foo'");
    request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest) Test(org.junit.Test)

Example 43 with TestRequest

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

the class SetActionTest method call.

private TestResponse call(@Nullable String projectKey, @Nullable String tags) {
    TestRequest request = ws.newRequest();
    setNullable(projectKey, p -> request.setParam("project", p));
    setNullable(tags, t -> request.setParam("tags", tags));
    return request.execute();
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 44 with TestRequest

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

the class IndexActionTest method executeAndVerify.

private void executeAndVerify(@Nullable String componentKey, @Nullable String key, String expectedFile) {
    TestRequest request = ws.newRequest().setMediaType(MediaTypes.JSON);
    if (key != null) {
        request.setParam("id", key);
    }
    if (componentKey != null) {
        request.setParam("resource", componentKey);
    }
    String result = request.execute().getInput();
    assertJson(result).isSimilarTo(resource(expectedFile));
}
Also used : TestRequest(org.sonar.server.ws.TestRequest)

Example 45 with TestRequest

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

the class GetByProjectActionTest method call.

private GetByProjectWsResponse call(@Nullable String projectUuid, @Nullable String projectKey) {
    TestRequest request = ws.newRequest().setMediaType(MediaTypes.PROTOBUF);
    if (projectUuid != null) {
        request.setParam(PARAM_PROJECT_ID, projectUuid);
    }
    if (projectKey != null) {
        request.setParam(PARAM_PROJECT_KEY, projectKey);
    }
    InputStream response = request.execute().getInputStream();
    try {
        return GetByProjectWsResponse.parseFrom(response);
    } catch (IOException e) {
        throw propagate(e);
    }
}
Also used : InputStream(java.io.InputStream) 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