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