77import static seedu .address .logic .commands .CommandTestUtil .showPersonAtIndex ;
88import static seedu .address .testutil .TypicalIndexes .INDEX_FIRST_PERSON ;
99import static seedu .address .testutil .TypicalIndexes .INDEX_SECOND_PERSON ;
10+ import static seedu .address .testutil .TypicalPersons .ALICE ;
11+ import static seedu .address .testutil .TypicalPersons .BOB ;
1012import static seedu .address .testutil .TypicalPersons .getTypicalAddressBook ;
1113
1214import org .junit .jupiter .api .Test ;
1618import seedu .address .model .Model ;
1719import seedu .address .model .ModelManager ;
1820import seedu .address .model .UserPrefs ;
21+ import seedu .address .model .person .Name ;
1922import seedu .address .model .person .Person ;
2023
2124/**
@@ -27,9 +30,9 @@ public class DeleteCommandTest {
2730 private Model model = new ModelManager (getTypicalAddressBook (), new UserPrefs ());
2831
2932 @ Test
30- public void execute_validIndexUnfilteredList_success () {
33+ public void execute_validNameUnfilteredList_success () {
3134 Person personToDelete = model .getFilteredPersonList ().get (INDEX_FIRST_PERSON .getZeroBased ());
32- DeleteCommand deleteCommand = new DeleteCommand (INDEX_FIRST_PERSON );
35+ DeleteCommand deleteCommand = new DeleteCommand (personToDelete . getName () );
3336
3437 String expectedMessage = String .format (DeleteCommand .MESSAGE_DELETE_PERSON_SUCCESS , personToDelete );
3538
@@ -40,19 +43,18 @@ public void execute_validIndexUnfilteredList_success() {
4043 }
4144
4245 @ Test
43- public void execute_invalidIndexUnfilteredList_throwsCommandException () {
44- Index outOfBoundIndex = Index .fromOneBased (model .getFilteredPersonList ().size () + 1 );
45- DeleteCommand deleteCommand = new DeleteCommand (outOfBoundIndex );
46+ public void execute_invalidNameUnfilteredList_throwsCommandException () {
47+ DeleteCommand deleteCommand = new DeleteCommand (new Name ("123" ));
4648
47- assertCommandFailure (deleteCommand , model , Messages .MESSAGE_INVALID_PERSON_DISPLAYED_INDEX );
49+ assertCommandFailure (deleteCommand , model , Messages .MESSAGE_INVALID_PERSON_DISPLAYED );
4850 }
4951
5052 @ Test
51- public void execute_validIndexFilteredList_success () {
53+ public void execute_validNameFilteredList_success () {
5254 showPersonAtIndex (model , INDEX_FIRST_PERSON );
5355
5456 Person personToDelete = model .getFilteredPersonList ().get (INDEX_FIRST_PERSON .getZeroBased ());
55- DeleteCommand deleteCommand = new DeleteCommand (INDEX_FIRST_PERSON );
57+ DeleteCommand deleteCommand = new DeleteCommand (personToDelete . getName () );
5658
5759 String expectedMessage = String .format (DeleteCommand .MESSAGE_DELETE_PERSON_SUCCESS , personToDelete );
5860
@@ -64,28 +66,28 @@ public void execute_validIndexFilteredList_success() {
6466 }
6567
6668 @ Test
67- public void execute_invalidIndexFilteredList_throwsCommandException () {
69+ public void execute_invalidNameFilteredList_throwsCommandException () {
6870 showPersonAtIndex (model , INDEX_FIRST_PERSON );
6971
7072 Index outOfBoundIndex = INDEX_SECOND_PERSON ;
7173 // ensures that outOfBoundIndex is still in bounds of address book list
7274 assertTrue (outOfBoundIndex .getZeroBased () < model .getAddressBook ().getPersonList ().size ());
7375
74- DeleteCommand deleteCommand = new DeleteCommand (outOfBoundIndex );
76+ DeleteCommand deleteCommand = new DeleteCommand (new Name ( "123" ) );
7577
76- assertCommandFailure (deleteCommand , model , Messages .MESSAGE_INVALID_PERSON_DISPLAYED_INDEX );
78+ assertCommandFailure (deleteCommand , model , Messages .MESSAGE_INVALID_PERSON_DISPLAYED );
7779 }
7880
7981 @ Test
8082 public void equals () {
81- DeleteCommand deleteFirstCommand = new DeleteCommand (INDEX_FIRST_PERSON );
82- DeleteCommand deleteSecondCommand = new DeleteCommand (INDEX_SECOND_PERSON );
83+ DeleteCommand deleteFirstCommand = new DeleteCommand (ALICE . getName () );
84+ DeleteCommand deleteSecondCommand = new DeleteCommand (BOB . getName () );
8385
8486 // same object -> returns true
8587 assertTrue (deleteFirstCommand .equals (deleteFirstCommand ));
8688
8789 // same values -> returns true
88- DeleteCommand deleteFirstCommandCopy = new DeleteCommand (INDEX_FIRST_PERSON );
90+ DeleteCommand deleteFirstCommandCopy = new DeleteCommand (ALICE . getName () );
8991 assertTrue (deleteFirstCommand .equals (deleteFirstCommandCopy ));
9092
9193 // different types -> returns false
0 commit comments