use of com.vaadin.flow.templatemodel.Bean in project flow by vaadin.
the class TemplateModelTest method setBeanExcludeSubBeanProperties.
@Test
public void setBeanExcludeSubBeanProperties() {
TemplateWithExcludeForSubBean template = new TemplateWithExcludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean1(new Bean(1));
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
Assert.assertNotNull(template.getModel().getBeanContainingBeans().getBean1());
Assert.assertTrue(getModelMap(template, "beanContainingBeans.bean1").hasValue("booleanValue"));
// bean1.booleanObject is excluded
Assert.assertFalse(getModelMap(template, "beanContainingBeans.bean1").hasValue("booleanObject"));
}
use of com.vaadin.flow.templatemodel.Bean in project flow by vaadin.
the class BeanModelTypeTest method importBean_withTypeFilter.
@Test
public void importBean_withTypeFilter() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, new PropertyFilter(name -> "intValue".equals(name)));
ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
Bean bean = new Bean(3);
beanType.importProperties(model, bean, PropertyFilter.ACCEPT_ALL);
Assert.assertEquals(1, model.getKeys().count());
Assert.assertEquals(Integer.valueOf(3), model.getValue("intValue"));
}
use of com.vaadin.flow.templatemodel.Bean in project flow by vaadin.
the class BeanModelTypeTest method importBean_differentBean.
@Test
public void importBean_differentBean() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL);
ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
DifferentBean bean = new DifferentBean(3);
// Ignore intValue which has an incompatible type
beanType.importProperties(model, bean, new PropertyFilter(name -> !"intValue".equals(name)));
Assert.assertEquals(1, model.getKeys().count());
Assert.assertEquals("3", model.getValue("string"));
Assert.assertFalse(model.hasValue("date"));
}
use of com.vaadin.flow.templatemodel.Bean in project flow by vaadin.
the class BeanModelTypeTest method applicationToModel.
@Test
public void applicationToModel() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL);
Bean bean = new Bean(3);
StateNode applicationToModel = beanType.applicationToModel(bean, PropertyFilter.ACCEPT_ALL);
ModelMap model = ModelMap.get(applicationToModel);
assertThreeBean(model);
}
use of com.vaadin.flow.templatemodel.Bean in project flow by vaadin.
the class TemplateModelTest method setBeanExcludeSubBeanProperties_getterThrows.
@Test(expected = InvalidTemplateModelException.class)
public void setBeanExcludeSubBeanProperties_getterThrows() {
TemplateWithExcludeForSubBean template = new TemplateWithExcludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
template.getModel().getBeanContainingBeans().getBean2();
}
Aggregations