use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap 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());
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.ElementPropertyMap in project flow by vaadin.
the class TemplateModelTest method setModelPropertyAndVerifyGetter.
private void setModelPropertyAndVerifyGetter(PolymerTemplate<?> template, Supplier<Object> getter, String beanPath, String property, Serializable expected) {
ElementPropertyMap feature = getModelMap(template, beanPath);
feature.setProperty(property, expected);
Assert.assertEquals(expected, getter.get());
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class TemplateModelTest method includeExcludeWhenUsingSubclass.
@Test
public void includeExcludeWhenUsingSubclass() {
TemplateWithExcludeAndIncludeSubclass template = new TemplateWithExcludeAndIncludeSubclass();
template.getModel().setBean(new Bean(123));
ElementPropertyMap modelMap = getModelMap(template, "bean");
assertTrue(modelMap.hasProperty("booleanObject"));
Assert.assertEquals(1, modelMap.getPropertyNames().count());
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class TemplateModelTest method verifyModel.
private void verifyModel(PolymerTemplate<?> template, String beanPath, String property, Serializable expected) {
ElementPropertyMap feature = getModelMap(template, beanPath);
Assert.assertNotNull(feature);
Assert.assertEquals(expected, feature.getProperty(property));
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class AbstractTemplate method removeSimpleProperties.
private List<String> removeSimpleProperties() {
ElementPropertyMap map = getStateNode().getFeature(ElementPropertyMap.class);
List<String> props = map.getPropertyNames().filter(name -> !(map.getProperty(name) instanceof StateNode)).collect(Collectors.toList());
props.forEach(map::removeProperty);
return props;
}
Aggregations