use of com.vaadin.flow.template.angular.ModelValueBindingProvider 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.template.angular.ModelValueBindingProvider in project flow by vaadin.
the class ModelValueBindingTest method toJson.
@Test
public void toJson() {
ModelValueBindingProvider binding = new ModelValueBindingProvider("bar");
JsonValue json = binding.toJson();
Assert.assertTrue(json instanceof JsonObject);
JsonObject object = (JsonObject) json;
Assert.assertEquals(ModelValueBindingProvider.TYPE, object.get(BindingValueProvider.TYPE_PROPERTY).asString());
Assert.assertEquals("bar", object.get(BindingValueProvider.VALUE_PROPERTY).asString());
}
use of com.vaadin.flow.template.angular.ModelValueBindingProvider in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementJsonProperties.
@Test
public void testElementJsonProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
JsonObject json = Json.createObject();
json.put("foo", "bar");
ModelMap.get(stateNode).setValue("key", json);
Assert.assertEquals(json, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.template.angular.ModelValueBindingProvider in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementDoubleProperties.
@Test
public void testElementDoubleProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
ModelMap.get(stateNode).setValue("key", 1.1d);
Assert.assertEquals(1.1d, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.template.angular.ModelValueBindingProvider in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementBooleanProperties.
@Test
public void testElementBooleanProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
ModelMap.get(stateNode).setValue("key", Boolean.TRUE);
Assert.assertEquals(Boolean.TRUE, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
Aggregations