diff --git a/src/main/java/van/AddCommand.java b/src/main/java/van/AddCommand.java index b90e4d97a3..ce75b7b907 100644 --- a/src/main/java/van/AddCommand.java +++ b/src/main/java/van/AddCommand.java @@ -12,4 +12,9 @@ public boolean executeCommand(Ui ui, TaskList taskList, Storage storage) { ui.taskMessage(newTask, taskList.getTaskCount()); return false; } + + @Override + public String toString() { + return newTask.getStatus(); + } } diff --git a/src/main/java/van/Parser.java b/src/main/java/van/Parser.java index 5d7e2e5a75..73f6931c80 100644 --- a/src/main/java/van/Parser.java +++ b/src/main/java/van/Parser.java @@ -39,7 +39,7 @@ public static Command parseCommand(String parameter) { if (parameters.length != 2) { throw new VanException("Invalid format. Please use: event /at "); } - taskArguments = parameters[1].split(" /by "); + taskArguments = parameters[1].split(" /at "); if (taskArguments.length != 2) { throw new VanException("Invalid format. Please use: event /at "); } diff --git a/src/test/java/van/ParserTest.java b/src/test/java/van/ParserTest.java new file mode 100644 index 0000000000..74d9f39b18 --- /dev/null +++ b/src/test/java/van/ParserTest.java @@ -0,0 +1,29 @@ +package van; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ParserTest { + @Test + public void deadLineTester() { + Command deadLine = Parser.parseCommand("deadline eat /by 22-10-2022 18:00"); + + assertEquals("[D][ ] eat (by:Oct 22 2022 1800)" + , deadLine.toString()); + } + + @Test + public void eventTester() { + Command eventTest = Parser.parseCommand("event sleep /at 12-01-2022 06:00"); + assertEquals("[E][ ] sleep (at:Jan 12 2022 0600)", + eventTest.toString()); + } + + @Test + public void toDoTester() { + Command toDoTest = Parser.parseCommand("todo study"); + assertEquals("[T][ ] study", toDoTest.toString()); + } + +}