diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index b7ba70bbde8..7f5a703e1f8 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -1,6 +1,13 @@ { "_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()", - "persons" : [ { + "persons" : [{ + "name" : "Bob Choo", + "phone" : "22222222", + "email" : "bob@example.com", + "lastContactedTime" : "2023-09-20T12:00", + "status" : "prospective", + "tags" : [ "friend", "husband" ] + }, { "name" : "Alice Pauline", "phone" : "94351253", "email" : "alice@example.com", diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 7732d417cbf..7ace22b0783 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -40,6 +40,7 @@ public class EditCommandTest { @Test public void updateAttendees() { + model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); Person firstPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); Person editedPerson = new PersonBuilder(firstPerson).withName("James").build(); @@ -62,7 +63,8 @@ public void updateAttendees() { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { - Person editedPerson = new PersonBuilder().build(); + model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + Person editedPerson = new PersonBuilder(model.getFilteredPersonList().get(0)).build(); EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); @@ -76,21 +78,22 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { @Test public void execute_someFieldsSpecifiedUnfilteredList_success() { - Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); - PersonBuilder personInList = new PersonBuilder(lastPerson); + Index indexFirstPerson = Index.fromOneBased(1); + Person firstPerson = model.getFilteredPersonList().get(indexFirstPerson.getZeroBased()); + + PersonBuilder personInList = new PersonBuilder(firstPerson); Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withTags(VALID_TAG_HUSBAND).build(); EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); - EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); + EditCommand editCommand = new EditCommand(indexFirstPerson, descriptor); String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastPerson, editedPerson); + expectedModel.setPerson(firstPerson, editedPerson); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 94885d928d9..326ac05c633 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -9,6 +9,7 @@ import static seedu.address.testutil.TypicalAddressBook.getTypicalAddressBook; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BENSON; +import static seedu.address.testutil.TypicalPersons.BOB; import static seedu.address.testutil.TypicalPersons.CARL; import static seedu.address.testutil.TypicalPersons.DANIEL; import static seedu.address.testutil.TypicalPersons.ELLE; @@ -97,7 +98,7 @@ public void execute_zeroKeywords_allPersonFound() { FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredPersonList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE, HOON), + assertEquals(Arrays.asList(BOB, ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE, HOON), model.getFilteredPersonList()); } diff --git a/src/test/java/seedu/address/logic/commands/FindMeetingCommandTest.java b/src/test/java/seedu/address/logic/commands/FindMeetingCommandTest.java index 30ab630b947..67d687c06df 100644 --- a/src/test/java/seedu/address/logic/commands/FindMeetingCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindMeetingCommandTest.java @@ -135,19 +135,6 @@ public void execute_multipleTitleAndMultipleLocationKeywords_oneMeetingFound() { assertCommandSuccess(command, model, expectedMessage, expectedModel); assertEquals(Arrays.asList(MEETING2, MEETING3, MEETING4), model.getFilteredMeetingList()); } - - @Test - public void execute_multipleTitleMultipleLocationAndAttendeeKeywords_twoMeetingFound() { - String expectedMessage = String.format(MESSAGE_MEETINGS_LISTED_OVERVIEW, 1); - GeneralMeetingPredicate predicate = - preparePredicate(new String[]{"ABCDE CS2101", "Zoom com", "Hoon", ""}, - start, end); - FindMeetingCommand command = new FindMeetingCommand(predicate); - expectedModel.updateFilteredMeetingList(predicate); - assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Arrays.asList(MEETING4), model.getFilteredMeetingList()); - } - @Test public void execute_multipleTitleMultipleLocationAndMultipleAttendeeKeywords_twoMeetingFound() { String expectedMessage = String.format(MESSAGE_MEETINGS_LISTED_OVERVIEW, 2); diff --git a/src/test/java/seedu/address/logic/commands/ViewContactCommandTest.java b/src/test/java/seedu/address/logic/commands/ViewContactCommandTest.java index c0fb5c2c5ae..5ffa450ead4 100644 --- a/src/test/java/seedu/address/logic/commands/ViewContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ViewContactCommandTest.java @@ -34,7 +34,7 @@ public void execute_validIndexUnfilteredList_success() { String expectedMessage = String.format(Messages.MESSAGE_PERSON_VIEWED_OVERVIEW, personToView.getName()); String expectedDisplayString = String.format( "Name: %s\nPhone: %s\nEmail: %s\nLast Meeting: %s\nStatus: %s\nRemark: %s", - "Alice Pauline", "94351253", "alice@example.com", "20 October 2023, 1100", "NIL", ""); + "Bob Choo", "22222222", "bob@example.com", "20 September 2023, 1200", "prospective", ""); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); @@ -60,7 +60,7 @@ public void execute_validIndexFilteredList_success() { String expectedMessage = String.format(Messages.MESSAGE_PERSON_VIEWED_OVERVIEW, personToView.getName()); String expectedDisplayString = String.format( "Name: %s\nPhone: %s\nEmail: %s\nLast Meeting: %s\nStatus: %s\nRemark: %s", - "Alice Pauline", "94351253", "alice@example.com", "20 October 2023, 1100", "NIL", ""); + "Bob Choo", "22222222", "bob@example.com", "20 September 2023, 1200", "prospective", ""); // Model displaying filtered list should not change Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); diff --git a/src/test/java/seedu/address/testutil/TypicalAddressBook.java b/src/test/java/seedu/address/testutil/TypicalAddressBook.java index 7d9f3466915..814fdba41af 100644 --- a/src/test/java/seedu/address/testutil/TypicalAddressBook.java +++ b/src/test/java/seedu/address/testutil/TypicalAddressBook.java @@ -18,14 +18,14 @@ private TypicalAddressBook() { public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Meeting meeting : TypicalMeetings.getTypicalMeetings()) { - ab.addMeeting(meeting); - } - for (Person person : TypicalPersons.getTypicalPersons()) { ab.addPerson(person); } + for (Meeting meeting : TypicalMeetings.getTypicalMeetings()) { + ab.addMeeting(meeting); + } + return ab; } } diff --git a/src/test/java/seedu/address/testutil/TypicalMeetings.java b/src/test/java/seedu/address/testutil/TypicalMeetings.java index 0b6f9d98242..3855020cca6 100644 --- a/src/test/java/seedu/address/testutil/TypicalMeetings.java +++ b/src/test/java/seedu/address/testutil/TypicalMeetings.java @@ -15,6 +15,7 @@ public class TypicalMeetings { .withLocation("Zoom call url") .withStart("20.09.2023 1000").withEnd("20.09.2023 1200") .withTags("work", "important") + .withAttendees() .build(); public static final Meeting MEETING2 = new MeetingBuilder().withTitle("CS2101 meeting") diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index d14996cee91..c9aae965d00 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -64,7 +64,7 @@ private TypicalPersons() { } // prevents instantiation public static List getTypicalPersons() { - return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE, HOON)); + return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE, HOON, BOB)); } /** @@ -81,7 +81,7 @@ public static AddressBook getTypicalPersonsAddressBook() { } public static String[] getTypicalAttendeesAll() { - List typicalPersons = getTypicalPersons(); + List typicalPersons = TypicalPersons.getTypicalPersons(); String[] typicalAttendees = typicalPersons.stream().map(Person::getName).map(Name::toString) .collect(Collectors.toList()).toArray(String[]::new); return typicalAttendees;