4
4
import static org .junit .jupiter .api .Assertions .assertFalse ;
5
5
import static org .junit .jupiter .api .Assertions .assertTrue ;
6
6
import static seedu .address .logic .commands .CommandTestUtil .NON_EXISTENT_NRIC ;
7
- import static seedu .address .testutil .TypicalPersons .BOB ;
7
+ import static seedu .address .logic .commands .CommandTestUtil .assertCommandFailure ;
8
+ import static seedu .address .logic .commands .CommandTestUtil .assertCommandSuccess ;
9
+ import static seedu .address .logic .commands .ReadCommand .MESSAGE_READ_PERSON_SUCCESS ;
10
+ import static seedu .address .model .Model .PREDICATE_SHOW_ALL_PERSONS ;
11
+ import static seedu .address .testutil .TypicalPersons .ALICE ;
8
12
import static seedu .address .testutil .TypicalPersons .getTypicalAddressBook ;
9
13
10
14
import org .junit .jupiter .api .Test ;
11
15
16
+ import seedu .address .logic .Messages ;
12
17
import seedu .address .model .Model ;
13
18
import seedu .address .model .ModelManager ;
14
19
import seedu .address .model .UserPrefs ;
15
20
import seedu .address .model .person .Nric ;
16
21
17
22
public class ReadCommandTest {
18
23
19
- private Model model = new ModelManager (getTypicalAddressBook (), new UserPrefs ());
20
-
21
- /* @Test
24
+ private final Model model = new ModelManager (getTypicalAddressBook (), new UserPrefs ());
25
+ private final Model expectedModel = new ModelManager ( getTypicalAddressBook (), new UserPrefs ());
26
+ @ Test
22
27
void execute_validNric_success () {
23
-
28
+ String expectedMessage = String .format (MESSAGE_READ_PERSON_SUCCESS , Messages .formatRead (ALICE ));
29
+ ReadCommand command = new ReadCommand (ALICE .getNric ());
30
+ expectedModel .updateFilteredPersonList (PREDICATE_SHOW_ALL_PERSONS );
31
+ assertCommandSuccess (command , model , expectedMessage , expectedModel );
24
32
}
25
33
26
34
@ Test
27
- void execute_invalidNric_failure() {
28
-
29
- }*/
35
+ void execute_nonExistentNric_failure () {
36
+ Nric nonexistentNric = new Nric ("S1234567A" );
37
+ assertCommandFailure (new ReadCommand (nonexistentNric ), model , Messages .MESSAGE_PERSON_NOT_FOUND );
38
+ }
30
39
31
40
@ Test
32
41
void equals () {
33
- ReadCommand readFirstCommand = new ReadCommand (BOB .getNric ());
42
+ ReadCommand readFirstCommand = new ReadCommand (ALICE .getNric ());
34
43
ReadCommand readSecondCommand = new ReadCommand (new Nric (NON_EXISTENT_NRIC ));
35
44
36
45
// same object -> returns true
37
46
assertTrue (readFirstCommand .equals (readFirstCommand ));
38
47
39
48
// same values -> returns true
40
- ReadCommand readFirstCommandCopy = new ReadCommand (BOB .getNric ());
49
+ ReadCommand readFirstCommandCopy = new ReadCommand (ALICE .getNric ());
41
50
assertTrue (readFirstCommand .equals (readFirstCommandCopy ));
42
51
43
52
// different types -> returns false
@@ -52,8 +61,8 @@ void equals() {
52
61
53
62
@ Test
54
63
void testToString () {
55
- ReadCommand readCommand = new ReadCommand (BOB .getNric ());
56
- String expected = ReadCommand .class .getCanonicalName () + "{nric=" + BOB .getNric () + "}" ;
64
+ ReadCommand readCommand = new ReadCommand (ALICE .getNric ());
65
+ String expected = ReadCommand .class .getCanonicalName () + "{nric=" + ALICE .getNric () + "}" ;
57
66
assertEquals (expected , readCommand .toString ());
58
67
}
59
68
0 commit comments