Search in sources :

Example 21 with StateNode

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

the class ModelMapTest method dotInvalidInKey.

@Test(expected = IllegalArgumentException.class)
public void dotInvalidInKey() {
    ModelMap map = new ModelMap(new StateNode());
    map.setValue("foo.bar", "a");
}
Also used : ModelMap(com.vaadin.flow.internal.nodefeature.ModelMap) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 22 with StateNode

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

the class ModelMapTest method hasValue.

@Test
public void hasValue() {
    ModelMap map = new ModelMap(new StateNode());
    Assert.assertFalse(map.hasValue("foo"));
    map.setValue("foo", "bar");
    Assert.assertTrue(map.hasValue("foo"));
    map.remove("foo");
    Assert.assertFalse(map.hasValue("foo"));
}
Also used : ModelMap(com.vaadin.flow.internal.nodefeature.ModelMap) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 23 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) ElementChildrenList(com.vaadin.flow.internal.nodefeature.ElementChildrenList) Before(org.junit.Before)

Example 24 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 25 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 : ElementClassList(com.vaadin.flow.internal.nodefeature.ElementClassList) 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)160 Test (org.junit.Test)99 Element (com.vaadin.flow.dom.Element)29 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)19 JsonObject (elemental.json.JsonObject)19 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)18 ModelMap (com.vaadin.flow.internal.nodefeature.ModelMap)16 ArrayList (java.util.ArrayList)14 StateNodeTest (com.vaadin.flow.internal.StateNodeTest)13 Serializable (java.io.Serializable)13 StateTree (com.vaadin.flow.internal.StateTree)10 ModelList (com.vaadin.flow.internal.nodefeature.ModelList)10 UI (com.vaadin.flow.component.UI)9 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)9 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)9 Bean (com.vaadin.flow.templatemodel.Bean)9 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)8 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)8 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)8 TemplateOverridesMap (com.vaadin.flow.internal.nodefeature.TemplateOverridesMap)6