forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from cshao02/shaoheng/update-edit-telegram
Update edit telegram username
- Loading branch information
Showing
6 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import seedu.address.model.person.Email; | ||
import seedu.address.model.person.Name; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.person.TelegramUsername; | ||
import seedu.address.model.role.Role; | ||
import seedu.address.model.role.RoleHandler; | ||
|
||
|
@@ -26,12 +27,14 @@ public class ParserUtilTest { | |
private static final String INVALID_PHONE = "+651234"; | ||
private static final String INVALID_ADDRESS = " "; | ||
private static final String INVALID_EMAIL = "example.com"; | ||
private static final String INVALID_TELE = "a"; | ||
private static final String INVALID_ROLE = "owner"; | ||
|
||
private static final String VALID_NAME = "Rachel Walker"; | ||
private static final String VALID_PHONE = "123456"; | ||
private static final String VALID_ADDRESS = "123 Main Street #0505"; | ||
private static final String VALID_EMAIL = "[email protected]"; | ||
private static final String VALID_TELE = "rachel"; | ||
|
||
private static final String VALID_ROLE_1 = "vendor"; | ||
private static final String VALID_ROLE_2 = "sponsor"; | ||
|
@@ -150,6 +153,54 @@ public void parseEmail_validValueWithWhitespace_returnsTrimmedEmail() throws Exc | |
assertEquals(expectedEmail, ParserUtil.parseEmail(emailWithWhitespace)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnAdd_nullTelegramUsername() throws ParseException { | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(null); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnAdd(null)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnAdd_invalidTelegramUsername_throwsParseException() { | ||
assertThrows(ParseException.class, () -> ParserUtil.parseTeleOnAdd(INVALID_TELE)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnAdd_validValueWithWhitespace_returnsTrimmedTele() throws ParseException { | ||
String teleWithWhitespace = WHITESPACE + VALID_TELE + WHITESPACE; | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(VALID_TELE); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnAdd(teleWithWhitespace)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnAdd_validValueWithoutWhitespace_returnsTele() throws Exception { | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(VALID_TELE); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnAdd(VALID_TELE)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnEdit_emptyTelegramUsername_removesTele() throws ParseException { | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(null); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnEdit("")); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnEdit_invalidTelegramUsername_throwsParseException() { | ||
assertThrows(ParseException.class, () -> ParserUtil.parseTeleOnEdit(INVALID_TELE)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnEdit_validValueWithWhitespace_returnsTrimmedTele() throws ParseException { | ||
String teleWithWhitespace = WHITESPACE + VALID_TELE + WHITESPACE; | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(VALID_TELE); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnEdit(teleWithWhitespace)); | ||
} | ||
|
||
@Test | ||
public void parseTeleOnEdit_validValueWithoutWhitespace_returnsTele() throws Exception { | ||
TelegramUsername expectedTelegramUsername = new TelegramUsername(VALID_TELE); | ||
assertEquals(expectedTelegramUsername, ParserUtil.parseTeleOnEdit(VALID_TELE)); | ||
} | ||
|
||
@Test | ||
public void parseRole_null_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> ParserUtil.parseRole((String) null)); | ||
|