Options { static Result<Nothing> writeToStream(final @NotNull byte[] bytesToWrite, final @NotNull Fun.ThrowingSupplier<OutputStream> streamSupplier) { try (OutputStream out = streamSupplier.tryGet()) { out.write(bytesToWrite); return Result.success(Nothing.instance); } catch (Exception e) { return Result.failure(e); } } 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);  }
@Test public void testWriteToStream_throwingSupplier() throws Exception { OutputStream mockOs = mock(OutputStream.class); doThrow(IllegalStateException.class).when(mockOs).write(any(byte[].class)); Result<Nothing> result = Options.writeToStream(new byte[0], () -> mockOs); assertTrue("expect failure", result.isFailure()); assertTrue("expect same exception", result.findCause(IllegalStateException.class).isPresent()); }