use of com.enonic.xp.repo.impl.storage.NodeMovedParams in project xp by enonic.
the class NodeEventListenerTest method node_moved_event.
@Test
public void node_moved_event() throws Exception {
final NodeId nodeId = NodeId.from("node1");
final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
final Node sourceNode = Node.create().id(nodeId).parentPath(nodePath.getParentPath()).name(nodePath.getLastElement().toString()).build();
final Node movedNode = Node.create(sourceNode).parentPath(NodePath.create("newParent").build()).build();
final Event localEvent = NodeEvents.moved(MoveNodeResult.create().addMovedNode(MoveNodeResult.MovedNode.create().node(movedNode).previousPath(sourceNode.path()).build()).sourceNode(sourceNode).build());
nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
final NodeMovedParams nodeMovedParams = new NodeMovedParams(sourceNode.path(), movedNode.path(), sourceNode.id());
Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeMoved(Mockito.eq(nodeMovedParams), Mockito.isA(InternalContext.class));
}
use of com.enonic.xp.repo.impl.storage.NodeMovedParams in project xp by enonic.
the class NodeMovedHandler method handleEvent.
@Override
public void handleEvent(NodeStorageService nodeStorageService, final Event event, final InternalContext context) {
final List<Map<Object, Object>> valueMapList = getValueMapList(event);
for (final Map<Object, Object> map : valueMapList) {
final InternalContext nodeContext = createNodeContext(map, context);
final NodeMovedParams nodeMovedParams = new NodeMovedParams(getPath(map), NodePath.create(map.get(NEW_PATH).toString()).build(), getId(map));
nodeStorageService.handleNodeMoved(nodeMovedParams, nodeContext);
}
}
use of com.enonic.xp.repo.impl.storage.NodeMovedParams in project xp by enonic.
the class NodeEventListenerTest method node_renamed_event.
@Test
public void node_renamed_event() throws Exception {
final NodeId nodeId = NodeId.from("node1");
final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
final Node sourceNode = Node.create().id(nodeId).parentPath(nodePath.getParentPath()).name(nodePath.getLastElement().toString()).build();
final Node movedNode = Node.create(sourceNode).parentPath(NodePath.create("newParent").build()).build();
final Event localEvent = NodeEvents.renamed(sourceNode.path(), movedNode);
nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
final NodeMovedParams nodeMovedParams = new NodeMovedParams(sourceNode.path(), movedNode.path(), sourceNode.id());
Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeMoved(Mockito.eq(nodeMovedParams), Mockito.isA(InternalContext.class));
}
Aggregations