@Test @PrepareForTest({ ShipLauncher.class, System.class }) public void testRun() { final ShipLauncher shipLauncher = spy(new ShipLauncher(DummyMessagePrinter.getInstance())); doNothing().when(shipLauncher).exit(anyInt()); shipLauncher.run(new String[] {}); verify(shipLauncher).exit(anyInt()); }
public void run(final String[] args) { if (args.length < 1) { messagePrinter.println(NL_0); exit(-1); } else { final CommandFactory commandFactory = new CommandFactory(messagePrinter); final Optional<Command> commandOpt = commandFactory.create(args); if (!commandOpt.isPresent()) { messagePrinter.println(NL_1, args[0]); exit(-1); } commandOpt.ifPresent(this::execute); } }
ShipLauncher { public void run(final String[] args) { if (args.length < 1) { messagePrinter.println(NL_0); exit(-1); } else { final CommandFactory commandFactory = new CommandFactory(messagePrinter); final Optional<Command> commandOpt = commandFactory.create(args); if (!commandOpt.isPresent()) { messagePrinter.println(NL_1, args[0]); exit(-1); } commandOpt.ifPresent(this::execute); } } }
ShipLauncher { public void run(final String[] args) { if (args.length < 1) { messagePrinter.println(NL_0); exit(-1); } else { final CommandFactory commandFactory = new CommandFactory(messagePrinter); final Optional<Command> commandOpt = commandFactory.create(args); if (!commandOpt.isPresent()) { messagePrinter.println(NL_1, args[0]); exit(-1); } commandOpt.ifPresent(this::execute); } }  }
ShipLauncher { public void run(final String[] args) { if (args.length < 1) { messagePrinter.println(NL_0); exit(-1); } else { final CommandFactory commandFactory = new CommandFactory(messagePrinter); final Optional<Command> commandOpt = commandFactory.create(args); if (!commandOpt.isPresent()) { messagePrinter.println(NL_1, args[0]); exit(-1); } commandOpt.ifPresent(this::execute); } }  static void main(final String[] args); void exit(int returnCode); void run(final String[] args); void execute(final Command command); }
ShipLauncher { public void run(final String[] args) { if (args.length < 1) { messagePrinter.println(NL_0); exit(-1); } else { final CommandFactory commandFactory = new CommandFactory(messagePrinter); final Optional<Command> commandOpt = commandFactory.create(args); if (!commandOpt.isPresent()) { messagePrinter.println(NL_1, args[0]); exit(-1); } commandOpt.ifPresent(this::execute); } }  static void main(final String[] args); void exit(int returnCode); void run(final String[] args); void execute(final Command command);  }