Search in sources :

Example 1 with BeanWithObjectProperty

use of cn.taketoday.validation.BeanWithObjectProperty in project today-framework by TAKETODAY.

the class DataBinderTests method testBindingWithCustomEditorOnObjectField.

@Test
void testBindingWithCustomEditorOnObjectField() {
    BeanWithObjectProperty tb = new BeanWithObjectProperty();
    DataBinder binder = new DataBinder(tb);
    binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
    PropertyValues pvs = new PropertyValues();
    pvs.add("object", "1");
    binder.bind(pvs);
    assertThat(tb.getObject()).isEqualTo(1);
}
Also used : BeanWithObjectProperty(cn.taketoday.validation.BeanWithObjectProperty) PropertyValues(cn.taketoday.beans.PropertyValues) CustomNumberEditor(cn.taketoday.beans.propertyeditors.CustomNumberEditor) DataBinder(cn.taketoday.validation.DataBinder) Test(org.junit.jupiter.api.Test)

Aggregations

PropertyValues (cn.taketoday.beans.PropertyValues)1 CustomNumberEditor (cn.taketoday.beans.propertyeditors.CustomNumberEditor)1 BeanWithObjectProperty (cn.taketoday.validation.BeanWithObjectProperty)1 DataBinder (cn.taketoday.validation.DataBinder)1 Test (org.junit.jupiter.api.Test)1