forked from nus-cs2103-AY2223S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a23bd57
commit fc2a6ec
Showing
14 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ public String getDateTime(LocalDateTime dt) { | |
} | ||
|
||
public abstract LocalDate getDateMaybe(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package pluto; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import pluto.command.AddCommand; | ||
import pluto.task.Event; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class ParserTest { | ||
@Test | ||
public void parseTask_invalidDateFormat_exceptionThrown() { | ||
try { | ||
Parser.parseTask("join meeting /by 04/05/2022", Parser.Type.DEADLINE); | ||
fail(); // the test should not reach this line | ||
} catch (Exception e) { | ||
assertEquals("\tOOPS!!! dd-MM-yyyy HHmm date format required.", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void parseTask_validFormat_success() throws PlutoException { | ||
LocalDateTime date = LocalDateTime.parse("04-05-2022 1800", DateTimeFormatter.ofPattern("dd-MM-yyyy HHmm")); | ||
assertEquals(new AddCommand(new Event("join meeting", date)), | ||
Parser.parseTask("join meeting /at 04-05-2022 1800", Parser.Type.EVENT)); | ||
} | ||
|
||
@Test | ||
public void isOnlyCommand_onlyCommand_exceptionThrown() { | ||
try { | ||
Parser.isOnlyCommand("todo"); | ||
fail(); // the test should not reach this line | ||
} catch (Exception e) { | ||
assertEquals("\tOOPS!!! The description of todo cannot be empty.", e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package pluto; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import pluto.task.Task; | ||
import pluto.task.Todo; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class TaskListTest { | ||
@Test | ||
public void deleteTask_validIndex_success() throws PlutoException { | ||
Task t1 = new Todo("test task1"); | ||
Task t2 = new Todo("test task2"); | ||
Task t3 = new Todo("test task3"); | ||
TaskList tasks = new TaskList(); | ||
tasks.addTask(t1); | ||
tasks.addTask(t2); | ||
tasks.addTask(t3); | ||
assertEquals(t3, tasks.deleteTask(2)); | ||
} | ||
@Test | ||
public void deleteTask_invalidIndex_exceptionThrown() { | ||
try { | ||
Task t = new Todo("test task"); | ||
TaskList tasks = new TaskList(); | ||
tasks.addTask(t); | ||
tasks.addTask(t); | ||
tasks.addTask(t); | ||
tasks.deleteTask(5); | ||
fail(); // the test should not reach this line | ||
} catch (Exception e) { | ||
assertEquals("\tOOPS!!! Valid index required.", e.getMessage()); | ||
} | ||
} | ||
@Test | ||
public void markTask_validIndex_success() throws PlutoException { | ||
Task t1 = new Todo("test task1"); | ||
Task t2 = new Todo("test task2"); | ||
Task t3 = new Todo("test task3"); | ||
TaskList tasks = new TaskList(); | ||
tasks.addTask(t1); | ||
tasks.addTask(t2); | ||
tasks.addTask(t3); | ||
tasks.markTask(1, true); | ||
assertEquals(t2.getStatusIcon(), "X"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pluto.task; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class EventTest { | ||
@Test | ||
public void toFile_returnsTasktoFileFormat() { | ||
LocalDateTime date = LocalDateTime.parse("04-05-2022 1800", DateTimeFormatter.ofPattern("dd-MM-yyyy HHmm")); | ||
Event e = new Event("join meeting", date); | ||
e.markAsDone(); | ||
assertEquals(e.toFile(), "E | 1 | join meeting | 04-05-2022 1800"); | ||
} | ||
|
||
@Test | ||
public void getDateMaybe_returnsLocalDate() { | ||
LocalDateTime date = LocalDateTime.parse("04-05-2022 1800", DateTimeFormatter.ofPattern("dd-MM-yyyy HHmm")); | ||
Deadline d = new Deadline("join meeting", date); | ||
assertEquals(d.getDateMaybe(), LocalDate.of(2022, 5,4)); | ||
} | ||
} |