use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method single_node_changed_name.
@Test
public void single_node_changed_name() throws Exception {
final Node originalNode = createNode(NodePath.ROOT, "initial-name");
final Node renamedNode = this.nodeService.rename(RenameNodeParams.create().nodeId(originalNode.id()).nodeName(NodeName.from("new-node-name")).build());
final NodeExportResult result = doExportRoot(true);
assertEquals(2, result.size());
printPaths();
assertExported(renamedNode);
assertVersionExported(renamedNode, originalNode);
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method single_node_with_binary.
@Test
public void single_node_with_binary() throws Exception {
final BinaryReference binaryRef = BinaryReference.from("myFile");
final PropertyTree data = new PropertyTree();
data.addBinaryReference("myBinary", binaryRef);
final Node myNode = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("myNode").data(data).attachBinary(binaryRef, ByteSource.wrap("this is a binary file".getBytes())).build());
final NodeExportResult result = doExportRoot(false);
assertEquals(2, result.size());
assertEquals(1, result.getExportedBinaries().size());
assertExported(myNode);
assertBinaryExported(myNode, binaryRef);
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method one_node_file.
@Test
public void one_node_file() throws Exception {
createNode("mynode", NodePath.ROOT);
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(2, result.size());
assertFileExists("myExport/_/node.xml");
assertFileExists("myExport/mynode/_/node.xml");
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method single_node_multiple_versions.
@Test
public void single_node_multiple_versions() throws Exception {
final Node node = createNode(NodePath.ROOT, "myNode");
final Node updatedNode = updateNode(UpdateNodeParams.create().id(node.id()).editor((n) -> n.data.addInstant("myInstant", Instant.now())).build());
final NodeExportResult result = doExportRoot(true);
assertEquals(2, result.size());
printPaths();
assertExported(updatedNode);
assertVersionExported(updatedNode, node);
}
use of com.enonic.xp.export.NodeExportResult in project xp by enonic.
the class NodeExportIntegrationTest method writerOrderList.
@Test
public void writerOrderList() {
final Node root = Node.create().name(NodeName.from("root")).parentPath(NodePath.ROOT).childOrder(ChildOrder.manualOrder()).build();
this.nodeService.create(CreateNodeParams.from(root).build());
createNode("child1", root.path());
createNode("child2", root.path());
createNode("child3", root.path());
createNode("child4", root.path());
createNode("child5", root.path());
createNode("child6", root.path());
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(8, result.size());
assertFileExists("myExport/root/_/node.xml");
assertFileExists("myExport/root/_/manualChildOrder.txt");
}
Aggregations