use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method bad_request_with_multiple_messages.
@Test
public void bad_request_with_multiple_messages() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/fail_with_multiple_messages").setParam("count", "3");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[" + "{\"msg\":\"Bad request reason #0\"}," + "{\"msg\":\"Bad request reason #1\"}," + "{\"msg\":\"Bad request reason #2\"}" + "]}");
assertThat(response.stream().status()).isEqualTo(400);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method bad_request_if_action_suffix_is_not_supported.
@Test
public void bad_request_if_action_suffix_is_not_supported() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/health.bat");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().status()).isEqualTo(400);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unknown action extension: bat\"}]}");
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method bad_controller.
@Test
public void bad_controller() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/xxx/health");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unknown url : /api/xxx/health\"}]}");
assertThat(response.stream().status()).isEqualTo(404);
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method bad_request.
@Test
public void bad_request() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/fail_bad_request").setParam("count", "3");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Bad request !\"}]}");
assertThat(response.stream().status()).isEqualTo(400);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method bad_action.
@Test
public void bad_action() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/xxx");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unknown url : /api/system/xxx\"}]}");
assertThat(response.stream().status()).isEqualTo(404);
}
Aggregations