Search in sources :

Example 1 with PushNodeEntry

use of com.enonic.xp.node.PushNodeEntry in project xp by enonic.

the class NodeEventListenerTest method node_pushed_event.

@Test
public void node_pushed_event() throws Exception {
    final NodeId nodeId = NodeId.from("node1");
    final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
    final NodePath previousNodePath = NodePath.create(NodePath.ROOT, "previousName").build();
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
    final PushNodeEntry pushNodeEntry = PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry).currentTargetPath(previousNodePath).build();
    final PushNodeEntries pushNodeEntries = PushNodeEntries.create().targetRepo(ContentConstants.CONTENT_REPO_ID).targetBranch(ContentConstants.BRANCH_MASTER).add(pushNodeEntry).build();
    final Event localEvent = NodeEvents.pushed(pushNodeEntries);
    nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
    Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodePushed(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.eq(previousNodePath), Mockito.isA(InternalContext.class));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) NodePath(com.enonic.xp.node.NodePath) PushNodeEntry(com.enonic.xp.node.PushNodeEntry) Test(org.junit.jupiter.api.Test)

Example 2 with PushNodeEntry

use of com.enonic.xp.node.PushNodeEntry in project xp by enonic.

the class NodeStorageServiceImpl method push.

@Override
public void push(final PushNodeEntries entries, final PushNodesListener pushListener, final InternalContext context) {
    for (final PushNodeEntry entry : entries) {
        final NodeBranchEntry nodeBranchEntry = entry.getNodeBranchEntry();
        this.branchService.store(nodeBranchEntry, entry.getCurrentTargetPath(), InternalContext.create(context).branch(entries.getTargetBranch()).build());
        if (pushListener != null) {
            pushListener.nodesPushed(1);
        }
    }
    this.indexDataService.push(IndexPushNodeParams.create().nodeIds(entries.getNodeIds()).targetBranch(entries.getTargetBranch()).targetRepo(entries.getTargetRepo()).pushListener(pushListener).build(), context);
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntry(com.enonic.xp.node.PushNodeEntry)

Aggregations

NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)2 PushNodeEntry (com.enonic.xp.node.PushNodeEntry)2 Event (com.enonic.xp.event.Event)1 NodeId (com.enonic.xp.node.NodeId)1 NodePath (com.enonic.xp.node.NodePath)1 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)1 InternalContext (com.enonic.xp.repo.impl.InternalContext)1 Test (org.junit.jupiter.api.Test)1