Search in sources :

Example 71 with StateNode

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

the class AttachExistingElementFeatureTest method forEachChild_register_registeredStatNodeIsAChild.

@Test
public void forEachChild_register_registeredStatNodeIsAChild() {
    StateNode node = new StateNode();
    AttachExistingElementFeature feature = new AttachExistingElementFeature(node);
    Element element = Mockito.mock(Element.class);
    StateNode child = Mockito.mock(StateNode.class);
    ChildElementConsumer callback = Mockito.mock(ChildElementConsumer.class);
    Node<?> parent = Mockito.mock(Node.class);
    feature.register(parent, element, child, callback);
    List<StateNode> children = new ArrayList<>(1);
    feature.forEachChild(children::add);
    Assert.assertEquals(1, children.size());
    Assert.assertEquals(child, children.get(0));
}
Also used : ChildElementConsumer(com.vaadin.flow.dom.ChildElementConsumer) Element(com.vaadin.flow.dom.Element) StateNode(com.vaadin.flow.internal.StateNode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 72 with StateNode

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

the class AttachExistingElementFeatureTest method unregister_dataIsNotAvailaleByNode.

@Test
public void unregister_dataIsNotAvailaleByNode() {
    StateNode node = new StateNode();
    AttachExistingElementFeature feature = new AttachExistingElementFeature(node);
    Element element = Mockito.mock(Element.class);
    StateNode child = Mockito.mock(StateNode.class);
    ChildElementConsumer callback = Mockito.mock(ChildElementConsumer.class);
    Node<?> parent = Mockito.mock(Node.class);
    feature.register(parent, element, child, callback);
    feature.unregister(child);
    Assert.assertNull(feature.getCallback(child));
    Assert.assertNull(feature.getParent(child));
    Assert.assertNull(feature.getPreviousSibling(child));
}
Also used : ChildElementConsumer(com.vaadin.flow.dom.ChildElementConsumer) Element(com.vaadin.flow.dom.Element) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 73 with StateNode

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

the class ClientCallableHandlersTest method attach_noFeature.

@Test
public void attach_noFeature() {
    StateTree tree = new StateTree(new UI().getInternals(), ElementChildrenList.class);
    StateNode stateNode = new StateNode(ClientCallableHandlers.class);
    tree.getRootNode().getFeature(ElementChildrenList.class).add(stateNode);
    Assert.assertEquals(0, stateNode.getFeature(ClientCallableHandlers.class).size());
}
Also used : StateTree(com.vaadin.flow.internal.StateTree) UI(com.vaadin.flow.component.UI) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 74 with StateNode

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

the class ClientCallableHandlersTest method attach_noComponent.

@Test
public void attach_noComponent() {
    StateTree tree = new StateTree(new UI().getInternals(), ElementChildrenList.class);
    StateNode stateNode = new StateNode(ComponentMapping.class, ClientCallableHandlers.class);
    tree.getRootNode().getFeature(ElementChildrenList.class).add(stateNode);
    Assert.assertEquals(0, stateNode.getFeature(ClientCallableHandlers.class).size());
}
Also used : StateTree(com.vaadin.flow.internal.StateTree) UI(com.vaadin.flow.component.UI) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 75 with StateNode

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

the class ElementPropertyMapTest method deferredUpdateFromClient_listChild_filterAllowsUpdate.

@Test
public void deferredUpdateFromClient_listChild_filterAllowsUpdate() throws PropertyChangeDeniedException {
    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);
    assertDeferredUpdate_putResult(childModel, "bar");
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

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