Search in sources :

Example 1 with ExportWriter

use of com.enonic.xp.core.impl.export.writer.ExportWriter in project xp by enonic.

the class NodeExportIntegrationTest method one_node_error.

@Test
public void one_node_error() throws Exception {
    createNode("mynode", NodePath.ROOT);
    final ExportWriter exportWriter = Mockito.mock(ExportWriter.class);
    Mockito.doThrow(new RuntimeException("exception message")).when(exportWriter).writeElement(Mockito.isA(Path.class), Mockito.anyString());
    final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(exportWriter).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
    assertEquals(1, result.getExportErrors().size());
    assertEquals("java.lang.RuntimeException: exception message", result.getExportErrors().get(0).toString());
}
Also used : Path(java.nio.file.Path) NodePath(com.enonic.xp.node.NodePath) NodeExportResult(com.enonic.xp.export.NodeExportResult) ExportWriter(com.enonic.xp.core.impl.export.writer.ExportWriter) FileExportWriter(com.enonic.xp.core.impl.export.writer.FileExportWriter) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

ExportWriter (com.enonic.xp.core.impl.export.writer.ExportWriter)1 FileExportWriter (com.enonic.xp.core.impl.export.writer.FileExportWriter)1 NodeExportResult (com.enonic.xp.export.NodeExportResult)1 NodePath (com.enonic.xp.node.NodePath)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 Path (java.nio.file.Path)1 Test (org.junit.jupiter.api.Test)1