Search in sources :

Example 1 with NodeExportListener

use of com.enonic.xp.export.NodeExportListener in project xp by enonic.

the class NodeExportIntegrationTest method children_nodes.

@Test
public void children_nodes() throws Exception {
    final Node root = createNode("mynode", NodePath.ROOT);
    final Node child1 = createNode("child1", root.path());
    createNode("child1_1", child1.path());
    final Node child1_2 = createNode("child1_2", child1.path());
    createNode("child1_2_1", child1_2.path());
    createNode("child1_2_2", child1_2.path());
    final Node child2 = createNode("child2", root.path());
    createNode("child2_1", child2.path());
    final NodeExportListener nodeExportListener = Mockito.mock(NodeExportListener.class);
    nodeService.refresh(RefreshMode.ALL);
    final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).nodeExportListener(nodeExportListener).build().execute();
    assertEquals(9, result.size());
    assertFileExists("myExport/_/node.xml");
    assertFileExists("myExport/mynode/_/node.xml");
    assertFileExists("myExport/mynode/child1/_/node.xml");
    assertFileExists("myExport/mynode/child1/child1_1/_/node.xml");
    assertFileExists("myExport/mynode/child1/child1_2/_/node.xml");
    assertFileExists("myExport/mynode/child1/child1_2/child1_2_1/_/node.xml");
    assertFileExists("myExport/mynode/child1/child1_2/child1_2_2/_/node.xml");
    assertFileExists("myExport/mynode/child2/_/node.xml");
    assertFileExists("myExport/mynode/child2/child2_1/_/node.xml");
    Mockito.verify(nodeExportListener).nodeResolved(9L);
    Mockito.verify(nodeExportListener, Mockito.times(9)).nodeExported(1L);
}
Also used : NodeExportResult(com.enonic.xp.export.NodeExportResult) Node(com.enonic.xp.node.Node) NodeExportListener(com.enonic.xp.export.NodeExportListener) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

FileExportWriter (com.enonic.xp.core.impl.export.writer.FileExportWriter)1 NodeExportListener (com.enonic.xp.export.NodeExportListener)1 NodeExportResult (com.enonic.xp.export.NodeExportResult)1 Node (com.enonic.xp.node.Node)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 Test (org.junit.jupiter.api.Test)1