@Test(groups = "fast") public void testDuplicateArg() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "-b", "bar", "--bar=baz"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Duplicate options: -b=bar, --bar=baz\n"); }
@Test(groups = "fast") public void testDispatchHelpFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "foo"); assertResult(resultStatus, 0, EXPECTED_FOO, ""); }
@Test(groups = "fast") public void testDispatchFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "--bar", "test"); assertResult(resultStatus, 0, "I am foo\n", "oof ma I\n"); }
@Test(groups = "fast") public void testDispatchHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help"); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
@Test(groups = "fast") public void testDispatchHelpHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "help"); assertResult(resultStatus, 0, EXPECTED_HELP, ""); }
@Test(groups = "fast") public void testDispatchNoArgs() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run(); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
@Test(groups = "fast") public void testDispatchFooMissingRequired() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Missing required option: --bar\n"); }
@Test(groups = "fast") public void testDispatchBogusArg() { CommandDispatcher dispatcher = createDispatcher(new FooCommand(io)); int resultStatus = dispatcher.run("bogus"); assertResult(resultStatus, -1, EXPECTED_ALL + "\n", "Unknown commandName: bogus\n"); }
@Test(groups = "fast") public void testDispatchHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help"); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
@Test(groups = "fast") public void testDispatchHelpFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "foo"); assertResult(resultStatus, 0, EXPECTED_FOO, ""); }
@Test(groups = "fast") public void testDispatchFoo() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "--bar", "test"); assertResult(resultStatus, 0, "I am foo\n", "oof ma I\n"); }
@Test(groups = "fast") public void testDuplicateArg() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo", "-b", "bar", "--bar=baz"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Duplicate options: -b=bar, --bar=baz\n"); }
@Test(groups = "fast") public void testDispatchNoArgs() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run(); assertResult(resultStatus, 0, EXPECTED_ALL, ""); }
@Test(groups = "fast") public void testDispatchHelpHelp() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("help", "help"); assertResult(resultStatus, 0, EXPECTED_HELP, ""); }
@Test(groups = "fast") public void testDispatchFooMissingRequired() { CommandDispatcher dispatcher = createDispatcher(fooCommand); int resultStatus = dispatcher.run("foo"); assertResult(resultStatus, -1, EXPECTED_FOO + "\n", "Missing required option: --bar\n"); }
@Test(groups = "fast") public void testDispatchBogusArg() { CommandDispatcher dispatcher = createDispatcher(new FooCommand(io)); int resultStatus = dispatcher.run("bogus"); assertResult(resultStatus, -1, EXPECTED_ALL + "\n", "Unknown commandName: bogus\n"); }