Search in sources :

Example 21 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method param_value_is_in_possible_values.

@Test
public void param_value_is_in_possible_values() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/print").setParam("message", "Hello World").setParam("format", "json");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("Hello World by -");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 22 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method bad_controller_with_no_action.

@Test
public void bad_controller_with_no_action() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/bad");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unknown url : /api/bad\"}]}");
    assertThat(response.stream().status()).isEqualTo(404);
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Example 23 with ValidatingRequest

use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.

the class WebServiceEngineTest method optional_parameter_is_set.

@Test
public void optional_parameter_is_set() {
    ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/print").setParam("message", "Hello World").setParam("author", "Marcel");
    DumbResponse response = new DumbResponse();
    underTest.execute(request, response);
    assertThat(response.stream().outputAsString()).isEqualTo("Hello World by Marcel");
}
Also used : ValidatingRequest(org.sonar.api.server.ws.internal.ValidatingRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 ValidatingRequest (org.sonar.api.server.ws.internal.ValidatingRequest)23 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Response (org.sonar.api.server.ws.Response)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ClientAbortException (org.apache.catalina.connector.ClientAbortException)1 IOUtils (org.apache.commons.io.IOUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 After (org.junit.After)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 ExpectedException (org.junit.rules.ExpectedException)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 WebService (org.sonar.api.server.ws.WebService)1 LogTester (org.sonar.api.utils.log.LogTester)1 LoggerLevel (org.sonar.api.utils.log.LoggerLevel)1 BadRequestException (org.sonar.server.exceptions.BadRequestException)1