Skip to content

Commit

Permalink
add attendance and payment update 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zoebelle-pang committed Mar 20, 2024
1 parent 485bb06 commit eee1c9a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
40 changes: 20 additions & 20 deletions src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -59,15 +59,15 @@ 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);
}

@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);
}
Expand All @@ -76,15 +76,15 @@ 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);
}

@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);
}
Expand All @@ -93,15 +93,15 @@ 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);
}

@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);
}
Expand All @@ -110,15 +110,15 @@ 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);
}

@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);
}
Expand All @@ -127,15 +127,15 @@ 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);
}

@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);
}
Expand All @@ -144,47 +144,47 @@ 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);
}

@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);
}

@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);
}

@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);
}

@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);
}

@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);
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit eee1c9a

Please sign in to comment.