CommandFactory { protected Optional<Command> create(final String keyword) { final Command command = createInternal(keyword); if (command instanceof AbstractCommand) { ((AbstractCommand) command).setPrinter(printer); } return ofNullable(command); }  Optional<Command> create(final String[] args);  }
@Test public void testCreate() { final CommandFactory commandFactory = new CommandFactory(DummyMessagePrinter.getInstance()); for (final String command : data()) { assertTrue(commandFactory.create(new String[] { command }).isPresent()); } }