Skip to content

Commit

Permalink
fix: update TypicalPersons to fix Test errors
Browse files Browse the repository at this point in the history
TypicalPersons had invalid values which caused Test Cases to fail.
Update TypicalPersons and Default Values to pass test cases.
  • Loading branch information
jovantanyk committed Mar 20, 2024
1 parent de86e72 commit 99b2bb7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/Nric.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Nric {
* The first character of the address must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = "^[ST]\\\\d{7}[A-Z]$";
public static final String VALIDATION_REGEX = "^[ST]\\d{7}[A-Z]$";

private final String nric;

Expand Down
11 changes: 5 additions & 6 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public JsonAdaptedPerson(@JsonProperty("nric") String nric, @JsonProperty("name"
@JsonProperty("status") String status, @JsonProperty("email") String email,
@JsonProperty("country") String country, @JsonProperty("allergies") String allergies,
@JsonProperty("bloodType") String bloodType, @JsonProperty("condition") String condition,
@JsonProperty("dateOfAdmission") String doa,
@JsonProperty("diagnosis") String diagnosis,
@JsonProperty("dateOfAdmission") String doa, @JsonProperty("diagnosis") String diagnosis,
@JsonProperty("symptom") String symptom) {
this.nric = nric;
this.name = name;
Expand Down Expand Up @@ -84,7 +83,7 @@ public JsonAdaptedPerson(Person source) {
this.phone = source.getPhone().toString();
this.address = source.getAddress().toString();
this.dateOfBirth = source.getDateOfBirth().toString();
this.sex = source.getEmail().toString();
this.sex = source.getSex().toString();
this.status = source.getStatus().toString();
this.email = Optional.ofNullable(source.getEmail().toString());
this.country = Optional.ofNullable(source.getCountry().toString());
Expand Down Expand Up @@ -139,11 +138,11 @@ public Person toModelType() throws IllegalValueException {
final Address modelAddress = new Address(address);
// Date of Birth Check
if (dateOfBirth == null) {
throw new IllegalValueException(
String.format(MISSING_FIELD_MESSAGE_FORMAT, DateOfBirth.class.getSimpleName()));
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
DateOfBirth.class.getSimpleName()));
}
if (!DateOfBirth.isValidDateOfBirth(dateOfBirth)) {
throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS);
throw new IllegalValueException(DateOfBirth.MESSAGE_CONSTRAINTS);
}
final DateOfBirth modelDateOfBirth = new DateOfBirth(dateOfBirth);
// Sex Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void toModelType_nullNric_throwsIllegalValueException() {
VALID_ADDRESS, VALID_DOB, VALID_SEX, VALID_STATUS, VALID_EMAIL, VALID_COUNTRY,
VALID_ALLERGIES, VALID_BLOODTYPE, VALID_CONDITION, VALID_DOA, VALID_DIAGNOSIS,
VALID_SYMPTOM);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName());
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Nric.class.getSimpleName());
assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
}
@Test
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/seedu/address/testutil/TypicalPersons.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ public class TypicalPersons {
.withName("Daniel Meier").withPhone("87652533")
.withAddress("10th street").withSex("M").withStatus("HEALTHY").build();
public static final Person ELLE = new PersonBuilder().withNric("S8913957B")
.withName("Elle Meyer").withPhone("9482224")
.withName("Elle Meyer").withPhone("94821224")
.withAddress("michegan ave").withSex("F").withStatus("UNWELL").build();
public static final Person FIONA = new PersonBuilder().withNric("T0536171Z")
.withName("Fiona Kunz").withPhone("9482427")
.withName("Fiona Kunz").withPhone("94820427")
.withAddress("little tokyo").withSex("F").withStatus("PENDING").build();
public static final Person GEORGE = new PersonBuilder().withNric("T0829102Z")
.withName("George Best").withPhone("9482442")
.withName("George Best").withPhone("94824421")
.withAddress("4th street").withSex("M").withStatus("HEALTHY").build();

// Manually added
public static final Person HOON = new PersonBuilder().withNric("T0123071C").withName("Hoon Meier")
.withPhone("8482424").withAddress("little india")
.withPhone("81482424").withAddress("little india")
.withSex("M").withStatus("HEALTHY").build();
public static final Person IDA = new PersonBuilder().withNric("T0239521A").withName("Ida Mueller")
.withPhone("8482131").withAddress("chicago ave")
.withPhone("84820131").withAddress("chicago ave")
.withSex("F").withStatus("PENDING").build();

// Manually added - Person's details found in {@code CommandTestUtil}
Expand Down

0 comments on commit 99b2bb7

Please sign in to comment.