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);
}
Aggregations