use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventListenerTest method node_create_event.
@Test
public void node_create_event() throws Exception {
final NodeId nodeId = NodeId.from("node1");
final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
final Event localEvent = NodeEvents.created(Node.create().id(nodeId).parentPath(nodePath.getParentPath()).name(nodePath.getLastElement().toString()).build());
nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeCreated(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.isA(InternalContext.class));
}
use of com.enonic.xp.event.Event 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.event.Event in project xp by enonic.
the class NodeEventListenerTest method local_event_ignored.
@Test
public void local_event_ignored() throws Exception {
final NodeId nodeId = NodeId.from("node1");
final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
final Event localEvent = NodeEvents.created(Node.create().id(nodeId).parentPath(nodePath.getParentPath()).name(nodePath.getLastElement().toString()).build());
nodeEventListener.onEvent(localEvent);
Mockito.verify(nodeStorageService, Mockito.never()).handleNodeCreated(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.isA(InternalContext.class));
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventListenerTest method node_duplicated_event.
@Test
public void node_duplicated_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.duplicated(sourceNode);
nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeCreated(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.isA(InternalContext.class));
}
use of com.enonic.xp.event.Event in project xp by enonic.
the class NodeEventListenerTest method node_delete_event.
@Test
public void node_delete_event() throws Exception {
final NodeId nodeId = NodeId.from("node1");
final NodePath nodePath = NodePath.create(NodePath.ROOT, "nodeName").build();
final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
final Event localEvent = NodeEvents.deleted(NodeBranchEntries.create().add(nodeBranchEntry).build());
nodeEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
Mockito.verify(nodeStorageService, Mockito.times(1)).handleNodeDeleted(Mockito.eq(nodeId), Mockito.eq(nodePath), Mockito.isA(InternalContext.class));
}
Aggregations