Search in sources :

Example 81 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ElementPropertyMapTest method deferredUpdateFromClient_filterAllowsUpdate.

@Test
public void deferredUpdateFromClient_filterAllowsUpdate() throws PropertyChangeDeniedException {
    ElementPropertyMap map = createSimplePropertyMap();
    StateNode child = new StateNode(ElementPropertyMap.class);
    ElementPropertyMap childModel = ElementPropertyMap.getModel(child);
    map.setUpdateFromClientFilter("foo.bar"::equals);
    map.put("foo", child);
    assertDeferredUpdate_putResult(childModel, "bar");
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 82 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ElementPropertyMapTest method listChildPropertyUpdateFilter_setFilterBeforeChild.

@Test
public void listChildPropertyUpdateFilter_setFilterBeforeChild() {
    ElementPropertyMap map = createSimplePropertyMap();
    ModelList list = map.resolveModelList("foo");
    StateNode child = new StateNode(ElementPropertyMap.class);
    map.setUpdateFromClientFilter("foo.bar"::equals);
    list.add(child);
    ElementPropertyMap childModel = ElementPropertyMap.getModel(child);
    Assert.assertTrue(childModel.mayUpdateFromClient("bar", "a"));
    Assert.assertFalse(childModel.mayUpdateFromClient("baz", "a"));
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 83 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class NodeListEmptyRequiredFeatureTest method setUp.

@Before
public void setUp() {
    node = new StateNode(Arrays.asList(ElementChildrenList.class)) {

        @Override
        public boolean isAttached() {
            return true;
        }
    };
    nodeList = node.getFeature(ElementChildrenList.class);
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) Before(org.junit.Before)

Example 84 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class StateNodeNodeListTest method testClear.

@Test
public void testClear() {
    StateNode one = StateNodeTest.createEmptyNode("one");
    StateNode two = StateNodeTest.createEmptyNode("two");
    nodeList.add(one);
    nodeList.add(two);
    Assert.assertEquals(2, nodeList.size());
    nodeList.clear();
    Assert.assertEquals(0, nodeList.size());
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test) StateNodeTest(com.vaadin.flow.internal.StateNodeTest)

Example 85 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class StateNodeNodeListTest method testSerializable.

@Test
public void testSerializable() {
    StateNode one = StateNodeTest.createTestNode("one", ElementClassList.class);
    one.getFeature(ElementClassList.class).add("foo");
    one.getFeature(ElementClassList.class).add("bar");
    StateNode two = StateNodeTest.createTestNode("two", ElementClassList.class);
    two.getFeature(ElementClassList.class).add("baz");
    nodeList.add(one);
    nodeList.add(two);
    List<StateNode> values = new ArrayList<>();
    int size = nodeList.size();
    for (int i = 0; i < size; i++) {
        values.add(nodeList.get(i));
    }
    NodeList<StateNode> copy = SerializationUtils.deserialize(SerializationUtils.serialize(nodeList));
    Assert.assertNotSame(nodeList, copy);
    Assert.assertEquals(values.size(), copy.size());
    for (int i = 0; i < size; i++) {
        assertNodeEquals(values.get(i), copy.get(i));
    }
    // Also verify that original value wasn't changed by the serialization
    Assert.assertEquals(values.size(), nodeList.size());
    for (int i = 0; i < size; i++) {
        assertNodeEquals(values.get(i), nodeList.get(i));
    }
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) ArrayList(java.util.ArrayList) Test(org.junit.Test) StateNodeTest(com.vaadin.flow.internal.StateNodeTest)

Aggregations

StateNode (com.vaadin.flow.internal.StateNode)196 Test (org.junit.Test)122 Element (com.vaadin.flow.dom.Element)32 JsonObject (elemental.json.JsonObject)24 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)22 UI (com.vaadin.flow.component.UI)19 StateTree (com.vaadin.flow.internal.StateTree)18 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)18 ArrayList (java.util.ArrayList)18 StateNodeTest (com.vaadin.flow.internal.StateNodeTest)17 Serializable (java.io.Serializable)17 ModelMap (com.vaadin.flow.internal.nodefeature.ModelMap)16 ModelList (com.vaadin.flow.internal.nodefeature.ModelList)10 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)9 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)9 VirtualChildrenList (com.vaadin.flow.internal.nodefeature.VirtualChildrenList)9 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)9 Bean (com.vaadin.flow.templatemodel.Bean)9 HashMap (java.util.HashMap)9 Collectors (java.util.stream.Collectors)9