Skip to content

Commit

Permalink
Add test for null key milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
jx124 committed Nov 8, 2023
1 parent 7663905 commit b22f234
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public void toModelType_nullPhone_throwsIllegalValueException() {
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}
//uncomment later
@Test
public void toModelType_nullPhoneWithValidKeyMilestone_throwsIllegalValueException() {
JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_TYPE,
Expand Down Expand Up @@ -142,7 +141,6 @@ public void toModelType_nullAddress_throwsIllegalValueException() {

@Test
public void toModelType_invalidType_throwsIllegalValueException() {
//todo: this test need to be fixed, the exception thrown is for meeting type, not for type
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_TYPE, VALID_ADDRESS,
CLIENT_KEYMILESTONE_NULL, VALID_MEETING_TIME, VALID_TAGS);
Expand Down Expand Up @@ -174,6 +172,7 @@ public void toModelType_leadWithInvalidKeyMilestone_throwsIllegalValueException(
VALID_MEETING_TIME, VALID_TAGS);
assertThrows(IllegalValueException.class, person::toModelType);
}

@Test
public void toModelType_invalidTagsWithValidKeyMilestone_throwsIllegalValueException() {
List<JsonAdaptedTag> invalidTags = new ArrayList<>(VALID_TAGS);
Expand All @@ -195,18 +194,25 @@ public void toModelType_invalidMeetingTime_throwsIllegalValueException() {

@Test
public void toModelType_invalidKeyMilestone_throwsIllegalValueException() {
//the meeting time is invalid, need to fix
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, TYPE_LEAD,
VALID_ADDRESS, VALID_KEYMILESTONE, VALID_MEETING_TIME, VALID_TAGS);
String expectedMessage = KeyMilestone.MESSAGE_CONSTRAINTS;
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_nullKeyMilestone_throwsIllegalValueException() {
JsonAdaptedPerson person =
new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, TYPE_LEAD,
VALID_ADDRESS, null, VALID_MEETING_TIME, VALID_TAGS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
KeyMilestone.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}

@Test
public void toModelType_validKeyMilestone_returnsPerson() throws Exception {
//the meeting time is invalid, need to fix
final List<JsonAdaptedTag> validTagBob = BOB.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList());
Expand Down

0 comments on commit b22f234

Please sign in to comment.