Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
zoebelle-pang committed Mar 21, 2024
1 parent 5632538 commit d1f63e4
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PersonCard extends UiPart<Region> {
private Label grade;
@FXML
private Label subject;
@FXML
private Label attendance;
@FXML
private Label payment;
Expand Down Expand Up @@ -72,7 +73,7 @@ public PersonCard(Person person, int displayedIndex) {
.sorted(Comparator.comparing(dateTime -> dateTime.value))
.forEach(dateTime -> dateTimes.getChildren()
.add(new Label(LocalDateTime.parse(dateTime.value,
DateTimeFormatter.ofPattern("uuuu-MM-dd HHmm"))
DateTimeFormatter.ofPattern("uuuu-MM-dd HHmm"))
.format(DateTimeFormatter.ofPattern("MMM d uuuu h:mma")))));
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"address": "123, Jurong West Ave 6, #08-111",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-03-02 1800" ],
"tags": [ "friends" ]
}, {
Expand All @@ -14,6 +16,8 @@
"email": "pauline@example.com",
"grade": "A",
"subject": "Maths",
"attendance": "Present",
"payment": "Not Paid",
"dateTimes": [ "2024-03-21 1800" ],
"address": "4th street"
} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"address" : "123, Jurong West Ave 6, #08-111",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ ],
"tags" : [ "friends" ]
}, {
Expand All @@ -16,6 +18,8 @@
"address" : "311, Clementi Ave 2, #02-25",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ "owesMoney", "friends" ]
}, {
Expand All @@ -25,6 +29,8 @@
"address" : "wall street",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ ]
}, {
Expand All @@ -34,6 +40,8 @@
"address" : "10th street",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ "friends" ]
}, {
Expand All @@ -43,6 +51,8 @@
"address" : "michegan ave",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ ]
}, {
Expand All @@ -52,6 +62,8 @@
"address" : "little tokyo",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ ]
}, {
Expand All @@ -61,6 +73,8 @@
"address" : "4th street",
"grade": "A",
"subject": "English",
"attendance": "Present",
"payment": "Paid",
"dateTimes": [ "2024-02-03 1800" ],
"tags" : [ ]
} ]
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/seedu/address/logic/commands/CommandTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ATTENDANCE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRADE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PAYMENT;
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;
Expand Down Expand Up @@ -41,6 +43,10 @@ public class CommandTestUtil {
public static final String VALID_GRADE_BOB = "B-";
public static final String VALID_SUBJECT_AMY = "Mathematics";
public static final String VALID_SUBJECT_BOB = "English";
public static final String VALID_ATTENDANCE_PRESENT = "Present";
public static final String VALID_ATTENDANCE_ABSENT = "Absent";
public static final String VALID_PAYMENT_PAID = "Paid";
public static final String VALID_PAYMENT_UNPAID = "Not Paid";
public static final String VALID_DATETIME_MAR = "2024-03-04 1800";
public static final String VALID_DATETIME_FEB = "2024-02-03 1800";
public static final String VALID_TAG_HUSBAND = "husband";
Expand All @@ -58,6 +64,10 @@ public class CommandTestUtil {
public static final String GRADE_DESC_BOB = " " + PREFIX_GRADE + VALID_GRADE_BOB;
public static final String SUBJECT_DESC_AMY = " " + PREFIX_SUBJECT + VALID_SUBJECT_AMY;
public static final String SUBJECT_DESC_BOB = " " + PREFIX_SUBJECT + VALID_SUBJECT_BOB;
public static final String ATTENDANCE_DESC_PRESENT = " " + PREFIX_ATTENDANCE + VALID_ATTENDANCE_PRESENT;
public static final String ATTENDANCE_DESC_ABSENT = " " + PREFIX_ATTENDANCE + VALID_ATTENDANCE_ABSENT;
public static final String PAYMENT_DESC_PAID = " " + PREFIX_PAYMENT + VALID_PAYMENT_PAID;
public static final String PAYMENT_DESC_UNPAID = " " + PREFIX_PAYMENT + VALID_PAYMENT_UNPAID;
public static final String DATETIME_DESC_MAR = " " + PREFIX_DATETIME + VALID_DATETIME_MAR;
public static final String DATETIME_DESC_FEB = " " + PREFIX_DATETIME + VALID_DATETIME_FEB;

Expand All @@ -70,6 +80,9 @@ 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
+ "Prasent"; // 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
public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags
Expand Down
50 changes: 34 additions & 16 deletions src/test/java/seedu/address/logic/parser/AddCommandParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.ATTENDANCE_DESC_PRESENT;
import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_FEB;
import static seedu.address.logic.commands.CommandTestUtil.DATETIME_DESC_MAR;
import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY;
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.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_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 @@ -49,10 +54,12 @@
import seedu.address.logic.Messages;
import seedu.address.logic.commands.AddCommand;
import seedu.address.model.person.Address;
import seedu.address.model.person.Attendance;
import seedu.address.model.person.DateTime;
import seedu.address.model.person.Email;
import seedu.address.model.person.Grade;
import seedu.address.model.person.Name;
import seedu.address.model.person.Payment;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;
Expand Down Expand Up @@ -210,38 +217,48 @@ public void parse_compulsoryFieldMissing_failure() {
public void parse_invalidValue_failure() {
// invalid name
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Name.MESSAGE_CONSTRAINTS);
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + DATETIME_DESC_MAR
+ TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_CONSTRAINTS);

// invalid phone
assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Phone.MESSAGE_CONSTRAINTS);
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + DATETIME_DESC_MAR
+ TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS);

// invalid email
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Email.MESSAGE_CONSTRAINTS);
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + DATETIME_DESC_MAR
+ TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS);

// invalid address
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Address.MESSAGE_CONSTRAINTS);
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID + DATETIME_DESC_MAR
+ TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS);

// invalid grade
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ INVALID_GRADE_DESC + SUBJECT_DESC_BOB + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Grade.MESSAGE_CONSTRAINTS);
+ INVALID_GRADE_DESC + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID
+ 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 + DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
Subject.MESSAGE_CONSTRAINTS);
+ 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
+ DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Attendance.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
+ DATETIME_DESC_MAR + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Payment.MESSAGE_CONSTRAINTS);

// invalid dateTime
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + INVALID_DATETIME_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
DateTime.MESSAGE_CONSTRAINTS);
+ GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_PAID
+ INVALID_DATETIME_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, DateTime.MESSAGE_CONSTRAINTS);

// invalid tag
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
Expand All @@ -253,7 +270,8 @@ public void parse_invalidValue_failure() {

// non-empty preamble
assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
+ ADDRESS_DESC_BOB + GRADE_DESC_BOB + SUBJECT_DESC_BOB + DATETIME_DESC_FEB + TAG_DESC_HUSBAND
+ TAG_DESC_FRIEND, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
+ ADDRESS_DESC_BOB + GRADE_DESC_BOB + SUBJECT_DESC_BOB + ATTENDANCE_DESC_PRESENT + PAYMENT_DESC_UNPAID
+ DATETIME_DESC_FEB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}
}
39 changes: 39 additions & 0 deletions src/test/java/seedu/address/logic/parser/ParserUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Attendance;
import seedu.address.model.person.DateTime;
import seedu.address.model.person.Email;
import seedu.address.model.person.Grade;
import seedu.address.model.person.Name;
import seedu.address.model.person.Payment;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Subject;
import seedu.address.model.tag.Tag;
Expand All @@ -30,6 +32,8 @@ public class ParserUtilTest {
private static final String INVALID_EMAIL = "example.com";
private static final String INVALID_GRADE = "C++";
private static final String INVALID_SUBJECT = " ";
private static final String INVALID_ATTENDANCE = "Pressent";
private static final String INVALID_PAYMENT = "PAID50";
private static final String INVALID_DATETIME = "2024-02-31 2500";
private static final String INVALID_TAG = "#friend";

Expand All @@ -39,6 +43,8 @@ public class ParserUtilTest {
private static final String VALID_EMAIL = "rachel@example.com";
private static final String VALID_GRADE = "B-";
private static final String VALID_SUBJECT = "English";
private static final String VALID_ATTENDANCE = "Present";
private static final String VALID_PAYMENT = "Paid";
private static final String VALID_DATETIME_1 = "2024-02-03 1800";
private static final String VALID_DATETIME_2 = "2024-03-04 1900";
private static final String VALID_TAG_1 = "friend";
Expand Down Expand Up @@ -204,6 +210,39 @@ void parseSubject_validValueWithWhitespace_returnsTrimmedSubject() throws Except
assertEquals(expectedSubject, ParserUtil.parseSubject(subjectWithWhitespace));
}

@Test
public void parseAttendance_invalidValue_throwsParseException() {
assertThrows(ParseException.class, () -> ParserUtil.parseAttendance(INVALID_ATTENDANCE));
}
@Test
public void parseAttendance_validValueWithoutWhitespace_returnsSubject() throws Exception {
Attendance expectedAttendance = new Attendance(VALID_ATTENDANCE);
assertEquals(expectedAttendance, ParserUtil.parseAttendance(VALID_ATTENDANCE));
}

@Test
void parseAttendance_validValueWithWhitespace_returnsTrimmedAttendance() throws Exception {
String attendanceWithWhitespace = WHITESPACE + VALID_ATTENDANCE + WHITESPACE;
Attendance expectedAttendance = new Attendance(VALID_ATTENDANCE);
assertEquals(expectedAttendance, ParserUtil.parseAttendance(attendanceWithWhitespace));
}
@Test
public void parsePayment_invalidValue_throwsParseException() {
assertThrows(ParseException.class, () -> ParserUtil.parsePayment(INVALID_PAYMENT));
}
@Test
public void parsePayment_validValueWithoutWhitespace_returnsPayment() throws Exception {
Payment expectedPayment = new Payment(VALID_PAYMENT);
assertEquals(expectedPayment, ParserUtil.parsePayment(VALID_PAYMENT));
}

@Test
void parsePayment_validValueWithWhitespace_returnsTrimmedPayment() throws Exception {
String paymentWithWhitespace = WHITESPACE + VALID_PAYMENT + WHITESPACE;
Payment expectedPayment = new Payment(VALID_PAYMENT);
assertEquals(expectedPayment, ParserUtil.parsePayment(paymentWithWhitespace));
}

@Test
public void parseDateTime_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> ParserUtil.parseDateTime(null));
Expand Down
54 changes: 54 additions & 0 deletions src/test/java/seedu/address/model/person/AttendanceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package seedu.address.model.person;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;

import org.junit.jupiter.api.Test;

public class AttendanceTest {

@Test
public void constructor_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Attendance(null));
}

@Test
public void constructor_invalidAttendance_throwsIllegalArgumentException() {
String invalidAttendance = "On leave";
assertThrows(IllegalArgumentException.class, () -> new Attendance(invalidAttendance));
}

@Test
public void isValidAttendance() {
// null attendance
assertThrows(NullPointerException.class, () -> Attendance.isValidAttendance(null));

// invalid attendance
assertFalse(Attendance.isValidAttendance("On leave")); // Invalid status

// valid attendance
assertTrue(Attendance.isValidAttendance("Present"));
assertTrue(Attendance.isValidAttendance("Absent"));
}

@Test
public void equals() {
Attendance attendance = new Attendance("Present");

// same values -> returns true
assertTrue(attendance.equals(new Attendance("Present")));

// same object -> returns true
assertTrue(attendance.equals(attendance));

// null -> returns false
assertFalse(attendance.equals(null));

// different types -> returns false
assertFalse(attendance.equals(5.0f));

// different values -> returns false
assertFalse(attendance.equals(new Attendance("Absent")));
}
}
Loading

0 comments on commit d1f63e4

Please sign in to comment.