@@ -29,27 +29,6 @@ public class CommandFactoryTest {
2929
3030 private CliContext ctx ;
3131
32- @ Before
33- public void setUp () {
34- ctx = new CliContext (new TestIo ());
35- CommandFactory .reload ();
36- }
37-
38- @ Test
39- public void constructorAddsCommands () {
40- assertTrue (!CommandFactory .getCommands ().isEmpty ());
41- }
42-
43- @ Test
44- public void createHelpCommand () {
45- assertNotNull (CommandFactory .createCommand ("help" ));
46- }
47-
48- @ Test
49- public void createNonexistingCommand () {
50- assertNull (CommandFactory .createCommand ("foobar" ));
51- }
52-
5332 @ Command (name = "good" , desc = "test" )
5433 public static class GoodCommand extends AbstractCommand {
5534
@@ -64,42 +43,25 @@ public void run(CliContext context, CommandLine args) {
6443 }
6544 }
6645
67- @ Test
68- public void addGoodCommand () {
69- CommandFactory .addCommand ("category" , GoodCommand .class );
70- //TODO check the all the stuff in the command
71- assertNotNull (CommandFactory .createCommand ("good" ));
46+ @ Before
47+ public void setUp () {
48+ ctx = new CliContext (new TestIo ());
49+ CommandFactory .reload ();
7250 }
7351
74- public static class BadCommand extends AbstractCommand {
75-
76- @ Override
77- public void getOptions (Options options ) {
78- throw new UnsupportedOperationException ();
79- }
80-
81- @ Override
82- public void run (CliContext context , CommandLine args ) {
83- throw new UnsupportedOperationException ();
84- }
52+ @ Test
53+ public void constructorAddsCommands () {
54+ assertTrue (!CommandFactory .getCommands ().isEmpty ());
8555 }
8656
87- @ Test (expected = RuntimeException .class )
88- public void addCommandWithoutProperAnnotation () {
89- //WARNING The exception code leads to unpredicatble test results
90- //exception.expect(RuntimeException.class);
91- //exception.expectMessage(contains("annotation"));
92- CommandFactory .addCommand ("category" , BadCommand .class );
57+ @ Test
58+ public void createHelpCommand () {
59+ assertNotNull (CommandFactory .createCommand ("help" ));
9360 }
9461
95- private static class ReallyBadCommand {}
96-
97- @ Test (expected = RuntimeException .class )
98- public void addCommandThatDoesntExtendInterface () {
99- //WARNING The exception code leads to unpredicatble test results
100- //exception.expect(RuntimeException.class);
101- //exception.expectMessage(contains("Interface"));
102- CommandFactory .addCommand ("category" , ReallyBadCommand .class );
62+ @ Test
63+ public void createNonexistingCommand () {
64+ assertNull (CommandFactory .createCommand ("foobar" ));
10365 }
10466
10567 @ Test
@@ -112,7 +74,7 @@ public void getCommandsGivesDefaultCommands() {
11274 @ Test
11375 public void getCommandsWhenSingleCommandIsAdded () {
11476 int oldSize = CommandFactory .getCommands ().size ();
115- CommandFactory .addCommand ("" , GoodCommand .class );
77+ CommandFactory .addCommand ("good" , " " , GoodCommand .class );
11678 assertEquals (oldSize + 1 , CommandFactory .getCommands ().size ());
11779 assertTrue (CommandFactory .getCommands ().contains (
11880 CommandFactory .castToCommandClass (GoodCommand .class )));
@@ -126,7 +88,7 @@ public void getCategoryCommandsWhenItsEmpty() {
12688 @ Test
12789 public void getCategoryCommandsWhenSingleCategorizedCommandIsAdded () {
12890 int oldSize = CommandFactory .getCommands ().size ();
129- CommandFactory .addCommand ("xyz" , GoodCommand .class );
91+ CommandFactory .addCommand ("good" , " xyz" , GoodCommand .class );
13092 List <Class <Command >> list = CommandFactory .getCategoryCommands ("xyz" );
13193 assertEquals (1 , list .size ());
13294 assertEquals (GoodCommand .class , list .get (0 ));
0 commit comments