Search in sources :

Example 1 with LoadNodeParams

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

the class LoadNodeCommandTest method node_already_exists_in_path.

@Test
public void node_already_exists_in_path() throws Exception {
    final Node originalNode = createNode(NodePath.ROOT, "fisk");
    final Node nodeToLoad = Node.create(originalNode).id(new NodeId()).parentPath(NodePath.ROOT).name("fisk").timestamp(Instant.now()).nodeVersionId(NodeVersionId.from("nodeVersionId")).build();
    final LoadNodeParams loadParams = LoadNodeParams.create().node(nodeToLoad).build();
    refresh();
    doLoadNode(loadParams);
    refresh();
    final Node storedNode = getNodeByPath(nodeToLoad.path());
    assertNotNull(storedNode);
    assertNotEquals(originalNode.id(), storedNode.id());
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) LoadNodeParams(com.enonic.xp.node.LoadNodeParams) Test(org.junit.jupiter.api.Test)

Example 2 with LoadNodeParams

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

the class LoadNodeCommandTest method parent_does_not_exist.

@Test
public void parent_does_not_exist() throws Exception {
    final LoadNodeParams loadParams = LoadNodeParams.create().node(Node.create().id(new NodeId()).parentPath(NodePath.create("ost").build()).name("fisk").timestamp(Instant.now()).nodeVersionId(NodeVersionId.from("nodeVersionId")).build()).build();
    assertThrows(NodeLoadException.class, () -> doLoadNode(loadParams));
}
Also used : NodeId(com.enonic.xp.node.NodeId) LoadNodeParams(com.enonic.xp.node.LoadNodeParams) Test(org.junit.jupiter.api.Test)

Example 3 with LoadNodeParams

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

the class LoadNodeCommandTest method load_node.

@Test
public void load_node() throws Exception {
    final Node node = Node.create().id(NodeId.from("myNodeId")).parentPath(NodePath.ROOT).name("fisk").nodeState(NodeState.DEFAULT).childOrder(ChildOrder.manualOrder()).nodeType(NodeType.from("myNodes")).timestamp(Instant.now()).nodeVersionId(NodeVersionId.from("nodeVersionId")).build();
    final LoadNodeParams loadParams = LoadNodeParams.create().node(node).build();
    doLoadNode(loadParams);
    final Node storedNode = NodeHelper.runAsAdmin(() -> getNode(node.id()));
    assertNodeProperties(node, storedNode);
}
Also used : Node(com.enonic.xp.node.Node) LoadNodeParams(com.enonic.xp.node.LoadNodeParams) Test(org.junit.jupiter.api.Test)

Aggregations

LoadNodeParams (com.enonic.xp.node.LoadNodeParams)3 Test (org.junit.jupiter.api.Test)3 Node (com.enonic.xp.node.Node)2 NodeId (com.enonic.xp.node.NodeId)2