use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class BeanModelTypeTest method applicationToModel.
@Test
public void applicationToModel() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL, false);
Bean bean = new Bean(3);
StateNode applicationToModel = beanType.applicationToModel(bean, PropertyFilter.ACCEPT_ALL);
ElementPropertyMap model = ElementPropertyMap.getModel(applicationToModel);
assertThreeBean(model);
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class BeanModelTypeTest method importBean_incompatibleBean.
@Test(expected = IllegalArgumentException.class)
public void importBean_incompatibleBean() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL, false);
ElementPropertyMap model = createEmptyModel();
DifferentBean bean = new DifferentBean(3);
beanType.importProperties(model, bean, PropertyFilter.ACCEPT_ALL);
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class BeanModelTypeTest method importBean.
@Test
public void importBean() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL, false);
ElementPropertyMap model = createEmptyModel();
Bean bean = new Bean(3);
beanType.importProperties(model, bean, PropertyFilter.ACCEPT_ALL);
assertThreeBean(model);
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class TemplateModelTest method setListWithSubBeanInclude.
@Test
public void setListWithSubBeanInclude() {
TemplateWithIncludeOnListSubBean template = new TemplateWithIncludeOnListSubBean();
List<BeanContainingBeans> beanContainingBeans = new ArrayList<>();
beanContainingBeans.add(new BeanContainingBeans(new Bean(11), new Bean(12)));
beanContainingBeans.add(new BeanContainingBeans(null, new Bean(22)));
template.getModel().setBeanContainingBeans(beanContainingBeans);
ModelList modelList = getModelList(template, "beanContainingBeans");
Assert.assertEquals(2, modelList.size());
ElementPropertyMap container1Map = ElementPropertyMap.getModel(modelList.get(0));
ElementPropertyMap container2Map = ElementPropertyMap.getModel(modelList.get(1));
Set<String> bean1bean2 = new HashSet<>();
bean1bean2.add("bean1");
bean1bean2.add("bean2");
Assert.assertEquals(bean1bean2, container1Map.getPropertyNames().collect(Collectors.toSet()));
Assert.assertEquals(bean1bean2, container2Map.getPropertyNames().collect(Collectors.toSet()));
Set<String> container1Bean1Properties = getKeys(container1Map.resolveModelMap("bean1"));
Assert.assertTrue(container1Bean1Properties.remove("intValue"));
Assert.assertEquals(0, container1Bean1Properties.size());
Set<String> container1Bean2Properties = getKeys(container1Map.resolveModelMap("bean2"));
Assert.assertTrue(container1Bean2Properties.remove("booleanValue"));
Assert.assertEquals(0, container1Bean2Properties.size());
Set<String> container2Bean1Properties = getKeys(container2Map.resolveModelMap("bean1"));
// Null value in the initial bean implies not imported or created
Assert.assertEquals(0, container2Bean1Properties.size());
Set<String> container2Bean2Properties = getKeys(container2Map.resolveModelMap("bean2"));
Assert.assertTrue(container2Bean2Properties.remove("booleanValue"));
Assert.assertEquals(0, container2Bean2Properties.size());
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class TemplateModelTest method setBeanIncludeSubBeanProperties.
@Test
public void setBeanIncludeSubBeanProperties() {
TemplateWithIncludeForSubBean template = new TemplateWithIncludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean1(new Bean(1));
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
Assert.assertNotNull(template.getModel().getBeanContainingBeans().getBean1());
ElementPropertyMap bean1Map = getModelMap(template, "beanContainingBeans.bean1");
Set<String> bean1Keys = getKeys(bean1Map);
Assert.assertTrue(bean1Keys.contains("booleanObject"));
Assert.assertEquals(1, bean1Keys.size());
}
Aggregations