From 6f8580685bfe7f5f71a67bb02ceb9c53768c6685 Mon Sep 17 00:00:00 2001 From: Aleksi Salmela Date: Thu, 19 May 2016 12:16:36 +0300 Subject: [PATCH] Create the command map in two parts. --- .travis.yml | 2 +- pom.xml | 1 - src/main/java/fi/helsinki/cs/tmc/cli/Application.java | 3 ++- .../java/fi/helsinki/cs/tmc/cli/command/CommandMap.java | 5 ++++- src/test/java/fi/helsinki/cs/tmc/cli/ApplicationTest.java | 7 +++---- .../fi/helsinki/cs/tmc/cli/command/CommandMapTest.java | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2110dd4..fe348e27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java script: -- mvn checkstyle:checkstyle +- mvn checkstyle:check cobertura:check test after_success: - mvn clean cobertura:cobertura coveralls:report diff --git a/pom.xml b/pom.xml index 5804edd9..a151b1f0 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,6 @@ true UTF-8 false - **/name/fraser/neil/**/* false 2.16 diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/Application.java b/src/main/java/fi/helsinki/cs/tmc/cli/Application.java index ed07706b..a58cedaa 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/Application.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/Application.java @@ -13,7 +13,8 @@ public Application() { } private void preinit() { - this.commands = new CommandMap(this); + this.commands = new CommandMap(); + this.commands.createCommands(this); this.initialized = true; } diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java index 36b481b5..c154bbce 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java @@ -15,8 +15,11 @@ public class CommandMap { /** * Constructor. */ - public CommandMap(Application app) { + public CommandMap() { this.commands = new HashMap<>(); + } + + public void createCommands(Application app) { createCommand(new TestCommand(app)); createCommand(new HelpCommand(app)); } diff --git a/src/test/java/fi/helsinki/cs/tmc/cli/ApplicationTest.java b/src/test/java/fi/helsinki/cs/tmc/cli/ApplicationTest.java index c6ded2d6..5b1e58d6 100644 --- a/src/test/java/fi/helsinki/cs/tmc/cli/ApplicationTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/cli/ApplicationTest.java @@ -6,10 +6,9 @@ public class ApplicationTest { - Application app = new Application(); - @Test - public void testingTest() { - assertTrue(true); + public void testThatProgramWontCrashWithEmptyArguments() { + Application app = new Application(); + app.run(new String[]{}); } } diff --git a/src/test/java/fi/helsinki/cs/tmc/cli/command/CommandMapTest.java b/src/test/java/fi/helsinki/cs/tmc/cli/command/CommandMapTest.java index 65083726..824ae53c 100644 --- a/src/test/java/fi/helsinki/cs/tmc/cli/command/CommandMapTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/cli/command/CommandMapTest.java @@ -27,7 +27,8 @@ public static void tearDownClass() { @Before public void setUp() { - cm = new CommandMap(new Application()); + cm = new CommandMap(); + cm.createCommands(new Application()); } @After