From eee1c9a4fd9e90dbbaa7dfc899ca5573b9b79dd4 Mon Sep 17 00:00:00 2001 From: zoebelle-pang Date: Thu, 21 Mar 2024 03:20:51 +0800 Subject: [PATCH] add attendance and payment update 1.1 --- .../logic/commands/CommandTestUtil.java | 4 +- .../logic/parser/AddCommandParserTest.java | 15 ++++--- .../storage/JsonAdaptedPersonTest.java | 40 +++++++++---------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 2bbe160eb69..8054aa7d674 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -12,7 +12,6 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_SUBJECT; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; @@ -80,7 +79,8 @@ public class CommandTestUtil { public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses public static final String INVALID_GRADE_DESC = " " + PREFIX_GRADE + "C++"; // extra + not allowed public static final String INVALID_SUBJECT_DESC = " " + PREFIX_SUBJECT; // empty string not allowed for subject - public static final String INVALID_ATTENDANCE_DESC = " " + PREFIX_ATTENDANCE + "Presentt"; // extra characters not allowed + public static final String INVALID_ATTENDANCE_DESC = " " + PREFIX_ATTENDANCE + + "Presentt"; // extra characters not allowed public static final String INVALID_PAYMENT_DESC = " " + PREFIX_PAYMENT + "paid1"; // numbers not allowed public static final String INVALID_DATETIME_DESC = " " + PREFIX_DATETIME + "2024-02-31 1800"; // invalid date not allowed in tags diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 7c2c2877e0b..866e6dd80da 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -10,21 +10,20 @@ import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.GRADE_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.GRADE_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.PAYMENT_DESC_PAID; -import static seedu.address.logic.commands.CommandTestUtil.PAYMENT_DESC_UNPAID; import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_ATTENDANCE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATETIME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_GRADE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PAYMENT_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_SUBJECT_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PAYMENT_DESC_PAID; +import static seedu.address.logic.commands.CommandTestUtil.PAYMENT_DESC_UNPAID; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY; @@ -234,7 +233,7 @@ public void parse_invalidValue_failure() { // invalid phone assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_UNPAID+ DATETIME_DESC_MAR + + GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_UNPAID + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS); // invalid email @@ -250,21 +249,21 @@ public void parse_invalidValue_failure() { // invalid grade assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INVALID_GRADE_DESC + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID - +DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Grade.MESSAGE_CONSTRAINTS); + + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Grade.MESSAGE_CONSTRAINTS); // invalid subject assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + GRADE_DESC_BOB + INVALID_SUBJECT_DESC + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + + GRADE_DESC_BOB + INVALID_SUBJECT_DESC + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Subject.MESSAGE_CONSTRAINTS); // invalid attendance assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + GRADE_DESC_BOB + SUBJECT_DESC_BOB + INVALID_ATTENDANCE_DESC + PAYMENT_DESC_PAID + + GRADE_DESC_BOB + SUBJECT_DESC_BOB + INVALID_ATTENDANCE_DESC + PAYMENT_DESC_PAID + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Subject.MESSAGE_CONSTRAINTS); // invalid payment assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + INVALID_PAYMENT_DESC + + GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + INVALID_PAYMENT_DESC + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Subject.MESSAGE_CONSTRAINTS); // invalid dateTime diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index cba8dea373d..50f8f2a5775 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -29,8 +29,8 @@ public class JsonAdaptedPersonTest { private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_GRADE = "E"; private static final String INVALID_SUBJECT = " "; - private static final String INVALID_ATTENDANCE= "MC"; - private static final String INVALID_PAYMENT= "500"; + private static final String INVALID_ATTENDANCE = "MC"; + private static final String INVALID_PAYMENT = "500"; private static final String INVALID_DATETIME = "2024-02-31 2500"; private static final String INVALID_TAG = "#friend"; @@ -59,7 +59,7 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { public void toModelType_invalidName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Name.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -67,7 +67,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { @Test public void toModelType_nullName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -76,7 +76,7 @@ public void toModelType_nullName_throwsIllegalValueException() { public void toModelType_invalidPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -84,7 +84,7 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { @Test public void toModelType_nullPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -93,7 +93,7 @@ public void toModelType_nullPhone_throwsIllegalValueException() { public void toModelType_invalidEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Email.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -101,7 +101,7 @@ public void toModelType_invalidEmail_throwsIllegalValueException() { @Test public void toModelType_nullEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -110,7 +110,7 @@ public void toModelType_nullEmail_throwsIllegalValueException() { public void toModelType_invalidAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Address.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -118,7 +118,7 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { @Test public void toModelType_nullAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -127,7 +127,7 @@ public void toModelType_nullAddress_throwsIllegalValueException() { public void toModelType_invalidGrade_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - INVALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + INVALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Grade.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -135,7 +135,7 @@ public void toModelType_invalidGrade_throwsIllegalValueException() { @Test public void toModelType_nullGrade_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - null, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + null, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Grade.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -144,7 +144,7 @@ public void toModelType_nullGrade_throwsIllegalValueException() { public void toModelType_invalidSubject_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, INVALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, INVALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Subject.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -152,7 +152,7 @@ public void toModelType_invalidSubject_throwsIllegalValueException() { @Test public void toModelType_nullSubject_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, null,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, null, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Subject.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -160,7 +160,7 @@ public void toModelType_nullSubject_throwsIllegalValueException() { @Test public void toModelType_invalidAttendance_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,INVALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, INVALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Attendance.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -168,7 +168,7 @@ public void toModelType_invalidAttendance_throwsIllegalValueException() { @Test public void toModelType_nullAttendance_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,null, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, null, VALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Attendance.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -176,7 +176,7 @@ public void toModelType_nullAttendance_throwsIllegalValueException() { @Test public void toModelType_invalidPayment_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,INVALID_ATTENDANCE, INVALID_PAYMENT, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, INVALID_ATTENDANCE, INVALID_PAYMENT, VALID_DATETIME, VALID_TAGS); String expectedMessage = Payment.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -184,7 +184,7 @@ public void toModelType_invalidPayment_throwsIllegalValueException() { @Test public void toModelType_nullPayment_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, null, VALID_DATETIME, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, null, VALID_DATETIME, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Payment.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -196,7 +196,7 @@ public void toModelType_invalidDateTimes_throwsIllegalValueException() { invalidDateTimes.add(new JsonAdaptedDateTime(INVALID_DATETIME)); JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, invalidDateTimes, VALID_TAGS); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, invalidDateTimes, VALID_TAGS); assertThrows(IllegalValueException.class, person::toModelType); } @@ -206,7 +206,7 @@ public void toModelType_invalidTags_throwsIllegalValueException() { invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_GRADE, VALID_SUBJECT,VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, invalidTags); + VALID_GRADE, VALID_SUBJECT, VALID_ATTENDANCE, VALID_PAYMENT, VALID_DATETIME, invalidTags); assertThrows(IllegalValueException.class, person::toModelType); }