From f1bbe9eee1ff10b2df89c08f0208ea824a50b2a8 Mon Sep 17 00:00:00 2001 From: zaidansani Date: Thu, 7 Nov 2024 02:39:14 +0800 Subject: [PATCH] Add tests for hasAppointment in model manager --- .../seedu/address/model/ModelManagerTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 1cff6bbd5d4..494372ebea5 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; import static seedu.address.testutil.Assert.assertThrows; +import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_1; import static seedu.address.testutil.TypicalAppointments.getTypicalAppointmentBook; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.ALICE_P; @@ -18,6 +19,7 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.core.GuiSettings; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.NameContainsKeywordsPredicate; import seedu.address.model.person.Person; import seedu.address.testutil.AddressBookBuilder; @@ -92,6 +94,26 @@ public void hasPerson_personInAddressBook_returnsTrue() { assertTrue(modelManager.hasPerson(ALICE)); } + @Test + public void hasAppointment_nullAppointment_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.hasAppointment((Appointment) null)); + } + + @Test + public void hasAppointment_appointmentNotInAppointmentBook_returnsFalse() { + assertFalse(modelManager.hasAppointment(APPOINTMENT_1)); + assertFalse(modelManager.hasAppointment(APPOINTMENT_1.getAppointmentDescriptor(), + APPOINTMENT_1.getPerson())); + } + + @Test + public void hasAppointment_appointmentInAppointmentBook_returnsTrue() { + modelManager.addAppointment(APPOINTMENT_1.getPerson(), APPOINTMENT_1.getAppointmentDescriptor()); + assertTrue(modelManager.hasAppointment(APPOINTMENT_1)); + assertTrue(modelManager.hasAppointment(APPOINTMENT_1.getAppointmentDescriptor(), + APPOINTMENT_1.getPerson())); + } + @Test public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredPersonList().remove(0));