diff --git a/collated/test/A0121501E.md b/collated/test/A0121501E.md index 8b5a8e42684a..31596f9e0aca 100644 --- a/collated/test/A0121501E.md +++ b/collated/test/A0121501E.md @@ -215,6 +215,7 @@ expectedTM.addTask(toBeUnmarkedCopy); model.addTask(toBeUnmarked); + logic.execute("list-all"); assertCommandBehavior("unmark 1", String.format(UnmarkCommand.MESSAGE_SUCCESS, toBeUnmarked), expectedTM, diff --git a/collated/test/A0126539Y.md b/collated/test/A0126539Y.md new file mode 100644 index 000000000000..6a12035f645f --- /dev/null +++ b/collated/test/A0126539Y.md @@ -0,0 +1,234 @@ +# A0126539Y +###### /java/seedu/priorityq/logic/commands/LoadCommandTest.java +``` java +public class LoadCommandTest { + + @Test(expected = IllegalValueException.class) + public void nullLocation() throws Exception { + new LoadCommand(null); + } + + @Test(expected = IllegalValueException.class) + public void emptyStringLocation() throws Exception { + new LoadCommand(""); + } + + @Test(expected = InvalidPathException.class) + public void invalidLocation() throws Exception{ + new LoadCommand("invalid.json"); + } +} +``` +###### /java/seedu/priorityq/logic/commands/SaveCommandTest.java +``` java +public class SaveCommandTest { + + @Test(expected = IllegalValueException.class) + public void nullLocation() throws Exception { + new SaveCommand(null); + } + + @Test(expected = IllegalValueException.class) + public void emptyStringLocation() throws Exception { + new SaveCommand(""); + } + + @Test(expected = InvalidPathException.class) + public void invalidLocation() throws Exception{ + new SaveCommand("invalid.json"); + } + + @Test + public void saveCommand() { + try { + new SaveCommand("data/newLocation.xml"); + } catch (Exception e) { + fail(); + } + } +} +``` +###### /java/seedu/priorityq/model/entry/EventTest.java +``` java + @Test + public void inheritanceTest() { + assertTrue(testEvent instanceof Entry); + } + + @Test + public void entryConstructor() { + assertTrue(testEvent.equals(new Event((Entry)testEvent))); + + Entry task = new Task(title, null, tags, false, description, lastModifiedTime); + assertFalse(new Task(task).equals(testEvent)); + } + + @Test(expected = IllegalArgumentException.class) + public void startDateAfterEnd() { + new Event(title, endTime.plusMinutes(1), endTime, tags, isMarked, description, -1, lastModifiedTime); + } + + @Test + public void getAsTextEqualToString() { + assertEquals(testEvent.getAsText(), testEvent.toString()); + } + + @Test + public void hashCodeTests() { + Event copy = new Event(testEvent); + assertNotEquals(testEvent.hashCode(), copy.hashCode()); + + // test consistency + assertEquals(testEvent.hashCode(), testEvent.hashCode()); + assertEquals(testEvent.hashCode(), testEvent.hashCode()); + + copy.setDescription("another description"); + assertNotEquals(testEvent.hashCode(), copy.hashCode()); + } + + @Test + public void equals() throws Exception { + // test null + assertFalse(testEvent.equals(null)); + + // test other instance + assertFalse(testEvent.equals(new Object())); + + // test reflexivity + assertTrue(testEvent.equals(testEvent)); + + + // test symmetricity + Event copy = new Event(testEvent); + assertTrue(testEvent.equals(copy)); + assertTrue(copy.equals(testEvent)); + + // test transitivity + Event copy2 = new Event(testEvent); + assertTrue(copy.equals(copy2)); + assertTrue(testEvent.equals(copy2)); + + copy.setTitle(new Title("some other title")); + assertFalse(testEvent.equals(copy)); + } + + @Test + public void testRecurrence() throws InterruptedException { + Event recurrenceBase = new Event(title, startTime, endTime, tags, isMarked, description, DAY_IN_MILLIS, lastModifiedTime); + Event copy; + LocalDateTime start; + LocalDateTime end; + + copy = new Event(recurrenceBase); + start = LocalDateTime.now().minusDays(1).plusMinutes(1); + end = start.plusMinutes(5); + copy.setStartTime(start); + copy.setEndTime(end); + copy = new Event(copy); + assertEquals(copy.getStartTime(), start.plusDays(1)); + assertEquals(copy.getEndTime(), end.plusDays(1)); + + + copy = new Event(recurrenceBase); + start = LocalDateTime.now().minusDays(5).plusMinutes(1); + end = start.plusMinutes(5); + copy.setStartTime(start); + copy.setEndTime(end); + copy = new Event(copy); + System.out.println(copy.getStartTime()); + System.out.println(start.plusDays(6)); + assertEquals(copy.getStartTime(), start.plusDays(5)); + assertEquals(copy.getEndTime(), end.plusDays(5)); + } + + @Test + public void getTimeObjectProperty() { + testEvent.startTimeObjectProperty().equals(testEvent.startTime); + testEvent.endTimeObjectProperty().equals(testEvent.endTime); + testEvent.recursionObjectProperty().equals(testEvent.recursion); + } +``` +###### /java/seedu/priorityq/model/entry/TaskTest.java +``` java + @Test + public void inheritanceTest() { + assertTrue(floating instanceof Entry); + } + + @Test + public void simpleConstructor() { + new Task(title, uniqueTagList); + } + + @Test + public void constructor_nullDeadline() { + new Task(title, null, uniqueTagList, false, description, lastModifiedTime); + } + + @Test + public void entryConstructor() { + assertTrue(floating.equals(new Task((Entry)floating))); + assertTrue(withDeadline.equals(new Task((Entry)withDeadline))); + + Entry event = new Event(title, LocalDateTime.MIN, LocalDateTime.MAX, uniqueTagList, false, description, 0, lastModifiedTime); + assertFalse(new Task(event).equals(event)); + } + + @Test + public void getAsTextEqualToString() { + assertEquals(floating.getAsText(), floating.toString()); + } + + @Test + public void hashCodeTests() { + Task copy = new Task(floating); + assertNotEquals(floating.hashCode(), copy.hashCode()); + Task deadlineCopy = new Task(withDeadline); + assertNotEquals(withDeadline.hashCode(), deadlineCopy.hashCode()); + + assertNotEquals(floating.hashCode(), withDeadline.hashCode()); + + // test consistency + assertEquals(floating.hashCode(), floating.hashCode()); + assertEquals(floating.hashCode(), floating.hashCode()); + + copy.setDescription("new description"); + assertNotEquals(floating.hashCode(), copy.hashCode()); + } + + @Test + public void equals() throws Exception { + // test null + assertFalse(floating.equals(null)); + assertFalse(withDeadline.equals(null)); + + // test other instance + assertFalse(floating.equals(new Object())); + assertFalse(withDeadline.equals(new Object())); + + // test reflexivity + assertTrue(withDeadline.equals(withDeadline)); + assertTrue(floating.equals(floating)); + + + // test symmetricity + Task copy = new Task(floating); + assertTrue(floating.equals(copy)); + assertTrue(copy.equals(floating)); + + Task copyDeadline = new Task(withDeadline); + assertTrue(withDeadline.equals(copyDeadline)); + assertTrue(copyDeadline.equals(withDeadline)); + + // test transitivity + Task copy2 = new Task(title, null, uniqueTagList, false, description, lastModifiedTime); + assertTrue(copy.equals(copy2)); + assertTrue(floating.equals(copy2)); + + + copy.setTitle(new Title("some other title")); + assertFalse(withDeadline.equals(copy)); + copy2.mark(); + assertFalse(withDeadline.equals(copy2)); + } +``` diff --git a/collated/test/A0127828W.md b/collated/test/A0127828W.md index f04412b1b578..74a21abdf4b4 100644 --- a/collated/test/A0127828W.md +++ b/collated/test/A0127828W.md @@ -85,7 +85,7 @@ public class CommandHistoryTest { } } ``` -###### /java/seedu/priorityq/model/task/EventTest.java +###### /java/seedu/priorityq/model/entry/EventTest.java ``` java */ public class EventTest { @@ -97,6 +97,7 @@ public class EventTest { private UniqueTagList tags; private String description; private boolean isMarked; + private static final int DAY_IN_MILLIS = 1 * 24 * 60 * 60 * 1000; @Before public void setUp() { @@ -113,59 +114,8 @@ public class EventTest { ive.printStackTrace(); } } - - @Test - public void createEvent() { - assertTrue(testEvent instanceof Event); - } - - @Test(expected = ClassCastException.class) - public void createEventFromEntry() { - Entry eventEntry = new Event(title, startTime, endTime, tags, isMarked, description, -1, lastModifiedTime); - assertTrue(new Event(eventEntry) instanceof Event); - - Entry taskEntry = new Task(title, endTime, tags, isMarked, description, lastModifiedTime); - // Should throw exception - new Event(taskEntry); - } - - @Test - public void getStartTime() { - assertEquals(testEvent.getStartTime(), startTime); - } - - @Test - public void setStartTime() { - LocalDateTime newStartTime = startTime.minusDays(1); - testEvent.setStartTime(newStartTime); - assertEquals(testEvent.getStartTime(), newStartTime); - testEvent.setStartTime(startTime); - assertEquals(testEvent.getStartTime(), startTime); - } - - @Test - public void getEndTime() { - assertEquals(testEvent.getEndTime(), endTime); - } - - @Test - public void setEndTime() { - LocalDateTime newEndTime = endTime.minusDays(1); - testEvent.setEndTime(newEndTime); - assertEquals(testEvent.getEndTime(), newEndTime); - testEvent.setEndTime(endTime); - assertEquals(testEvent.getEndTime(), endTime); - } - - @Test - public void isSameStateAs() { - Event otherEvent = new Event(title, startTime, endTime, tags, isMarked, description, -1, lastModifiedTime); - assertTrue(testEvent.isSameStateAs(otherEvent)); - } - -} ``` -###### /java/seedu/priorityq/model/task/TaskTest.java +###### /java/seedu/priorityq/model/entry/TaskTest.java ``` java */ public class TaskTest { @@ -189,119 +139,5 @@ public class TaskTest { floating = new Task(title, null, uniqueTagList, isMarked, description, lastModifiedTime); withDeadline = new Task(title, deadline, uniqueTagList, isMarked, description, lastModifiedTime); } - - @Test - public void getDeadline_Present_Success() { - assertEquals(deadline, withDeadline.getDeadline()); - } - - @Test - public void getDeadline_FloatingTask_null() { - assertEquals(null, floating.getDeadline()); - } - - @Test - public void getDeadlineDisplay_floating_emptyString() { - assertEquals("", floating.getDeadlineDisplay()); - } - - @Test - public void getDeadlineDisplay_notToday_success() { - String expected = "Mon, Oct 10 at 10:00"; - - assertEquals(expected, withDeadline.getDeadlineDisplay()); - } - - @Test - public void getDeadlineDisplay_today_success() { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime someTimeToday = LocalDateTime.of(now.toLocalDate(), LocalTime.NOON); - withDeadline.setDeadline(someTimeToday); - - Date interpreted = Date.from(someTimeToday.atZone(ZoneId.systemDefault()).toInstant()); - String expected = Task.prettyTime.format(interpreted); - - assertEquals(expected, withDeadline.getDeadlineDisplay()); - withDeadline.setDeadline(deadline); - } - - @Test - public void setDeadline_nullAndNotNull_success() { - withDeadline.setDeadline(null); - assertEquals(null, withDeadline.getDeadline()); - withDeadline.setDeadline(deadline); - assertEquals(deadline, withDeadline.getDeadline()); - } - - @Test - public void equals() throws Exception { - Task alt = new Task(title, deadline, uniqueTagList, false, description, lastModifiedTime); - assertEquals(true, withDeadline.equals(alt)); - - alt.setTitle(new Title("some other title")); - assertEquals(false, withDeadline.equals(alt)); - } - - @Test - public void isSameStateAs() throws Exception { - Task alt = new Task(title, deadline, uniqueTagList, false, description, lastModifiedTime); - assertTrue(withDeadline.isSameStateAs(alt)); - - alt.setTitle(new Title("some other title")); - assertFalse(withDeadline.isSameStateAs(alt)); - } - - @Test - public void isFloatingTask() { - assertTrue(floating.isFloatingTask()); - assertFalse(withDeadline.isFloatingTask()); - } - - @Test - public void getAsText_floating() { - String expectedFloating = "Test title (Something described) #TAG1"; - - assertEquals(expectedFloating, floating.getAsText()); - } - - @Test - public void getAsText_withDeadline() { - String exprectedWithDeadline = "Test title (Something described) #TAG1 Due: " + withDeadline.getDeadlineDisplay(); - - assertEquals(exprectedWithDeadline, withDeadline.getAsText()); - } - - @Test - public void getDateDisplay_today_success() { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime someTimeToday = LocalDateTime.of(now.toLocalDate(), LocalTime.NOON); - Date interpreted = Date.from(someTimeToday.atZone(ZoneId.systemDefault()).toInstant()); - String expected = Task.prettyTime.format(interpreted); - - assertEquals(expected, withDeadline.getDateDisplay(someTimeToday)); - } - - @Test - public void getDateDisplay_notToday_success() { - String expected = "Mon, Oct 10 at 10:00"; - - assertEquals(expected, withDeadline.getDateDisplay(deadline)); - } - - @Test - public void getDateDisplay_null_emptyString() { - assertEquals("", withDeadline.getDateDisplay(null)); - } - - @Test - public void getComparableTime_floating() { - assertEquals(lastModifiedTime, floating.getComparableTime()); - } - - @Test - public void getComparableTime_withDeadline() { - assertEquals(deadline, withDeadline.getComparableTime()); - } - -} + ```