From 953dbeed76712a38d0b0c40d60ba81a884069a33 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Fri, 13 Oct 2023 23:14:46 +0800 Subject: [PATCH 01/14] Implement tag feature and enum class StudentRank.java --- .../address/logic/parser/ParserUtil.java | 13 +++++++-- .../seedu/address/model/tag/StudentRank.java | 10 +++++++ .../java/seedu/address/model/tag/Tag.java | 19 ++++++------ .../address/model/util/SampleDataUtil.java | 29 ++++++++++--------- .../seedu/address/storage/JsonAdaptedTag.java | 15 +++++----- .../java/seedu/address/ui/PersonCard.java | 4 +-- .../seedu/address/testutil/PersonBuilder.java | 3 +- 7 files changed, 58 insertions(+), 35 deletions(-) create mode 100644 src/main/java/seedu/address/model/tag/StudentRank.java diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..518c9b3f482 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -13,6 +13,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** @@ -96,7 +97,7 @@ public static Email parseEmail(String email) throws ParseException { } /** - * Parses a {@code String tag} into a {@code Tag}. + * Parses a {@code StudentRank tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. * * @throws ParseException if the given {@code tag} is invalid. @@ -107,7 +108,15 @@ public static Tag parseTag(String tag) throws ParseException { if (!Tag.isValidTagName(trimmedTag)) { throw new ParseException(Tag.MESSAGE_CONSTRAINTS); } - return new Tag(trimmedTag); + if (trimmedTag.equals(StudentRank.GOOD.toString())) { + return new Tag(StudentRank.GOOD); + } else if (trimmedTag.equals(StudentRank.POOR.toString())) { + return new Tag(StudentRank.POOR); + } else if (trimmedTag.equals(StudentRank.AVERAGE.toString())) { + return new Tag(StudentRank.AVERAGE); + } else { + throw new ParseException(Tag.MESSAGE_CONSTRAINTS_ENUMS); + } } /** diff --git a/src/main/java/seedu/address/model/tag/StudentRank.java b/src/main/java/seedu/address/model/tag/StudentRank.java new file mode 100644 index 00000000000..d8a0c5735f3 --- /dev/null +++ b/src/main/java/seedu/address/model/tag/StudentRank.java @@ -0,0 +1,10 @@ +package seedu.address.model.tag; + +/** + * Enumeration representing the ranking of a student's performance. + */ +public enum StudentRank { + GOOD, + AVERAGE, + POOR +} diff --git a/src/main/java/seedu/address/model/tag/Tag.java b/src/main/java/seedu/address/model/tag/Tag.java index f1a0d4e233b..26cb66df79d 100644 --- a/src/main/java/seedu/address/model/tag/Tag.java +++ b/src/main/java/seedu/address/model/tag/Tag.java @@ -10,19 +10,20 @@ public class Tag { public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; + public static final String MESSAGE_CONSTRAINTS_ENUMS = "Tags names should be GOOD/AVERAGE/POOR"; public static final String VALIDATION_REGEX = "\\p{Alnum}+"; - public final String tagName; + public final StudentRank ranking; /** * Constructs a {@code Tag}. * - * @param tagName A valid tag name. + * @param ranking A valid tag name. */ - public Tag(String tagName) { - requireNonNull(tagName); - checkArgument(isValidTagName(tagName), MESSAGE_CONSTRAINTS); - this.tagName = tagName; + public Tag(StudentRank ranking) { + requireNonNull(ranking); + checkArgument(isValidTagName(ranking.toString()), MESSAGE_CONSTRAINTS); + this.ranking = ranking; } /** @@ -44,19 +45,19 @@ public boolean equals(Object other) { } Tag otherTag = (Tag) other; - return tagName.equals(otherTag.tagName); + return ranking.toString().equals(otherTag.ranking.toString()); } @Override public int hashCode() { - return tagName.hashCode(); + return ranking.hashCode(); } /** * Format state as text for viewing. */ public String toString() { - return '[' + tagName + ']'; + return '[' + ranking.toString() + ']'; } } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..4234355520d 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,6 +11,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** @@ -20,23 +21,23 @@ public class SampleDataUtil { public static Person[] getSamplePersons() { return new Person[] { new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Address("Blk 30 Geylang Street 29, #06-40"), - getTagSet("friends")), + new Address("Blk 30 Geylang Street 29, #06-40"), + getTagSet(StudentRank.GOOD)), new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet("colleagues", "friends")), + new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + getTagSet(StudentRank.POOR, StudentRank.AVERAGE)), new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet("neighbours")), + new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + getTagSet(StudentRank.POOR)), new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - getTagSet("family")), + new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), + getTagSet(StudentRank.AVERAGE)), new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet("classmates")), + new Address("Blk 47 Tampines Street 20, #17-35"), + getTagSet(StudentRank.GOOD)), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Address("Blk 45 Aljunied Street 85, #11-31"), - getTagSet("colleagues")) + new Address("Blk 45 Aljunied Street 85, #11-31"), + getTagSet(StudentRank.GOOD)) }; } @@ -51,8 +52,8 @@ public static ReadOnlyAddressBook getSampleAddressBook() { /** * Returns a tag set containing the list of strings given. */ - public static Set getTagSet(String... strings) { - return Arrays.stream(strings) + public static Set getTagSet(StudentRank... ranking) { + return Arrays.stream(ranking) .map(Tag::new) .collect(Collectors.toSet()); } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java index 0df22bdb754..65d8031a4ee 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonValue; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** @@ -11,26 +12,26 @@ */ class JsonAdaptedTag { - private final String tagName; + private final StudentRank ranking; /** * Constructs a {@code JsonAdaptedTag} with the given {@code tagName}. */ @JsonCreator - public JsonAdaptedTag(String tagName) { - this.tagName = tagName; + public JsonAdaptedTag(StudentRank ranking) { + this.ranking = ranking; } /** * Converts a given {@code Tag} into this class for Jackson use. */ public JsonAdaptedTag(Tag source) { - tagName = source.tagName; + ranking = source.ranking; } @JsonValue public String getTagName() { - return tagName; + return ranking.toString(); } /** @@ -39,10 +40,10 @@ public String getTagName() { * @throws IllegalValueException if there were any data constraints violated in the adapted tag. */ public Tag toModelType() throws IllegalValueException { - if (!Tag.isValidTagName(tagName)) { + if (!Tag.isValidTagName(ranking.toString())) { throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS); } - return new Tag(tagName); + return new Tag(ranking); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 094c42cda82..b402af058cd 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -53,7 +53,7 @@ public PersonCard(Person person, int displayedIndex) { address.setText(person.getAddress().value); email.setText(person.getEmail().value); person.getTags().stream() - .sorted(Comparator.comparing(tag -> tag.tagName)) - .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + .sorted(Comparator.comparing(tag -> tag.ranking)) + .forEach(tag -> tags.getChildren().add(new Label(tag.ranking.toString()))); } } diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 6be381d39ba..03afc759de5 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -8,6 +8,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; @@ -60,7 +61,7 @@ public PersonBuilder withName(String name) { /** * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. */ - public PersonBuilder withTags(String ... tags) { + public PersonBuilder withTags(StudentRank... tags) { this.tags = SampleDataUtil.getTagSet(tags); return this; } From 4ed6841ae2687621a4d04e274b97e04e305ce281 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Fri, 13 Oct 2023 23:41:30 +0800 Subject: [PATCH 02/14] Edit test cases --- .../logic/commands/CommandTestUtil.java | 13 ++++---- .../logic/commands/EditCommandTest.java | 6 ++-- .../commands/EditPersonDescriptorTest.java | 4 +-- .../logic/parser/AddCommandParserTest.java | 30 +++++++++---------- .../logic/parser/EditCommandParserTest.java | 28 ++++++++--------- .../address/logic/parser/ParserUtilTest.java | 15 +++++----- .../seedu/address/model/AddressBookTest.java | 6 ++-- .../address/model/person/PersonTest.java | 6 ++-- .../model/person/UniquePersonListTest.java | 6 ++-- .../java/seedu/address/model/tag/TagTest.java | 2 +- .../storage/JsonAdaptedPersonTest.java | 19 ++++++------ .../testutil/EditPersonDescriptorBuilder.java | 3 +- .../seedu/address/testutil/PersonUtil.java | 4 +-- .../address/testutil/TypicalPersons.java | 15 +++++----- 14 files changed, 81 insertions(+), 76 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 643a1d08069..1ec8fb67eaa 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -19,6 +19,7 @@ import seedu.address.model.Model; import seedu.address.model.person.NameContainsKeywordsPredicate; import seedu.address.model.person.Person; +import seedu.address.model.tag.StudentRank; import seedu.address.testutil.EditPersonDescriptorBuilder; /** @@ -34,8 +35,8 @@ public class CommandTestUtil { public static final String VALID_EMAIL_BOB = "bob@example.com"; public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; - public static final String VALID_TAG_HUSBAND = "husband"; - public static final String VALID_TAG_FRIEND = "friend"; + public static final StudentRank VALID_TAG_AVERAGE = StudentRank.AVERAGE; + public static final StudentRank VALID_TAG_GOOD = StudentRank.GOOD; public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY; public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB; @@ -45,8 +46,8 @@ public class CommandTestUtil { public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; - public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; - public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; + public static final String TAG_DESC_AVERAGE = " " + PREFIX_TAG + VALID_TAG_AVERAGE; + public static final String TAG_DESC_GOOD = " " + PREFIX_TAG + VALID_TAG_GOOD; public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones @@ -63,10 +64,10 @@ public class CommandTestUtil { static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withTags(VALID_TAG_FRIEND).build(); + .withTags(VALID_TAG_AVERAGE).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) - .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withTags(VALID_TAG_GOOD).build(); } /** diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 469dd97daa7..b84cb03edaf 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -7,7 +7,7 @@ import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; @@ -56,10 +56,10 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { PersonBuilder personInList = new PersonBuilder(lastPerson); Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withTags(VALID_TAG_HUSBAND).build(); + .withTags(VALID_TAG_AVERAGE).build(); EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) - .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); + .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_AVERAGE).build(); EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java index b17c1f3d5c2..93447b5d0f8 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java @@ -9,7 +9,7 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import org.junit.jupiter.api.Test; @@ -53,7 +53,7 @@ public void equals() { assertFalse(DESC_AMY.equals(editedAmy)); // different tags -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); + editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_GOOD).build(); assertFalse(DESC_AMY.equals(editedAmy)); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 5bc11d3cdaa..beca588dff0 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -16,14 +16,14 @@ import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; -import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_GOOD; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; @@ -50,25 +50,25 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); + Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_GOOD).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_AVERAGE, new AddCommand(expectedPerson)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) + Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_AVERAGE) .build(); assertParseSuccess(parser, - NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_GOOD + TAG_DESC_AVERAGE, new AddCommand(expectedPersonMultipleTags)); } @Test public void parse_repeatedNonTagValue_failure() { String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND; + + ADDRESS_DESC_BOB + TAG_DESC_AVERAGE; // multiple names assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString, @@ -166,23 +166,23 @@ 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 - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_CONSTRAINTS); + + TAG_DESC_GOOD + TAG_DESC_AVERAGE, Name.MESSAGE_CONSTRAINTS); // invalid phone assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS); + + TAG_DESC_GOOD + TAG_DESC_AVERAGE, Phone.MESSAGE_CONSTRAINTS); // invalid email assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS); + + TAG_DESC_GOOD + TAG_DESC_AVERAGE, Email.MESSAGE_CONSTRAINTS); // invalid address assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); + + TAG_DESC_GOOD + TAG_DESC_AVERAGE, Address.MESSAGE_CONSTRAINTS); // invalid tag assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS); + + INVALID_TAG_DESC + VALID_TAG_AVERAGE, Tag.MESSAGE_CONSTRAINTS); // two invalid values, only first invalid value reported assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC, @@ -190,7 +190,7 @@ 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 + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + + ADDRESS_DESC_BOB + TAG_DESC_AVERAGE + TAG_DESC_GOOD, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } } diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index cc7175172d4..1a32449706e 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -13,15 +13,15 @@ import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; 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.TAG_DESC_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_AVERAGE; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; @@ -94,9 +94,9 @@ public void parse_invalidValue_failure() { // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Person} being edited, // parsing it together with a valid tag results in error - assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_DESC_HUSBAND + TAG_EMPTY, Tag.MESSAGE_CONSTRAINTS); - assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_EMPTY + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); - assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, "1" + TAG_DESC_GOOD + TAG_DESC_AVERAGE + TAG_EMPTY, Tag.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, "1" + TAG_DESC_GOOD + TAG_EMPTY + TAG_DESC_AVERAGE, Tag.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_GOOD + TAG_DESC_AVERAGE, Tag.MESSAGE_CONSTRAINTS); // multiple invalid values, but only the first invalid value is captured assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + VALID_PHONE_AMY, @@ -106,12 +106,12 @@ public void parse_invalidValue_failure() { @Test public void parse_allFieldsSpecified_success() { Index targetIndex = INDEX_SECOND_PERSON; - String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; + String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_AVERAGE + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_AVERAGE; EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withTags(VALID_TAG_AVERAGE, VALID_TAG_GOOD).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -157,8 +157,8 @@ public void parse_oneFieldSpecified_success() { assertParseSuccess(parser, userInput, expectedCommand); // tags - userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; - descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); + userInput = targetIndex.getOneBased() + TAG_DESC_GOOD; + descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_GOOD).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); } @@ -181,8 +181,8 @@ public void parse_multipleRepeatedFields_failure() { // mulltiple valid fields repeated userInput = targetIndex.getOneBased() + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY - + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND - + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND; + + TAG_DESC_GOOD + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_GOOD + + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_AVERAGE; assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..451d7509417 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -18,6 +18,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; public class ParserUtilTest { @@ -25,14 +26,14 @@ public class ParserUtilTest { private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; - private static final String INVALID_TAG = "#friend"; + private static final StudentRank INVALID_TAG = null; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; private static final String VALID_ADDRESS = "123 Main Street #0505"; private static final String VALID_EMAIL = "rachel@example.com"; - private static final String VALID_TAG_1 = "friend"; - private static final String VALID_TAG_2 = "neighbour"; + private static final StudentRank VALID_TAG_1 = StudentRank.GOOD; + private static final StudentRank VALID_TAG_2 = StudentRank.AVERAGE; private static final String WHITESPACE = " \t\r\n"; @@ -155,13 +156,13 @@ public void parseTag_null_throwsNullPointerException() { @Test public void parseTag_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTag(INVALID_TAG)); + assertThrows(ParseException.class, () -> ParserUtil.parseTag(INVALID_TAG.toString())); } @Test public void parseTag_validValueWithoutWhitespace_returnsTag() throws Exception { Tag expectedTag = new Tag(VALID_TAG_1); - assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1)); + assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1.toString())); } @Test @@ -178,7 +179,7 @@ public void parseTags_null_throwsNullPointerException() { @Test public void parseTags_collectionWithInvalidTags_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, INVALID_TAG))); + assertThrows(ParseException.class, () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1.toString(), INVALID_TAG.toString()))); } @Test @@ -188,7 +189,7 @@ public void parseTags_emptyCollection_returnsEmptySet() throws Exception { @Test public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception { - Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, VALID_TAG_2)); + Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1.toString(), VALID_TAG_2.toString())); Set expectedTagSet = new HashSet(Arrays.asList(new Tag(VALID_TAG_1), new Tag(VALID_TAG_2))); assertEquals(expectedTagSet, actualTagSet); diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 68c8c5ba4d5..035b6f74a9b 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; @@ -46,7 +46,7 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { @Test public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { // Two persons with the same identity fields - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE) .build(); List newPersons = Arrays.asList(ALICE, editedAlice); AddressBookStub newData = new AddressBookStub(newPersons); @@ -73,7 +73,7 @@ public void hasPerson_personInAddressBook_returnsTrue() { @Test public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { addressBook.addPerson(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE) .build(); assertTrue(addressBook.hasPerson(editedAlice)); } diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 31a10d156c9..2726b9a7663 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -7,7 +7,7 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BOB; @@ -34,7 +34,7 @@ public void isSamePerson() { // same name, all other attributes different -> returns true Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) - .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); + .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE).build(); assertTrue(ALICE.isSamePerson(editedAlice)); // different name, all other attributes same -> returns false @@ -86,7 +86,7 @@ public void equals() { assertFalse(ALICE.equals(editedAlice)); // different tags -> returns false - editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); + editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_AVERAGE).build(); assertFalse(ALICE.equals(editedAlice)); } diff --git a/src/test/java/seedu/address/model/person/UniquePersonListTest.java b/src/test/java/seedu/address/model/person/UniquePersonListTest.java index 17ae501df08..a1ed3bb8cab 100644 --- a/src/test/java/seedu/address/model/person/UniquePersonListTest.java +++ b/src/test/java/seedu/address/model/person/UniquePersonListTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BOB; @@ -42,7 +42,7 @@ public void contains_personInList_returnsTrue() { @Test public void contains_personWithSameIdentityFieldsInList_returnsTrue() { uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE) .build(); assertTrue(uniquePersonList.contains(editedAlice)); } @@ -85,7 +85,7 @@ public void setPerson_editedPersonIsSamePerson_success() { @Test public void setPerson_editedPersonHasSameIdentity_success() { uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE) .build(); uniquePersonList.setPerson(ALICE, editedAlice); UniquePersonList expectedUniquePersonList = new UniquePersonList(); diff --git a/src/test/java/seedu/address/model/tag/TagTest.java b/src/test/java/seedu/address/model/tag/TagTest.java index 64d07d79ee2..9c803113391 100644 --- a/src/test/java/seedu/address/model/tag/TagTest.java +++ b/src/test/java/seedu/address/model/tag/TagTest.java @@ -13,7 +13,7 @@ public void constructor_null_throwsNullPointerException() { @Test public void constructor_invalidTagName_throwsIllegalArgumentException() { - String invalidTagName = ""; + StudentRank invalidTagName = null; assertThrows(IllegalArgumentException.class, () -> new Tag(invalidTagName)); } diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index 83b11331cdb..bda52e2259a 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -16,13 +16,14 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; public class JsonAdaptedPersonTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; - private static final String INVALID_TAG = "#friend"; + private static final StudentRank INVALID_TAG = null; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); @@ -98,13 +99,13 @@ public void toModelType_nullAddress_throwsIllegalValueException() { assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } - @Test - public void toModelType_invalidTags_throwsIllegalValueException() { - List invalidTags = new ArrayList<>(VALID_TAGS); - invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); - assertThrows(IllegalValueException.class, person::toModelType); - } +// @Test +// public void toModelType_invalidTags_throwsIllegalValueException() { +// List invalidTags = new ArrayList<>(VALID_TAGS); +// invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); +// JsonAdaptedPerson person = +// new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); +// assertThrows(IllegalValueException.class, person::toModelType); +// } } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e..dea1316dfdc 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -10,6 +10,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** @@ -75,7 +76,7 @@ public EditPersonDescriptorBuilder withAddress(String address) { * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} * that we are building. */ - public EditPersonDescriptorBuilder withTags(String... tags) { + public EditPersonDescriptorBuilder withTags(StudentRank... tags) { Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); descriptor.setTags(tagSet); return this; diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 90849945183..444b1c4e071 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -35,7 +35,7 @@ public static String getPersonDetails(Person person) { sb.append(PREFIX_EMAIL + person.getEmail().value + " "); sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); person.getTags().stream().forEach( - s -> sb.append(PREFIX_TAG + s.tagName + " ") + s -> sb.append(PREFIX_TAG + s.ranking.toString() + " ") ); return sb.toString(); } @@ -54,7 +54,7 @@ public static String getEditPersonDescriptorDetails(EditPersonDescriptor descrip if (tags.isEmpty()) { sb.append(PREFIX_TAG); } else { - tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" ")); + tags.forEach(s -> sb.append(PREFIX_TAG).append(s.ranking).append(" ")); } } return sb.toString(); diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index fec76fb7129..d84e65c36dc 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -8,8 +8,8 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import java.util.ArrayList; import java.util.Arrays; @@ -17,6 +17,7 @@ import seedu.address.model.AddressBook; import seedu.address.model.person.Person; +import seedu.address.model.tag.StudentRank; /** * A utility class containing a list of {@code Person} objects to be used in tests. @@ -26,15 +27,15 @@ public class TypicalPersons { public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") .withPhone("94351253") - .withTags("friends").build(); + .withTags(StudentRank.AVERAGE).build(); public static final Person BENSON = new PersonBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") .withEmail("johnd@example.com").withPhone("98765432") - .withTags("owesMoney", "friends").build(); + .withTags(StudentRank.GOOD).build(); public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") .withEmail("heinz@example.com").withAddress("wall street").build(); public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") - .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); + .withEmail("cornelia@example.com").withAddress("10th street").withTags(StudentRank.GOOD).build(); public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") .withEmail("werner@example.com").withAddress("michegan ave").build(); public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") @@ -50,9 +51,9 @@ public class TypicalPersons { // Manually added - Person's details found in {@code CommandTestUtil} public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_AVERAGE).build(); public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_GOOD) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From 79821dee58ef72b8c46f8b3bda65287ab66be55e Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Fri, 13 Oct 2023 23:50:01 +0800 Subject: [PATCH 03/14] Fix checkstyles --- .../address/logic/parser/EditCommandParserTest.java | 4 ++-- .../seedu/address/logic/parser/ParserUtilTest.java | 5 +++-- .../seedu/address/storage/JsonAdaptedPersonTest.java | 11 +---------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 1a32449706e..6e5e3aca21d 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -13,15 +13,15 @@ import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; 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.TAG_DESC_GOOD; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_GOOD; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 451d7509417..10e87b4e043 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -26,7 +26,7 @@ public class ParserUtilTest { private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; - private static final StudentRank INVALID_TAG = null; + private static final String INVALID_TAG = "im a invalid tag"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; @@ -179,7 +179,8 @@ public void parseTags_null_throwsNullPointerException() { @Test public void parseTags_collectionWithInvalidTags_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1.toString(), INVALID_TAG.toString()))); + assertThrows(ParseException.class, () -> ParserUtil.parseTags( + Arrays.asList(VALID_TAG_1.toString(), INVALID_TAG.toString()))); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index bda52e2259a..0d456d30d99 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -5,7 +5,7 @@ import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.BENSON; -import java.util.ArrayList; +//import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -99,13 +99,4 @@ public void toModelType_nullAddress_throwsIllegalValueException() { assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } -// @Test -// public void toModelType_invalidTags_throwsIllegalValueException() { -// List invalidTags = new ArrayList<>(VALID_TAGS); -// invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); -// JsonAdaptedPerson person = -// new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); -// assertThrows(IllegalValueException.class, person::toModelType); -// } - } From 7c033334ff45da51f7b33abb5ec5c04ae367efcf Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Sat, 14 Oct 2023 00:11:52 +0800 Subject: [PATCH 04/14] Fix testcases --- .../duplicatePersonAddressBook.json | 3 +-- .../typicalPersonsAddressBook.json | 6 +++--- .../seedu/address/logic/parser/AddCommandParserTest.java | 4 ++-- .../seedu/address/logic/parser/EditCommandParserTest.java | 2 +- src/test/java/seedu/address/model/person/PersonTest.java | 8 ++------ src/test/java/seedu/address/model/tag/TagTest.java | 6 ------ 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json index a7427fe7aa2..903a7152e2a 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json @@ -3,8 +3,7 @@ "name": "Alice Pauline", "phone": "94351253", "email": "alice@example.com", - "address": "123, Jurong West Ave 6, #08-111", - "tags": [ "friends" ] + "address": "123, Jurong West Ave 6, #08-111" }, { "name": "Alice Pauline", "phone": "94351253", diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index 72262099d35..1b22c95dff7 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -5,13 +5,13 @@ "phone" : "94351253", "email" : "alice@example.com", "address" : "123, Jurong West Ave 6, #08-111", - "tags" : [ "friends" ] + "tags" : [ "AVERAGE" ] }, { "name" : "Benson Meier", "phone" : "98765432", "email" : "johnd@example.com", "address" : "311, Clementi Ave 2, #02-25", - "tags" : [ "owesMoney", "friends" ] + "tags" : [ "GOOD" ] }, { "name" : "Carl Kurz", "phone" : "95352563", @@ -23,7 +23,7 @@ "phone" : "87652533", "email" : "cornelia@example.com", "address" : "10th street", - "tags" : [ "friends" ] + "tags" : [ "GOOD" ] }, { "name" : "Elle Meyer", "phone" : "9482224", diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index beca588dff0..de687289df5 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -50,7 +50,7 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_GOOD).build(); + Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_AVERAGE).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB @@ -58,7 +58,7 @@ public void parse_allFieldsPresent_success() { // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_AVERAGE) + Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_GOOD, VALID_TAG_AVERAGE) .build(); assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_GOOD + TAG_DESC_AVERAGE, diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 6e5e3aca21d..ca552169dea 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -111,7 +111,7 @@ public void parse_allFieldsSpecified_success() { EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withTags(VALID_TAG_AVERAGE, VALID_TAG_GOOD).build(); + .withTags(VALID_TAG_AVERAGE, VALID_TAG_AVERAGE).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 2726b9a7663..b3c73f55a47 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -3,11 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.*; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BOB; @@ -86,7 +82,7 @@ public void equals() { assertFalse(ALICE.equals(editedAlice)); // different tags -> returns false - editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_AVERAGE).build(); + editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_GOOD).build(); assertFalse(ALICE.equals(editedAlice)); } diff --git a/src/test/java/seedu/address/model/tag/TagTest.java b/src/test/java/seedu/address/model/tag/TagTest.java index 9c803113391..3c133c7066e 100644 --- a/src/test/java/seedu/address/model/tag/TagTest.java +++ b/src/test/java/seedu/address/model/tag/TagTest.java @@ -11,12 +11,6 @@ public void constructor_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> new Tag(null)); } - @Test - public void constructor_invalidTagName_throwsIllegalArgumentException() { - StudentRank invalidTagName = null; - assertThrows(IllegalArgumentException.class, () -> new Tag(invalidTagName)); - } - @Test public void isValidTagName() { // null tag name From cc169c6895311d05a95ae16c6dcc952d237dc5ce Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Sat, 14 Oct 2023 00:16:21 +0800 Subject: [PATCH 05/14] Fix checkstyle --- src/test/java/seedu/address/model/person/PersonTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index b3c73f55a47..4cffef9cbe6 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -3,7 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.*; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.ALICE; import static seedu.address.testutil.TypicalPersons.BOB; From d83358c67239cf5d94e7aaf9fb21dc79e8e85201 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Sat, 14 Oct 2023 12:52:50 +0800 Subject: [PATCH 06/14] Add testcases --- .../java/seedu/address/storage/JsonAdaptedTag.java | 13 +++++++------ src/test/java/seedu/address/model/tag/TagTest.java | 9 +++++++++ .../address/storage/JsonAdaptedPersonTest.java | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java index 65d8031a4ee..22e24cae365 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonValue; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.parser.ParserUtil; import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; @@ -12,13 +13,13 @@ */ class JsonAdaptedTag { - private final StudentRank ranking; + private final String ranking; /** * Constructs a {@code JsonAdaptedTag} with the given {@code tagName}. */ @JsonCreator - public JsonAdaptedTag(StudentRank ranking) { + public JsonAdaptedTag(String ranking) { this.ranking = ranking; } @@ -26,12 +27,12 @@ public JsonAdaptedTag(StudentRank ranking) { * Converts a given {@code Tag} into this class for Jackson use. */ public JsonAdaptedTag(Tag source) { - ranking = source.ranking; + ranking = source.ranking.toString(); } @JsonValue public String getTagName() { - return ranking.toString(); + return ranking; } /** @@ -40,10 +41,10 @@ public String getTagName() { * @throws IllegalValueException if there were any data constraints violated in the adapted tag. */ public Tag toModelType() throws IllegalValueException { - if (!Tag.isValidTagName(ranking.toString())) { + if (!Tag.isValidTagName(ranking)) { throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS); } - return new Tag(ranking); + return ParserUtil.parseTag(ranking); } } diff --git a/src/test/java/seedu/address/model/tag/TagTest.java b/src/test/java/seedu/address/model/tag/TagTest.java index 3c133c7066e..dda71ffda3f 100644 --- a/src/test/java/seedu/address/model/tag/TagTest.java +++ b/src/test/java/seedu/address/model/tag/TagTest.java @@ -4,6 +4,9 @@ import org.junit.jupiter.api.Test; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.parser.ParserUtil; + public class TagTest { @Test @@ -11,6 +14,12 @@ public void constructor_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> new Tag(null)); } + @Test + public void constructor_invalidTagName_throwsIllegalValueException() { + String invalidTagName = "#invalid"; + assertThrows(IllegalValueException.class, () -> ParserUtil.parseTag(invalidTagName)); + } + @Test public void isValidTagName() { // null tag name diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index 0d456d30d99..f70279a8e93 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -6,24 +6,25 @@ import static seedu.address.testutil.TypicalPersons.BENSON; //import java.util.ArrayList; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; -import seedu.address.model.tag.StudentRank; public class JsonAdaptedPersonTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; - private static final StudentRank INVALID_TAG = null; + private static final String INVALID_TAG = "invalid tag"; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); @@ -99,4 +100,13 @@ public void toModelType_nullAddress_throwsIllegalValueException() { assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } + @Test + public void toModelType_invalidTags_throwsIllegalValueException() throws ParseException { + List invalidTags = new ArrayList<>(VALID_TAGS); + invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); + JsonAdaptedPerson person = + new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); + assertThrows(IllegalValueException.class, person::toModelType); + } + } From ccd30f46bdf06f0d02789ecce1c3e9df484b49b4 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Sat, 14 Oct 2023 12:55:04 +0800 Subject: [PATCH 07/14] Remove unused import --- src/main/java/seedu/address/storage/JsonAdaptedTag.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java index 22e24cae365..226de2c6e6e 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java @@ -5,7 +5,6 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.logic.parser.ParserUtil; -import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** From 41bfe3059fa19a4a5c43a101df6dfa0bb73039ba Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Mon, 16 Oct 2023 11:54:17 +0800 Subject: [PATCH 08/14] Add testcases --- .../logic/commands/CommandTestUtil.java | 14 +++++++++++ .../logic/parser/AddCommandParserTest.java | 25 ++++++++++++++----- .../address/testutil/TypicalPersons.java | 10 +++++++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 1ec8fb67eaa..ad841b4e730 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -29,25 +29,35 @@ public class CommandTestUtil { public static final String VALID_NAME_AMY = "Amy Bee"; public static final String VALID_NAME_BOB = "Bob Choo"; + public static final String VALID_NAME_CLARA = "Clara Ng"; public static final String VALID_PHONE_AMY = "11111111"; public static final String VALID_PHONE_BOB = "22222222"; + public static final String VALID_PHONE_CLARA = "33333333"; public static final String VALID_EMAIL_AMY = "amy@example.com"; public static final String VALID_EMAIL_BOB = "bob@example.com"; + public static final String VALID_EMAIL_CLARA = "clara@example.com"; public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; + public static final String VALID_ADDRESS_CLARA = "Block 123, Clara Street 3"; public static final StudentRank VALID_TAG_AVERAGE = StudentRank.AVERAGE; public static final StudentRank VALID_TAG_GOOD = StudentRank.GOOD; + public static final StudentRank VALID_TAG_POOR = StudentRank.POOR; public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY; public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB; + public static final String NAME_DESC_CLARA = " " + PREFIX_NAME + VALID_NAME_CLARA; public static final String PHONE_DESC_AMY = " " + PREFIX_PHONE + VALID_PHONE_AMY; public static final String PHONE_DESC_BOB = " " + PREFIX_PHONE + VALID_PHONE_BOB; + public static final String PHONE_DESC_CLARA = " " + PREFIX_PHONE + VALID_PHONE_CLARA; public static final String EMAIL_DESC_AMY = " " + PREFIX_EMAIL + VALID_EMAIL_AMY; public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; + public static final String EMAIL_DESC_CLARA = " " + PREFIX_EMAIL + VALID_EMAIL_CLARA; public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; + public static final String ADDRESS_DESC_CLARA = " " + PREFIX_ADDRESS + VALID_ADDRESS_CLARA; public static final String TAG_DESC_AVERAGE = " " + PREFIX_TAG + VALID_TAG_AVERAGE; public static final String TAG_DESC_GOOD = " " + PREFIX_TAG + VALID_TAG_GOOD; + public static final String TAG_DESC_POOR = " " + PREFIX_TAG + VALID_TAG_POOR; public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones @@ -60,6 +70,7 @@ public class CommandTestUtil { public static final EditCommand.EditPersonDescriptor DESC_AMY; public static final EditCommand.EditPersonDescriptor DESC_BOB; + public static final EditCommand.EditPersonDescriptor DESC_CLARA; static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) @@ -67,6 +78,9 @@ public class CommandTestUtil { .withTags(VALID_TAG_AVERAGE).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) + .withTags(VALID_TAG_POOR).build(); + DESC_CLARA = new EditPersonDescriptorBuilder().withName(VALID_NAME_CLARA) + .withPhone(VALID_PHONE_CLARA).withEmail(VALID_EMAIL_CLARA).withAddress(VALID_ADDRESS_CLARA) .withTags(VALID_TAG_GOOD).build(); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index de687289df5..d9b418152e1 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -3,8 +3,10 @@ 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.ADDRESS_DESC_CLARA; 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.EMAIL_DESC_CLARA; import static seedu.address.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; @@ -12,26 +14,29 @@ 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.NAME_DESC_CLARA; 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.PHONE_DESC_CLARA; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_AVERAGE; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_POOR; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_POOR; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalPersons.AMY; -import static seedu.address.testutil.TypicalPersons.BOB; +import static seedu.address.testutil.TypicalPersons.*; import org.junit.jupiter.api.Test; @@ -50,18 +55,18 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_AVERAGE).build(); + Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_GOOD).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_AVERAGE, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_GOOD, new AddCommand(expectedPerson)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_GOOD, VALID_TAG_AVERAGE) + Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_POOR, VALID_TAG_AVERAGE) .build(); assertParseSuccess(parser, - NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_GOOD + TAG_DESC_AVERAGE, + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_POOR + TAG_DESC_AVERAGE, new AddCommand(expectedPersonMultipleTags)); } @@ -137,6 +142,14 @@ public void parse_optionalFieldsMissing_success() { new AddCommand(expectedPerson)); } + @Test + public void parse_optionalFieldsMissing_success2() { + // zero tags + Person expectedPerson = new PersonBuilder(CLARA).withTags().build(); + assertParseSuccess(parser, NAME_DESC_CLARA + PHONE_DESC_CLARA + EMAIL_DESC_CLARA + ADDRESS_DESC_CLARA, + new AddCommand(expectedPerson)); + } + @Test public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index d84e65c36dc..f8d8265f613 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -2,14 +2,19 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_CLARA; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_CLARA; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_CLARA; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_CLARA; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_POOR; import java.util.ArrayList; import java.util.Arrays; @@ -53,9 +58,12 @@ public class TypicalPersons { public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_AVERAGE).build(); public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_GOOD) + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_POOR) .build(); + public static final Person CLARA = new PersonBuilder().withName(VALID_NAME_CLARA).withPhone(VALID_PHONE_CLARA) + .withEmail(VALID_EMAIL_CLARA).withAddress(VALID_ADDRESS_CLARA).withTags(VALID_TAG_GOOD) + .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER private TypicalPersons() {} // prevents instantiation From 4808fa7925f4366ff5d016bf846e38f552448822 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Mon, 16 Oct 2023 12:17:14 +0800 Subject: [PATCH 09/14] Fix import order --- src/main/java/seedu/address/model/util/SampleDataUtil.java | 2 +- src/test/java/seedu/address/testutil/PersonBuilder.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index be6d86a03d7..8735d5389fe 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,8 +11,8 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; -import seedu.address.model.tag.StudentRank; import seedu.address.model.person.Remark; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 9474025860a..ddcc8f6ad9a 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -10,7 +10,6 @@ import seedu.address.model.person.Phone; import seedu.address.model.person.Remark; import seedu.address.model.tag.StudentRank; -import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; From 415cfbe58caed79a57714d5d1c67ccab43b48b92 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Mon, 16 Oct 2023 12:21:35 +0800 Subject: [PATCH 10/14] Fix testcase assertion --- src/test/java/seedu/address/model/person/PersonTest.java | 4 ++-- src/test/java/seedu/address/testutil/TypicalPersons.java | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 0772cdfed26..3be9dfdba0a 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -33,10 +33,10 @@ public void isSamePerson() { // null -> returns false assertFalse(ALICE.isSamePerson(null)); - // same name, all other attributes different -> returns true + // same name, all other attributes different -> returns false Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_AVERAGE).build(); - assertTrue(ALICE.isSamePerson(editedAlice)); + assertFalse(ALICE.isSamePerson(editedAlice)); // different name, all other attributes same -> returns false editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index c07b31f67a0..ef285d9b696 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -31,8 +31,6 @@ public class TypicalPersons { public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") - .withPhone("94351253") - .withTags(StudentRank.AVERAGE).build(); .withPhone("94351253").withRemark("She likes aardvarks.") .withTags(StudentRank.AVERAGE).build(); public static final Person BENSON = new PersonBuilder().withName("Benson Meier") From 67a4bc60fa0bb7efc6ecbb943fd8acb5434de951 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Mon, 16 Oct 2023 12:26:58 +0800 Subject: [PATCH 11/14] Fix import statements --- .../java/seedu/address/logic/parser/AddCommandParserTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index d9b418152e1..f2535677a36 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -36,7 +36,9 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalPersons.*; +import static seedu.address.testutil.TypicalPersons.AMY; +import static seedu.address.testutil.TypicalPersons.BOB; +import static seedu.address.testutil.TypicalPersons.CLARA; import org.junit.jupiter.api.Test; From f02262ec15bbc13f3243031b10ee6ed54441d521 Mon Sep 17 00:00:00 2001 From: tiong jjyi Date: Mon, 16 Oct 2023 12:42:36 +0800 Subject: [PATCH 12/14] Fix testcases --- .../typicalPersonsAddressBook.json | 8 +++----- src/test/java/seedu/address/model/person/PersonTest.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index cf71139f011..4c4d283dadf 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -5,17 +5,15 @@ "phone" : "94351253", "email" : "alice@example.com", "address" : "123, Jurong West Ave 6, #08-111", - "remark" : "", + "remark" : "She likes aardvarks.", "tagged" : [ "AVERAGE" ] }, { "name" : "Benson Meier", "phone" : "98765432", "email" : "johnd@example.com", "address" : "311, Clementi Ave 2, #02-25", - "remark" : "", - "tags" : [ "GOOD" ] - "remark" : "", - "tagged" : [ "owesMoney", "friends" ] + "remark" : "He can't take beer!", + "tagged" : [ "GOOD" ] }, { "name" : "Carl Kurz", "phone" : "95352563", diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 3be9dfdba0a..c8b3761fd9e 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -94,7 +94,7 @@ public void equals() { @Test public void toStringMethod() { String expected = "Alice Pauline Phone: 94351253 Email: alice@example.com Address: 123," - + " Jurong West Ave 6, #08-111 Remark: She likes aardvarks. Tags: [friends]"; + + " Jurong West Ave 6, #08-111 Remark: She likes aardvarks. Tags: [AVERAGE]"; assertEquals(expected, ALICE.toString()); } } From 255213d562e95ad0fc0bd66199eb494887fe68e5 Mon Sep 17 00:00:00 2001 From: tiongjjyi Date: Mon, 16 Oct 2023 14:17:43 +0800 Subject: [PATCH 13/14] Resolve conflicts --- .../duplicateStudentStudentList.json | 2 +- .../seedu/address/model/StudentListTest.java | 6 +++--- .../model/person/UniqueStudentListTest.java | 6 +++--- .../EditStudentDescriptorBuilder.java | 3 ++- .../address/testutil/TypicalStudents.java | 19 ++++++++++--------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/test/data/JsonSerializableStudentListTest/duplicateStudentStudentList.json b/src/test/data/JsonSerializableStudentListTest/duplicateStudentStudentList.json index 17f3bcc7d19..7255794584f 100644 --- a/src/test/data/JsonSerializableStudentListTest/duplicateStudentStudentList.json +++ b/src/test/data/JsonSerializableStudentListTest/duplicateStudentStudentList.json @@ -4,7 +4,7 @@ "course": "CS2103T", "email": "alice@example.com", "remark" : "", - "tags": [ "friends" ] + "tags": [ "GOOD" ] }, { "name": "Alice Pauline", "course": "CS2103T", diff --git a/src/test/java/seedu/address/model/StudentListTest.java b/src/test/java/seedu/address/model/StudentListTest.java index 724758772d7..e4875cfebb8 100644 --- a/src/test/java/seedu/address/model/StudentListTest.java +++ b/src/test/java/seedu/address/model/StudentListTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalStudents.ALICE; import static seedu.address.testutil.TypicalStudents.getTypicalStudentList; @@ -45,7 +45,7 @@ public void resetData_withValidReadOnlyStudentList_replacesData() { @Test public void resetData_withDuplicateStudents_throwsDuplicateStudentException() { // Two Students with the same identity fields - Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_GOOD) .build(); List newStudents = Arrays.asList(ALICE, editedAlice); StudentListStub newData = new StudentListStub(newStudents); @@ -72,7 +72,7 @@ public void hasStudent_studentInStudentList_returnsTrue() { @Test public void hasStudent_studentWithSameIdentityFieldsInStudentList_returnsTrue() { studentList.addStudent(ALICE); - Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_GOOD) .build(); assertTrue(studentList.hasStudent(editedAlice)); } diff --git a/src/test/java/seedu/address/model/person/UniqueStudentListTest.java b/src/test/java/seedu/address/model/person/UniqueStudentListTest.java index ad38b220b64..0bca802343c 100644 --- a/src/test/java/seedu/address/model/person/UniqueStudentListTest.java +++ b/src/test/java/seedu/address/model/person/UniqueStudentListTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalStudents.ALICE; import static seedu.address.testutil.TypicalStudents.BOB; @@ -41,7 +41,7 @@ public void contains_studentInList_returnsTrue() { @Test public void contains_studentWithSameIdentityFieldsInList_returnsTrue() { uniqueStudentList.add(ALICE); - Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_GOOD) .build(); assertTrue(uniqueStudentList.contains(editedAlice)); } @@ -84,7 +84,7 @@ public void setStudent_editedStudentIsSameStudent_success() { @Test public void setStudent_editedStudentHasSameIdentity_success() { uniqueStudentList.add(ALICE); - Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_HUSBAND) + Student editedAlice = new StudentBuilder(ALICE).withTags(VALID_TAG_GOOD) .build(); uniqueStudentList.setStudent(ALICE, editedAlice); UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); diff --git a/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java index cc0dc66f36c..51d6cd17cc9 100644 --- a/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java @@ -9,6 +9,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Student; +import seedu.address.model.tag.StudentRank; import seedu.address.model.tag.Tag; /** @@ -66,7 +67,7 @@ public EditStudentDescriptorBuilder withEmail(String email) { * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} * that we are building. */ - public EditStudentDescriptorBuilder withTags(String... tags) { + public EditStudentDescriptorBuilder withTags(StudentRank... tags) { Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); descriptor.setTags(tagSet); return this; diff --git a/src/test/java/seedu/address/testutil/TypicalStudents.java b/src/test/java/seedu/address/testutil/TypicalStudents.java index 42626c657f5..050782f4589 100644 --- a/src/test/java/seedu/address/testutil/TypicalStudents.java +++ b/src/test/java/seedu/address/testutil/TypicalStudents.java @@ -6,8 +6,9 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; -import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_AVERAGE; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_GOOD; +import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_POOR; import java.util.ArrayList; import java.util.Arrays; @@ -22,15 +23,15 @@ public class TypicalStudents { public static final Student ALICE = new StudentBuilder().withName("Alice Pauline") - .withEmail("alice@example.com").withCourse("CS2103T") - .withTags("friends").build(); + .withEmail("alice@example.com").withCourse("CS2103T").withRemark("She likes aardvarks.") + .withTags(VALID_TAG_AVERAGE).build(); public static final Student BENSON = new StudentBuilder().withName("Benson Meier") - .withEmail("johnd@example.com").withCourse("CS2103T") - .withTags("owesMoney", "friends").build(); + .withEmail("johnd@example.com").withCourse("CS2103T").withRemark("He can't take beer!") + .withTags(VALID_TAG_GOOD).build(); public static final Student CARL = new StudentBuilder().withName("Carl Kurz").withCourse("CS2103T") .withEmail("heinz@example.com").build(); public static final Student DANIEL = new StudentBuilder().withName("Daniel Meier").withCourse("CS2103T") - .withEmail("cornelia@example.com").withTags("friends").build(); + .withEmail("cornelia@example.com").withTags(VALID_TAG_GOOD).build(); public static final Student ELLE = new StudentBuilder().withName("Elle Meyer").withCourse("CS2103T") .withEmail("werner@example.com").build(); public static final Student FIONA = new StudentBuilder().withName("Fiona Kunz").withCourse("CS2103T") @@ -46,9 +47,9 @@ public class TypicalStudents { // Manually added - Student's details found in {@code CommandTestUtil} public static final Student AMY = new StudentBuilder().withName(VALID_NAME_AMY).withCourse(VALID_COURSE_AMY) - .withEmail(VALID_EMAIL_AMY).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withTags(VALID_TAG_AVERAGE).build(); public static final Student BOB = new StudentBuilder().withName(VALID_NAME_BOB).withCourse(VALID_COURSE_BOB) - .withEmail(VALID_EMAIL_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + .withEmail(VALID_EMAIL_BOB).withTags(VALID_TAG_POOR) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From ac1c74a50fb6cee891165ed0536bcc2316ddbc93 Mon Sep 17 00:00:00 2001 From: tiongjjyi Date: Mon, 16 Oct 2023 14:20:30 +0800 Subject: [PATCH 14/14] Remove unused import --- .../java/seedu/address/logic/parser/AddCommandParserTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 250c43cc129..d7e96d03369 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -37,7 +37,6 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Student; -import seedu.address.model.tag.Tag; import seedu.address.testutil.StudentBuilder; public class AddCommandParserTest {