Beispiel #1
0
  @Test
  public void adhocValidation() {
    Form<javaguide.forms.u3.User> userForm = Form.form(javaguide.forms.u3.User.class);
    Form<javaguide.forms.u3.User> bound =
        userForm.bind(ImmutableMap.of("email", "e", "password", "p"));
    assertThat(bound.hasGlobalErrors(), equalTo(true));
    assertThat(bound.globalError().message(), equalTo("Invalid email or password"));

    // Run it through the template
    assertThat(
        javaguide.forms.html.view.render(bound).toString(),
        containsString("Invalid email or password"));
  }