10
10
import static seedu .address .logic .commands .CommandTestUtil .VALID_PHONE_BOB ;
11
11
import static seedu .address .logic .commands .CommandTestUtil .VALID_TAG_HUSBAND ;
12
12
import static seedu .address .logic .commands .CommandTestUtil .assertCommandFailure ;
13
+ import static seedu .address .logic .commands .CommandTestUtil .assertCommandFailureWithoutModel ;
13
14
import static seedu .address .logic .commands .CommandTestUtil .assertCommandSuccess ;
14
15
import static seedu .address .logic .commands .CommandTestUtil .showPersonAtIndex ;
15
16
import static seedu .address .testutil .TypicalIndexes .INDEX_FIRST_PERSON ;
@@ -45,7 +46,10 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() {
45
46
String expectedMessage = String .format (EditCommand .MESSAGE_EDIT_PERSON_SUCCESS , Messages .format (editedPerson ));
46
47
47
48
Model expectedModel = new ModelManager (new CampusConnect (model .getCampusConnect ()), new UserPrefs ());
48
- expectedModel .setPerson (model .getFilteredPersonList ().get (0 ), editedPerson );
49
+
50
+ Person firstPerson = model .getFilteredPersonList ().get (INDEX_FIRST_PERSON .getZeroBased ());
51
+ expectedModel .deletePerson (firstPerson );
52
+ expectedModel .insertPerson (editedPerson , INDEX_FIRST_PERSON .getZeroBased ());
49
53
50
54
assertCommandSuccess (editCommand , model , expectedMessage , expectedModel );
51
55
}
@@ -79,6 +83,9 @@ public void execute_noFieldSpecifiedUnfilteredList_success() {
79
83
String expectedMessage = String .format (EditCommand .MESSAGE_EDIT_PERSON_SUCCESS , Messages .format (editedPerson ));
80
84
81
85
Model expectedModel = new ModelManager (new CampusConnect (model .getCampusConnect ()), new UserPrefs ());
86
+ Person firstPerson = expectedModel .getFilteredPersonList ().get (INDEX_FIRST_PERSON .getZeroBased ());
87
+ expectedModel .deletePerson (firstPerson );
88
+ expectedModel .insertPerson (firstPerson , INDEX_FIRST_PERSON .getZeroBased ());
82
89
83
90
assertCommandSuccess (editCommand , model , expectedMessage , expectedModel );
84
91
}
@@ -104,7 +111,8 @@ public void execute_filteredList_success() {
104
111
String expectedMessage = String .format (EditCommand .MESSAGE_EDIT_PERSON_SUCCESS , Messages .format (editedPerson ));
105
112
106
113
Model expectedModel = new ModelManager (new CampusConnect (model .getCampusConnect ()), new UserPrefs ());
107
- expectedModel .setPerson (model .getFilteredPersonList ().get (0 ), editedPerson );
114
+ expectedModel .deletePerson (personInFilteredList );
115
+ expectedModel .insertPerson (editedPerson , INDEX_FIRST_PERSON .getZeroBased ());
108
116
109
117
assertCommandSuccess (editCommand , model , expectedMessage , expectedModel );
110
118
}
@@ -115,7 +123,7 @@ public void execute_duplicatePersonUnfilteredList_failure() {
115
123
EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder (firstPerson ).build ();
116
124
EditCommand editCommand = new EditCommand (INDEX_SECOND_PERSON , descriptor );
117
125
118
- assertCommandFailure (editCommand , model , EditCommand .MESSAGE_DUPLICATE_PERSON );
126
+ assertCommandFailureWithoutModel (editCommand , model , EditCommand .MESSAGE_DUPLICATE_PERSON );
119
127
}
120
128
121
129
@ Test
@@ -127,7 +135,7 @@ public void execute_duplicatePersonFilteredList_failure() {
127
135
EditCommand editCommand = new EditCommand (INDEX_FIRST_PERSON ,
128
136
new EditPersonDescriptorBuilder (personInList ).build ());
129
137
130
- assertCommandFailure (editCommand , model , EditCommand .MESSAGE_DUPLICATE_PERSON );
138
+ assertCommandFailureWithoutModel (editCommand , model , EditCommand .MESSAGE_DUPLICATE_PERSON );
131
139
}
132
140
133
141
@ Test
0 commit comments