use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method does_not_fail_to_render_error_message_having_percent.
@Test
public void does_not_fail_to_render_error_message_having_percent() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/error_message_having_percent");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"this should not fail %s\"}]}");
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 param_value_is_not_in_possible_values.
@Test
public void param_value_is_not_in_possible_values() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/print").setParam("message", "Hello World").setParam("format", "html");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Value of parameter 'format' (html) must be one of: [json, xml]\"}]}");
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method execute_request.
@Test
public void execute_request() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/health");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("good");
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method internal_error.
@Test
public void internal_error() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/fail");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"An error has occurred. Please contact your administrator\"}]}");
assertThat(response.stream().status()).isEqualTo(500);
assertThat(response.stream().mediaType()).isEqualTo(MediaTypes.JSON);
assertThat(logTester.logs(LoggerLevel.ERROR)).filteredOn(l -> l.contains("Fail to process request")).isNotEmpty();
}
use of org.sonar.api.server.ws.internal.ValidatingRequest in project sonarqube by SonarSource.
the class WebServiceEngineTest method execute_request_when_path_does_not_begin_with_slash.
@Test
public void execute_request_when_path_does_not_begin_with_slash() {
ValidatingRequest request = new TestRequest().setMethod("GET").setPath("/api/system/health");
DumbResponse response = new DumbResponse();
underTest.execute(request, response);
assertThat(response.stream().outputAsString()).isEqualTo("good");
}
Aggregations