use of com.vaadin.flow.templatemodel.BeanContainingBeans in project flow by vaadin.
the class TemplateModelTest method setBeanIncludeSubBeanProperties_getterThrows.
@Test(expected = InvalidTemplateModelException.class)
public void setBeanIncludeSubBeanProperties_getterThrows() {
TemplateWithIncludeForSubBean template = new TemplateWithIncludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
template.getModel().getBeanContainingBeans().getBean2();
}
use of com.vaadin.flow.templatemodel.BeanContainingBeans 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.templatemodel.BeanContainingBeans in project flow by vaadin.
the class TemplateModelTest method setBeanExcludeSubBeanProperties.
@Test
public void setBeanExcludeSubBeanProperties() {
TemplateWithExcludeForSubBean template = new TemplateWithExcludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean1(new Bean(1));
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
Assert.assertNotNull(template.getModel().getBeanContainingBeans().getBean1());
Assert.assertTrue(getModelMap(template, "beanContainingBeans.bean1").hasValue("booleanValue"));
// bean1.booleanObject is excluded
Assert.assertFalse(getModelMap(template, "beanContainingBeans.bean1").hasValue("booleanObject"));
}
use of com.vaadin.flow.templatemodel.BeanContainingBeans in project flow by vaadin.
the class TemplateModelTest method setBeanExcludeSubBeanProperties_getterThrows.
@Test(expected = InvalidTemplateModelException.class)
public void setBeanExcludeSubBeanProperties_getterThrows() {
TemplateWithExcludeForSubBean template = new TemplateWithExcludeForSubBean();
BeanContainingBeans beanContainer = new BeanContainingBeans();
beanContainer.setBean2(new Bean(2));
template.getModel().setBeanContainingBeans(beanContainer);
template.getModel().getBeanContainingBeans().getBean2();
}
use of com.vaadin.flow.templatemodel.BeanContainingBeans 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());
ModelMap bean1Map = getModelMap(template, "beanContainingBeans.bean1");
Set<String> bean1Keys = getKeys(bean1Map);
Assert.assertTrue(bean1Keys.contains("booleanObject"));
Assert.assertEquals(1, bean1Keys.size());
}
Aggregations