diff --git a/.travis.yml b/.travis.yml index ee7ad11b56..78cfc6a5dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ matrix: - jdk: openjdk11 script: >- - ./gradlew clean test + ./config/travis/run-checks.sh && + ./gradlew clean test coverage coveralls asciidoctor deploy: skip_cleanup: true diff --git a/build.gradle b/build.gradle index 1b59f22094..413ad8d83a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,14 @@ plugins { id 'java' id 'application' - id 'org.openjfx.javafxplugin' version '0.0.7' + id 'checkstyle' id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'org.openjfx.javafxplugin' version '0.0.7' } - group 'seedu.duke' version '0.1.0' -repositories { - mavenCentral() -} - application { // Change this to your main class. mainClassName = "duke.Launcher" @@ -22,22 +18,8 @@ run { standardInput = System.in } -dependencies { - testCompileOnly 'junit:junit:4.12' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1' -} - -test { - useJUnitPlatform() - testLogging { - events "failed" - exceptionFormat "short" - } -} - -javafx { - version = "11.0.2" - modules = [ 'javafx.controls', 'javafx.fxml' ] +checkstyle { + toolVersion = '8.23' } shadowJar { @@ -45,4 +27,32 @@ shadowJar { archiveVersion = "0.1.3" archiveClassifier = null archiveAppendix = null +} + +repositories { + mavenCentral() +} + +dependencies { + String javaFxVersion = '11' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0' + + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' +} + + +test { + useJUnitPlatform() } \ No newline at end of file diff --git a/data/dukeStorage.txt b/data/dukeStorage.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java index 478c5f96c8..c2ddc34804 100644 --- a/src/main/java/duke/Duke.java +++ b/src/main/java/duke/Duke.java @@ -12,6 +12,8 @@ /** * A GUI for Duke using FXML. + * + * */ public class Duke extends Application { diff --git a/src/main/java/duke/MainWindow.java b/src/main/java/duke/MainWindow.java index 77bb9205e5..c2e597957e 100644 --- a/src/main/java/duke/MainWindow.java +++ b/src/main/java/duke/MainWindow.java @@ -39,7 +39,8 @@ public void initialize() { UI.UIString = ""; taskList = new TaskList(); - storage = new Storage("tasks.txt", taskList); + String filePath = "./data/dukeStorage.txt"; + storage = new Storage(filePath, taskList); ui = new UI(); storage.readFromFile(); diff --git a/src/main/java/duke/tool/Storage.java b/src/main/java/duke/tool/Storage.java index 0b6ab756ca..5538dd54ef 100644 --- a/src/main/java/duke/tool/Storage.java +++ b/src/main/java/duke/tool/Storage.java @@ -28,6 +28,16 @@ public class Storage { */ public Storage(String filePath, TaskList taskList) { this.filePath = filePath; + try { + File taskFile = new File("data/dukeStorage.txt"); + if (!taskFile.exists()) { + taskFile.getParentFile().mkdirs(); + taskFile.createNewFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + this.taskList = taskList; } diff --git a/src/test/java/duke/DukeTest.java b/src/test/java/duke/DukeTest.java index 1c77deb655..069dc93c60 100644 --- a/src/test/java/duke/DukeTest.java +++ b/src/test/java/duke/DukeTest.java @@ -35,23 +35,29 @@ public void testDelete() { @Test public void testDone() { - String[] actionsList = new String[]{"todo sleep 100 years", "event fireworks /at 2019-10-12 20:00 to 2019-10-12 21:00", "done 1"}; + String[] actionsList = new String[]{"todo sleep 100 years", "event fireworks /at 2019-10-12 20:00 to 2019-10-12 21:00", "done 1", "list"}; Parser parser = new Parser(); TaskList taskList = new TaskList(); - Storage storage = new Storage("tasks_test.txt", taskList); UI ui = new UI(); - storage.clearFile(); + StringBuilder outputString = new StringBuilder(); for (String action : actionsList) { Command c = parser.parse(action); - c.execute(taskList, ui); - storage.saveToFile(); + outputString.append(c.execute(taskList, ui)); } - String filePath = "tasks_test.txt"; - String actual = storage.readAllBytes(filePath); - String expected = "T|V|sleep 100 years\n" + - "E|X|fireworks|12 Oct. 2019 20:00HRS to 12 Oct. 2019 21:00HRS\n"; + String actual = outputString.toString(); + String expected = "Got it. I've added this task:\n" + + "[T][X] sleep 100 years\n" + + "Now you have 1 tasks in the list.\n" + + "Got it. I've added this task:\n" + + "[E][X] fireworks (at: 12 Oct. 2019 20:00HRS to 12 Oct. 2019 21:00HRS)\n" + + "Now you have 2 tasks in the list.\n" + + "Nice! I've marked this task as done:\n" + + "[T][V] sleep 100 years\n" + + "Here are the tasks in your list:\n" + + "1.[T][V] sleep 100 years\n" + + "2.[E][X] fireworks (at: 12 Oct. 2019 20:00HRS to 12 Oct. 2019 21:00HRS)\n"; System.out.println("Actual: " + actual); System.out.println("Expected: " + expected); @@ -61,24 +67,33 @@ public void testDone() { @Test public void testTasks() { - String[] actionsList = new String[]{"todo study 24 hours", "deadline get six packs /by 2020-02-29 09:00", "event holidaysss /at 2020-05-01 20:00 to 2019-08-01 21:00", "done 2"}; + String[] actionsList = new String[]{"todo study 24 hours", "deadline get six packs /by 2020-02-29 09:00", "event holidaysss /at 2020-05-01 20:00 to 2019-08-01 21:00", "done 2", "list"}; Parser parser = new Parser(); TaskList taskList = new TaskList(); - Storage storage = new Storage("tasks_test.txt", taskList); UI ui = new UI(); - storage.clearFile(); + StringBuilder outputString = new StringBuilder(); for (String action : actionsList) { Command c = parser.parse(action); - c.execute(taskList, ui); - storage.saveToFile(); + outputString.append(c.execute(taskList, ui)); } - String filePath = "tasks_test.txt"; - String actual = storage.readAllBytes( filePath ); - String expected = "T|X|study 24 hours\n" + - "D|V|get six packs|29 Feb. 2020 09:00HRS\n" + - "E|X|holidaysss|01 May 2020 20:00HRS to 01 Aug. 2019 21:00HRS\n"; + String actual = outputString.toString(); + String expected = "Got it. I've added this task:\n" + + "[T][X] study 24 hours\n" + + "Now you have 1 tasks in the list.\n" + + "Got it. I've added this task:\n" + + "[D][X] get six packs (by: 29 Feb. 2020 09:00HRS)\n" + + "Now you have 2 tasks in the list.\n" + + "Got it. I've added this task:\n" + + "[E][X] holidaysss (at: 01 May 2020 20:00HRS to 01 Aug. 2019 21:00HRS)\n" + + "Now you have 3 tasks in the list.\n" + + "Nice! I've marked this task as done:\n" + + "[D][V] get six packs (by: 29 Feb. 2020 09:00HRS)\n" + + "Here are the tasks in your list:\n" + + "1.[T][X] study 24 hours\n" + + "2.[D][V] get six packs (by: 29 Feb. 2020 09:00HRS)\n" + + "3.[E][X] holidaysss (at: 01 May 2020 20:00HRS to 01 Aug. 2019 21:00HRS)\n"; System.out.println("Actual: " + actual); System.out.println("Expected: " + expected); @@ -91,15 +106,12 @@ public void testFind() { String[] actionsList = new String[]{"todo study 24 hours", "deadline get six packs /by 2020-02-29 09:00", "event holidaysss /at 2020-05-01 20:00 to 2020-08-01 20:00", "done 1", "find 2020"}; Parser parser = new Parser(); TaskList taskList = new TaskList(); - Storage storage = new Storage("tasks_test.txt", taskList); UI ui = new UI(); - storage.clearFile(); StringBuilder outputString = new StringBuilder(); for (String action : actionsList) { Command c = parser.parse(action); outputString.append(c.execute(taskList, ui)); - storage.saveToFile(); } String actual = outputString.toString(); @@ -129,15 +141,12 @@ public void testList() { String[] actionsList = new String[]{"todo study 24 hours", "deadline get six packs /by 2020-02-29 09:00", "event holidaysss /at 2020-05-01 20:00 to 2020-08-01 20:00", "done 3", "list"}; Parser parser = new Parser(); TaskList taskList = new TaskList(); - Storage storage = new Storage("tasks_test.txt", taskList); UI ui = new UI(); - storage.clearFile(); StringBuilder outputString = new StringBuilder(); for (String action : actionsList) { Command c = parser.parse(action); outputString.append(c.execute(taskList, ui)); - storage.saveToFile(); } String actual = outputString.toString(); @@ -168,15 +177,12 @@ public void testHelp() { String[] actionsList = new String[]{"help"}; Parser parser = new Parser(); TaskList taskList = new TaskList(); - Storage storage = new Storage("tasks_test.txt", taskList); UI ui = new UI(); - storage.clearFile(); StringBuilder outputString = new StringBuilder(); for (String action : actionsList) { Command c = parser.parse(action); outputString.append(c.execute(taskList, ui)); - storage.saveToFile(); } String actual = outputString.toString(); diff --git a/tasks_test.txt b/tasks_test.txt deleted file mode 100644 index 8ac21501a5..0000000000 --- a/tasks_test.txt +++ /dev/null @@ -1 +0,0 @@ -T|X|sleep 100 years