use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ForTemplateView method createModelItem.
private StateNode createModelItem(String text, String key) {
StateNode modelItem1 = new StateNode(TemplateOverridesMap.class, ModelMap.class);
updateModelItem(modelItem1, text, key);
return modelItem1;
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ModelValueBindingTest method getValue.
public void getValue() {
ModelValueBindingProvider binding = new ModelValueBindingProvider("bar");
StateNode node = new StateNode(ModelMap.class);
ModelMap.get(node).setValue("bar", "someValue");
Assert.assertEquals("someValue", binding.getValue(node));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ScriptParsingTest method inlineStyles.
@Test
public void inlineStyles() {
String contents = //
".foo {\n" + //
" font-weight: bold;\n" + "}\n";
TemplateNode templateNode = parse(//
"<style>" + contents + //
"</style>");
//
Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
Assert.assertEquals("style", elementTemplate.getTag());
TextTemplateNode textNode = ((TextTemplateNode) elementTemplate.getChild(0));
String nodeContents = (String) textNode.getTextBinding().getValue(new StateNode());
Assert.assertEquals(contents, nodeContents);
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ScriptParsingTest method inlineScript.
@Test
public void inlineScript() {
String script = "window.alert('hello');\n" + "window.alert('world');\n";
TemplateNode templateNode = parse(//
"<script>" + script + //
"</script>");
//
Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
Assert.assertEquals("script", elementTemplate.getTag());
TextTemplateNode textNode = ((TextTemplateNode) elementTemplate.getChild(0));
String nodeContents = (String) textNode.getTextBinding().getValue(new StateNode());
Assert.assertEquals(script, nodeContents);
}
use of com.vaadin.flow.internal.StateNode 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());
}
Aggregations