use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class ForTemplateView method updateModelItem.
private void updateModelItem(StateNode stateNode, String text, String key) {
ModelMap model = ModelMap.get(stateNode);
model.setValue("text", text);
model.setValue("key", key);
}
use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class BeanModelTypeTest method modelToApplication.
@Test
public void modelToApplication() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL);
ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
model.setValue("string", "3");
model.setValue("intValue", Integer.valueOf(3));
Bean bean = beanType.modelToApplication(model.getNode());
Assert.assertEquals("3", bean.getString());
Assert.assertEquals(3, bean.getIntValue());
Assert.assertNull(bean.getIntObject());
}
use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class BeanModelTypeTest method applicationToModel_filtered.
@Test
public void applicationToModel_filtered() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, new PropertyFilter(name -> !name.equals("intValue")));
Bean bean = new Bean(3);
StateNode applicationToModel = beanType.applicationToModel(bean, new PropertyFilter(name -> name.equals("string") || name.equals("intValue")));
ModelMap model = ModelMap.get(applicationToModel);
Assert.assertEquals(Arrays.asList("string"), model.getKeys().collect(Collectors.toList()));
Assert.assertEquals("3", model.getValue("string"));
}
use of com.vaadin.flow.internal.nodefeature.ModelMap 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);
ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
DifferentBean bean = new DifferentBean(3);
beanType.importProperties(model, bean, PropertyFilter.ACCEPT_ALL);
}
use of com.vaadin.flow.internal.nodefeature.ModelMap in project flow by vaadin.
the class BeanModelTypeTest method importBean_withImportFilter.
@Test
public void importBean_withImportFilter() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL);
ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
Bean bean = new Bean(3);
beanType.importProperties(model, bean, new PropertyFilter(name -> "intObject".equals(name)));
Assert.assertEquals(1, model.getKeys().count());
Assert.assertEquals(Integer.valueOf(3), model.getValue("intObject"));
}
Aggregations