use of com.vaadin.flow.internal.nodefeature.ModelList in project flow by vaadin.
the class TemplateModelTest method setListWithInclude.
@Test
public void setListWithInclude() {
TemplateWithIncludeOnList template = new TemplateWithIncludeOnList();
List<Bean> beans = new ArrayList<>();
beans.add(new Bean(1));
beans.add(new Bean(2));
template.getModel().setBeans(beans);
ModelList modelList = getModelList(template, "beans");
ElementPropertyMap bean1 = ElementPropertyMap.getModel(modelList.get(0));
Set<String> propertiesInMap = bean1.getPropertyNames().collect(Collectors.toSet());
Assert.assertTrue("Bean in model should have an 'intValue' property", propertiesInMap.remove("intValue"));
Assert.assertEquals("All other properties should have been filtered out", 0, propertiesInMap.size());
}
use of com.vaadin.flow.internal.nodefeature.ModelList in project flow by vaadin.
the class TemplateModelTest method setListWithExclude.
@Test
public void setListWithExclude() {
TemplateWithExcludeOnList template = new TemplateWithExcludeOnList();
List<Bean> beans = new ArrayList<>();
beans.add(new Bean(1));
beans.add(new Bean(2));
template.getModel().setBeans(beans);
ModelList modelList = getModelList(template, "beans");
ElementPropertyMap bean1 = ElementPropertyMap.getModel(modelList.get(0));
ElementPropertyMap bean2 = ElementPropertyMap.getModel(modelList.get(1));
Set<String> bean1InMap = getKeys(bean1);
Set<String> bean2InMap = getKeys(bean2);
Assert.assertFalse("Bean1 in model should not have an 'intValue' property", bean1InMap.contains("intValue"));
Assert.assertFalse("Bean2 in model should not have an 'intValue' property", bean2InMap.contains("intValue"));
Assert.assertEquals("All other properties should have been included", 6, bean1InMap.size());
Assert.assertEquals("All other properties should have been included", 6, bean2InMap.size());
}
use of com.vaadin.flow.internal.nodefeature.ModelList in project flow by vaadin.
the class ModelMapTest method resolveAndCreateSubChildList.
@Test
public void resolveAndCreateSubChildList() {
ModelList child = rootMap.resolveModelList("parent.child");
ModelMap parent = getParentMapAndAssertMapping(child, "child");
ModelMap resolvedRoot = getParentMapAndAssertMapping(parent, "parent");
Assert.assertEquals(rootMap, resolvedRoot);
}
use of com.vaadin.flow.internal.nodefeature.ModelList in project flow by vaadin.
the class ModelMapTest method resolveAndCreateImmediateChildList.
@Test
public void resolveAndCreateImmediateChildList() {
ModelList child = rootMap.resolveModelList("child");
ModelMap parent = getParentMapAndAssertMapping(child, "child");
Assert.assertEquals(rootMap, parent);
}
Aggregations