Package org.sonar.api.server.ws.internal

Examples of org.sonar.api.server.ws.internal.ValidatingRequest


    assertThat(response.stream().outputAsString()).isEqualTo("Hello World by Marcel");
  }

  @Test
  public void param_value_is_in_possible_values() throws Exception {
    ValidatingRequest request = new SimpleRequest("GET")
      .setParam("message", "Hello World")
      .setParam("format", "json");
    ServletResponse response = new ServletResponse();
    engine.execute(request, response, "api/system", "print");
View Full Code Here


    assertThat(response.stream().outputAsString()).isEqualTo("Hello World by -");
  }

  @Test
  public void param_value_is_not_in_possible_values() throws Exception {
    ValidatingRequest request = new SimpleRequest("GET")
      .setParam("message", "Hello World")
      .setParam("format", "html");
    ServletResponse response = new ServletResponse();
    engine.execute(request, response, "api/system", "print");
View Full Code Here

    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Value of parameter 'format' (html) must be one of: [json, xml]\"}]}");
  }

  @Test
  public void internal_error() throws Exception {
    ValidatingRequest request = new SimpleRequest("GET");
    ServletResponse response = new ServletResponse();
    engine.execute(request, response, "api/system", "fail");

    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"Unexpected\"}]}");
    assertThat(response.stream().httpStatus()).isEqualTo(500);
View Full Code Here

  }

  @Test
  public void bad_request_with_i18n_message() throws Exception {
    MockUserSession.set().setLocale(Locale.ENGLISH);
    ValidatingRequest request = new SimpleRequest("GET").setParam("count", "3");
    ServletResponse response = new ServletResponse();
    when(i18n.message(Locale.ENGLISH, "bad.request.reason", "bad.request.reason", 0)).thenReturn("reason #0");

    engine.execute(request, response, "api/system", "fail_with_i18n_message");
View Full Code Here

    assertThat(response.stream().mediaType()).isEqualTo(MimeTypes.JSON);
  }

  @Test
  public void bad_request_with_multiple_messages() throws Exception {
    ValidatingRequest request = new SimpleRequest("GET").setParam("count", "3");
    ServletResponse response = new ServletResponse();

    engine.execute(request, response, "api/system", "fail_with_multiple_messages");

    assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":["
View Full Code Here

  @Test
  public void bad_request_with_multiple_i18n_messages() throws Exception {
    MockUserSession.set().setLocale(Locale.ENGLISH);

    ValidatingRequest request = new SimpleRequest("GET").setParam("count", "3");
    ServletResponse response = new ServletResponse();
    when(i18n.message(Locale.ENGLISH, "bad.request.reason", "bad.request.reason", 0)).thenReturn("reason #0");
    when(i18n.message(Locale.ENGLISH, "bad.request.reason", "bad.request.reason", 1)).thenReturn("reason #1");
    when(i18n.message(Locale.ENGLISH, "bad.request.reason", "bad.request.reason", 2)).thenReturn("reason #2");
View Full Code Here

TOP

Related Classes of org.sonar.api.server.ws.internal.ValidatingRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.