Search in sources :

Example 16 with Event

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));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 17 with Event

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));
}
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 18 with Event

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));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 19 with Event

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));
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) Event(com.enonic.xp.event.Event) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 20 with Event

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));
}
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) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Aggregations

Event (com.enonic.xp.event.Event)48 Test (org.junit.jupiter.api.Test)46 Node (com.enonic.xp.node.Node)12 NodeId (com.enonic.xp.node.NodeId)7 NodePath (com.enonic.xp.node.NodePath)7 InternalContext (com.enonic.xp.repo.impl.InternalContext)7 EventListener (com.enonic.xp.event.EventListener)6 TaskInfo (com.enonic.xp.task.TaskInfo)6 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)3 ScriptEventListener (com.enonic.xp.script.event.ScriptEventListener)3 Branch (com.enonic.xp.branch.Branch)2 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)2 NodeMovedParams (com.enonic.xp.repo.impl.storage.NodeMovedParams)2 RepositoryId (com.enonic.xp.repository.RepositoryId)2 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)2 MapSerializable (com.enonic.xp.script.serializer.MapSerializable)2 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)2 Member (com.hazelcast.core.Member)2 Message (com.hazelcast.core.Message)2 List (java.util.List)2