public PreviewResult preview() throws IOException {
            if (inConfig == null) {
                throw new IllegalStateException("inputPath must be set");
            }
            if (outputPath == null) {
                throw new IllegalStateException("outputPath must be set");
            }

            // Execute preview to get PreviewResult
            ConfigSource previewConfig = newConfig()
                    .set("exec", execConfig.set("min_output_tasks", 1)) // exec: config
                    .set("in", inConfig)
                    .set("filters", filtersConfig);
            PreviewResult result = embed.preview(previewConfig);
            PreviewResultInputPlugin.setPreviewResult(result);

            String fileName = outputPath.getFileName().toString();
            if (!fileName.endsWith(".csv")) {
                throw new IllegalArgumentException("outputPath must end with .csv");
            }
            Path dir = outputPath.getParent().resolve(fileName.substring(0, fileName.length() - 4));
            Files.createDirectories(dir);

            // Execute run to write PreviewResult's Page objects to output files
            ConfigSource runConfig = newConfig()
                    .set("in", newConfig().set("type", "preview_result")) // in: config
                    .set("out", newConfig() // out: config
                            .set("type", "file")
                            .set("path_prefix", dir.resolve("fragments_").toString())
                            .set("file_ext", "csv")
                            .set("formatter", newConfig()
                                    .set("type", "csv")
                                    .set("header_line", false)
                                    .set("newline", "LF")));
            embed.run(runConfig);

            return buildPreviewResultWithOutput(result, dir, outputPath);
        }
This method returns PreviewResult.

@return PreviewResult returns the result by PreviewExecutor
@throws IOException in case of failures in file operations
embulk-junit4/src/main/java/org/embulk/test/TestingEmbulk.java