From ede9311ac281edc22f239b29948ec5aae8882fb9 Mon Sep 17 00:00:00 2001 From: Archit Date: Wed, 3 Apr 2024 13:12:36 +0800 Subject: [PATCH] Update tests --- .../logic/commands/EditAppointmentCommandTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/seedu/address/logic/commands/EditAppointmentCommandTest.java b/src/test/java/seedu/address/logic/commands/EditAppointmentCommandTest.java index 13d9d8cda3d..f8694e6f56f 100644 --- a/src/test/java/seedu/address/logic/commands/EditAppointmentCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditAppointmentCommandTest.java @@ -2,11 +2,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.CommandTestUtil.showAppointmentAtIndex; +import static seedu.address.testutil.TypicalAppointments.APPOINTMENT_1; import static seedu.address.testutil.TypicalAppointments.getTypicalAddressBook; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_APPOINTMENT; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_APPOINTMENT; @@ -17,6 +19,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; import seedu.address.logic.commands.EditAppointmentCommand.EditAppointmentDescriptor; +import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; @@ -103,6 +106,16 @@ public void execute_filteredList_success() { assertCommandSuccess(editAppointmentCommand, model, expectedMessage, expectedModel); } + @Test + public void execute_appointmentAlreadyExists_failure() { + model.addAppointment(APPOINTMENT_1); + Index idx = Index.fromOneBased(1); + EditAppointmentDescriptor descriptor = new EditAppointmentDescriptorBuilder().withDate("2124-03-19").build(); + EditAppointmentCommand editAppointmentCommand = new EditAppointmentCommand(idx, descriptor); + + assertThrows(CommandException.class, () -> editAppointmentCommand.execute(model)); + } + @Test public void execute_invalidAppointmentIndexUnfilteredList_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredAppointmentList().size() + 1);