Skip to content

Commit ff26e39

Browse files
committed
Modify isSamePerson test and valid phone test
1 parent 247bb2a commit ff26e39

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

src/main/java/seedu/address/logic/parser/person/ParserUtil.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ public static Phone parsePhone(Optional<String> phone) throws ParseException {
6565
return new Phone(trimmedPhone);
6666
}
6767

68-
/**
69-
* Parses a {@code String phone} into a {@code Phone}.
70-
* Leading and trailing whitespaces will be trimmed.
71-
*
72-
* @throws ParseException if the given {@code phone} is invalid.
73-
*/
74-
public static Phone parsePhone(String phone) throws ParseException {
75-
return parsePhone(Optional.of(phone));
76-
}
77-
7868
/**
7969
* Parses a {@code String email} into an {@code Email}.
8070
* Leading and trailing whitespaces will be trimmed.

src/test/java/seedu/address/logic/parser/person/ParserUtilTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import static seedu.address.testutil.Assert.assertThrows;
66
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
77

8+
import java.util.Optional;
9+
810
import org.junit.jupiter.api.Test;
911

1012
import seedu.address.logic.parser.exceptions.ParseException;
@@ -15,12 +17,12 @@
1517

1618
public class ParserUtilTest {
1719
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");
1921
private static final String INVALID_EMAIL = "example.com";
2022
private static final String INVALID_ROLE = "friend";
2123

2224
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");
2426
private static final String VALID_EMAIL = "rachel@example.com";
2527
private static final String VALID_ROLE = "stk";
2628

@@ -48,7 +50,7 @@ public void parseIndex_validInput_success() throws Exception {
4850

4951
@Test
5052
public void parseName_null_throwsNullPointerException() {
51-
assertThrows(NullPointerException.class, () -> ParserUtil.parseName((String) null));
53+
assertThrows(NullPointerException.class, () -> ParserUtil.parseName(null));
5254
}
5355

5456
@Test
@@ -82,14 +84,14 @@ public void parsePhone_validValueWithoutWhitespace_returnsPhone() throws Excepti
8284

8385
@Test
8486
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);
8688
Phone expectedPhone = new Phone(VALID_PHONE);
8789
assertEquals(expectedPhone, ParserUtil.parsePhone(phoneWithWhitespace));
8890
}
8991

9092
@Test
9193
public void parseEmail_null_throwsNullPointerException() {
92-
assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null));
94+
assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail(null));
9395
}
9496

9597
@Test

src/test/java/seedu/address/model/person/person/PersonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void isSamePerson() {
4444

4545
// same name, same phone, same email, different attributes -> returns true
4646
editedAlice = new PersonBuilder(ALICE)
47-
.withDescription("wnjevjnkklfwe").build();
47+
.withDescription(VALID_DESCRIPTION_BOB).build();
4848
assertTrue(ALICE.isSamePerson(editedAlice));
4949
}
5050

0 commit comments

Comments
 (0)