Search in sources :

Example 1 with AttachTemplateChildRpcHandler

use of com.vaadin.flow.server.communication.rpc.AttachTemplateChildRpcHandler in project flow by vaadin.

the class AttachTemplateChildRpcHandlerTest method assertHandleNode.

private void assertHandleNode(int assignedId, JsonValue id) {
    AttachTemplateChildRpcHandler handler = new AttachTemplateChildRpcHandler();
    int requestedId = 1;
    JsonObject object = Json.createObject();
    object.put(JsonConstants.RPC_ATTACH_REQUESTED_ID, requestedId);
    object.put(JsonConstants.RPC_ATTACH_ASSIGNED_ID, assignedId);
    object.put(JsonConstants.RPC_ATTACH_ID, id);
    StateNode node = Mockito.mock(StateNode.class);
    StateNode parentNode = Mockito.mock(StateNode.class);
    StateTree tree = Mockito.mock(StateTree.class);
    Mockito.when(node.getOwner()).thenReturn(tree);
    Mockito.when(node.getParent()).thenReturn(parentNode);
    Mockito.when(tree.getNodeById(requestedId)).thenReturn(node);
    ElementData data = new ElementData(node);
    data.setTag("foo");
    Mockito.when(node.getFeature(ElementData.class)).thenReturn(data);
    Mockito.when(parentNode.getId()).thenReturn(3);
    handler.handleNode(node, object);
}
Also used : AttachTemplateChildRpcHandler(com.vaadin.flow.server.communication.rpc.AttachTemplateChildRpcHandler) StateTree(com.vaadin.flow.internal.StateTree) StateNode(com.vaadin.flow.internal.StateNode) JsonObject(elemental.json.JsonObject) ElementData(com.vaadin.flow.internal.nodefeature.ElementData)

Aggregations

StateNode (com.vaadin.flow.internal.StateNode)1 StateTree (com.vaadin.flow.internal.StateTree)1 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)1 AttachTemplateChildRpcHandler (com.vaadin.flow.server.communication.rpc.AttachTemplateChildRpcHandler)1 JsonObject (elemental.json.JsonObject)1