use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class TemplateModelTest method setBeanIncludeAndExcludeProperties.
@Test
public void setBeanIncludeAndExcludeProperties() {
TemplateWithExcludeAndInclude template = new TemplateWithExcludeAndInclude();
template.getModel().setBean(new Bean(123));
ModelMap modelMap = getModelMap(template, "bean");
Assert.assertTrue(modelMap.hasValue("booleanObject"));
Assert.assertEquals(1, modelMap.getKeys().count());
}
use of com.vaadin.flow.internal.nodefeature.ModelMap 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());
ModelMap container1Map = ModelMap.get(modelList.get(0));
ModelMap container2Map = ModelMap.get(modelList.get(1));
Set<String> bean1bean2 = new HashSet<>();
bean1bean2.add("bean1");
bean1bean2.add("bean2");
Assert.assertEquals(bean1bean2, container1Map.getKeys().collect(Collectors.toSet()));
Assert.assertEquals(bean1bean2, container2Map.getKeys().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.ModelMap in project flow by vaadin.
the class ModelMapTest method resolveAndCreateSubSubChildMap.
@Test
public void resolveAndCreateSubSubChildMap() {
ModelMap child = rootMap.resolveModelMap("grand.parent.child");
ModelMap parent = getParentMapAndAssertMapping(child, "child");
ModelMap grand = getParentMapAndAssertMapping(parent, "parent");
ModelMap resolvedRoot = getParentMapAndAssertMapping(grand, "grand");
Assert.assertEquals(rootMap, resolvedRoot);
}
use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class ModelMapTest method dotInvalidInKey.
@Test(expected = IllegalArgumentException.class)
public void dotInvalidInKey() {
ModelMap map = new ModelMap(new StateNode());
map.setValue("foo.bar", "a");
}
use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class ModelMapTest method resolveAndCreateSubChildMap.
@Test
public void resolveAndCreateSubChildMap() {
ModelMap child = rootMap.resolveModelMap("parent.child");
ModelMap parent = getParentMapAndAssertMapping(child, "child");
ModelMap resolvedRoot = getParentMapAndAssertMapping(parent, "parent");
Assert.assertEquals(rootMap, resolvedRoot);
}
Aggregations