forked from AY2324S2-CS2103T-T08-1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NatLeong
committed
Mar 20, 2024
1 parent
9341aea
commit f1a2618
Showing
3 changed files
with
36 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,7 @@ | |
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.commons.exceptions.IllegalValueException; | ||
import seedu.address.model.person.Address; | ||
import seedu.address.model.person.DateOfBirth; | ||
import seedu.address.model.person.Name; | ||
import seedu.address.model.person.Nric; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.person.Sex; | ||
import seedu.address.model.person.Status; | ||
import seedu.address.model.person.*; | ||
|
||
|
||
public class JsonAdaptedPersonTest { | ||
|
@@ -33,6 +27,7 @@ public class JsonAdaptedPersonTest { | |
private static final String VALID_DOB = "2022-01-01"; | ||
private static final String VALID_SEX = BENSON.getSex().toString(); | ||
private static final String VALID_STATUS = BENSON.getStatus().toString(); | ||
private static final String VALID_EMAIL = "[email protected]"; | ||
@Test | ||
public void toModelType_validPersonDetails_returnsPerson() throws Exception { | ||
JsonAdaptedPerson person = new JsonAdaptedPerson(BENSON); | ||
|
@@ -43,7 +38,7 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { | |
public void toModelType_invalidNric_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(INVALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Nric.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -52,15 +47,15 @@ public void toModelType_invalidNric_throwsIllegalValueException() { | |
public void toModelType_nullNric_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(null, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
@Test | ||
public void toModelType_invalidName_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, INVALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Name.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -69,7 +64,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { | |
public void toModelType_nullName_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, null, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -78,7 +73,7 @@ public void toModelType_nullName_throwsIllegalValueException() { | |
public void toModelType_invalidPhone_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, INVALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Phone.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -87,7 +82,7 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { | |
public void toModelType_nullPhone_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, null, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -96,7 +91,7 @@ public void toModelType_nullPhone_throwsIllegalValueException() { | |
public void toModelType_invalidAddress_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
INVALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
INVALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Address.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -105,15 +100,15 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { | |
public void toModelType_nullAddress_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
null, VALID_DOB, VALID_SEX, VALID_STATUS); | ||
null, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
@Test | ||
public void toModelType_invalidDob_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, INVALID_DOB, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, INVALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = DateOfBirth.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -122,15 +117,15 @@ public void toModelType_invalidDob_throwsIllegalValueException() { | |
public void toModelType_nullDob_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, null, VALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, null, VALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
@Test | ||
public void toModelType_invalidSex_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, INVALID_SEX, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, INVALID_SEX, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Sex.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -139,15 +134,15 @@ public void toModelType_invalidSex_throwsIllegalValueException() { | |
public void toModelType_nullSex_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, null, VALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, null, VALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
@Test | ||
public void toModelType_invalidStatus_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, INVALID_STATUS); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, INVALID_STATUS, VALID_EMAIL); | ||
String expectedMessage = Status.MESSAGE_CONSTRAINTS; | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
@@ -156,10 +151,9 @@ public void toModelType_invalidStatus_throwsIllegalValueException() { | |
public void toModelType_nullStatus_throwsIllegalValueException() { | ||
JsonAdaptedPerson person = | ||
new JsonAdaptedPerson(VALID_NRIC, VALID_NAME, VALID_PHONE, | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, null); | ||
VALID_ADDRESS, VALID_DOB, VALID_SEX, null, VALID_EMAIL); | ||
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); | ||
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); | ||
} | ||
|
||
|
||
} |
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