use of com.enonic.xp.node.NodeId 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());
}
use of com.enonic.xp.node.NodeId 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));
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class ReorderChildNodeCommandTest method move_in_between.
@Test
public void move_in_between() throws Exception {
final Node parentNode = createNode(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).build());
createChildNodes(parentNode);
setChildOrder(parentNode, NodeIndexPath.NAME, OrderExpr.Direction.ASC);
setChildOrder(parentNode, NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.DESC);
// current node order: a,b,c,d,e,f
ReorderChildNodeCommand.create().parentNode(getNodeById(parentNode.id())).nodeToMove(getNodeById(NodeId.from("c"))).nodeToMoveBefore(getNodeById(NodeId.from("b"))).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
refresh();
final FindNodesByParentResult reOrderedResult = findByParent(FindNodesByParentParams.create().parentPath(parentNode.path()).build());
// updated node order: a,c,b,d,e,f
final Iterator<NodeId> iterator = reOrderedResult.getNodeIds().iterator();
assertEquals("a", iterator.next().toString());
assertEquals("c", iterator.next().toString());
assertEquals("b", iterator.next().toString());
assertEquals("d", iterator.next().toString());
assertEquals("e", iterator.next().toString());
assertEquals("f", iterator.next().toString());
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class ReorderChildNodeCommandTest method move_first.
@Test
public void move_first() throws Exception {
final Node parentNode = createNode(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).build());
createChildNodes(parentNode);
setChildOrder(parentNode, NodeIndexPath.NAME, OrderExpr.Direction.ASC);
setChildOrder(parentNode, NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.DESC);
// current node order: a,b,c,d,e,f
ReorderChildNodeCommand.create().parentNode(getNodeById(parentNode.id())).nodeToMove(getNodeById(NodeId.from("c"))).nodeToMoveBefore(getNodeById(NodeId.from("a"))).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
refresh();
final FindNodesByParentResult reOrderedResult = findByParent(FindNodesByParentParams.create().parentPath(parentNode.path()).build());
// updated node order: c,a,b,d,e,f
final Iterator<NodeId> iterator = reOrderedResult.getNodeIds().iterator();
assertEquals("c", iterator.next().toString());
assertEquals("a", iterator.next().toString());
assertEquals("b", iterator.next().toString());
assertEquals("d", iterator.next().toString());
assertEquals("e", iterator.next().toString());
assertEquals("f", iterator.next().toString());
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class SetNodeChildOrderCommandTest method order_by_name_desc.
@Test
public void order_by_name_desc() throws Exception {
final FindNodesByParentResult result = createNodeAndReturnOrderedChildren(NodeIndexPath.NAME, OrderExpr.Direction.DESC);
String previousName = "";
for (final NodeId n : result.getNodeIds()) {
final Node node = getNode(n);
final boolean largerThanPreviousName = previousName.compareTo(node.name().toString()) > 0;
assertTrue(Objects.equals(previousName, "") || largerThanPreviousName);
previousName = node.name().toString();
}
}
Aggregations