From 7d790a809b423978fd611e8b3a404969e7ff83c0 Mon Sep 17 00:00:00 2001 From: Darren Date: Thu, 19 Oct 2023 22:14:19 +0800 Subject: [PATCH] Modify withAppointments method --- .../duplicatePersonAddressBook.json | 8 +++---- .../typicalPersonsAddressBook.json | 24 ------------------- .../seedu/address/testutil/PersonBuilder.java | 9 +++++++ .../address/testutil/TypicalPersons.java | 9 ++++--- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json index 6987cc1a2c3..a1e1dcae7ec 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json @@ -12,8 +12,8 @@ "isPinned": true, "appointments": [ { - "name": "Eye Examination", - "dateTime": "18-09-2023 1800" + "name": "Eye Exam", + "dateTime": "01-01-2001 1200" } ] }, @@ -28,8 +28,8 @@ "isPinned": true, "appointments": [ { - "name": "Eye Examination", - "dateTime": "18-09-2023 1800" + "name": "Eye Exam", + "dateTime": "01-01-2001 1200" } ] } diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index 8a45af431f2..6a264a4ed6b 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -14,14 +14,6 @@ { "name": "Eye Exam", "dateTime": "01-01-2001 1200" - }, - { - "name": "Vaccination", - "dateTime": "11-09-2001 1200" - }, - { - "name": "Colonoscopy", - "dateTime": "21-12-2001 1200" } ] }, @@ -35,17 +27,9 @@ "allergies": ["Pollen", "Soil"], "isPinned": false, "appointments": [ - { - "name": "Eye Exam", - "dateTime": "01-01-2001 1200" - }, { "name": "Vaccination", "dateTime": "11-09-2001 1200" - }, - { - "name": "Colonoscopy", - "dateTime": "21-12-2001 1200" } ] }, @@ -59,14 +43,6 @@ "allergies": ["Dogs"], "isPinned": false, "appointments": [ - { - "name": "Eye Exam", - "dateTime": "01-01-2001 1200" - }, - { - "name": "Vaccination", - "dateTime": "11-09-2001 1200" - }, { "name": "Colonoscopy", "dateTime": "21-12-2001 1200" diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 52588505052..d17c92a93ef 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -11,6 +11,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.appointment.Appointment; import seedu.address.model.person.appointment.UniqueAppointmentList; import seedu.address.model.util.SampleDataUtil; @@ -139,6 +140,14 @@ public PersonBuilder withAppointments(UniqueAppointmentList appointment) { return this; } + /** + * Sets the {@code appointments} of the {@code Person} that we are building. + */ + public PersonBuilder withAppointments(Appointment ... appointments) { + this.appointments = SampleDataUtil.getAppointmentList(appointments); + return this; + } + public Person build() { return new Person(name, email, phone, gender, age, bloodType, allergies, isPinned, appointments); } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index d9b19d91fcd..93e66903297 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -14,6 +14,9 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.testutil.TypicalAppointments.COLONOSCOPY; +import static seedu.address.testutil.TypicalAppointments.EYE_EXAM; +import static seedu.address.testutil.TypicalAppointments.VACCINATION; import java.util.ArrayList; import java.util.Arrays; @@ -34,7 +37,7 @@ public class TypicalPersons { .withBloodType("AB+") .withAllergies("Chocolate") .withIsPinned(true) - .withAppointments(TypicalAppointments.getTypicalAppointments()).build(); + .withAppointments(EYE_EXAM).build(); public static final Person BENSON = new PersonBuilder().withName("Benson Meier") .withEmail("johnd@example.com") .withPhone("98765432") @@ -43,7 +46,7 @@ public class TypicalPersons { .withBloodType("B-") .withAllergies("Pollen", "Soil") .withIsPinned(false) - .withAppointments(TypicalAppointments.getTypicalAppointments()).build(); + .withAppointments(VACCINATION).build(); public static final Person CARL = new PersonBuilder().withName("Carl Kurz") .withEmail("heinz@example.com") .withPhone("95352563") @@ -52,7 +55,7 @@ public class TypicalPersons { .withBloodType("AB-") .withAllergies("Dogs") .withIsPinned(false) - .withAppointments(TypicalAppointments.getTypicalAppointments()).build(); + .withAppointments(COLONOSCOPY).build(); public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier") .withEmail("cornelia@example.com") .withPhone("87652533")