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));
}
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));
}
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());
}
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());
}
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");
}
Aggregations