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