From 2b6cea3330fc4fdb6670462f8d4d8802236aa7ee Mon Sep 17 00:00:00 2001 From: dylen chew <56499861+rgonslayer@users.noreply.github.com> Date: Wed, 26 Oct 2022 00:32:28 +0800 Subject: [PATCH] Add Plan Tag Feature FAP has no way to show the plan that clients have signed up for. This prevents FAs from providing quality advice. Added Plan Tag feature for users to indicate clients FA plan --- build.gradle | 2 +- .../address/logic/commands/AddCommand.java | 3 + .../address/logic/commands/EditCommand.java | 2 + .../logic/parser/AddCommandParser.java | 14 ++-- .../seedu/address/logic/parser/CliSyntax.java | 1 + .../logic/parser/EditCommandParser.java | 11 ++- .../logic/parser/EditPersonDescriptor.java | 28 +++++-- .../address/logic/parser/ParserUtil.java | 29 +++++-- .../seedu/address/model/person/Person.java | 23 ++++-- .../seedu/address/model/tag/NormalTag.java | 39 ++++++++++ .../java/seedu/address/model/tag/PlanTag.java | 39 ++++++++++ .../java/seedu/address/model/tag/RiskTag.java | 2 +- .../java/seedu/address/model/tag/Tag.java | 4 +- .../address/model/util/SampleDataUtil.java | 24 +++--- .../address/storage/JsonAdaptedPerson.java | 24 ++++-- .../seedu/address/storage/JsonAdaptedTag.java | 11 +-- .../invalidAndValidPersonAddressBook.json | 6 +- .../invalidPersonAddressBook.json | 1 + .../duplicatePersonAddressBook.json | 2 + .../invalidPersonAddressBook.json | 1 + .../typicalPersonsAddressBook.json | 7 ++ .../seedu/address/logic/LogicManagerTest.java | 3 +- .../logic/commands/CommandTestUtil.java | 9 ++- .../logic/parser/AddCommandParserTest.java | 76 ++++++++++++------- .../logic/parser/EditCommandParserTest.java | 10 ++- .../address/logic/parser/ParserUtilTest.java | 11 +-- .../java/seedu/address/model/tag/TagTest.java | 4 +- .../storage/JsonAdaptedPersonTest.java | 47 ++++++++---- .../testutil/EditPersonDescriptorBuilder.java | 13 +++- .../seedu/address/testutil/PersonBuilder.java | 19 ++++- .../seedu/address/testutil/PersonUtil.java | 7 +- .../address/testutil/TypicalPersons.java | 15 +++- 32 files changed, 371 insertions(+), 116 deletions(-) create mode 100644 src/main/java/seedu/address/model/tag/NormalTag.java create mode 100644 src/main/java/seedu/address/model/tag/PlanTag.java diff --git a/build.gradle b/build.gradle index 28fd84feb6d..7bf7b8b7222 100644 --- a/build.gradle +++ b/build.gradle @@ -82,7 +82,7 @@ run { } dependencies { - String jUnitVersion = '5.4.0' + String jUnitVersion = '5.9.0' String javaFxVersion = '11' implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 4885bbb1b82..45081570e3f 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -7,6 +7,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -30,6 +31,7 @@ public class AddCommand extends Command { + "[" + PREFIX_INCOME + "INCOME] " + "[" + PREFIX_MONTHLY + "MONTHLY] " + "[" + PREFIX_RISKTAG + "RISKTAG] " + + "[" + PREFIX_PLANTAG + "PLANTAG] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " @@ -39,6 +41,7 @@ public class AddCommand extends Command { + PREFIX_INCOME + "$1000 " + PREFIX_MONTHLY + "$200 " + PREFIX_RISKTAG + "HIGH " + + PREFIX_PLANTAG + "Savings Plan" + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index eb62301eb94..4f0586935d0 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -7,6 +7,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.EditPersonDescriptor.createEditedPerson; @@ -39,6 +40,7 @@ public class EditCommand extends Command { + "[" + PREFIX_INCOME + "INCOME] " + "[" + PREFIX_MONTHLY + "MONTHLY} " + "[" + PREFIX_RISKTAG + "RISKTAG] " + + "[" + PREFIX_PLANTAG + "PLANTAG] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3189f09fe2f..6bcab05ad3f 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -10,6 +10,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -24,8 +25,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** * Parses input arguments and creates a new AddCommand object @@ -41,10 +43,10 @@ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_INCOME, PREFIX_MONTHLY, PREFIX_RISKTAG, - PREFIX_TAG, PREFIX_APPOINTMENT_DATE, PREFIX_APPOINTMENT_LOCATION); + PREFIX_PLANTAG, PREFIX_TAG, PREFIX_APPOINTMENT_DATE, PREFIX_APPOINTMENT_LOCATION); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, - PREFIX_EMAIL, PREFIX_INCOME, PREFIX_MONTHLY, PREFIX_RISKTAG) + PREFIX_EMAIL, PREFIX_INCOME, PREFIX_MONTHLY, PREFIX_PLANTAG, PREFIX_RISKTAG) || !argMultimap.getPreamble().isEmpty() || arePrefixesPresent(argMultimap, PREFIX_APPOINTMENT_DATE, PREFIX_APPOINTMENT_LOCATION)) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); @@ -57,9 +59,9 @@ public AddCommand parse(String args) throws ParseException { IncomeLevel incomeLevel = ParserUtil.parseIncomeLevel(argMultimap.getValue(PREFIX_INCOME).get()); Monthly monthly = ParserUtil.parseMonthly(argMultimap.getValue(PREFIX_MONTHLY).get()); RiskTag riskTag = ParserUtil.parseRiskTag(argMultimap.getValue(PREFIX_RISKTAG).get()); - Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - - Person person = new Person(name, phone, email, address, incomeLevel, monthly, riskTag, tagList); + PlanTag planTag = ParserUtil.parsePlanTag(argMultimap.getValue(PREFIX_PLANTAG).get()); + Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); + Person person = new Person(name, phone, email, address, incomeLevel, monthly, riskTag, planTag, tagList); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index c6a44dc98e2..6411aa3eb02 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,6 +11,7 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_RISKTAG = new Prefix("r/"); + public static final Prefix PREFIX_PLANTAG = new Prefix("ip/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); public static final Prefix PREFIX_APPOINTMENT_DATE = new Prefix("d/"); public static final Prefix PREFIX_APPOINTMENT_LOCATION = new Prefix("l/"); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index edd485a1e7f..e0555ced794 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -8,6 +8,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -19,7 +20,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.EditCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.tag.Tag; +import seedu.address.model.tag.NormalTag; /** * Parses input arguments and creates a new EditCommand object @@ -34,7 +35,8 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, - PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_INCOME, PREFIX_MONTHLY, PREFIX_RISKTAG, PREFIX_TAG); + PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_INCOME, PREFIX_MONTHLY, + PREFIX_RISKTAG, PREFIX_PLANTAG, PREFIX_TAG); Index index; @@ -60,6 +62,9 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_RISKTAG).isPresent()) { editPersonDescriptor.setRiskTag(ParserUtil.parseRiskTag(argMultimap.getValue(PREFIX_RISKTAG).get())); } + if (argMultimap.getValue(PREFIX_PLANTAG).isPresent()) { + editPersonDescriptor.setPlanTag(ParserUtil.parsePlanTag(argMultimap.getValue(PREFIX_PLANTAG).get())); + } if (argMultimap.getValue(PREFIX_INCOME).isPresent()) { editPersonDescriptor.setIncome(ParserUtil.parseIncomeLevel(argMultimap.getValue(PREFIX_INCOME).get())); } @@ -81,7 +86,7 @@ public EditCommand parse(String args) throws ParseException { * If {@code tags} contain only one element which is an empty string, it will be parsed into a * {@code Set} containing zero tags. */ - private Optional> parseTagsForEdit(Collection tags) throws ParseException { + private Optional> parseTagsForEdit(Collection tags) throws ParseException { assert tags != null; if (tags.isEmpty()) { diff --git a/src/main/java/seedu/address/logic/parser/EditPersonDescriptor.java b/src/main/java/seedu/address/logic/parser/EditPersonDescriptor.java index 5e214503d5d..30286a6d558 100644 --- a/src/main/java/seedu/address/logic/parser/EditPersonDescriptor.java +++ b/src/main/java/seedu/address/logic/parser/EditPersonDescriptor.java @@ -15,8 +15,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** * Stores the details to edit the person with. Each non-empty field value will replace the @@ -30,7 +31,8 @@ public class EditPersonDescriptor { private IncomeLevel income; private Monthly monthly; private RiskTag riskTag; - private Set tags; + private PlanTag planTag; + private Set tags; public EditPersonDescriptor() {} /** @@ -45,6 +47,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setIncome(toCopy.income); setMonthly(toCopy.monthly); setRiskTag(toCopy.riskTag); + setPlanTag(toCopy.planTag); setTags(toCopy.tags); } @@ -52,7 +55,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, address, income, monthly, riskTag, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, address, income, monthly, riskTag, planTag, tags); } public void setName(Name name) { @@ -95,6 +98,14 @@ public Optional getRiskTag() { return Optional.ofNullable(riskTag); } + public void setPlanTag(PlanTag planTag) { + this.planTag = planTag; + } + + public Optional getPlanTag() { + return Optional.ofNullable(planTag); + } + public void setIncome(IncomeLevel income) { this.income = income; } @@ -112,7 +123,7 @@ public Optional getMonthly() { * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. */ - public void setTags(Set tags) { + public void setTags(Set tags) { this.tags = (tags != null) ? new HashSet<>(tags) : null; } @@ -121,7 +132,7 @@ public void setTags(Set tags) { * if modification is attempted. * Returns {@code Optional#empty()} if {@code tags} is null. */ - public Optional> getTags() { + public Optional> getTags() { return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); } @@ -139,11 +150,13 @@ public static Person createEditedPerson(Person personToEdit, EditPersonDescripto IncomeLevel updatedIncomeLevel = editPersonDescriptor.getIncome().orElse(personToEdit.getIncome()); Monthly updateMonthly = editPersonDescriptor.getMonthly().orElse(personToEdit.getMonthly()); RiskTag updatedRiskTag = editPersonDescriptor.getRiskTag().orElse(personToEdit.getRiskTag()); - Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + PlanTag updatedPlanTag = editPersonDescriptor.getPlanTag().orElse(personToEdit.getPlanTag()); + Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); MaximumSortedList originalAppointments = personToEdit.getAppointments(); return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedIncomeLevel, - updateMonthly, updatedRiskTag, updatedTags, originalAppointments); + updateMonthly, updatedRiskTag, updatedPlanTag, updatedTags, originalAppointments); + } @Override public boolean equals(Object other) { @@ -166,6 +179,7 @@ && getEmail().equals(e.getEmail()) && getAddress().equals(e.getAddress()) && getRiskTag().equals(e.getRiskTag()) && getMonthly().equals(e.getMonthly()) + && getPlanTag().equals(e.getPlanTag()) && getTags().equals(e.getTags()); } } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index aa5c99b9497..867a97eeb7f 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -21,8 +21,9 @@ import seedu.address.model.person.Monthly; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** * Contains utility methods used for parsing strings in the various *Parser classes. @@ -217,7 +218,7 @@ public static Monthly parseMonthly(String monthly) throws ParseException { } /** - * Parses a {@code String dateAndTime} into an {@code DateTime}. + * Parses a {@code String riskTag} into an {@code RiskTag}. * Leading and trailing whitespaces will be trimmed. */ public static RiskTag parseRiskTag(String riskTag) throws ParseException { @@ -229,6 +230,18 @@ public static RiskTag parseRiskTag(String riskTag) throws ParseException { return new RiskTag(trimmedRiskTag); } + /** + * Parses a {@code String planTag} into an {@code PlanTag}. + * Leading and trailing whitespaces will be trimmed. + */ + public static PlanTag parsePlanTag(String planTag) throws ParseException { + requireNonNull(planTag); + String trimmedPlanTag = planTag.trim(); + if (!PlanTag.isValidPlanTagName(trimmedPlanTag)) { + throw new ParseException(PlanTag.MESSAGE_CONSTRAINTS); + } + return new PlanTag(trimmedPlanTag); + } /** * Parses a {@code String tag} into a {@code Tag}. @@ -236,21 +249,21 @@ public static RiskTag parseRiskTag(String riskTag) throws ParseException { * * @throws ParseException if the given {@code tag} is invalid. */ - public static Tag parseTag(String tag) throws ParseException { + public static NormalTag parseTag(String tag) throws ParseException { requireNonNull(tag); String trimmedTag = tag.trim(); - if (!Tag.isValidTagName(trimmedTag)) { - throw new ParseException(Tag.MESSAGE_CONSTRAINTS); + if (!NormalTag.isValidTagName(trimmedTag)) { + throw new ParseException(NormalTag.MESSAGE_CONSTRAINTS); } - return new Tag(trimmedTag); + return new NormalTag(trimmedTag); } /** * Parses {@code Collection tags} into a {@code Set}. */ - public static Set parseTags(Collection tags) throws ParseException { + public static Set parseTags(Collection tags) throws ParseException { requireNonNull(tags); - final Set tagSet = new HashSet<>(); + final Set tagSet = new HashSet<>(); for (String tagName : tags) { tagSet.add(parseTag(tagName)); } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index a04b5ed7a48..b2eef978406 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -11,6 +11,8 @@ import seedu.address.logic.util.MaximumSortedList; import seedu.address.model.calendar.CalendarEvent; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; import seedu.address.model.tag.Tag; @@ -30,24 +32,26 @@ public class Person { // Data fields private final Address address; private final RiskTag riskTag; + private final PlanTag planTag; private final Set specialTags = new HashSet<>(); - - private final Set tags = new HashSet<>(); + private final Set tags = new HashSet<>(); private MaximumSortedList appointments = new MaximumSortedList<>(MAXIMUM_NUM_OF_APPOINTMENTS); /** * Every field must be present and not null. */ public Person(Name name, Phone phone, Email email, Address address, IncomeLevel incomeLevel, - Monthly monthly, RiskTag riskTag, Set tags) { - requireAllNonNull(name, phone, email, address, incomeLevel, monthly, riskTag, tags); + Monthly monthly, RiskTag riskTag, PlanTag planTag, Set tags) { + requireAllNonNull(name, phone, email, address, incomeLevel, monthly, riskTag, planTag, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; this.riskTag = riskTag; + this.planTag = planTag; this.specialTags.add(riskTag); + this.specialTags.add(planTag); this.incomeLevel = incomeLevel; this.monthly = monthly; this.tags.addAll(tags); @@ -57,14 +61,16 @@ public Person(Name name, Phone phone, Email email, Address address, IncomeLevel * Every field must be present and not null. */ public Person(Name name, Phone phone, Email email, Address address, IncomeLevel incomeLevel, Monthly monthly, - RiskTag riskTag, Set tags, MaximumSortedList appointments) { + RiskTag riskTag, PlanTag planTag, Set tags, MaximumSortedList appointments) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; this.riskTag = riskTag; + this.planTag = planTag; this.specialTags.add(riskTag); + this.specialTags.add(planTag); this.monthly = monthly; this.tags.addAll(tags); this.appointments = appointments; @@ -106,13 +112,16 @@ public IncomeLevel getIncome() { public RiskTag getRiskTag() { return riskTag; } + public PlanTag getPlanTag() { + return planTag; + } /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. */ - public Set getTags() { + public Set getTags() { return Collections.unmodifiableSet(tags); } public Set getSpecialTags() { @@ -186,7 +195,7 @@ public String toString() { ); } - Set tags = getTags(); + Set tags = getTags(); if (!tags.isEmpty()) { builder.append("; Tags: "); tags.forEach(builder::append); diff --git a/src/main/java/seedu/address/model/tag/NormalTag.java b/src/main/java/seedu/address/model/tag/NormalTag.java new file mode 100644 index 00000000000..657b97c84e8 --- /dev/null +++ b/src/main/java/seedu/address/model/tag/NormalTag.java @@ -0,0 +1,39 @@ +package seedu.address.model.tag; + +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Tag in the address book. + * Guarantees: immutable; name is valid as declared in {@link #isValidNormalTagName(String)} + */ +public class NormalTag extends Tag { + + public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; + public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; + + + /** + * Constructs a {@code Tag}. + * + * @param tagName A valid tag name. + */ + public NormalTag(String tagName) { + super(tagName); + checkArgument(isValidNormalTagName(tagName), MESSAGE_CONSTRAINTS); + } + + /** + * Returns true if a given string is a valid tag name. + */ + public static boolean isValidNormalTagName(String test) { + return test.matches(VALIDATION_REGEX); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof NormalTag // instanceof handles nulls + && tagName.equals(((NormalTag) other).tagName)); // state check + } + +} diff --git a/src/main/java/seedu/address/model/tag/PlanTag.java b/src/main/java/seedu/address/model/tag/PlanTag.java new file mode 100644 index 00000000000..563fe34e7fd --- /dev/null +++ b/src/main/java/seedu/address/model/tag/PlanTag.java @@ -0,0 +1,39 @@ +package seedu.address.model.tag; + +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a PlanTag in the address book. + * Guarantees: immutable; name is valid as declared in {@link #isValidPlanTagName(String)} + */ +public class PlanTag extends Tag { + + public static final String MESSAGE_CONSTRAINTS = "Plan tag name should only contain alphanumeric characters " + + "and spaces, ending with Plan"; + public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*[Plan]"; + + /** + * Constructs a {@code Tag}. + * + * @param tagName A valid tag name. + */ + public PlanTag(String tagName) { + super(tagName); + checkArgument(isValidPlanTagName(tagName), MESSAGE_CONSTRAINTS); + } + + + /** + * Returns true if a given string is a valid tag name. + */ + public static boolean isValidPlanTagName(String test) { + return test.matches(VALIDATION_REGEX); + } + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof PlanTag // instanceof handles nulls + && tagName.equals(((PlanTag) other).tagName)); // state check + } + +} diff --git a/src/main/java/seedu/address/model/tag/RiskTag.java b/src/main/java/seedu/address/model/tag/RiskTag.java index 3283e88998f..ed82637fb79 100644 --- a/src/main/java/seedu/address/model/tag/RiskTag.java +++ b/src/main/java/seedu/address/model/tag/RiskTag.java @@ -6,7 +6,7 @@ * Represents a RiskTag in the address book. * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} */ -public class RiskTag extends Tag { +public class RiskTag extends NormalTag { public static final String MESSAGE_CONSTRAINTS = "Risk tag name should be [LOW], [MEDIUM], or [HIGH]"; public static final String VALIDATION_REGEX = "(HIGH|MEDIUM|LOW)"; diff --git a/src/main/java/seedu/address/model/tag/Tag.java b/src/main/java/seedu/address/model/tag/Tag.java index b0ea7e7dad7..f7164a4af9c 100644 --- a/src/main/java/seedu/address/model/tag/Tag.java +++ b/src/main/java/seedu/address/model/tag/Tag.java @@ -7,10 +7,10 @@ * Represents a Tag in the address book. * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)} */ -public class Tag { +public abstract class Tag { public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; - public static final String VALIDATION_REGEX = "\\p{Alnum}+"; + public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; public final String tagName; diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 83aa0ce0b38..a6a5289f9cb 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -13,8 +13,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** @@ -25,22 +26,27 @@ 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 IncomeLevel("$3000"), - new Monthly("$200"), new RiskTag("HIGH"), getTagSet("friends")), + new Monthly("$200"), new RiskTag("HIGH"), new PlanTag("Savings Plan"), + 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 IncomeLevel("$30000"), - new Monthly("$100"), new RiskTag("LOW"), getTagSet("colleagues", "friends")), + new Monthly("$100"), new RiskTag("LOW"), new PlanTag("Savings Plan"), + 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 IncomeLevel("$1000000"), - new Monthly("$400"), new RiskTag("MEDIUM"), getTagSet("neighbours")), + new Monthly("$400"), new RiskTag("MEDIUM"), new PlanTag("Savings Plan"), + 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 IncomeLevel("$1"), - new Monthly("$100"), new RiskTag("HIGH"), getTagSet("family")), + new Monthly("$100"), new RiskTag("HIGH"), new PlanTag("Savings Plan"), + 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 IncomeLevel("$20000"), - new Monthly("$300"), new RiskTag("LOW"), getTagSet("classmates")), + new Monthly("$300"), new RiskTag("LOW"), new PlanTag("Savings Plan"), + 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 IncomeLevel("$40000"), new Monthly("$250"), - new RiskTag("HIGH"), getTagSet("colleagues")) + new RiskTag("HIGH"), new PlanTag("Savings Plan"), getTagSet("colleagues")) }; } @@ -55,9 +61,9 @@ public static ReadOnlyAddressBook getSampleAddressBook() { /** * Returns a tag set containing the list of strings given. */ - public static Set getTagSet(String... strings) { + public static Set getTagSet(String... strings) { return Arrays.stream(strings) - .map(Tag::new) + .map(NormalTag::new) .collect(Collectors.toSet()); } } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index dcfc46fb042..d137838d416 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -21,8 +21,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** @@ -37,6 +38,7 @@ class JsonAdaptedPerson { private final String email; private final String address; private final String riskTag; + private final String planTag; private final String income; private final String monthly; private final List tagged = new ArrayList<>(); @@ -50,13 +52,16 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone @JsonProperty("email") String email, @JsonProperty("address") String address, @JsonProperty("income") String income, @JsonProperty("monthly") String monthly, - @JsonProperty("riskTag") String riskTag, @JsonProperty("tagged") List tagged, + @JsonProperty("riskTag") String riskTag, + @JsonProperty("planTag") String planTag, + @JsonProperty("tagged") List tagged, @JsonProperty("appointments") List appointments) { this.name = name; this.phone = phone; this.email = email; this.address = address; this.riskTag = riskTag; + this.planTag = planTag; this.income = income; this.monthly = monthly; if (tagged != null) { @@ -76,6 +81,7 @@ public JsonAdaptedPerson(Person source) { email = source.getEmail().value; address = source.getAddress().value; riskTag = source.getRiskTag().tagName; + planTag = source.getPlanTag().tagName; income = source.getIncome().value; monthly = source.getMonthly().value; tagged.addAll(source.getTags().stream() @@ -92,7 +98,7 @@ public JsonAdaptedPerson(Person source) { * @throws IllegalValueException if there were any data constraints violated in the adapted person. */ public Person toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); + final List personTags = new ArrayList<>(); for (JsonAdaptedTag tag : tagged) { personTags.add(tag.toModelType()); } @@ -158,9 +164,17 @@ public Person toModelType() throws IllegalValueException { } final RiskTag modelRiskTag = new RiskTag(riskTag); - final Set modelTags = new HashSet<>(personTags); + if (planTag == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, PlanTag.class.getSimpleName())); + } + if (!PlanTag.isValidPlanTagName(planTag)) { + throw new IllegalValueException(PlanTag.MESSAGE_CONSTRAINTS); + } + final PlanTag modelPlanTag = new PlanTag(planTag); + + final Set modelTags = new HashSet<>(personTags); Person newPerson = new Person(modelName, modelPhone, modelEmail, - modelAddress, modelIncome, modelMonthly, modelRiskTag, modelTags); + modelAddress, modelIncome, modelMonthly, modelRiskTag, modelPlanTag, modelTags); newPerson.setAppointments(modelAppointments); return newPerson; diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java index 0df22bdb754..7e59781351e 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java @@ -4,10 +4,11 @@ import com.fasterxml.jackson.annotation.JsonValue; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.tag.NormalTag; import seedu.address.model.tag.Tag; /** - * Jackson-friendly version of {@link Tag}. + * Jackson-friendly version of {@link NormalTag}. */ class JsonAdaptedTag { @@ -38,11 +39,11 @@ 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)) { - throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS); + public NormalTag toModelType() throws IllegalValueException { + if (!NormalTag.isValidNormalTagName(tagName)) { + throw new IllegalValueException(NormalTag.MESSAGE_CONSTRAINTS); } - return new Tag(tagName); + return new NormalTag(tagName); } } diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json index 286826f6c26..c0df23cc573 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json @@ -3,7 +3,8 @@ "name": "Valid Person", "phone": "9482424", "email": "hans@example.com", - "riskTag": "HIGH" + "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "address": "4th street", "monthly": "$1000" @@ -11,7 +12,8 @@ "name": "Person With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", - "riskTag": "HIGH" + "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "address": "4th street", "monthly": "$1000" diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json index 62aa5181070..5ab5df7ec25 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json @@ -5,6 +5,7 @@ "email": "hans@example.com", "address": "4th street", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$1000" } ] diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json index 2c5ab05178a..4be5fc2cfcf 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json @@ -5,6 +5,7 @@ "email": "alice@example.com", "address": "123, Jurong West Ave 6, #08-111", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$1000", "tagged": [ "friends" ] @@ -14,6 +15,7 @@ "email": "pauline@example.com", "address": "4th street", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$1000" } ] diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json index 8c24fcc48ee..3206c3f4653 100644 --- a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json @@ -5,6 +5,7 @@ "email": "invalid@email!3e", "address": "4th street", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$1000" } ] diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index c4b464ecb29..52eced3fdde 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -6,6 +6,7 @@ "email" : "alice@example.com", "address" : "123, Jurong West Ave 6, #08-111", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$200", "tagged" : [ "friends" ] @@ -15,6 +16,7 @@ "email" : "johnd@example.com", "address" : "311, Clementi Ave 2, #02-25", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$100", "tagged" : [ "owesMoney", "friends" ] @@ -24,6 +26,7 @@ "email" : "heinz@example.com", "address" : "wall street", "riskTag": "MEDIUM", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$200", "tagged" : [ ] @@ -33,6 +36,7 @@ "email" : "cornelia@example.com", "address" : "10th street", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$300", "tagged" : [ "friends" ] @@ -42,6 +46,7 @@ "email" : "werner@example.com", "address" : "michegan ave", "riskTag": "LOW", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$250", "tagged" : [ ], @@ -55,6 +60,7 @@ "email" : "lydia@example.com", "address" : "little tokyo", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$500", "tagged" : [ ], @@ -68,6 +74,7 @@ "email" : "anna@example.com", "address" : "4th street", "riskTag": "HIGH", + "planTag": "Savings Plan", "income": "$1000", "monthly": "$400", "tagged" : [ ], diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 1b21e750080..ee4bb445da2 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -9,6 +9,7 @@ import static seedu.address.logic.commands.CommandTestUtil.MONTHLY_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.PLANTAG_DESC_SAVINGS; import static seedu.address.logic.commands.CommandTestUtil.RISKTAG_DESC_LOW; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.AMY; @@ -89,7 +90,7 @@ public void execute_storageThrowsIoException_throwsCommandException() { // Execute add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY - + ADDRESS_DESC_AMY + INCOME_DESC_AMY + MONTHLY_DESC_AMY + RISKTAG_DESC_LOW; + + ADDRESS_DESC_AMY + INCOME_DESC_AMY + MONTHLY_DESC_AMY + RISKTAG_DESC_LOW + PLANTAG_DESC_SAVINGS; Person expectedPerson = new PersonBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); expectedModel.addPerson(expectedPerson); diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 33e338f4093..c4977f5e70a 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -10,6 +10,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.testutil.Assert.assertThrows; @@ -42,6 +43,7 @@ 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_PLANTAG_SAVINGS = "Savings Plan"; public static final String VALID_RISKTAG_HIGH = "HIGH"; public static final String VALID_RISKTAG_LOW = "LOW"; @@ -78,6 +80,7 @@ public class CommandTestUtil { + VALID_DATETIME_22_JAN_2023 + " " + PREFIX_APPOINTMENT_LOCATION + VALID_LOCATION_JURONGPOINT; public static final String MONTHLY_DESC_AMY = " " + PREFIX_MONTHLY + VALID_MONTHLY_AMY; public static final String MONTHLY_DESC_BOB = " " + PREFIX_MONTHLY + VALID_MONTHLY_BOB; + public static final String PLANTAG_DESC_SAVINGS = " " + PREFIX_PLANTAG + VALID_PLANTAG_SAVINGS; public static final String RISKTAG_DESC_HIGH = " " + PREFIX_RISKTAG + VALID_RISKTAG_HIGH; public static final String RISKTAG_DESC_LOW = " " + PREFIX_RISKTAG + VALID_RISKTAG_LOW; public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; @@ -86,6 +89,7 @@ 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_PLANTAG_DESC = " " + PREFIX_PLANTAG + "none"; // must end with Plan public static final String INVALID_RISKTAG_DESC = " " + PREFIX_RISKTAG + "none"; // must be HIGH LOW or MEDIUM public static final String INVALID_INCOME_DESC = " " + PREFIX_INCOME + "000"; // income should include "$" sign public static final String INVALID_MONTHLY_DESC = " " + PREFIX_MONTHLY + "000"; // monthly should include "$" @@ -110,11 +114,12 @@ public class CommandTestUtil { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) .withIncome(VALID_INCOME_AMY).withMonthly(VALID_MONTHLY_AMY) - .withRiskTag(VALID_RISKTAG_LOW).withTags(VALID_TAG_FRIEND).build(); + .withRiskTag(VALID_RISKTAG_LOW).withPlanTag(VALID_PLANTAG_SAVINGS).withTags(VALID_TAG_FRIEND).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) .withIncome(VALID_INCOME_BOB).withMonthly(VALID_MONTHLY_AMY) - .withRiskTag(VALID_RISKTAG_HIGH).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withRiskTag(VALID_RISKTAG_HIGH).withPlanTag(VALID_PLANTAG_SAVINGS) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); DESC_APPT_1 = new EditAppointmentDescriptorBuilder().withDateTime(VALID_DATETIME_21_JAN_2023) .withLocation(VALID_LOCATION_NUS).build(); DESC_APPT_2 = new EditAppointmentDescriptorBuilder().withDateTime(VALID_DATETIME_22_JAN_2023) diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index b8e0acb60e2..8bf6c0ba6b5 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -13,6 +13,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_MONTHLY_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_PLANTAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_RISKTAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.MONTHLY_DESC_AMY; @@ -21,6 +22,7 @@ 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.PLANTAG_DESC_SAVINGS; 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.RISKTAG_DESC_HIGH; @@ -33,6 +35,7 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_MONTHLY_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_PLANTAG_SAVINGS; import static seedu.address.logic.commands.CommandTestUtil.VALID_RISKTAG_HIGH; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; @@ -50,6 +53,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -64,43 +68,49 @@ public void parse_allFieldsPresent_success() { // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple names - last name accepted assertParseSuccess(parser, NAME_DESC_AMY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple phones - last phone accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple emails - last email accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_AMY + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple addresses - last address accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple income - last income accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + MONTHLY_DESC_BOB + INCOME_DESC_AMY + INCOME_DESC_BOB - + RISKTAG_DESC_HIGH + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); //multiple riskTags - last riskTag accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB - + RISKTAG_DESC_LOW + RISKTAG_DESC_HIGH + + RISKTAG_DESC_LOW + PLANTAG_DESC_SAVINGS + RISKTAG_DESC_HIGH + + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + //multiple planTags - last planTag accepted + assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY + + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB + + RISKTAG_DESC_LOW + PLANTAG_DESC_SAVINGS + PLANTAG_DESC_SAVINGS + 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 - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + TAG_DESC_HUSBAND + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @@ -109,7 +119,7 @@ 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 - + INCOME_DESC_AMY + MONTHLY_DESC_AMY + RISKTAG_DESC_LOW, + + INCOME_DESC_AMY + MONTHLY_DESC_AMY + RISKTAG_DESC_LOW + PLANTAG_DESC_SAVINGS, new AddCommand(expectedPerson)); } @@ -119,86 +129,98 @@ public void parse_compulsoryFieldMissing_failure() { // missing name prefix assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, expectedMessage); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + PLANTAG_DESC_SAVINGS, expectedMessage); // missing phone prefix assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, expectedMessage); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + PLANTAG_DESC_SAVINGS, expectedMessage); // missing email prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, expectedMessage); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS, expectedMessage); // missing address prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, expectedMessage); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + PLANTAG_DESC_SAVINGS, expectedMessage); // missing income prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + VALID_INCOME_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, expectedMessage); + + VALID_INCOME_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS, expectedMessage); // missing monthly prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + VALID_MONTHLY_BOB + RISKTAG_DESC_HIGH, + + INCOME_DESC_BOB + VALID_MONTHLY_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS, expectedMessage); // missing riskTag prefix assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + VALID_RISKTAG_HIGH, expectedMessage); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + VALID_RISKTAG_HIGH + PLANTAG_DESC_SAVINGS, expectedMessage); + // missing planTag prefix + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + VALID_PLANTAG_SAVINGS, expectedMessage); // all prefixes missing assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB - + VALID_INCOME_BOB + VALID_MONTHLY_BOB + VALID_RISKTAG_HIGH, expectedMessage); + + VALID_INCOME_BOB + VALID_MONTHLY_BOB + VALID_RISKTAG_HIGH + VALID_PLANTAG_SAVINGS, expectedMessage); } @Test public void parse_invalidValue_failure() { // invalid name assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + 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 - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + 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 - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + 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 - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); // invalid income assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INVALID_INCOME_DESC + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INVALID_INCOME_DESC + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, IncomeLevel.MESSAGE_CONSTRAINTS); // invalid monthly assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - + INCOME_DESC_BOB + INVALID_MONTHLY_DESC + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + INVALID_MONTHLY_DESC + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); // invalid riskTag assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + PLANTAG_DESC_SAVINGS + INVALID_RISKTAG_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, RiskTag.MESSAGE_CONSTRAINTS); + // invalid planTag + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + + RISKTAG_DESC_HIGH + INVALID_PLANTAG_DESC + TAG_DESC_HUSBAND + + TAG_DESC_FRIEND, PlanTag.MESSAGE_CONSTRAINTS); // invalid tag assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + 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 - + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH, Name.MESSAGE_CONSTRAINTS); + + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + PLANTAG_DESC_SAVINGS, Name.MESSAGE_CONSTRAINTS); // non-empty preamble assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + + ADDRESS_DESC_BOB + INCOME_DESC_BOB + MONTHLY_DESC_BOB + RISKTAG_DESC_HIGH + PLANTAG_DESC_SAVINGS + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, 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 2e60658e196..7afd4002ba1 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -12,12 +12,14 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_MONTHLY_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_PLANTAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_RISKTAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC; import static seedu.address.logic.commands.CommandTestUtil.MONTHLY_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.PHONE_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.PLANTAG_DESC_SAVINGS; import static seedu.address.logic.commands.CommandTestUtil.RISKTAG_DESC_LOW; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; @@ -30,6 +32,7 @@ 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_PLANTAG_SAVINGS; import static seedu.address.logic.commands.CommandTestUtil.VALID_RISKTAG_LOW; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; @@ -50,6 +53,7 @@ import seedu.address.model.person.Monthly; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; import seedu.address.model.tag.Tag; import seedu.address.testutil.EditPersonDescriptorBuilder; @@ -97,6 +101,7 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS); // invalid email assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address assertParseFailure(parser, "1" + INVALID_RISKTAG_DESC, RiskTag.MESSAGE_CONSTRAINTS); // invalid riskTag + assertParseFailure(parser, "1" + INVALID_PLANTAG_DESC, PlanTag.MESSAGE_CONSTRAINTS); // invalid PlanTag assertParseFailure(parser, "1" + INVALID_INCOME_DESC, IncomeLevel.MESSAGE_CONSTRAINTS); // invalid income assertParseFailure(parser, "1" + INVALID_MONTHLY_DESC, Monthly.MESSAGE_CONSTRAINTS); // invalid monthly assertParseFailure(parser, "1" + INVALID_TAG_DESC, Tag.MESSAGE_CONSTRAINTS); // invalid tag @@ -124,12 +129,13 @@ 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 + INCOME_DESC_AMY + MONTHLY_DESC_AMY - + NAME_DESC_AMY + RISKTAG_DESC_LOW + TAG_DESC_FRIEND; + + NAME_DESC_AMY + RISKTAG_DESC_LOW + PLANTAG_DESC_SAVINGS + TAG_DESC_FRIEND; EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) .withIncome(VALID_INCOME_AMY).withMonthly(VALID_MONTHLY_AMY) - .withRiskTag(VALID_RISKTAG_LOW).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withRiskTag(VALID_RISKTAG_LOW).withPlanTag(VALID_PLANTAG_SAVINGS) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..8cc4cf66a8f 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.NormalTag; import seedu.address.model.tag.Tag; public class ParserUtilTest { @@ -160,14 +161,14 @@ public void parseTag_invalidValue_throwsParseException() { @Test public void parseTag_validValueWithoutWhitespace_returnsTag() throws Exception { - Tag expectedTag = new Tag(VALID_TAG_1); + Tag expectedTag = new NormalTag(VALID_TAG_1); assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1)); } @Test public void parseTag_validValueWithWhitespace_returnsTrimmedTag() throws Exception { String tagWithWhitespace = WHITESPACE + VALID_TAG_1 + WHITESPACE; - Tag expectedTag = new Tag(VALID_TAG_1); + Tag expectedTag = new NormalTag(VALID_TAG_1); assertEquals(expectedTag, ParserUtil.parseTag(tagWithWhitespace)); } @@ -188,9 +189,9 @@ 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 expectedTagSet = new HashSet(Arrays.asList(new Tag(VALID_TAG_1), new Tag(VALID_TAG_2))); - + Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, VALID_TAG_2)); + Set expectedTagSet = new HashSet(Arrays.asList(new NormalTag(VALID_TAG_1), + new NormalTag(VALID_TAG_2))); assertEquals(expectedTagSet, actualTagSet); } } diff --git a/src/test/java/seedu/address/model/tag/TagTest.java b/src/test/java/seedu/address/model/tag/TagTest.java index 64d07d79ee2..1f165fff0d0 100644 --- a/src/test/java/seedu/address/model/tag/TagTest.java +++ b/src/test/java/seedu/address/model/tag/TagTest.java @@ -8,13 +8,13 @@ public class TagTest { @Test public void constructor_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> new Tag(null)); + assertThrows(NullPointerException.class, () -> new NormalTag(null)); } @Test public void constructor_invalidTagName_throwsIllegalArgumentException() { String invalidTagName = ""; - assertThrows(IllegalArgumentException.class, () -> new Tag(invalidTagName)); + assertThrows(IllegalArgumentException.class, () -> new NormalTag(invalidTagName)); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index 711ec3b1173..eb4ab873dce 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -1,6 +1,7 @@ package seedu.address.storage; import static org.junit.jupiter.api.Assertions.assertEquals; +import static seedu.address.logic.commands.CommandTestUtil.VALID_RISKTAG_HIGH; import static seedu.address.storage.JsonAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.BENSON; @@ -18,6 +19,7 @@ import seedu.address.model.person.Monthly; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; public class JsonAdaptedPersonTest { @@ -26,6 +28,7 @@ public class JsonAdaptedPersonTest { private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_RISKTAG = "jump"; + private static final String INVALID_PLANTAG = "sit"; private static final String INVALID_INCOME = "301222"; private static final String INVALID_MONTHLY = "201"; private static final String INVALID_TAG = "#friend"; @@ -39,6 +42,7 @@ public class JsonAdaptedPersonTest { private static final String VALID_INCOME = BENSON.getIncome().toString(); private static final String VALID_ADDRESS = BENSON.getAddress().toString(); private static final String VALID_RISKTAG = BENSON.getRiskTag().toString(); + private static final String VALID_PLANTAG = BENSON.getPlanTag().toString(); private static final String VALID_MONTHLY = BENSON.getMonthly().toString(); private static final List VALID_TAGS = BENSON.getTags().stream() .map(JsonAdaptedTag::new) @@ -57,7 +61,7 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { public void toModelType_invalidName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = Name.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); @@ -66,7 +70,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { @Test public void toModelType_nullName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -75,7 +79,7 @@ public void toModelType_nullName_throwsIllegalValueException() { public void toModelType_invalidPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -83,7 +87,7 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { @Test public void toModelType_nullPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -92,7 +96,7 @@ public void toModelType_nullPhone_throwsIllegalValueException() { public void toModelType_invalidEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = Email.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -100,7 +104,7 @@ public void toModelType_invalidEmail_throwsIllegalValueException() { @Test public void toModelType_nullEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -109,7 +113,7 @@ public void toModelType_nullEmail_throwsIllegalValueException() { public void toModelType_invalidAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = Address.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -117,7 +121,7 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { @Test public void toModelType_nullAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -127,7 +131,7 @@ public void toModelType_nullAddress_throwsIllegalValueException() { public void toModelType_invalidRiskTag_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, INVALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, INVALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = RiskTag.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -135,7 +139,7 @@ public void toModelType_invalidRiskTag_throwsIllegalValueException() { @Test public void toModelType_nullRiskTag_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, - VALID_INCOME, VALID_MONTHLY, null, VALID_TAGS, VALID_APPOINTMENTS); + VALID_INCOME, VALID_MONTHLY, null, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, RiskTag.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -144,7 +148,7 @@ public void toModelType_nullRiskTag_throwsIllegalValueException() { public void toModelType_invalidIncome_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, INVALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = IncomeLevel.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -153,7 +157,7 @@ public void toModelType_invalidIncome_throwsIllegalValueException() { public void toModelType_invalidMonthly_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - INVALID_MONTHLY, VALID_RISKTAG, VALID_TAGS, VALID_APPOINTMENTS); + INVALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); String expectedMessage = Monthly.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -164,7 +168,24 @@ public void toModelType_invalidTags_throwsIllegalValueException() { invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, - VALID_MONTHLY, VALID_RISKTAG, invalidTags, VALID_APPOINTMENTS); + VALID_MONTHLY, VALID_RISKTAG, VALID_PLANTAG, invalidTags, VALID_APPOINTMENTS); assertThrows(IllegalValueException.class, person::toModelType); } + + @Test + public void toModelType_invalidPlanTag_throwsIllegalValueException() { + JsonAdaptedPerson person = + new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_INCOME, + VALID_MONTHLY, VALID_RISKTAG_HIGH, INVALID_PLANTAG, VALID_TAGS, VALID_APPOINTMENTS); + String expectedMessage = PlanTag.MESSAGE_CONSTRAINTS; + assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } + + @Test + public void toModelType_nullPlanTag_throwsIllegalValueException() { + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, + VALID_INCOME, VALID_MONTHLY, VALID_RISKTAG_HIGH, null, VALID_TAGS, VALID_APPOINTMENTS); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, PlanTag.class.getSimpleName()); + assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 7d3bf339cd9..1cef33b36a4 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -12,8 +12,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; /** * A utility class to help with building EditPersonDescriptor objects. @@ -82,6 +83,14 @@ public EditPersonDescriptorBuilder withRiskTag(String riskTag) { return this; } + /** + * Sets the {@code PlanTag} of the {@code EditPersonDescriptor} that we are building. + */ + public EditPersonDescriptorBuilder withPlanTag(String planTag) { + descriptor.setPlanTag(new PlanTag(planTag)); + return this; + } + /** * Sets the {@code Income} of the {@code EditPersonDescriptor} that we are building. */ @@ -103,7 +112,7 @@ public EditPersonDescriptorBuilder withMonthly(String monthly) { * that we are building. */ public EditPersonDescriptorBuilder withTags(String... tags) { - Set tagSet = Stream.of(tags).map(Tag::new).collect(Collectors.toSet()); + Set tagSet = Stream.of(tags).map(NormalTag::new).collect(Collectors.toSet()); descriptor.setTags(tagSet); return this; } diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index a93dbfb1403..31bd3eea5cd 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -14,8 +14,9 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.tag.NormalTag; +import seedu.address.model.tag.PlanTag; import seedu.address.model.tag.RiskTag; -import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; /** @@ -28,6 +29,7 @@ public class PersonBuilder { 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_RISKTAG = "LOW"; + public static final String DEFAULT_PLANTAG = "Savings Plan"; public static final String DEFAULT_INCOME = "$1000"; public static final String DEFAULT_MONTHLY = "$200"; private Name name; @@ -35,9 +37,10 @@ public class PersonBuilder { private Email email; private Address address; private RiskTag riskTag; + private PlanTag planTag; private IncomeLevel income; private Monthly monthly; - private Set tags; + private Set tags; private MaximumSortedList appointments; /** @@ -49,6 +52,7 @@ public PersonBuilder() { email = new Email(DEFAULT_EMAIL); address = new Address(DEFAULT_ADDRESS); riskTag = new RiskTag(DEFAULT_RISKTAG); + planTag = new PlanTag(DEFAULT_PLANTAG); income = new IncomeLevel(DEFAULT_INCOME); monthly = new Monthly(DEFAULT_MONTHLY); tags = new HashSet<>(); @@ -66,6 +70,7 @@ public PersonBuilder(Person personToCopy) { income = personToCopy.getIncome(); monthly = personToCopy.getMonthly(); riskTag = personToCopy.getRiskTag(); + planTag = personToCopy.getPlanTag(); income = personToCopy.getIncome(); tags = new HashSet<>(personToCopy.getTags()); appointments = new MaximumSortedList<>(personToCopy.getAppointments()); @@ -119,6 +124,14 @@ public PersonBuilder withRiskTag(String riskTag) { return this; } + /** + * Sets the {@code PlanTag} of the {@code Person} that we are building. + */ + public PersonBuilder withPlanTag(String planTag) { + this.planTag = new PlanTag(planTag); + return this; + } + /** * Sets the {@code Income} of the {@code Person} that we are building. */ @@ -147,7 +160,7 @@ public PersonBuilder withAppointment(Appointment appointmentToBeAdded) { * By default, the set of appointments field is created but is empty */ public Person build() { - return new Person(name, phone, email, address, income, monthly, riskTag, tags, appointments); + return new Person(name, phone, email, address, income, monthly, riskTag, planTag, tags, appointments); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 3a2100f7299..84e04f68c6f 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_MONTHLY; 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_PLANTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_RISKTAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -14,7 +15,7 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.EditPersonDescriptor; import seedu.address.model.person.Person; -import seedu.address.model.tag.Tag; +import seedu.address.model.tag.NormalTag; @@ -41,6 +42,7 @@ public static String getPersonDetails(Person person) { sb.append(PREFIX_EMAIL + person.getEmail().value + " "); sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); sb.append(PREFIX_RISKTAG + person.getRiskTag().tagName + " "); + sb.append(PREFIX_PLANTAG + person.getPlanTag().tagName + " "); sb.append(PREFIX_INCOME + person.getIncome().value + " "); sb.append(PREFIX_MONTHLY + person.getMonthly().value + " "); person.getTags().stream().forEach( @@ -60,9 +62,10 @@ public static String getEditPersonDescriptorDetails(EditPersonDescriptor descrip descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" ")); descriptor.getRiskTag().ifPresent(riskTag -> sb.append(PREFIX_RISKTAG).append(riskTag.tagName).append(" ")); descriptor.getMonthly().ifPresent(monthly -> sb.append(PREFIX_MONTHLY).append(monthly.value).append(" ")); + descriptor.getPlanTag().ifPresent(planTag -> sb.append(PREFIX_PLANTAG).append(planTag.tagName).append(" ")); if (descriptor.getTags().isPresent()) { - Set tags = descriptor.getTags().get(); + Set tags = descriptor.getTags().get(); if (tags.isEmpty()) { sb.append(PREFIX_TAG); } else { diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index d12ea205843..7acb320196e 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -35,7 +35,6 @@ */ public class TypicalPersons { - public static final Person ALICE = new PersonBuilder() .withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111") @@ -44,15 +43,19 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$200") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withTags("friends") .build(); public static final Person MUSAB_WITH_NO_APPT = new PersonBuilder() .withName("Musab") .withAddress("301 Upper Thomson Rd, Singapore 574408") + .withEmail("musab@gmail.com") .withPhone("92345678") .withMonthly("$100") + .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withTags("gay") .build(); @@ -64,6 +67,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$100") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withTags("owesMoney", "friends") .build(); public static final Person CARL = new PersonBuilder() @@ -74,6 +78,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$200") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .build(); public static final Person DANIEL = new PersonBuilder() .withName("Daniel Meier") @@ -84,6 +89,7 @@ public class TypicalPersons { .withMonthly("$300") .withRiskTag("HIGH") .withTags("friends") + .withPlanTag("Savings Plan") .build(); public static final Person ELLE = new PersonBuilder() .withName("Elle Meyer") @@ -93,6 +99,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$250") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withAppointment(new AppointmentBuilder() .withDateTime(VALID_DATETIME_22_JAN_2023) .withLocation(VALID_LOCATION_JURONGPOINT).build()) @@ -105,6 +112,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$500") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withAppointment(new AppointmentBuilder() .withDateTime(VALID_DATETIME_23_MAR_2024) .withLocation(VALID_LOCATION_WESTMALL).build()) @@ -115,6 +123,7 @@ public class TypicalPersons { .withEmail("anna@example.com") .withAddress("4th street").withIncome("$1000").withMonthly("$400") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .withAppointment(new AppointmentBuilder() .withDateTime(VALID_DATETIME_21_JAN_2023) .withLocation(VALID_LOCATION_NUS).build()) @@ -132,6 +141,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$300") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .build(); public static final Person IDA = new PersonBuilder() .withName("Ida Mueller") @@ -141,6 +151,7 @@ public class TypicalPersons { .withIncome("$1000") .withMonthly("$200") .withRiskTag("HIGH") + .withPlanTag("Savings Plan") .build(); // Manually added - Person's details found in {@code CommandTestUtil} @@ -152,6 +163,7 @@ public class TypicalPersons { .withIncome(VALID_INCOME_AMY) .withMonthly(VALID_MONTHLY_AMY) .withRiskTag(VALID_RISKTAG_LOW) + .withPlanTag("Savings Plan") .withTags(VALID_TAG_FRIEND) .build(); public static final Person BOB = new PersonBuilder() @@ -162,6 +174,7 @@ public class TypicalPersons { .withIncome(VALID_INCOME_BOB) .withMonthly(VALID_MONTHLY_BOB) .withRiskTag(VALID_RISKTAG_HIGH) + .withPlanTag("Savings Plan") .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build();