|
5 | 5 | import static seedu.address.testutil.Assert.assertThrows; |
6 | 6 | import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; |
7 | 7 |
|
| 8 | +import java.util.Optional; |
| 9 | + |
8 | 10 | import org.junit.jupiter.api.Test; |
9 | 11 |
|
10 | 12 | import seedu.address.logic.parser.exceptions.ParseException; |
|
15 | 17 |
|
16 | 18 | public class ParserUtilTest { |
17 | 19 | private static final String INVALID_NAME = "R@chel"; |
18 | | - private static final String INVALID_PHONE = "+651234"; |
| 20 | + private static final Optional<String> INVALID_PHONE = Optional.of("+651234"); |
19 | 21 | private static final String INVALID_EMAIL = "example.com"; |
20 | 22 | private static final String INVALID_ROLE = "friend"; |
21 | 23 |
|
22 | 24 | private static final String VALID_NAME = "Rachel Walker"; |
23 | | - private static final String VALID_PHONE = "123456"; |
| 25 | + private static final Optional<String> VALID_PHONE = Optional.of("123456"); |
24 | 26 | private static final String VALID_EMAIL = "rachel@example.com"; |
25 | 27 | private static final String VALID_ROLE = "stk"; |
26 | 28 |
|
@@ -48,7 +50,7 @@ public void parseIndex_validInput_success() throws Exception { |
48 | 50 |
|
49 | 51 | @Test |
50 | 52 | public void parseName_null_throwsNullPointerException() { |
51 | | - assertThrows(NullPointerException.class, () -> ParserUtil.parseName((String) null)); |
| 53 | + assertThrows(NullPointerException.class, () -> ParserUtil.parseName(null)); |
52 | 54 | } |
53 | 55 |
|
54 | 56 | @Test |
@@ -82,14 +84,14 @@ public void parsePhone_validValueWithoutWhitespace_returnsPhone() throws Excepti |
82 | 84 |
|
83 | 85 | @Test |
84 | 86 | public void parsePhone_validValueWithWhitespace_returnsTrimmedPhone() throws Exception { |
85 | | - String phoneWithWhitespace = WHITESPACE + VALID_PHONE + WHITESPACE; |
| 87 | + Optional<String> phoneWithWhitespace = Optional.of(WHITESPACE + VALID_PHONE.get() + WHITESPACE); |
86 | 88 | Phone expectedPhone = new Phone(VALID_PHONE); |
87 | 89 | assertEquals(expectedPhone, ParserUtil.parsePhone(phoneWithWhitespace)); |
88 | 90 | } |
89 | 91 |
|
90 | 92 | @Test |
91 | 93 | public void parseEmail_null_throwsNullPointerException() { |
92 | | - assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null)); |
| 94 | + assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail(null)); |
93 | 95 | } |
94 | 96 |
|
95 | 97 | @Test |
|
0 commit comments