Skip to content

Commit

Permalink
Merge pull request #10 from ShengXue97/TempPR2
Browse files Browse the repository at this point in the history
Add Fixed gradle
  • Loading branch information
ShengXue97 authored Mar 2, 2020
2 parents 1da2c50 + f0a19ba commit 7591ab3
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 32 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -22,27 +18,41 @@ 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 {
archiveBaseName = "duke"
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()
}
Empty file added data/dukeStorage.txt
Empty file.
2 changes: 2 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

/**
* A GUI for Duke using FXML.
*
*
*/
public class Duke extends Application {

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/duke/tool/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
62 changes: 34 additions & 28 deletions src/test/java/duke/DukeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion tasks_test.txt

This file was deleted.

0 comments on commit 7591ab3

Please sign in to comment.