@Test public void testOutFile() throws Exception { final Console console = getMockConsole(); when(console.getCwd()).thenReturn(tempDir); Options.Builder builder = new Options.Builder().setOutputJson(true); final File outFile = new File(tempDir, "testOutFile.json"); builder.setOutFile(outFile); final DisposablePrinter printer = new Main.DisposablePrinterImpl(new PrintWriter(outFile)); when(console.openPrinter(outFile)).thenReturn(Result.success(printer)); final Result<Options> options = builder.build(console); options.stream().forEachOrdered(opts -> { opts.getPrinter().apply(() -> JavaxJson.key("message", "test").get()).get(); }); printer.dispose(); try (Reader fileReader = new InputStreamReader(new FileInputStream(outFile), StandardCharsets.UTF_8); JsonReader reader = Json.createReader(fileReader)) { JsonObject json = reader.readObject(); assertTrue("json should have 'message' key", json.containsKey("message")); } }
public Function<StructuredMessage, IO<Nothing>> getPrinter() { return printer; }
Options { public Function<StructuredMessage, IO<Nothing>> getPrinter() { return printer; } }
Options { public Function<StructuredMessage, IO<Nothing>> getPrinter() { return printer; } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); }
Options { public Function<StructuredMessage, IO<Nothing>> getPrinter() { return printer; } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); boolean isJustHelp(); boolean isJustVersion(); boolean isStoreBlobs(); boolean isNoHooks(); URL getPlanUrl(); ClassLoader getScanClassLoader(); File getCacheDir(); @Nullable File getOpearFile(); @Nullable String getPlanName(); @Nullable File getPlanFile(); @Nullable File getPlanFileBaseDir(); @NotNull List<File> getPreInstallFiles(); @NotNull List<File> getRepoInitFiles(); @NotNull List<String> getRunModes(); boolean isNoRunModes(); @NotNull List<File> getExtendedClassPathFiles(); List<File> getScanFiles(); Function<StructuredMessage, IO<Nothing>> getPrinter(); Severity getFailOnSeverity(); OakpalPlan applyOverrides(final @NotNull OakpalPlan basePlan); }
Options { public Function<StructuredMessage, IO<Nothing>> getPrinter() { return printer; } Options();   Options(final boolean justHelp,
            final boolean justVersion,
            final boolean storeBlobs,
            final @NotNull URL planUrl,
            final @NotNull ClassLoader scanClassLoader,
            final @NotNull File cacheDir,
            final @Nullable File opearFile,
            final @Nullable String planName,
            final @Nullable File planFile,
            final @Nullable File planFileBaseDir,
            final @NotNull List<File> preInstallFiles,
            final @NotNull List<File> repoInitFiles,
            final @NotNull List<String> runModes,
            final boolean noRunModes,
            final @NotNull List<File> extendedClassPathFiles,
            final boolean noHooks,
            final @NotNull List<File> scanFiles,
            final @NotNull Function<StructuredMessage, IO<Nothing>> printer,
            final @NotNull Severity failOnSeverity); boolean isJustHelp(); boolean isJustVersion(); boolean isStoreBlobs(); boolean isNoHooks(); URL getPlanUrl(); ClassLoader getScanClassLoader(); File getCacheDir(); @Nullable File getOpearFile(); @Nullable String getPlanName(); @Nullable File getPlanFile(); @Nullable File getPlanFileBaseDir(); @NotNull List<File> getPreInstallFiles(); @NotNull List<File> getRepoInitFiles(); @NotNull List<String> getRunModes(); boolean isNoRunModes(); @NotNull List<File> getExtendedClassPathFiles(); List<File> getScanFiles(); Function<StructuredMessage, IO<Nothing>> getPrinter(); Severity getFailOnSeverity(); OakpalPlan applyOverrides(final @NotNull OakpalPlan basePlan);  }