Search in sources :

Example 11 with NodeExportResult

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);
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 12 with NodeExportResult

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);
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) BinaryReference(com.enonic.xp.util.BinaryReference) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 13 with NodeExportResult

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");
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 14 with NodeExportResult

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);
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 15 with NodeExportResult

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");
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) Node(com.enonic.xp.node.Node) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

NodeExportResult (com.enonic.xp.export.NodeExportResult)16 Test (org.junit.jupiter.api.Test)14 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)12 Node (com.enonic.xp.node.Node)9 FileExportWriter (com.enonic.xp.core.impl.export.writer.FileExportWriter)8 PropertyTree (com.enonic.xp.data.PropertyTree)3 BinaryReference (com.enonic.xp.util.BinaryReference)3 ExportWriter (com.enonic.xp.core.impl.export.writer.ExportWriter)2 ExportNodesParams (com.enonic.xp.export.ExportNodesParams)2 NodeExportListener (com.enonic.xp.export.NodeExportListener)2 NodePath (com.enonic.xp.node.NodePath)2 Path (java.nio.file.Path)2 Disabled (org.junit.jupiter.api.Disabled)2 BINARY_FOLDER (com.enonic.xp.core.impl.export.writer.NodeExportPathResolver.BINARY_FOLDER)1 NODE_XML_EXPORT_NAME (com.enonic.xp.core.impl.export.writer.NodeExportPathResolver.NODE_XML_EXPORT_NAME)1 SYSTEM_FOLDER_NAME (com.enonic.xp.core.impl.export.writer.NodeExportPathResolver.SYSTEM_FOLDER_NAME)1 VERSION_FOLDER (com.enonic.xp.core.impl.export.writer.NodeExportPathResolver.VERSION_FOLDER)1 ExportError (com.enonic.xp.export.ExportError)1 ExportNodesRequestJson (com.enonic.xp.impl.server.rest.model.ExportNodesRequestJson)1 ExportListenerImpl (com.enonic.xp.impl.server.rest.task.listener.ExportListenerImpl)1