Search in sources :

Example 1 with SubSubConstraint

use of com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint in project flow by vaadin.

the class BeanBinderTest method subSubfield_name_valueCanBeValidated.

@Test
public void subSubfield_name_valueCanBeValidated() {
    BeanValidationBinder<RequiredConstraints> binder = new BeanValidationBinder<>(RequiredConstraints.class);
    TestTextField field = new TestTextField();
    binder.bind(field, "subfield.subsub.value");
    RequiredConstraints bean = new RequiredConstraints();
    SubConstraint subfield = new SubConstraint();
    bean.setSubfield(subfield);
    subfield.setSubsub(new SubSubConstraint());
    binder.setBean(bean);
    Assert.assertFalse(binder.validate().isOk());
    field.setValue("overtencharacters");
    Assert.assertTrue(binder.validate().isOk());
}
Also used : TestTextField(com.vaadin.flow.data.binder.testcomponents.TestTextField) SubSubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint) SubSubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint) SubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubConstraint) Test(org.junit.Test)

Example 2 with SubSubConstraint

use of com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint in project flow by vaadin.

the class BeanBinderTest method subsubfield_name_fieldIsRequired.

@Test
public void subsubfield_name_fieldIsRequired() {
    BeanValidationBinder<RequiredConstraints> binder = new BeanValidationBinder<>(RequiredConstraints.class);
    RequiredConstraints bean = new RequiredConstraints();
    RequiredConstraints.SubConstraint subfield = new RequiredConstraints.SubConstraint();
    subfield.setSubsub(new SubSubConstraint());
    bean.setSubfield(subfield);
    TestTextField field = new TestTextField();
    binder.bind(field, "subfield.subsub.value");
    binder.setBean(bean);
    Assert.assertTrue(field.isRequiredIndicatorVisible());
    testSerialization(binder);
}
Also used : SubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubConstraint) SubSubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint) TestTextField(com.vaadin.flow.data.binder.testcomponents.TestTextField) SubSubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint) SubConstraint(com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubConstraint) Test(org.junit.Test)

Aggregations

SubConstraint (com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubConstraint)2 SubSubConstraint (com.vaadin.flow.data.binder.BeanBinderTest.RequiredConstraints.SubSubConstraint)2 TestTextField (com.vaadin.flow.data.binder.testcomponents.TestTextField)2 Test (org.junit.Test)2