Package com.google.sitebricks.client

Examples of com.google.sitebricks.client.WebResponse


*/
@Test
public class FormTest extends AbstractJettyTest {

  public void normal_case() {
    WebResponse response = post("?notNull=abc&positive=5");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(true));

    String url = res.getRedirectUrl();
    assertThat(url, equalTo("http://localhost:4000/pojo/1234"));
  }
View Full Code Here


    String url = res.getRedirectUrl();
    assertThat(url, equalTo("http://localhost:4000/pojo/1234"));
  }

  public void jsr303_single_validation_failed() {
    WebResponse response = post("");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));
View Full Code Here

    String url = res.getRedirectUrl();
    assertThat(url, is(nullValue()));
  }

  public void jsr303_multiple_validation_failed() {
    WebResponse response = post("?positive=-5");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    Collections.sort(errors);
    assertThat(errors.size(), equalTo(2));
View Full Code Here

    String url = res.getRedirectUrl();
    assertThat(url, is(nullValue()));
  }

  public void custom_validation_should_fail() {
    WebResponse response = post("?notNull=abc&positive=5&fail=true");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));
View Full Code Here

  }

  protected Map<String, String> login(String login, String senha) {
    String url = String.format("api/login?login=%s&senha=%s", login, senha);

    WebResponse response = webClientOf(url).post("");
    Map<String, String> headers = response.getHeaders();
    String cookie = headers.get("Set-Cookie");
    Map<String, String> cookies = ImmutableMap.of("Cookie", cookie);

    return cookies;
  }
View Full Code Here

*/
@Test
public class FormTest extends AbstractJettyTest {

  public void normal_case() {
    WebResponse response = post("?notNull=abc&positive=5");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(true));

    String url = res.getRedirectUrl();
    assertThat(url, equalTo("http://localhost:4000/pojo/1234"));
  }
View Full Code Here

    String url = res.getRedirectUrl();
    assertThat(url, equalTo("http://localhost:4000/pojo/1234"));
  }

  public void jsr303_single_validation_failed() {
    WebResponse response = post("");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));
View Full Code Here

    String url = res.getRedirectUrl();
    assertThat(url, is(nullValue()));
  }

  public void jsr303_multiple_validation_failed() {
    WebResponse response = post("?positive=-5");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    Collections.sort(errors);
    assertThat(errors.size(), equalTo(2));
View Full Code Here

    String url = res.getRedirectUrl();
    assertThat(url, is(nullValue()));
  }

  public void custom_validation_should_fail() {
    WebResponse response = post("?notNull=abc&positive=5&fail=true");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(false));

    List<FieldErrorJson> errors = res.getErrors();
    assertThat(errors.size(), equalTo(1));
View Full Code Here

*/
@Test
public class FormTest extends AbstractJettyTest {

  public void normal_case() {
    WebResponse response = post("?notNull=abc&positive=5");
    assertThat(response.status(), equalTo(HttpServletResponse.SC_OK));

    FormResponseJson res = response.to(FormResponseJson.class).using(Json.class);
    assertThat(res.isValid(), equalTo(true));

    String url = res.getRedirectUrl();
    assertThat(url, endsWith("/pojo/1234"));
  }
View Full Code Here

TOP

Related Classes of com.google.sitebricks.client.WebResponse

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.