use of com.enonic.xp.node.ReorderChildNodesParams in project xp by enonic.
the class NodeServiceImplTest method testReorderChildren.
@Test
public void testReorderChildren() {
final Node parent = createNode(CreateNodeParams.create().name("my-parent").parent(NodePath.ROOT).childOrder(ChildOrder.manualOrder()).build());
final Node child1 = createNode(CreateNodeParams.create().name("my-child-1").parent(parent.path()).build());
final Node child2 = createNode(CreateNodeParams.create().name("my-child-2").parent(parent.path()).build());
final Node child3 = createNode(CreateNodeParams.create().name("my-child-3").parent(parent.path()).build());
final ReorderChildNodesParams params = ReorderChildNodesParams.create().add(ReorderChildNodeParams.create().nodeId(child1.id()).moveBefore(child2.id()).build()).add(ReorderChildNodeParams.create().nodeId(child3.id()).moveBefore(child1.id()).build()).processor(data -> {
data.addString("processedValue", "value");
return data;
}).build();
final ReorderChildNodesResult result = this.nodeService.reorderChildren(params);
assertThat(result.getNodeIds()).containsExactly(child1.id(), child3.id());
assertThat(result.getParentNodes().getIds()).containsExactly(parent.id());
assertThat(nodeService.findByParent(FindNodesByParentParams.create().parentId(parent.id()).build()).getNodeIds()).containsExactly(child3.id(), child1.id(), child2.id());
nodeService.refresh(RefreshMode.ALL);
final Node processedParent = this.nodeService.getById(parent.id());
assertEquals("value", processedParent.data().getString("processedValue"));
}
Aggregations