diff --git a/src/main/java/seedu/address/model/reminder/ReminderList.java b/src/main/java/seedu/address/model/reminder/ReminderList.java index dc60bf206d1..530387ce32b 100644 --- a/src/main/java/seedu/address/model/reminder/ReminderList.java +++ b/src/main/java/seedu/address/model/reminder/ReminderList.java @@ -66,6 +66,10 @@ public boolean equals(Object other) { return false; } + if (!remindersList.equals(otherReminderList.remindersList)) { + return false; + } + return true; } } diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 638c7d80a5d..1d071658e6c 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -177,6 +177,11 @@ public void scheduleStringFormat() { missedAlice.scheduleStringFormat()); } + @Test + public void birthdayStringFormat() { + assertEquals(ALICE.birthdayStringFormat(), ALICE.getBirthday() + " - " + ALICE.getName()); + } + @Test public void hasUpcomingBirthday() { Person upcomingAlice = new PersonBuilder(ALICE).withBirthday(DateUtil.parseDateToString( diff --git a/src/test/java/seedu/address/model/reminder/ReminderListTest.java b/src/test/java/seedu/address/model/reminder/ReminderListTest.java index 9d35705b474..2303f99ec1a 100644 --- a/src/test/java/seedu/address/model/reminder/ReminderListTest.java +++ b/src/test/java/seedu/address/model/reminder/ReminderListTest.java @@ -1,6 +1,7 @@ package seedu.address.model.reminder; import static org.junit.jupiter.api.Assertions.assertEquals; +import static seedu.address.testutil.TypicalPersons.ALICE; import java.time.LocalDate; import java.time.LocalDateTime; @@ -9,6 +10,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import seedu.address.commons.util.DateUtil; import seedu.address.model.person.Person; import seedu.address.testutil.PersonBuilder; @@ -38,4 +40,73 @@ public void toStringMethodSchedule() { assertEquals(reminderList.toString(), person1.scheduleStringFormat() + "\n" + person2.scheduleStringFormat() + "\n"); } + + @Test + public void toStringMethodBirthday() { + ObservableList remindersList = FXCollections.observableArrayList(); + Person person1 = new PersonBuilder().withBirthday(DateUtil.parseDateToString( + LocalDate.of(2001, 1, 1))).build(); + remindersList.add(person1); + Person person2 = new PersonBuilder().withBirthday(DateUtil.parseDateToString( + LocalDate.of(2002, 2, 2))).build(); + remindersList.add(person2); + ReminderList reminderList = new ReminderList(ReminderType.BIRTHDAYS, remindersList); + assertEquals(reminderList.toString(), person1.birthdayStringFormat() + + "\n" + person2.birthdayStringFormat() + "\n"); + } + + @Test + public void equals_sameObject_true() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList); + assertEquals(reminderList, reminderList); + } + + @Test + public void equals_sameValues_true() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList); + ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList); + assertEquals(reminderList1, reminderList2); + } + + @Test + public void equals_differentType_false() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList); + assertEquals(reminderList.equals(1), false); + } + + @Test + public void equals_differentReminderType_false() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList); + ReminderList reminderList2 = new ReminderList(ReminderType.SCHEDULES, remindersList); + assertEquals(reminderList1.equals(reminderList2), false); + } + + @Test + public void equals_null_false() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList = new ReminderList(ReminderType.LAST_MET, remindersList); + assertEquals(reminderList.equals(null), false); + } + + @Test + public void equals_differentRemindersList_false() { + ObservableList remindersList1 = FXCollections.observableArrayList(); + ObservableList remindersList2 = FXCollections.observableArrayList(); + remindersList2.add(ALICE); + ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList1); + ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList2); + assertEquals(reminderList1.equals(reminderList2), false); + } + + @Test + public void equals_sameRemindersList_true() { + ObservableList remindersList = FXCollections.observableArrayList(); + ReminderList reminderList1 = new ReminderList(ReminderType.LAST_MET, remindersList); + ReminderList reminderList2 = new ReminderList(ReminderType.LAST_MET, remindersList); + assertEquals(reminderList1.equals(reminderList2), true); + } } diff --git a/src/test/java/seedu/address/model/reminder/ReminderTypeTest.java b/src/test/java/seedu/address/model/reminder/ReminderTypeTest.java index 85cdbec9c0a..2c142a4bc4e 100644 --- a/src/test/java/seedu/address/model/reminder/ReminderTypeTest.java +++ b/src/test/java/seedu/address/model/reminder/ReminderTypeTest.java @@ -9,5 +9,6 @@ public class ReminderTypeTest { public void toStringMethod() { assertEquals("Last Met", ReminderType.LAST_MET.toString()); assertEquals("Schedules", ReminderType.SCHEDULES.toString()); + assertEquals("Birthday", ReminderType.BIRTHDAYS.toString()); } }