diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 202a52e3f80..ae96213b53f 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -166,10 +166,10 @@ e.g. `Alex` will not match `Alexandra`, `Alex` will match `Alex Becker` e.g. `Alex Becker` will return `Alex Keller` and `Becker Anderson` Examples: -* find `Alex` returns `alex` and `Alex becker` -* find `alex becker` returns `alex`, `Alex Becker` and `Becker Li` +* `find Alex` returns `alex` and `Alex becker` +* `find alex becker` returns `alex`, `Alex Becker` and `Becker Li` -![result for 'find patients whose name is alex becker'](images/findPatientAlexBeckerResult.png) +![result for 'find patients whose name is alex ali'](images/findPatientAlexAliResult.png) -------------------------------------------------------------------------------------------------------------------- @@ -187,7 +187,7 @@ Examples: * `find Betsy` followed by `delete 1` deletes the 1st patient in the results of the `find` command. * `list` followed by `delete 2` deletes the 2nd patient in the address book. -![result for 'delete 2'](images/deleteResult.png) +![result for 'delete 2'](images/deletePatientResult.png) -------------------------------------------------------------------------------------------------------------------- @@ -261,8 +261,8 @@ Format: `findt KEYWORD [MORE_KEYWORDS]` e.g. `depression diabetes` will return `depression wheelchair` and `diabetes tumour` Examples: -* find `depression` returns `depression` and `depression diabetes` -* find `depression diabetes` returns `depression`, `depression diabetes` and `diabetes wheelchair` +* `findt depression` returns `depression` and `depression diabetes` +* `findt depression diabetes` returns `depression`, `depression diabetes` and `diabetes wheelchair` ![result for 'find tags'](images/findTagsResult.png) @@ -272,7 +272,7 @@ Examples: Adds an Event to a patient in the address book. -Format: `adde INDEX [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE]` +Format: `adde INDEX n/NAME_OF_EVENT_ON_THAT_DATE d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE` * Adds an Event with a Name, as well as the Date and optionally, the Time Period for which the Event is happening on that date to a patient identified by the index number used in the last patient listing. * The index **must be a positive integer** 1, 2, 3, ... @@ -280,6 +280,7 @@ Format: `adde INDEX [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DATE_OR_DATETIME_OF_EVENT_ * The Name must be alphanumerical * The format of the Date must be: DD-MM-YYYY * If there is a Time Period, the format of the DateTime must be: DD-MM-YYYY, HH:mm - HH:mm, where the End Time must be after or equal to the Start Time +* The Date / Datetime of the Event can occur in the past as well; However, a warning message will be shown * There is currently no support for Events spanning multiple days Examples: @@ -294,7 +295,7 @@ Examples: Deletes an Event from a patient in the address book. -Format `deletee PATIENT_INDEX [e/EVENT_INDEX]` +Format `deletee PATIENT_INDEX e/EVENT_INDEX` * Deletes an Event from a specified Patient using `PATIENT_INDEX` and `EVENT_INDEX`. * `PATIENT_INDEX` is the index of the patient shown in the UI after using `list` or `find` command. @@ -316,7 +317,7 @@ Examples: Edits an Event for a Patient in the address book. -Format `edite PATIENT_INDEX [e/EVENT_INDEX] [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE]` +Format `edite PATIENT_INDEX e/EVENT_INDEX n/NAME_OF_EVENT_ON_THAT_DATE d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE` * Edits an Event for a Patient using `PATIENT_INDEX`, `EVENT_INDEX`, `NAME_OF_EVENT_ON_THAT_DATE` and `DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE`. @@ -325,6 +326,7 @@ Format `edite PATIENT_INDEX [e/EVENT_INDEX] [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DA * Note that, it is okay to exclude `TIME` for `DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE` * The format of `DATE_OF_EVENT_ON_THAT_DATE` must be: DD-MM-YYYY. * The format of `DATETIME_OF_EVENT_ON_THAT_DATE` must be: DD-MM-YYYY, HH:mm - HH:mm. +* The Date / Datetime of the Event can occur in the past as well; However, a warning message will be shown * Both `PATIENT_INDEX` and `EVENT_INDEX` **must be a positive integer** 1, 2, 3, ... * Both `PATIENT_INDEX` and `EVENT_INDEX` **must be of a valid index** (i.e. within the range of total number of Patients/Events). @@ -428,9 +430,9 @@ Action | Format, Examples **Add Tags** | `addt INDEX [t/TAG]+`
e.g. `addt 1 t/critical` **Delete Tags** | `deletet INDEX [t/TAG]+`
e.g. `deletet 1 t/critical` **Find Tags** | `findt KEYWORD [MORE_KEYWORDS]`
e.g. `findt depression diabetes` -**AddEvent** | `adde INDEX [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE]`
e.g. `adde 1 n/Birthday d/20-01-2022` -**DeleteEvent** | `deletee PATIENT_INDEX [e/EVENT_INDEX]`
e.g. `deletee 1 e/1` -**EditEvent** | `edite PATIENT_INDEX [e/EVENT_INDEX] [n/NAME_OF_EVENT_ON_THAT_DATE] [d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE]`
e.g. `edite 1 e/1 n/Papa Birthday d/20-01-2023` +**Add Event** | `adde INDEX n/NAME_OF_EVENT_ON_THAT_DATE d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE`
e.g. `adde 1 n/Birthday d/20-01-2022` +**Delete Event** | `deletee PATIENT_INDEX e/EVENT_INDEX`
e.g. `deletee 1 e/1` +**Edit Event** | `edite PATIENT_INDEX e/EVENT_INDEX n/NAME_OF_EVENT_ON_THAT_DATE d/DATE_OR_DATETIME_OF_EVENT_ON_THAT_DATE`
e.g. `edite 1 e/1 n/Papa Birthday d/20-01-2023` **Sort** | `sort [ATTRIBUTE]`
e.g. `sort p` **List** | `list` **Help** | `help` diff --git a/docs/images/Ui.png b/docs/images/Ui.png index b55de6a2bb6..95c3eee6443 100644 Binary files a/docs/images/Ui.png and b/docs/images/Ui.png differ diff --git a/docs/images/addEventResult.png b/docs/images/addEventResult.png index 7e6d7501597..fe9863e3439 100644 Binary files a/docs/images/addEventResult.png and b/docs/images/addEventResult.png differ diff --git a/docs/images/addTagsResult.png b/docs/images/addTagsResult.png index 6d4a1da7a80..b683c5d9815 100644 Binary files a/docs/images/addTagsResult.png and b/docs/images/addTagsResult.png differ diff --git a/docs/images/deleteEventResult.png b/docs/images/deleteEventResult.png index 829b6b9f92c..d5bd4b2c228 100644 Binary files a/docs/images/deleteEventResult.png and b/docs/images/deleteEventResult.png differ diff --git a/docs/images/deletePatientResult.png b/docs/images/deletePatientResult.png new file mode 100644 index 00000000000..99812f64f1a Binary files /dev/null and b/docs/images/deletePatientResult.png differ diff --git a/docs/images/deleteResult.png b/docs/images/deleteResult.png deleted file mode 100644 index be581d1613f..00000000000 Binary files a/docs/images/deleteResult.png and /dev/null differ diff --git a/docs/images/deleteTagsResult.png b/docs/images/deleteTagsResult.png index e73afb5ed0f..ddfe37da90c 100644 Binary files a/docs/images/deleteTagsResult.png and b/docs/images/deleteTagsResult.png differ diff --git a/docs/images/editEventResult.png b/docs/images/editEventResult.png index e929f67fa87..42b3d7ec06e 100644 Binary files a/docs/images/editEventResult.png and b/docs/images/editEventResult.png differ diff --git a/docs/images/editPatientResult.png b/docs/images/editPatientResult.png index 0fcebbe82b7..0f4741b2d2c 100644 Binary files a/docs/images/editPatientResult.png and b/docs/images/editPatientResult.png differ diff --git a/docs/images/findPatientAlexAliResult.png b/docs/images/findPatientAlexAliResult.png new file mode 100644 index 00000000000..8e37fc0bd16 Binary files /dev/null and b/docs/images/findPatientAlexAliResult.png differ diff --git a/docs/images/findPatientAlexBeckerResult.png b/docs/images/findPatientAlexBeckerResult.png deleted file mode 100644 index 24e6f406c8d..00000000000 Binary files a/docs/images/findPatientAlexBeckerResult.png and /dev/null differ diff --git a/docs/images/findTagsResult.png b/docs/images/findTagsResult.png index 529a01aaf6c..481b81e7d0d 100644 Binary files a/docs/images/findTagsResult.png and b/docs/images/findTagsResult.png differ diff --git a/docs/images/listResult.png b/docs/images/listResult.png index 324235e31eb..95c3eee6443 100644 Binary files a/docs/images/listResult.png and b/docs/images/listResult.png differ diff --git a/docs/images/sortResult.png b/docs/images/sortResult.png index 7fed59157ad..d384257d698 100644 Binary files a/docs/images/sortResult.png and b/docs/images/sortResult.png differ diff --git a/src/main/java/seedu/address/logic/commands/AddEventCommand.java b/src/main/java/seedu/address/logic/commands/AddEventCommand.java index 09b28f381a0..53ad2228dbd 100644 --- a/src/main/java/seedu/address/logic/commands/AddEventCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddEventCommand.java @@ -38,6 +38,8 @@ public class AddEventCommand extends Command { + PREFIX_DATETIME + "29-09-1789"; public static final String MESSAGE_SUCCESS = "Event %1$s successfully added for Patient %2$s with ID %3$s for %4$s"; public static final String MESSAGE_DUPLICATE = "Event %1$s already exists for Patient %2$s with ID %3$s for %4$s"; + public static final String MESSAGE_PAST_EVENT_WARNING = "Warning: This Event occurred before the current " + + "date / datetime"; private static final Logger logger = LogsCenter.getLogger(AddEventCommand.class); @@ -95,6 +97,11 @@ public CommandResult execute(Model model) throws CommandException { logger.info("Event added to patient's event set"); + if (this.eventToAdd.isPastEvent()) { + return new CommandResult(String.format(MESSAGE_SUCCESS, eventToAdd.name, + editedPatient.getName(), index.getOneBased(), eventToAdd.date) + "\n" + MESSAGE_PAST_EVENT_WARNING); + } + return new CommandResult(String.format(MESSAGE_SUCCESS, eventToAdd.name, editedPatient.getName(), index.getOneBased(), eventToAdd.date)); } diff --git a/src/main/java/seedu/address/logic/commands/EditEventCommand.java b/src/main/java/seedu/address/logic/commands/EditEventCommand.java index 5a881a342f8..2ca7ee4a6a0 100644 --- a/src/main/java/seedu/address/logic/commands/EditEventCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditEventCommand.java @@ -48,6 +48,8 @@ public class EditEventCommand extends Command { public static final String MESSAGE_SUCCESS = "Event %1$s with ID %2$s on %3$s successfully updated " + "for Patient %4$s with ID %5$s"; public static final String MESSAGE_DUPLICATE = "Event %1$s on %2$s already exists for Patient %3$s with ID %4$s"; + public static final String MESSAGE_PAST_EVENT_WARNING = "Warning: This Event occurred before the current " + + "date / datetime"; private static final Logger logger = LogsCenter.getLogger(EditEventCommand.class); @@ -95,6 +97,12 @@ public CommandResult execute(Model model) throws CommandException { updatePatientList(model, patientToEditEvent, updatedPatient); logger.log(Level.INFO, "Updated the information on the patient list successfully."); + if (this.eventToUpdate.isPastEvent()) { + return new CommandResult(String.format(MESSAGE_SUCCESS, eventToUpdate.name, + eventIndex.getOneBased(), eventToUpdate.date, updatedPatient.getName(), patientIndex.getOneBased()) + + "\n" + MESSAGE_PAST_EVENT_WARNING); + } + return new CommandResult(String.format(MESSAGE_SUCCESS, eventToUpdate.name, eventIndex.getOneBased(), eventToUpdate.date, updatedPatient.getName(), patientIndex.getOneBased())); } diff --git a/src/main/java/seedu/address/model/patient/Event.java b/src/main/java/seedu/address/model/patient/Event.java index 10173f6c260..940be3d2a43 100644 --- a/src/main/java/seedu/address/model/patient/Event.java +++ b/src/main/java/seedu/address/model/patient/Event.java @@ -101,6 +101,11 @@ public static boolean isValidEvent(String test) { */ public static boolean isValidDateTimeStr(String timeStr) { String[] args = timeStr.split("-"); + + if (args.length != 2) { + return false; + } + try { LocalTime start = LocalTime.parse(args[0].trim(), DateTimeFormatter.ofPattern(TIME_PATTERN)); // start time LocalTime end = LocalTime.parse(args[1].trim(), DateTimeFormatter.ofPattern(TIME_PATTERN)); // end time @@ -115,6 +120,24 @@ public static boolean isValidDateTimeStr(String timeStr) { } } + /** + * Returns True if the Date / DateTime of the Event is before the current Date / Datetime + * + * @return True if the Date / DateTime is before the current Date / Datetime + * False otherwise + */ + public boolean isPastEvent() { + LocalDate eventDate = LocalDate.parse(this.date, DateTimeFormatter.ofPattern(DATE_PATTERN)); + LocalDate curDate = LocalDate.now(); + + if (eventDate.isBefore(curDate)) { + return true; + } else if (eventDate.equals(curDate) && this.endTime != null) { + return LocalTime.parse(this.endTime, DateTimeFormatter.ofPattern(TIME_PATTERN)).isBefore(LocalTime.now()); + } + + return false; + } /** * Extracts the date and/or time arguments from the user input diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 692d99d93fa..4f82034ab02 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -29,7 +29,7 @@ public static Patient[] getSamplePatients() { getFamilyConditionSet("Stable ", "Has 2 sons that visits him regularly"), getHobbySet("Singing karaoke"), getTagSet("diabetes"), - getEventSet(new String[]{"Birthday"}, new String[]{"20-01-2022"})), + getEventSet(new String[]{"Birthday"}, new String[]{"20-01-2100"})), new Patient(new PatientHospitalId("12346"), new Name("Bernice Yu Sheng Huat"), new PreferredName("Bern"), @@ -37,7 +37,7 @@ public static Patient[] getSamplePatients() { getFamilyConditionSet("Lives alone", "no family members around"), getHobbySet("Playing Mahjong"), getTagSet("high blood pressure"), - getEventSet(new String[]{"Family Visit"}, new String[]{"30-03-2022, 15:00 - 18:00"})), + getEventSet(new String[]{"Family Visit"}, new String[]{"30-03-2100, 15:00 - 18:00"})), new Patient(new PatientHospitalId("12347"), new Name("Mary Jane"), new PreferredName("Mary"), diff --git a/src/main/java/seedu/address/ui/PatientCard.java b/src/main/java/seedu/address/ui/PatientCard.java index b3925ce555c..02919d1938d 100644 --- a/src/main/java/seedu/address/ui/PatientCard.java +++ b/src/main/java/seedu/address/ui/PatientCard.java @@ -93,7 +93,7 @@ public PatientCard(Patient patient, int displayedIndex) { .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); if (patient.getEvents().size() >= 1) { - events.getChildren().add(new Label("Upcoming:\n")); + events.getChildren().add(new Label("Events:\n")); ArrayList allEvents = new ArrayList<>(patient.getEvents()); Collections.sort(allEvents); diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPatientAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPatientAddressBook.json index 17e305ea042..520b1d91967 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPatientAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPatientAddressBook.json @@ -20,10 +20,10 @@ "tags" : [ "diabetes", "cholesterol" ], "events" : [ { "name": "Birthday", - "dateTime": "20-02-2022" + "dateTime": "20-02-9999" }, { "name": "Birthday", - "dateTime": "20-02-2022, 12:12 - 15:15" + "dateTime": "20-02-9999, 12:12 - 15:15" } ] }, { "patientHospitalId" : "12236", diff --git a/src/test/java/seedu/address/logic/commands/AddEventCommandTest.java b/src/test/java/seedu/address/logic/commands/AddEventCommandTest.java index f4ff5b0bfd5..91047d79a75 100644 --- a/src/test/java/seedu/address/logic/commands/AddEventCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddEventCommandTest.java @@ -23,9 +23,9 @@ import seedu.address.model.patient.Patient; public class AddEventCommandTest { - private final Event validDate = new Event("Test", "20-02-2022"); - private final Event secondValidDate = new Event("SomethingElse", "20-02-2022"); - private final Event thirdValidDate = new Event("Test", "20-02-2023"); + private final Event validDate = new Event("Test", "20-02-9999"); + private final Event secondValidDate = new Event("SomethingElse", "20-02-9999"); // different name + private final Event pastDate = new Event("Test", "20-12-1999"); // different date private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); @@ -69,6 +69,22 @@ public void execute_addValidEvent_success() throws CommandException { assertTrue(editedPatient.getEvents().equals(expectedEvents)); } + @Test + public void execute_addPastEvent_success() throws CommandException { + Index validIndex = Index.fromZeroBased(1); + AddEventCommand addEventCommand = new AddEventCommand(validIndex, pastDate); + CommandResult result = addEventCommand.execute(model); + + Patient editedPatient = model.getFilteredPatientList().get(validIndex.getZeroBased()); + String expected = String.format(AddEventCommand.MESSAGE_SUCCESS, pastDate.name, + editedPatient.getName(), validIndex.getOneBased(), pastDate.date + + "\n" + AddEventCommand.MESSAGE_PAST_EVENT_WARNING); + assertEquals(expected, result.getFeedbackToUser()); + + Set expectedEvents = new HashSet<>(editedPatient.getEvents()); + assertTrue(editedPatient.getEvents().equals(expectedEvents)); + } + @Test public void execute_addDuplicateEvent_success() throws CommandException { Index validIndex = Index.fromZeroBased(1); @@ -110,7 +126,7 @@ public void equalsTest() { AddEventCommand addEventCommandThird = new AddEventCommand( INDEX_FIRST_PATIENT, secondValidDate); AddEventCommand addEventCommandFourth = new AddEventCommand( - INDEX_FIRST_PATIENT, thirdValidDate); + INDEX_FIRST_PATIENT, pastDate); assertFalse(addEventCommandFirst.equals(addEventCommandSecond)); diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 41ff8140332..d4d20df0465 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -35,8 +35,8 @@ public class CommandTestUtil { public static final String VALID_NAME_AMY = "Amy Bee"; public static final String VALID_NAME_BOB = "Bob Choo"; public static final String VALID_EVENT_NAME = "Birthday"; - public static final String VALID_EVENT_DATE = "20-02-2022"; - public static final String VALID_EVENT_DATETIME = "20-02-2022, 12:12 - 15:15"; + public static final String VALID_EVENT_DATE = "20-02-9999"; + public static final String VALID_EVENT_DATETIME = "20-02-9999, 12:12 - 15:15"; public static final String VALID_PREFERRED_NAME_AMY = "Amy"; public static final String VALID_PREFERRED_NAME_BOB = "Bob"; public static final String VALID_FOOD_AMY = "Dim sum"; diff --git a/src/test/java/seedu/address/logic/commands/EditEventCommandTest.java b/src/test/java/seedu/address/logic/commands/EditEventCommandTest.java index dbc2c6b69a4..4a2df859a5b 100644 --- a/src/test/java/seedu/address/logic/commands/EditEventCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditEventCommandTest.java @@ -28,9 +28,9 @@ public class EditEventCommandTest { private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); - private final Event validEvent = new Event("Test", "20-02-2022"); - private final Event secondValidEvent = new Event("SomethingElse", "20-02-2022"); - private final Event thirdValidEvent = new Event("Test", "20-02-2023"); + private final Event validEvent = new Event("Test", "20-02-9999"); + private final Event secondValidEvent = new Event("SomethingElse", "20-02-9999"); + private final Event pastEvent = new Event("Test", "20-12-1999"); @Test public void constructor_nullPatientIndex_throwsNullPointerException() { @@ -92,6 +92,24 @@ public void execute_editEvent_success() throws CommandException { assertEquals(editedPatient.getEvents(), expectedEvents); } + @Test + public void execute_editPastEvent_success() throws CommandException { + EditEventCommand editEventCommand = new EditEventCommand(INDEX_SECOND_PATIENT, + INDEX_FIRST_EVENT, pastEvent); + CommandResult result = editEventCommand.execute(model); + Patient editedPatient = model.getFilteredPatientList().get(INDEX_SECOND_PATIENT.getZeroBased()); + + String expected = String.format(EditEventCommand.MESSAGE_SUCCESS, pastEvent.name, + INDEX_FIRST_EVENT.getOneBased(), pastEvent.date, editedPatient.getName(), + INDEX_SECOND_PATIENT.getOneBased() + "\n" + EditEventCommand.MESSAGE_PAST_EVENT_WARNING); + + assertEquals(expected, result.getFeedbackToUser()); + + Set expectedEvents = new HashSet<>(editedPatient.getEvents()); + + assertEquals(editedPatient.getEvents(), expectedEvents); + } + @Test public void execute_editEventWithInvalidPatientIndex_throwsCommandException() { Index invalidPatientIndex = Index.fromOneBased(model.getFilteredPatientList().size() + 1); @@ -161,7 +179,7 @@ public void equals_differentEvent_returnFalse() { EditEventCommand editEventCommandSecond = new EditEventCommand( INDEX_SECOND_PATIENT, INDEX_SECOND_EVENT, secondValidEvent); EditEventCommand editEventCommandThird = new EditEventCommand( - INDEX_SECOND_PATIENT, INDEX_SECOND_EVENT, thirdValidEvent); + INDEX_SECOND_PATIENT, INDEX_SECOND_EVENT, pastEvent); // Test same patient index, same event index, same event date but different event name assertNotEquals(editEventCommandFirst, editEventCommandSecond); @@ -181,9 +199,9 @@ public void equals_differentInstance_returnFalse() { @Test public void equals_sameValues_returnTrue() { EditEventCommand editEventCommandFirst = new EditEventCommand( - INDEX_THIRD_PATIENT, INDEX_THIRD_EVENT, thirdValidEvent); + INDEX_THIRD_PATIENT, INDEX_THIRD_EVENT, pastEvent); EditEventCommand editEventCommandSecond = new EditEventCommand( - INDEX_THIRD_PATIENT, INDEX_THIRD_EVENT, thirdValidEvent); + INDEX_THIRD_PATIENT, INDEX_THIRD_EVENT, pastEvent); // Test with the same object assertEquals(editEventCommandFirst, editEventCommandFirst); diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 6076ec16869..f99d7033d2b 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -100,7 +100,7 @@ public void parseCommand_findTags() throws Exception { @Test public void parseCommand_addEvent() throws Exception { String name = "Birthday"; - String date = "20-01-2022"; + String date = "20-01-9999"; String args = "1 " + PREFIX_NAME + name + " " + PREFIX_DATETIME + date; AddEventCommand command = (AddEventCommand) parser.parseCommand( AddEventCommand.COMMAND_WORD + " " + args); diff --git a/src/test/java/seedu/address/model/patient/EventTest.java b/src/test/java/seedu/address/model/patient/EventTest.java index c283c7a29e6..fa693ea4fc2 100644 --- a/src/test/java/seedu/address/model/patient/EventTest.java +++ b/src/test/java/seedu/address/model/patient/EventTest.java @@ -41,6 +41,12 @@ public void constructor_invalidTime_throwsIllegalArgumentException() { validDate + "21-02-2022, 06:00 - 00:00")); assertThrows(IllegalArgumentException.class, () -> new Event("Family Visit", validDate + "21-02-2022, 01:00 - 00:59")); + assertThrows(IllegalArgumentException.class, () -> new Event("Family Visit", + validDate + "21-02-2022, 01:00")); + assertThrows(IllegalArgumentException.class, () -> new Event("Family Visit", + validDate + "21-02-2022, 01:00 - 02:00 - 03:00")); + assertThrows(IllegalArgumentException.class, () -> new Event("Family Visit", + validDate + "21-02-2022, 01:00, 02:00 - 03:00")); } @Test @@ -64,6 +70,14 @@ public void isValidEvent() { assertTrue(Event.isValidEvent("21-02-2022, 00:00 - 00:00")); } + @Test + public void isPastEvent() { + assertTrue(new Event("Family Visit", "01-01-1999, 12:12 - 19:12").isPastEvent()); + assertTrue(new Event("Family Visit", "01-01-2022, 12:12 - 19:12").isPastEvent()); + assertTrue(new Event("Family Visit", "01-01-2024, 12:12 - 19:12").isPastEvent()); + + assertFalse(new Event("Family Visit", "01-01-9999, 12:12 - 19:12").isPastEvent()); + } @Test public void compareTo() { diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java index 3a933dbcde4..630120c90de 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java @@ -24,7 +24,6 @@ public class JsonAdaptedPatientTest { private static final String INVALID_NAME = "R@chel Lim"; private static final String INVALID_PREFERRED_NAME = "R@chel"; private static final String INVALID_FOOD_PREFERENCE = " "; - private static final String INVALID_FAMILY_CONDITION = " "; private static final String INVALID_HOBBY = " "; private static final String INVALID_TAG = "#Diabetes"; private static final String INVALID_EVENT_DATETIME_STR = "Something";