Commands { public static CommandResult toResult(CommandFuture future) throws IOException { return toResult(future, CommandResult.NO_EXIT_STATUS); } private  Commands(); static Command get(String command, Object... args); static Command get(Path executable, Object... args); static Command.Builder getBuilder(Path executable); static Command.Builder getBuilder(String command); static CommandResult execute(Command command); static CommandResult execute(Command command, CommandContext context); static CommandResult execute(Command command, long timeout, TimeUnit timeUnit); static CommandResult execute(Command command, CommandContext context,
            long timeout, TimeUnit unit); static CommandFuture executeAsync(Command command); static CommandFuture executeAsync(Command command, CommandContext context); static CommandResult waitFor(CommandFuture future); static CommandResult waitFor(CommandFuture future, long timeout, TimeUnit unit); static CommandResult toResult(CommandFuture future); static CommandResult toResult(CommandFuture future, int exitStatus); static boolean isLocal(Command command);  }
@Test public void toResultUsesResolved() throws IOException { CommandResult expected = new CommandResult(0, "", ""); commandFuture.succeed(expected, 0); CommandResult actual = Commands.toResult(commandFuture); assertThat(actual, sameInstance(expected)); }
@Test public void toResultReadsAvailableOutput() throws IOException { CommandResult expected = new CommandResult(0, "standard out", "standard error"); InputStream outStream = toStream(expected.getStdOut()); InputStream errStream = toStream(expected.getStdErr()); commandFuture = new MockCommandFuture(outStream, errStream, null); CommandResult actual = Commands.toResult(commandFuture, 0); assertEquals("wrong exit status", expected.getExitStatus(), actual.getExitStatus()); assertEquals("wrong stdout", expected.getStdOut(), actual.getStdOut()); assertEquals("wrong stderr", expected.getStdErr(), actual.getStdErr()); }