From 45169e6027feb8570b70f5662725e01282718553 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Tue, 12 Mar 2024 15:39:57 +0800 Subject: [PATCH 01/15] Change add command Update add command to specify next of kin and description for Person --- .../seedu/address/logic/commands/AddCommand.java | 12 ++++++------ .../logic/commands/exceptions/CommandException.java | 2 ++ .../seedu/address/logic/parser/AddCommandParser.java | 12 ++++-------- .../java/seedu/address/model/person/NextOfKin.java | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 5d7185a9680..af671258239 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,11 +1,7 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -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.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -26,13 +22,17 @@ public class AddCommand extends Command { + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_NOK + "NEXT OF KIN " + + PREFIX_DESCRIPTION + "DESCRIPTION " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " - + PREFIX_TAG + "friends " + + PREFIX_NOK + "Joe Doe " + + PREFIX_DESCRIPTION + "Has a history of memory loss " + + PREFIX_TAG + "mentalIllness " + PREFIX_TAG + "owesMoney"; public static final String MESSAGE_SUCCESS = "New person added: %1$s"; diff --git a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java index a16bd14f2cd..f44c0c19186 100644 --- a/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java +++ b/src/main/java/seedu/address/logic/commands/exceptions/CommandException.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands.exceptions; +import seedu.address.logic.commands.Command; + /** * Represents an error which occurs during execution of a {@link Command}. */ diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 1c334293f96..99b4c1944f2 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,11 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -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.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import java.util.Set; import java.util.stream.Stream; @@ -33,7 +29,7 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_NOK, PREFIX_DESCRIPTION, PREFIX_TAG); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { @@ -45,8 +41,8 @@ public AddCommand parse(String args) throws ParseException { Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); - Description description = new Description("Description placeholder"); - NextOfKin nextOfKin = new NextOfKin("Next of kin placeholder"); + Description description = ParserUtil.parseDescription(argMultimap.getValue(PREFIX_DESCRIPTION).get()); + NextOfKin nextOfKin = ParserUtil.parseNextOfKin(argMultimap.getValue(PREFIX_NOK).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); Person person = new Person(name, phone, email, address, description, nextOfKin, tagList); diff --git a/src/main/java/seedu/address/model/person/NextOfKin.java b/src/main/java/seedu/address/model/person/NextOfKin.java index 29a0770de11..7c9bf374d61 100644 --- a/src/main/java/seedu/address/model/person/NextOfKin.java +++ b/src/main/java/seedu/address/model/person/NextOfKin.java @@ -14,7 +14,7 @@ public class NextOfKin { * The first character of the next of kin must not be a whitespace, * otherwise " " (a blank string) becomes a valid input. */ - public static final String VALIDATION_REGEX = "[^\\s].*"; + public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; public final String value; From d9b09b21f5ffa8d45bbd7bfec9268a8c62667a2d Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Tue, 12 Mar 2024 16:17:29 +0800 Subject: [PATCH 02/15] Fix test case Change test case: include next of kin and description information --- .../address/model/util/SampleDataUtil.java | 24 +++++------ .../logic/commands/CommandTestUtil.java | 18 ++++----- .../logic/parser/AddCommandParserTest.java | 40 +++++-------------- .../seedu/address/testutil/PersonBuilder.java | 4 +- 4 files changed, 32 insertions(+), 54 deletions(-) diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index fafe4218574..9de29c52988 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -25,33 +25,33 @@ 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"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Suffers from blood disorder"), + new NextOfKin("Bob Yeoah"), getTagSet("friends")), new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Suffers from diabetes"), + new NextOfKin("Choon Yu"), getTagSet("colleagues", "friends")), 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"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Has asthama"), + new NextOfKin("David Oliveiro"), getTagSet("neighbours")), new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Has Huntington's Disease"), + new NextOfKin("Elliot Li"), getTagSet("family")), new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), new Address("Blk 47 Tampines Street 20, #17-35"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Suffers from Crohn's disease"), + new NextOfKin("Ilyasa Ibrahim"), getTagSet("classmates")), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), - new Description(DESCRIPTION_PLACEHOLDER), - new NextOfKin(NOK_PLACEHOLDER), + new Description("Suffers from errectile dysfunction"), + new NextOfKin("Pam Balakrishnan"), getTagSet("colleagues")) }; } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 1482e462236..9c325021adf 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,11 +2,7 @@ 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_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.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; @@ -34,10 +30,10 @@ 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_DESCRIPTION_AMY = "Description placeholder"; - public static final String VALID_DESCRIPTION_BOB = "Description placeholder"; - public static final String VALID_NOK_AMY = "Next of kin placeholder"; - public static final String VALID_NOK_BOB = "Next of kin placeholder"; + public static final String VALID_DESCRIPTION_AMY = "Blood Disorder"; + public static final String VALID_DESCRIPTION_BOB = "Blood Disorder"; + public static final String VALID_NOK_AMY = "Ben Bee"; + public static final String VALID_NOK_BOB = "Ben Bee"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; @@ -49,6 +45,10 @@ 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 NOK_DESC_AMY = " " + PREFIX_NOK + VALID_NOK_AMY; + public static final String NOK_DESC_BOB = " " + PREFIX_NOK + VALID_NOK_BOB; + public static final String DESCRIPTION_DESC_AMY = " " + PREFIX_DESCRIPTION + VALID_DESCRIPTION_AMY; + public static final String DESCRIPTION_DESC_BOB = " " + PREFIX_DESCRIPTION + VALID_DESCRIPTION_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; diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 5bc11d3cdaa..3328cf72050 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -1,29 +1,7 @@ package seedu.address.logic.parser; 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.EMAIL_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; -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; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_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.PHONE_DESC_AMY; -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.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.*; 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; @@ -54,14 +32,14 @@ public void parse_allFieldsPresent_success() { // 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 + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple tags - all accepted Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) .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 + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @@ -133,7 +111,7 @@ public void parse_repeatedNonTagValue_failure() { public void parse_optionalFieldsMissing_success() { // zero tags Person expectedPerson = new PersonBuilder(AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NOK_DESC_AMY + DESCRIPTION_DESC_AMY, new AddCommand(expectedPerson)); } @@ -166,23 +144,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); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + 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 - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + 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 - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + 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 - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, 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); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, 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, diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 489ef91947c..96b897f935f 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -22,8 +22,8 @@ public class PersonBuilder { public static final String DEFAULT_PHONE = "85355255"; public static final String DEFAULT_EMAIL = "amy@gmail.com"; public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111"; - public static final String DEFAULT_DESCRIPTION = "Description placeholder"; - public static final String DEFAULT_NOK = "Next of kin placeholder"; + public static final String DEFAULT_DESCRIPTION = "Blood Disorder"; + public static final String DEFAULT_NOK = "Ben Bee"; private Name name; private Phone phone; From 722cb675bd708f5c475fefd71386347e92b9abb1 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Tue, 12 Mar 2024 16:27:42 +0800 Subject: [PATCH 03/15] Improve test cases Test for add command is insufficient Let's, * improve the test case to include tests for next of kins * include tests for description --- .../java/seedu/address/model/person/NextOfKin.java | 4 +++- .../seedu/address/logic/commands/CommandTestUtil.java | 2 ++ .../address/logic/parser/AddCommandParserTest.java | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/model/person/NextOfKin.java b/src/main/java/seedu/address/model/person/NextOfKin.java index 7c9bf374d61..903f0161901 100644 --- a/src/main/java/seedu/address/model/person/NextOfKin.java +++ b/src/main/java/seedu/address/model/person/NextOfKin.java @@ -8,7 +8,9 @@ * Guarantees: immutable; is valid as declared in {@link #isValidNextOfKin(String)} */ public class NextOfKin { - public static final String MESSAGE_CONSTRAINTS = "Next of kins can take any values, and it should not be blank"; + public static final String MESSAGE_CONSTRAINTS = + "Names should only contain alphanumeric characters and spaces, and it should not be blank"; + /* * The first character of the next of kin must not be a whitespace, diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 9c325021adf..5843f99a931 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -56,6 +56,8 @@ public class CommandTestUtil { public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses + public static final String INVALID_DESCRIPTION_DESC = " " + PREFIX_DESCRIPTION; // empty string not allowed for descriptions + public static final String INVALID_NOK_DESC = " " + PREFIX_NOK; // empty string not allowed for next of kin public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags public static final String PREAMBLE_WHITESPACE = "\t \r \n"; diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 3328cf72050..ad1a5e5f542 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -20,6 +20,8 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.NextOfKin; +import seedu.address.model.person.Description; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -158,6 +160,14 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); + // invalid next of kin + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + INVALID_NOK_DESC + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, NextOfKin.MESSAGE_CONSTRAINTS); + + // invalid description + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + NOK_DESC_BOB + INVALID_DESCRIPTION_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Description.MESSAGE_CONSTRAINTS); + // invalid tag assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS); From edd010a8ae5e5c1f6c4f89af92c7edf83aa909c7 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 13:42:53 +0800 Subject: [PATCH 04/15] Fix errors in checkstyle --- .../java/seedu/address/logic/commands/AddCommand.java | 8 +++++++- .../java/seedu/address/logic/parser/AddCommandParser.java | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index af671258239..9e3f4fabe31 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,7 +1,13 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NOK; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 99b4c1944f2..aa051d72d93 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -29,7 +29,8 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_NOK, PREFIX_DESCRIPTION, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_NOK, + PREFIX_DESCRIPTION, PREFIX_TAG); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { From 6a83d7ec421cae4374744f408dbeceb00b8d221b Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 15:49:25 +0800 Subject: [PATCH 05/15] Fix order of imports --- .../java/seedu/address/logic/commands/AddCommand.java | 8 ++++---- .../seedu/address/logic/parser/AddCommandParser.java | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 9e3f4fabe31..020ede006cc 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,12 +1,12 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NOK; import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION; +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_NOK; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import seedu.address.commons.util.ToStringBuilder; diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index aa051d72d93..3e5c5972d36 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,7 +1,14 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.*; + +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION; +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_NOK; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import java.util.Set; import java.util.stream.Stream; From ba62dfca9ebdf90225a1720289ea418fe7e432f6 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 15:53:17 +0800 Subject: [PATCH 06/15] Update AddCommandParser.java --- .../java/seedu/address/logic/parser/AddCommandParser.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3e5c5972d36..6017c5dc844 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,7 +1,6 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; @@ -12,7 +11,6 @@ import java.util.Set; import java.util.stream.Stream; - import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; @@ -25,13 +23,14 @@ import seedu.address.model.tag.Tag; /** - * Parses input arguments and creates a new AddCommand object + * Parses input arguments and creates a new AddCommand object. */ public class AddCommandParser implements Parser { /** * Parses the given {@code String} of arguments in the context of the AddCommand * and returns an AddCommand object for execution. + * * @throws ParseException if the user input does not conform the expected format */ public AddCommand parse(String args) throws ParseException { From 8ec542e479fd86cddf0bf079dc7837fddc9e167b Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 15:59:43 +0800 Subject: [PATCH 07/15] Update AddCommandParser.java --- src/main/java/seedu/address/logic/parser/AddCommandParser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 6017c5dc844..f1933d549f1 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.stream.Stream; + import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; From 66c03f6fa5cadcb776a480e7d9cd50ceeb76374c Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 16:11:22 +0800 Subject: [PATCH 08/15] Improve code quality --- .../logic/commands/CommandTestUtil.java | 13 ++++++++-- .../logic/parser/AddCommandParserTest.java | 24 ++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 5843f99a931..689c52d3283 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,7 +2,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.parser.CliSyntax.*; + +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION; +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_NOK; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; + import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; @@ -56,7 +64,8 @@ public class CommandTestUtil { public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses - public static final String INVALID_DESCRIPTION_DESC = " " + PREFIX_DESCRIPTION; // empty string not allowed for descriptions + // empty string not allowed for descriptions + public static final String INVALID_DESCRIPTION_DESC = " " + PREFIX_DESCRIPTION; public static final String INVALID_NOK_DESC = " " + PREFIX_NOK; // empty string not allowed for next of kin public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index ad1a5e5f542..ac183f37982 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -16,12 +16,12 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.AddCommand; import seedu.address.model.person.Address; +import seedu.address.model.person.Description; import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; import seedu.address.model.person.NextOfKin; -import seedu.address.model.person.Description; +import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -34,15 +34,17 @@ public void parse_allFieldsPresent_success() { // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple tags - all accepted Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) .build(); assertParseSuccess(parser, - NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, - new AddCommand(expectedPersonMultipleTags)); + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @Test @@ -113,7 +115,8 @@ public void parse_repeatedNonTagValue_failure() { public void parse_optionalFieldsMissing_success() { // zero tags Person expectedPerson = new PersonBuilder(AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NOK_DESC_AMY + DESCRIPTION_DESC_AMY, + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + + ADDRESS_DESC_AMY + NOK_DESC_AMY + DESCRIPTION_DESC_AMY, new AddCommand(expectedPerson)); } @@ -158,15 +161,18 @@ public void parse_invalidValue_failure() { // invalid address assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); + + NOK_DESC_BOB + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); // invalid next of kin assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INVALID_NOK_DESC + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, NextOfKin.MESSAGE_CONSTRAINTS); + + INVALID_NOK_DESC + DESCRIPTION_DESC_BOB + TAG_DESC_HUSBAND + + TAG_DESC_FRIEND, NextOfKin.MESSAGE_CONSTRAINTS); // invalid description assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + NOK_DESC_BOB + INVALID_DESCRIPTION_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Description.MESSAGE_CONSTRAINTS); + + NOK_DESC_BOB + INVALID_DESCRIPTION_DESC + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Description.MESSAGE_CONSTRAINTS); // invalid tag assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB From e57d9c86b9df9c250be52d268e906aa8177798fc Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 16:17:39 +0800 Subject: [PATCH 09/15] Change import order --- .../address/logic/commands/CommandTestUtil.java | 1 - .../address/logic/parser/AddCommandParserTest.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 689c52d3283..0dd718ee4a8 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -10,7 +10,6 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NOK; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; - import static seedu.address.testutil.Assert.assertThrows; import java.util.ArrayList; diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index ac183f37982..e44d4c5319a 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -1,7 +1,16 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.*; + +import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.NOK_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; +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.VALID_TAG_FRIEND; 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; @@ -18,9 +27,9 @@ import seedu.address.model.person.Address; import seedu.address.model.person.Description; import seedu.address.model.person.Email; +import seedu.address.model.person.NextOfKin; import seedu.address.model.person.Name; import seedu.address.model.person.Person; -import seedu.address.model.person.NextOfKin; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; From ddf06caacb0ed2f3f497caaeda6ad30579b4e088 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 16:22:42 +0800 Subject: [PATCH 10/15] Update import order --- .../address/logic/commands/CommandTestUtil.java | 1 - .../logic/parser/AddCommandParserTest.java | 15 +++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 0dd718ee4a8..ba638f5c4cd 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -2,7 +2,6 @@ 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_DESCRIPTION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index e44d4c5319a..88aab9a32ab 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -1,16 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; - -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.NOK_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB; -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.VALID_TAG_FRIEND; +import static seedu.address.logic.commands.CommandTestUtil.*; 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; @@ -25,10 +16,10 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.AddCommand; import seedu.address.model.person.Address; -import seedu.address.model.person.Description; import seedu.address.model.person.Email; -import seedu.address.model.person.NextOfKin; +import seedu.address.model.person.Description; import seedu.address.model.person.Name; +import seedu.address.model.person.NextOfKin; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; From 9d8b5a0b37c8813d82d68b590d8ad86ac2e9f495 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 16:28:59 +0800 Subject: [PATCH 11/15] Update imports --- .../logic/parser/AddCommandParserTest.java | 30 ++++++++++++++++++- 1 file changed, 29 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 88aab9a32ab..331862908a2 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -1,7 +1,35 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.commands.CommandTestUtil.*; +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.EMAIL_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_BOB; +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_DESCRIPTION_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_NOK_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_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.NOK_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.NOK_DESC_BOB; +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; +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.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.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; From 16635b2b0951b9c65fe2320f2a6b2ad762727bd2 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Wed, 13 Mar 2024 16:31:39 +0800 Subject: [PATCH 12/15] Improve code quality --- .../seedu/address/logic/parser/AddCommandParserTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 331862908a2..9e7c87f7741 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -3,13 +3,13 @@ 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.EMAIL_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_AMY; import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_BOB; +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.INVALID_ADDRESS_DESC; -import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_DESCRIPTION_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_NOK_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; @@ -44,8 +44,8 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.AddCommand; import seedu.address.model.person.Address; -import seedu.address.model.person.Email; import seedu.address.model.person.Description; +import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.NextOfKin; import seedu.address.model.person.Person; From 216d217ad30dbffd52d0451431941ccdef459415 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Thu, 14 Mar 2024 13:48:33 +0800 Subject: [PATCH 13/15] Update testcases --- .../logic/parser/AddCommandParser.java | 3 +- .../logic/parser/ArgumentTokenizer.java | 1 - .../invalidAndValidPersonAddressBook.json | 8 +++-- .../invalidPersonAddressBook.json | 4 ++- .../invalidPersonAddressBook.json | 4 ++- .../typicalPersonsAddressBook.json | 10 +++--- .../seedu/address/logic/LogicManagerTest.java | 7 ++-- .../address/model/person/NextOfKinTest.java | 1 - .../seedu/address/testutil/PersonUtil.java | 2 ++ .../address/testutil/TypicalPersons.java | 36 +++++++++++-------- 10 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index f1933d549f1..c077a448cbb 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -44,7 +44,8 @@ public AddCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, + PREFIX_DESCRIPTION); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); diff --git a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java b/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java index 5c9aebfa488..e1c05d22962 100644 --- a/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java +++ b/src/main/java/seedu/address/logic/parser/ArgumentTokenizer.java @@ -144,5 +144,4 @@ Prefix getPrefix() { return prefix; } } - } diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json index 6a4d2b7181c..449907b31ee 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json @@ -3,11 +3,15 @@ "name": "Valid Person", "phone": "9482424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "nok": "Valid NOK", + "description": "Suffers from depression" }, { "name": "Person With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "nok": "Valid nok", + "description": "Suffers from anxiety" } ] } diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json index ccd21f7d1a9..06220e4bca7 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json @@ -3,6 +3,8 @@ "name": "Person with invalid name field: Ha!ns Mu@ster", "phone": "9482424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "nok": "Valid NOK", + "description": "Suffers from depression" } ] } diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json index ad3f135ae42..699670c4755 100644 --- a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json @@ -3,6 +3,8 @@ "name": "Hans Muster", "phone": "9482424", "email": "invalid@email!3e", - "address": "4th street" + "address": "4th street", + "nok": "Valid NOK", + "description": "Suffers from depression" } ] } diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index 016984f34d1..f9809cf71b4 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -22,7 +22,7 @@ "email" : "heinz@example.com", "address" : "wall street", "description": "Description placeholder", - "nextOfKin": "Next of kin placeholder", + "nextOfKin": "Sam Sung", "tags" : [ ] }, { "name" : "Daniel Meier", @@ -30,7 +30,7 @@ "email" : "cornelia@example.com", "address" : "10th street", "description": "Description placeholder", - "nextOfKin": "Next of kin placeholder", + "nextOfKin": "Sam Sung", "tags" : [ "friends" ] }, { "name" : "Elle Meyer", @@ -38,7 +38,7 @@ "email" : "werner@example.com", "address" : "michegan ave", "description": "Description placeholder", - "nextOfKin": "Next of kin placeholder", + "nextOfKin": "Sam Sung", "tags" : [ ] }, { "name" : "Fiona Kunz", @@ -46,7 +46,7 @@ "email" : "lydia@example.com", "address" : "little tokyo", "description": "Description placeholder", - "nextOfKin": "Next of kin placeholder", + "nextOfKin": "Sam Sung", "tags" : [ ] }, { "name" : "George Best", @@ -54,7 +54,7 @@ "email" : "anna@example.com", "address" : "4th street", "description": "Description placeholder", - "nextOfKin": "Next of kin placeholder", + "nextOfKin": "Sam Sung", "tags" : [ ] } ] } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index baf8ce336a2..8bad9f19fed 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -3,10 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; -import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; -import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; -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.*; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.AMY; @@ -166,7 +163,7 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) // Triggers the saveAddressBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NOK_DESC_AMY + DESCRIPTION_DESC_AMY; Person expectedPerson = new PersonBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); expectedModel.addPerson(expectedPerson); diff --git a/src/test/java/seedu/address/model/person/NextOfKinTest.java b/src/test/java/seedu/address/model/person/NextOfKinTest.java index 81b9b288205..d2b14138986 100644 --- a/src/test/java/seedu/address/model/person/NextOfKinTest.java +++ b/src/test/java/seedu/address/model/person/NextOfKinTest.java @@ -30,7 +30,6 @@ public void isValidNextOfKin() { // valid next of kins assertTrue(NextOfKin.isValidNextOfKin("Sam Sung")); - assertTrue(NextOfKin.isValidNextOfKin("-")); // one character assertTrue(NextOfKin.isValidNextOfKin("Alexander Maximilian Bartholomew Fitzwilliam III")); // long next of kin } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index ed44cb4a53b..eda18d283b9 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -36,6 +36,8 @@ public static String getPersonDetails(Person person) { sb.append(PREFIX_PHONE + person.getPhone().value + " "); sb.append(PREFIX_EMAIL + person.getEmail().value + " "); sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); + sb.append(PREFIX_DESCRIPTION + person.getDescription().value + " "); + sb.append(PREFIX_NOK + person.getNextOfKin().value + " "); person.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index 462ac187041..f0508c381bd 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -1,16 +1,5 @@ package seedu.address.testutil; -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_EMAIL_AMY; -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_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 java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -18,6 +7,8 @@ import seedu.address.model.AddressBook; import seedu.address.model.person.Person; +import static seedu.address.logic.commands.CommandTestUtil.*; + /** * A utility class containing a list of {@code Person} objects to be used in tests. */ @@ -36,27 +27,44 @@ public class TypicalPersons { .withNextOfKin("Alexander Maximilian Bartholomew Fitzwilliam III") .withTags("owesMoney", "friends").build(); public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") - .withEmail("heinz@example.com").withAddress("wall street").build(); + .withEmail("heinz@example.com").withAddress("wall street") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung").build(); public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("werner@example.com").withAddress("michegan ave").build(); public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("lydia@example.com").withAddress("little tokyo").build(); public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("anna@example.com").withAddress("4th street").build(); // Manually added public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("stefan@example.com").withAddress("little india").build(); public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + .withDescription("Description placeholder") + .withNextOfKin("Sam Sung") .withEmail("hans@example.com").withAddress("chicago ave").build(); // 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) + .withNextOfKin(VALID_NOK_AMY).withDescription(VALID_DESCRIPTION_AMY).withTags(VALID_TAG_FRIEND).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) + .withDescription(VALID_DESCRIPTION_BOB).withNextOfKin(VALID_NOK_BOB) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From 8da5660bf8829cbe6a9aba813462457afd2d6916 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Thu, 14 Mar 2024 14:03:44 +0800 Subject: [PATCH 14/15] Improve code quality --- .../seedu/address/logic/LogicManagerTest.java | 7 ++++++- .../seedu/address/testutil/TypicalPersons.java | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 8bad9f19fed..9d7349d07b1 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -3,7 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; -import static seedu.address.logic.commands.CommandTestUtil.*; +import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.DESCRIPTION_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.NOK_DESC_AMY; +import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.AMY; diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index f0508c381bd..8dc7dd9899b 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -1,5 +1,20 @@ package seedu.address.testutil; +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_DESCRIPTION_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DESCRIPTION_BOB; +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_NAME_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NOK_AMY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_NOK_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 java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -7,8 +22,6 @@ import seedu.address.model.AddressBook; import seedu.address.model.person.Person; -import static seedu.address.logic.commands.CommandTestUtil.*; - /** * A utility class containing a list of {@code Person} objects to be used in tests. */ From 177e4a3dfc3c20dd1ee9f37b0be4b1fb126f8675 Mon Sep 17 00:00:00 2001 From: Rishit02 Date: Fri, 15 Mar 2024 11:11:45 +0800 Subject: [PATCH 15/15] Fix parse function --- .../java/seedu/address/logic/parser/AddCommandParser.java | 2 +- src/main/java/seedu/address/model/util/SampleDataUtil.java | 2 +- .../invalidAndValidPersonAddressBook.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index c077a448cbb..864f519098d 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -44,7 +44,7 @@ public AddCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_NOK, PREFIX_DESCRIPTION); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 9de29c52988..e5753eb8cab 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -50,7 +50,7 @@ public static Person[] getSamplePersons() { getTagSet("classmates")), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), - new Description("Suffers from errectile dysfunction"), + new Description("Suffers from erectile dysfunction"), new NextOfKin("Pam Balakrishnan"), getTagSet("colleagues")) }; diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json index 449907b31ee..bc22ee59aac 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json @@ -4,14 +4,14 @@ "phone": "9482424", "email": "hans@example.com", "address": "4th street", - "nok": "Valid NOK", + "NOK": "Valid NOK", "description": "Suffers from depression" }, { "name": "Person With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", "address": "4th street", - "nok": "Valid nok", + "NOK": "Valid nok", "description": "Suffers from anxiety" } ] }