Search in sources :

Example 21 with NodePath

use of com.enonic.xp.node.NodePath 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)

Example 22 with NodePath

use of com.enonic.xp.node.NodePath 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 23 with NodePath

use of com.enonic.xp.node.NodePath 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 24 with NodePath

use of com.enonic.xp.node.NodePath 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 25 with NodePath

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

the class NodeStorageServiceImplTest method testGetNode.

@Test
public void testGetNode() {
    final NodePath nodePath = NodePath.create("path").build();
    final NodeVersionMetadata nodeVersionMetadata = NodeVersionMetadata.create().nodeVersionId(nodeVersionId).nodeVersionKey(versionKey).nodePath(nodePath).build();
    final NodeVersion nodeVersion = NodeVersion.create().permissions(AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()).build();
    when(versionService.getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class))).thenReturn(nodeVersionMetadata);
    when(nodeVersionService.get(any(NodeVersionKey.class), any(InternalContext.class))).thenReturn(nodeVersion);
    final Node result = instance.getNode(nodeId, nodeVersionId, context);
    assertNotNull(result);
    verify(versionService, times(1)).getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class));
    verify(nodeVersionService, times(1)).get(any(NodeVersionKey.class), any(InternalContext.class));
    verifyNoMoreInteractions(versionService, nodeVersionService);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionId(com.enonic.xp.node.NodeVersionId) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Aggregations

NodePath (com.enonic.xp.node.NodePath)54 Node (com.enonic.xp.node.Node)27 Test (org.junit.jupiter.api.Test)20 NodeId (com.enonic.xp.node.NodeId)15 InternalContext (com.enonic.xp.repo.impl.InternalContext)12 Content (com.enonic.xp.content.Content)7 Event (com.enonic.xp.event.Event)7 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 ChildOrder (com.enonic.xp.index.ChildOrder)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ContentId (com.enonic.xp.content.ContentId)2 ContentPath (com.enonic.xp.content.ContentPath)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 Context (com.enonic.xp.context.Context)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 MoveNodeParams (com.enonic.xp.node.MoveNodeParams)2 NodeVersion (com.enonic.xp.node.NodeVersion)2