From ab47662c571cc6c7e40524678526ac83abf73cbc Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Thu, 6 Oct 2022 14:33:36 +0800 Subject: [PATCH 1/6] Update Find command to query all fields of a person Find command only searches the "name" field of a person. A find command that searches all fields of a person returns more precise results. Let's update the find command to search the "name", "phone", "email", and "address" fields. --- .../address/logic/commands/FindCommand.java | 6 +- .../logic/parser/FindCommandParser.java | 51 +++++++++++- .../address/logic/parser/ParserUtil.java | 82 +++++++++++++++++++ .../PersonContainsKeywordsPredicate.java | 63 ++++++++++++++ 4 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 src/main/java/seedu/address/model/person/PersonContainsKeywordsPredicate.java diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index d6b19b0a0de..64761a2311e 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -4,7 +4,7 @@ import seedu.address.commons.core.Messages; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.PersonContainsKeywordsPredicate; /** * Finds and lists all persons in address book whose name contains any of the argument keywords. @@ -19,9 +19,9 @@ public class FindCommand extends Command { + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; - private final NameContainsKeywordsPredicate predicate; + private final PersonContainsKeywordsPredicate predicate; - public FindCommand(NameContainsKeywordsPredicate predicate) { + public FindCommand(PersonContainsKeywordsPredicate predicate) { this.predicate = predicate; } diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 4fb71f23103..6008a901fa6 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -1,12 +1,21 @@ package seedu.address.logic.parser; import static seedu.address.commons.core.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 java.util.Arrays; +import java.util.ArrayList; +import java.util.List; import seedu.address.logic.commands.FindCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.Address; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.PersonContainsKeywordsPredicate; +import seedu.address.model.person.Phone; /** * Parses input arguments and creates a new FindCommand object @@ -25,9 +34,43 @@ public FindCommand parse(String args) throws ParseException { String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); } - String[] nameKeywords = trimmedArgs.split("\\s+"); + ArgumentMultimap argMultimap = + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); - return new FindCommand(new NameContainsKeywordsPredicate(Arrays.asList(nameKeywords))); + List names = getNames(argMultimap); + List phones = getPhones(argMultimap); + List emails = getEmails(argMultimap); + List
addresses = getAddresses(argMultimap); + + return new FindCommand(new PersonContainsKeywordsPredicate(names, phones, emails, addresses)); + } + + private List getNames(ArgumentMultimap argMultimap) throws ParseException { + if (argMultimap.getValue(PREFIX_NAME).isEmpty()) { + return new ArrayList<>(); + } + return ParserUtil.parseNames(argMultimap.getValue(PREFIX_NAME).get()); + } + + private List getPhones(ArgumentMultimap argMultimap) throws ParseException { + if (argMultimap.getValue(PREFIX_PHONE).isEmpty()) { + return new ArrayList<>(); + } + return ParserUtil.parsePhones(argMultimap.getValue(PREFIX_PHONE).get()); + } + + private List getEmails(ArgumentMultimap argMultimap) throws ParseException { + if (argMultimap.getValue(PREFIX_EMAIL).isEmpty()) { + return new ArrayList<>(); + } + return ParserUtil.parseEmails(argMultimap.getValue(PREFIX_EMAIL).get()); + } + + private List
getAddresses(ArgumentMultimap argMultimap) throws ParseException { + if (argMultimap.getValue(PREFIX_ADDRESS).isEmpty()) { + return new ArrayList<>(); + } + return ParserUtil.parseAddresses(argMultimap.getValue(PREFIX_ADDRESS).get()); } } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..06081504f4e 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -2,8 +2,10 @@ import static java.util.Objects.requireNonNull; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; import seedu.address.commons.core.index.Index; @@ -50,6 +52,26 @@ public static Name parseName(String name) throws ParseException { return new Name(trimmedName); } + /** + * Parses a string of {@code String names} into a list of {@code String names}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if any {@code name} is invalid. + */ + public static List parseNames(String names) throws ParseException { + requireNonNull(names); + String trimmedNames = names.trim(); + String[] nameArr = trimmedNames.split(" "); + ArrayList nameList = new ArrayList<>(); + for (String name : nameArr) { + if (!Name.isValidName(name)) { + throw new ParseException(Name.MESSAGE_CONSTRAINTS); + } + nameList.add(new Name(name)); + } + return nameList; + } + /** * Parses a {@code String phone} into a {@code Phone}. * Leading and trailing whitespaces will be trimmed. @@ -65,6 +87,26 @@ public static Phone parsePhone(String phone) throws ParseException { return new Phone(trimmedPhone); } + /** + * Parses a string of {@code String phones} into a list of {@code String phones}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if any {@code phone} is invalid. + */ + public static List parsePhones(String phones) throws ParseException { + requireNonNull(phones); + String trimmedNames = phones.trim(); + String[] phoneArr = trimmedNames.split(" "); + ArrayList phoneList = new ArrayList<>(); + for (String phone : phoneArr) { + if (!Phone.isValidPhone(phone)) { + throw new ParseException(Phone.MESSAGE_CONSTRAINTS); + } + phoneList.add(new Phone(phone)); + } + return phoneList; + } + /** * Parses a {@code String address} into an {@code Address}. * Leading and trailing whitespaces will be trimmed. @@ -80,6 +122,26 @@ public static Address parseAddress(String address) throws ParseException { return new Address(trimmedAddress); } + /** + * Parses a string of {@code String addresses} into a list of {@code String addresses}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if any {@code address} is invalid. + */ + public static List
parseAddresses(String addresses) throws ParseException { + requireNonNull(addresses); + String trimmedNames = addresses.trim(); + String[] addressArr = trimmedNames.split(" "); + ArrayList
addressList = new ArrayList<>(); + for (String address : addressArr) { + if (!Address.isValidAddress(address)) { + throw new ParseException(Address.MESSAGE_CONSTRAINTS); + } + addressList.add(new Address(address)); + } + return addressList; + } + /** * Parses a {@code String email} into an {@code Email}. * Leading and trailing whitespaces will be trimmed. @@ -95,6 +157,26 @@ public static Email parseEmail(String email) throws ParseException { return new Email(trimmedEmail); } + /** + * Parses a string of {@code String emails} into a list of {@code String emails}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if any {@code email} is invalid. + */ + public static List parseEmails(String emails) throws ParseException { + requireNonNull(emails); + String trimmedNames = emails.trim(); + String[] emailArr = trimmedNames.split(" "); + ArrayList emailList = new ArrayList<>(); + for (String email : emailArr) { + if (!Email.isValidEmail(email)) { + throw new ParseException(Email.MESSAGE_CONSTRAINTS); + } + emailList.add(new Email(email)); + } + return emailList; + } + /** * Parses a {@code String tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/person/PersonContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/person/PersonContainsKeywordsPredicate.java new file mode 100644 index 00000000000..c3034a44540 --- /dev/null +++ b/src/main/java/seedu/address/model/person/PersonContainsKeywordsPredicate.java @@ -0,0 +1,63 @@ +package seedu.address.model.person; + +import java.util.List; +import java.util.function.Predicate; + +import seedu.address.commons.util.StringUtil; + +/** + * Tests that a {@code Person}'s {@code Name} and/or {@code Phone} and/or {@code Email} and/or {@code Address} + * matches any of the keywords given. + */ +public class PersonContainsKeywordsPredicate implements Predicate { + private final List nameKeywords; + private final List phoneKeywords; + private final List emailKeywords; + private final List
addressKeywords; + + /** + * Constructs an {@code PersonContainsKeywordsPredicate}. + * + * @param nameKeywords A list containing keywords for {@code Name}. + * @param phoneKeywords A list containing keywords for {@code Phone}. + * @param emailKeywords A list containing keywords for {@code Email}. + * @param addressKeywords A list containing keywords for {@code Address}. + */ + public PersonContainsKeywordsPredicate(List nameKeywords, + List phoneKeywords, List emailKeywords, List
addressKeywords) { + this.nameKeywords = nameKeywords; + this.phoneKeywords = phoneKeywords; + this.emailKeywords = emailKeywords; + this.addressKeywords = addressKeywords; + } + + @Override + public boolean test(Person person) { + return (nameKeywords.isEmpty() || nameKeywords.stream().anyMatch(keyword -> + StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword.toString()))) + && (phoneKeywords.isEmpty() || phoneKeywords.stream().anyMatch(keyword -> + StringUtil.containsWordIgnoreCase(person.getPhone().value, keyword.toString()))) + && (emailKeywords.isEmpty() || emailKeywords.stream().anyMatch(keyword -> + StringUtil.containsWordIgnoreCase(person.getEmail().value, keyword.toString()))) + && (addressKeywords.isEmpty() || addressKeywords.stream().anyMatch(keyword -> + StringUtil.containsWordIgnoreCase(person.getAddress().value, keyword.toString()))); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + if (!(other instanceof PersonContainsKeywordsPredicate)) { + return false; + } + + PersonContainsKeywordsPredicate castedOther = (PersonContainsKeywordsPredicate) other; + + return nameKeywords.equals(castedOther.nameKeywords) + && phoneKeywords.equals(castedOther.phoneKeywords) + && emailKeywords.equals(castedOther.emailKeywords) + && addressKeywords.equals(castedOther.addressKeywords); + } +} From 1609820a88c5b3cccd1523d05f3707d93fae8a60 Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Fri, 7 Oct 2022 02:42:49 +0800 Subject: [PATCH 2/6] Update test cases --- .../address/logic/commands/FindCommand.java | 2 +- .../logic/parser/FindCommandParser.java | 20 ++++-- .../logic/commands/FindCommandTest.java | 63 ++++++++++++------- .../logic/parser/AddressBookParserTest.java | 28 +++++++-- .../logic/parser/FindCommandParserTest.java | 55 ++++++++++++++-- 5 files changed, 132 insertions(+), 36 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 64761a2311e..647f4985573 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -12,7 +12,7 @@ */ public class FindCommand extends Command { - public static final String COMMAND_WORD = "find"; + public static final String COMMAND_WORD = "findC"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 6008a901fa6..7b5e7aba84e 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import seedu.address.logic.commands.FindCommand; import seedu.address.logic.parser.exceptions.ParseException; @@ -28,15 +29,14 @@ public class FindCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public FindCommand parse(String args) throws ParseException { - String trimmedArgs = args.trim(); - if (trimmedArgs.isEmpty()) { - throw new ParseException( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); - } - ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + if (arePrefixesEmpty(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) + || !argMultimap.getPreamble().isEmpty()) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + List names = getNames(argMultimap); List phones = getPhones(argMultimap); List emails = getEmails(argMultimap); @@ -73,4 +73,12 @@ private List
getAddresses(ArgumentMultimap argMultimap) throws ParseExc return ParserUtil.parseAddresses(argMultimap.getValue(PREFIX_ADDRESS).get()); } + /** + * Returns true if all the prefixes contains empty {@code Optional} values in the given + * {@code ArgumentMultimap}. + */ + private static boolean arePrefixesEmpty(ArgumentMultimap argumentMultimap, Prefix... prefixes) { + return Stream.of(prefixes).noneMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); + } + } diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 9b15db28bbb..b0be6e8baf6 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -3,22 +3,24 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.commons.core.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.testutil.TypicalPersons.CARL; -import static seedu.address.testutil.TypicalPersons.ELLE; -import static seedu.address.testutil.TypicalPersons.FIONA; +import static seedu.address.testutil.TypicalPersons.ALICE; +import static seedu.address.testutil.TypicalPersons.BENSON; import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.Test; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.*; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -27,12 +29,34 @@ public class FindCommandTest { private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); + private final String nameKeyword1 = "Alice"; + private final String nameKeyword2 = "Benson"; + private final String phoneKeyword1 = "999"; + private final String phoneKeyword2 = "62353535"; + private final String emailKeyword1 = "john@gmail.com"; + private final String emailKeyword2 = "colonel-sanders-123@kfc.co.uk"; + private final String addressKeyword1 = "17A Lower Kent Ridge Road, #01-01, S(119081)"; + private final String addressKeyword2 = "17A Lower Kent Ridge Road, c/o reception@sally, #01-01, S(119081)"; + + private final List nameKeywords = Arrays.asList(new Name(nameKeyword1), new Name(nameKeyword2)); + private final List phoneKeywords = Arrays.asList(new Phone(phoneKeyword1), new Phone(phoneKeyword2)); + private final List emailKeywords = Arrays.asList(new Email(emailKeyword1), new Email(emailKeyword2)); + private final List
addressKeywords = Arrays.asList(new Address(addressKeyword1), + new Address(addressKeyword2)); + + private final List emptyNameKeywords = new ArrayList<>(); + private final List emptyPhoneKeywords = new ArrayList<>(); + private final List emptyEmailKeywords = new ArrayList<>(); + private final List
emptyAddressKeywords = new ArrayList<>(); + @Test public void equals() { - NameContainsKeywordsPredicate firstPredicate = - new NameContainsKeywordsPredicate(Collections.singletonList("first")); - NameContainsKeywordsPredicate secondPredicate = - new NameContainsKeywordsPredicate(Collections.singletonList("second")); + PersonContainsKeywordsPredicate firstPredicate = + new PersonContainsKeywordsPredicate(nameKeywords, phoneKeywords, + emailKeywords, addressKeywords); + PersonContainsKeywordsPredicate secondPredicate = + new PersonContainsKeywordsPredicate(nameKeywords, emptyPhoneKeywords, + emptyEmailKeywords, emptyAddressKeywords); FindCommand findFirstCommand = new FindCommand(firstPredicate); FindCommand findSecondCommand = new FindCommand(secondPredicate); @@ -55,9 +79,12 @@ public void equals() { } @Test - public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); - NameContainsKeywordsPredicate predicate = preparePredicate(" "); + public void execute_zeroMatchingKeywords_noPersonFound() { + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, + FindCommand.MESSAGE_USAGE); + PersonContainsKeywordsPredicate predicate = + new PersonContainsKeywordsPredicate(emptyNameKeywords, + emptyPhoneKeywords, emptyEmailKeywords, emptyAddressKeywords); FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredPersonList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); @@ -66,18 +93,12 @@ public void execute_zeroKeywords_noPersonFound() { @Test public void execute_multipleKeywords_multiplePersonsFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 3); - NameContainsKeywordsPredicate predicate = preparePredicate("Kurz Elle Kunz"); + String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 2); + PersonContainsKeywordsPredicate predicate = + new PersonContainsKeywordsPredicate(nameKeywords, emptyPhoneKeywords, emptyEmailKeywords, emptyAddressKeywords); FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredPersonList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredPersonList()); - } - - /** - * Parses {@code userInput} into a {@code NameContainsKeywordsPredicate}. - */ - private NameContainsKeywordsPredicate preparePredicate(String userInput) { - return new NameContainsKeywordsPredicate(Arrays.asList(userInput.split("\\s+"))); + assertEquals(Arrays.asList(ALICE, BENSON), model.getFilteredPersonList()); } } diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index d9659205b57..6597f70d5f7 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -4,6 +4,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; +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.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; @@ -23,8 +27,12 @@ import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.Name; import seedu.address.model.person.Person; +import seedu.address.model.person.PersonContainsKeywordsPredicate; +import seedu.address.model.person.Phone; +import seedu.address.model.person.Email; +import seedu.address.model.person.Address; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; @@ -70,10 +78,22 @@ public void parseCommand_exit() throws Exception { @Test public void parseCommand_find() throws Exception { - List keywords = Arrays.asList("foo", "bar", "baz"); + List nameKeywords = List.of(new Name("ali")); + List phoneKeywords = List.of(new Phone("999")); + List emailKeywords = List.of(new Email("john@gmail.com")); + List
addressKeywords = List.of(new Address("17A Lower Kent Ridge Road, #01-01, S(119081)")); FindCommand command = (FindCommand) parser.parseCommand( - FindCommand.COMMAND_WORD + " " + keywords.stream().collect(Collectors.joining(" "))); - assertEquals(new FindCommand(new NameContainsKeywordsPredicate(keywords)), command); + FindCommand.COMMAND_WORD + " " + + PREFIX_NAME + + nameKeywords.stream().map(Name::toString).collect(Collectors.joining(" ")) + " " + + PREFIX_PHONE + + phoneKeywords.stream().map(Phone::toString).collect(Collectors.joining(" "))+ " " + + PREFIX_EMAIL + + emailKeywords.stream().map(Email::toString).collect(Collectors.joining(" ")) + " " + + PREFIX_ADDRESS + + addressKeywords.stream().map(Address::toString).collect(Collectors.joining(" "))); + assertEquals(new FindCommand(new PersonContainsKeywordsPredicate( + nameKeywords, phoneKeywords, emailKeywords, addressKeywords)), command); } @Test diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index 70f4f0e79c4..49512813950 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -1,15 +1,24 @@ package seedu.address.logic.parser; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +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.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; import java.util.Arrays; +import java.util.List; import org.junit.jupiter.api.Test; import seedu.address.logic.commands.FindCommand; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.person.Name; +import seedu.address.model.person.PersonContainsKeywordsPredicate; +import seedu.address.model.person.Phone; +import seedu.address.model.person.Email; +import seedu.address.model.person.Address; public class FindCommandParserTest { @@ -22,13 +31,51 @@ public void parse_emptyArg_throwsParseException() { @Test public void parse_validArgs_returnsFindCommand() { + String nameKeyword1 = "ali"; + String nameKeyword2 = "baba"; + String phoneKeyword1 = "999"; + String phoneKeyword2 = "62353535"; + String emailKeyword1 = "john@gmail.com"; + String emailKeyword2 = "colonel-sanders-123@kfc.co.uk"; + String addressKeyword1 = "17A Lower Kent Ridge Road, #01-01, S(119081)"; + String addressKeyword2 = "17A Lower Kent Ridge Road, c/o reception@sally, #01-01, S(119081)"; + + List nameKeywords = Arrays.asList(new Name(nameKeyword1), new Name(nameKeyword2)); + List phoneKeywords = Arrays.asList(new Phone(phoneKeyword1), new Phone(phoneKeyword2)); + List emailKeywords = Arrays.asList(new Email(emailKeyword1), new Email(emailKeyword2)); + List
addressKeywords = Arrays.asList(new Address(addressKeyword1), new Address(addressKeyword2)); + + FindCommand expectedFindCommand = new FindCommand(new PersonContainsKeywordsPredicate( + nameKeywords, phoneKeywords, emailKeywords, addressKeywords)); + // no leading and trailing whitespaces - FindCommand expectedFindCommand = - new FindCommand(new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob"))); - assertParseSuccess(parser, "Alice Bob", expectedFindCommand); + assertParseSuccess(parser, String.format("%s %s %s %s %s %s %s %s %s %s %s %s", + PREFIX_NAME, nameKeyword1, nameKeyword2, + PREFIX_PHONE, phoneKeyword1, phoneKeyword2, + PREFIX_EMAIL, emailKeyword1, emailKeyword2, + PREFIX_ADDRESS, addressKeyword1, addressKeyword2), + expectedFindCommand); // multiple whitespaces between keywords assertParseSuccess(parser, " \n Alice \n \t Bob \t", expectedFindCommand); + assertParseSuccess(parser, String.format("\n%s %s \n %s \n %s \t %s %s %s \n\n %s %s %s %s %s ", + PREFIX_NAME, nameKeyword1, nameKeyword2, + PREFIX_PHONE, phoneKeyword1, phoneKeyword2, + PREFIX_EMAIL, emailKeyword1, emailKeyword2, + PREFIX_ADDRESS, addressKeyword1, addressKeyword2), + expectedFindCommand); + + // no prefix + //todo throw error + + // repeated prefixes + assertParseSuccess(parser, String.format("%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s", + PREFIX_NAME, nameKeyword1, nameKeyword2, + PREFIX_PHONE, phoneKeyword1, phoneKeyword2, + PREFIX_PHONE, phoneKeyword1, phoneKeyword2, + PREFIX_EMAIL, emailKeyword1, emailKeyword2, + PREFIX_ADDRESS, addressKeyword1, addressKeyword2), + expectedFindCommand); } } From c279464f99a251efbdafceef10f74821e65eadfa Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Fri, 7 Oct 2022 02:55:32 +0800 Subject: [PATCH 3/6] Update code to comply with checkstyle --- .../seedu/address/logic/commands/FindCommandTest.java | 9 +++++++-- .../address/logic/parser/AddressBookParserTest.java | 11 +++++------ .../address/logic/parser/FindCommandParserTest.java | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index b0be6e8baf6..53efeba7332 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -20,7 +20,11 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.*; +import seedu.address.model.person.Address; +import seedu.address.model.person.Email; +import seedu.address.model.person.Name; +import seedu.address.model.person.PersonContainsKeywordsPredicate; +import seedu.address.model.person.Phone; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -95,7 +99,8 @@ public void execute_zeroMatchingKeywords_noPersonFound() { public void execute_multipleKeywords_multiplePersonsFound() { String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 2); PersonContainsKeywordsPredicate predicate = - new PersonContainsKeywordsPredicate(nameKeywords, emptyPhoneKeywords, emptyEmailKeywords, emptyAddressKeywords); + new PersonContainsKeywordsPredicate(nameKeywords, emptyPhoneKeywords, + emptyEmailKeywords, emptyAddressKeywords); FindCommand command = new FindCommand(predicate); expectedModel.updateFilteredPersonList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 6597f70d5f7..bccc7a193ee 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -4,14 +4,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; +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_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -27,12 +26,12 @@ import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Address; +import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.PersonContainsKeywordsPredicate; import seedu.address.model.person.Phone; -import seedu.address.model.person.Email; -import seedu.address.model.person.Address; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; @@ -87,7 +86,7 @@ public void parseCommand_find() throws Exception { + PREFIX_NAME + nameKeywords.stream().map(Name::toString).collect(Collectors.joining(" ")) + " " + PREFIX_PHONE - + phoneKeywords.stream().map(Phone::toString).collect(Collectors.joining(" "))+ " " + + phoneKeywords.stream().map(Phone::toString).collect(Collectors.joining(" ")) + " " + PREFIX_EMAIL + emailKeywords.stream().map(Email::toString).collect(Collectors.joining(" ")) + " " + PREFIX_ADDRESS diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index 49512813950..616e12fba8c 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -1,10 +1,10 @@ package seedu.address.logic.parser; import static seedu.address.commons.core.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_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; @@ -14,11 +14,11 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.commands.FindCommand; +import seedu.address.model.person.Address; +import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.PersonContainsKeywordsPredicate; import seedu.address.model.person.Phone; -import seedu.address.model.person.Email; -import seedu.address.model.person.Address; public class FindCommandParserTest { From 25a6372c977fcf73494207d87b493348c96a254c Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Fri, 7 Oct 2022 12:29:27 +0800 Subject: [PATCH 4/6] Edit test cases --- .../commands/FindContactCommandTest.java | 12 +--- .../logic/parser/AddressBookParserTest.java | 30 +--------- .../logic/parser/FindCommandParserTest.java | 32 +--------- .../PersonContainsKeywordsPredicateTest.java | 60 +++++++++++++++++++ 4 files changed, 65 insertions(+), 69 deletions(-) create mode 100644 src/test/java/seedu/address/model/person/PersonContainsKeywordsPredicateTest.java diff --git a/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java b/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java index 9eabfaea575..6691d201cc8 100644 --- a/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.commons.core.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalPersons.ALICE; @@ -12,7 +11,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; @@ -84,15 +82,7 @@ public void equals() { @Test public void execute_zeroMatchingKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, - FindContactCommand.MESSAGE_USAGE); - PersonContainsKeywordsPredicate predicate = - new PersonContainsKeywordsPredicate(emptyNameKeywords, - emptyPhoneKeywords, emptyEmailKeywords, emptyAddressKeywords); - FindContactCommand command = new FindContactCommand(predicate); - expectedModel.updateFilteredPersonList(predicate); - assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Collections.emptyList(), model.getFilteredPersonList()); + // TODO } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 10627ac07a2..319ba3585f7 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -4,16 +4,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; -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.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import java.util.List; -import java.util.stream.Collectors; - import org.junit.jupiter.api.Test; import seedu.address.logic.commands.AddContactCommand; @@ -22,16 +15,10 @@ import seedu.address.logic.commands.EditContactCommand; import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.FindContactCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListContactCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; import seedu.address.model.person.Person; -import seedu.address.model.person.PersonContainsKeywordsPredicate; -import seedu.address.model.person.Phone; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; @@ -77,22 +64,7 @@ public void parseCommand_exit() throws Exception { @Test public void parseCommand_find() throws Exception { - List nameKeywords = List.of(new Name("ali")); - List phoneKeywords = List.of(new Phone("999")); - List emailKeywords = List.of(new Email("john@gmail.com")); - List
addressKeywords = List.of(new Address("17A Lower Kent Ridge Road, #01-01, S(119081)")); - FindContactCommand command = (FindContactCommand) parser.parseCommand( - FindContactCommand.COMMAND_WORD + " " - + PREFIX_NAME - + nameKeywords.stream().map(Name::toString).collect(Collectors.joining(" ")) + " " - + PREFIX_PHONE - + phoneKeywords.stream().map(Phone::toString).collect(Collectors.joining(" ")) + " " - + PREFIX_EMAIL - + emailKeywords.stream().map(Email::toString).collect(Collectors.joining(" ")) + " " - + PREFIX_ADDRESS - + addressKeywords.stream().map(Address::toString).collect(Collectors.joining(" "))); - assertEquals(new FindContactCommand(new PersonContainsKeywordsPredicate( - nameKeywords, phoneKeywords, emailKeywords, addressKeywords)), command); + // TODO } @Test diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index 30f57f0e45d..6719d197278 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -1,12 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.commons.core.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.CommandParserTestUtil.assertParseFailure; -import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; import java.util.Arrays; import java.util.List; @@ -49,34 +44,13 @@ public void parse_validArgs_returnsFindCommand() { FindContactCommand expectedFindCommand = new FindContactCommand(new PersonContainsKeywordsPredicate( nameKeywords, phoneKeywords, emailKeywords, addressKeywords)); - // no leading and trailing whitespaces - assertParseSuccess(parser, String.format("%s %s %s %s %s %s %s %s %s %s %s %s", - PREFIX_NAME, nameKeyword1, nameKeyword2, - PREFIX_PHONE, phoneKeyword1, phoneKeyword2, - PREFIX_EMAIL, emailKeyword1, emailKeyword2, - PREFIX_ADDRESS, addressKeyword1, addressKeyword2), - expectedFindCommand); - // multiple whitespaces between keywords - assertParseSuccess(parser, " \n Alice \n \t Bob \t", expectedFindCommand); - assertParseSuccess(parser, String.format("\n%s %s \n %s \n %s \t %s %s %s \n\n %s %s %s %s %s ", - PREFIX_NAME, nameKeyword1, nameKeyword2, - PREFIX_PHONE, phoneKeyword1, phoneKeyword2, - PREFIX_EMAIL, emailKeyword1, emailKeyword2, - PREFIX_ADDRESS, addressKeyword1, addressKeyword2), - expectedFindCommand); + // TODO: Add test case // no prefix - //todo throw error + // TODO: throw error // repeated prefixes - assertParseSuccess(parser, String.format("%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s", - PREFIX_NAME, nameKeyword1, nameKeyword2, - PREFIX_PHONE, phoneKeyword1, phoneKeyword2, - PREFIX_PHONE, phoneKeyword1, phoneKeyword2, - PREFIX_EMAIL, emailKeyword1, emailKeyword2, - PREFIX_ADDRESS, addressKeyword1, addressKeyword2), - expectedFindCommand); + // TODO: throw error } - } diff --git a/src/test/java/seedu/address/model/person/PersonContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/PersonContainsKeywordsPredicateTest.java new file mode 100644 index 00000000000..764fb9a2459 --- /dev/null +++ b/src/test/java/seedu/address/model/person/PersonContainsKeywordsPredicateTest.java @@ -0,0 +1,60 @@ +package seedu.address.model.person; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; + +public class PersonContainsKeywordsPredicateTest { + + private final String nameKeyword1 = "Alice"; + private final String nameKeyword2 = "Benson"; + private final String phoneKeyword1 = "999"; + private final String phoneKeyword2 = "62353535"; + private final String emailKeyword1 = "john@gmail.com"; + private final String emailKeyword2 = "colonel-sanders-123@kfc.co.uk"; + private final String addressKeyword1 = "17A Lower Kent Ridge Road, #01-01, S(119081)"; + private final String addressKeyword2 = "17A Lower Kent Ridge Road, c/o reception@sally, #01-01, S(119081)"; + + private final List nameKeywords = Arrays.asList(new Name(nameKeyword1), new Name(nameKeyword2)); + private final List phoneKeywords = Arrays.asList(new Phone(phoneKeyword1), new Phone(phoneKeyword2)); + private final List emailKeywords = Arrays.asList(new Email(emailKeyword1), new Email(emailKeyword2)); + private final List
addressKeywords = Arrays.asList(new Address(addressKeyword1), + new Address(addressKeyword2)); + + private final List emptyNameKeywords = new ArrayList<>(); + private final List emptyPhoneKeywords = new ArrayList<>(); + private final List emptyEmailKeywords = new ArrayList<>(); + private final List
emptyAddressKeywords = new ArrayList<>(); + + @Test + public void equals() { + + PersonContainsKeywordsPredicate firstPredicate = + new PersonContainsKeywordsPredicate(nameKeywords, phoneKeywords, + emailKeywords, addressKeywords); + PersonContainsKeywordsPredicate secondPredicate = + new PersonContainsKeywordsPredicate(nameKeywords, emptyPhoneKeywords, + emptyEmailKeywords, emptyAddressKeywords); + // same object -> returns true + assertTrue(firstPredicate.equals(firstPredicate)); + + // same values -> returns true + PersonContainsKeywordsPredicate firstPredicateCopy = new PersonContainsKeywordsPredicate( + nameKeywords, phoneKeywords, emailKeywords, addressKeywords); + assertTrue(firstPredicate.equals(firstPredicateCopy)); + + // different types -> returns false + assertFalse(firstPredicate.equals(1)); + + // null -> returns false + assertFalse(firstPredicate.equals(null)); + + // different person -> returns false + assertFalse(firstPredicate.equals(secondPredicate)); + } +} From 6982ab978139b4dcdeff170c8886a8d26889ac94 Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Fri, 7 Oct 2022 16:22:15 +0800 Subject: [PATCH 5/6] Refactor code into packages for task, person, and tag --- .../address/logic/commands/HelpCommand.java | 1 + .../{ => contact}/AddContactCommand.java | 4 ++- .../{ => contact}/DeleteContactCommand.java | 4 ++- .../{ => contact}/EditContactCommand.java | 4 ++- .../{ => contact}/FindContactCommand.java | 4 ++- .../{ => contact}/ListContactCommand.java | 4 ++- .../commands/{ => tag}/AddTagCommand.java | 4 ++- .../commands/{ => tag}/DeleteTagCommand.java | 4 ++- .../commands/{ => task}/AddTaskCommand.java | 4 ++- .../commands/{ => task}/ListTaskCommand.java | 4 ++- .../commands/{ => task}/MarkTaskCommand.java | 4 ++- .../{ => task}/UnmarkTaskCommand.java | 4 ++- .../logic/parser/AddressBookParser.java | 28 ++++++++++++------- .../AddContactCommandParser.java | 5 ++-- .../DeleteContactCommandParser.java | 6 ++-- .../EditContactCommandParser.java | 10 +++++-- .../FindContactCommandParser.java | 5 ++-- .../parser/{ => tag}/AddTagCommandParser.java | 10 +++++-- .../{ => tag}/DeleteTagCommandParser.java | 12 +++++--- .../{ => task}/AddTaskCommandParser.java | 5 ++-- .../{ => task}/MarkTaskCommandParser.java | 6 ++-- .../{ => task}/UnmarkTaskCommandParser.java | 6 ++-- .../seedu/address/logic/LogicManagerTest.java | 4 +-- .../AddContactCommandIntegrationTest.java | 1 + .../logic/commands/AddContactCommandTest.java | 1 + .../logic/commands/CommandTestUtil.java | 1 + .../commands/DeleteContactCommandTest.java | 1 + .../commands/EditContactCommandTest.java | 3 +- .../commands/EditPersonDescriptorTest.java | 2 +- .../commands/FindContactCommandTest.java | 1 + .../commands/ListContactCommandTest.java | 1 + .../parser/AddContactCommandParserTest.java | 3 +- .../logic/parser/AddressBookParserTest.java | 10 +++---- .../logic/parser/DeleteCommandParserTest.java | 3 +- .../logic/parser/EditCommandParserTest.java | 5 ++-- .../logic/parser/FindCommandParserTest.java | 3 +- .../testutil/EditPersonDescriptorBuilder.java | 2 +- .../seedu/address/testutil/PersonUtil.java | 4 +-- 38 files changed, 123 insertions(+), 60 deletions(-) rename src/main/java/seedu/address/logic/commands/{ => contact}/AddContactCommand.java (94%) rename src/main/java/seedu/address/logic/commands/{ => contact}/DeleteContactCommand.java (93%) rename src/main/java/seedu/address/logic/commands/{ => contact}/EditContactCommand.java (98%) rename src/main/java/seedu/address/logic/commands/{ => contact}/FindContactCommand.java (91%) rename src/main/java/seedu/address/logic/commands/{ => contact}/ListContactCommand.java (81%) rename src/main/java/seedu/address/logic/commands/{ => tag}/AddTagCommand.java (98%) rename src/main/java/seedu/address/logic/commands/{ => tag}/DeleteTagCommand.java (98%) rename src/main/java/seedu/address/logic/commands/{ => task}/AddTaskCommand.java (92%) rename src/main/java/seedu/address/logic/commands/{ => task}/ListTaskCommand.java (80%) rename src/main/java/seedu/address/logic/commands/{ => task}/MarkTaskCommand.java (92%) rename src/main/java/seedu/address/logic/commands/{ => task}/UnmarkTaskCommand.java (92%) rename src/main/java/seedu/address/logic/parser/{ => contact}/AddContactCommandParser.java (94%) rename src/main/java/seedu/address/logic/parser/{ => contact}/DeleteContactCommandParser.java (83%) rename src/main/java/seedu/address/logic/parser/{ => contact}/EditContactCommandParser.java (89%) rename src/main/java/seedu/address/logic/parser/{ => contact}/FindContactCommandParser.java (96%) rename src/main/java/seedu/address/logic/parser/{ => tag}/AddTagCommandParser.java (90%) rename src/main/java/seedu/address/logic/parser/{ => tag}/DeleteTagCommandParser.java (88%) rename src/main/java/seedu/address/logic/parser/{ => task}/AddTaskCommandParser.java (93%) rename src/main/java/seedu/address/logic/parser/{ => task}/MarkTaskCommandParser.java (83%) rename src/main/java/seedu/address/logic/parser/{ => task}/UnmarkTaskCommandParser.java (83%) diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index 3bf9bdd4edc..61d5e364a7f 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,5 +1,6 @@ package seedu.address.logic.commands; +import seedu.address.logic.commands.contact.*; import seedu.address.model.Model; /** diff --git a/src/main/java/seedu/address/logic/commands/AddContactCommand.java b/src/main/java/seedu/address/logic/commands/contact/AddContactCommand.java similarity index 94% rename from src/main/java/seedu/address/logic/commands/AddContactCommand.java rename to src/main/java/seedu/address/logic/commands/contact/AddContactCommand.java index 66ca8ce9243..b6c3fa0f0c5 100644 --- a/src/main/java/seedu/address/logic/commands/AddContactCommand.java +++ b/src/main/java/seedu/address/logic/commands/contact/AddContactCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.contact; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; @@ -7,6 +7,8 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Person; diff --git a/src/main/java/seedu/address/logic/commands/DeleteContactCommand.java b/src/main/java/seedu/address/logic/commands/contact/DeleteContactCommand.java similarity index 93% rename from src/main/java/seedu/address/logic/commands/DeleteContactCommand.java rename to src/main/java/seedu/address/logic/commands/contact/DeleteContactCommand.java index 18fc1f6231a..15a6556ddd2 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteContactCommand.java +++ b/src/main/java/seedu/address/logic/commands/contact/DeleteContactCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.contact; import static java.util.Objects.requireNonNull; @@ -6,6 +6,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Person; diff --git a/src/main/java/seedu/address/logic/commands/EditContactCommand.java b/src/main/java/seedu/address/logic/commands/contact/EditContactCommand.java similarity index 98% rename from src/main/java/seedu/address/logic/commands/EditContactCommand.java rename to src/main/java/seedu/address/logic/commands/contact/EditContactCommand.java index a9826252170..628e59c120e 100644 --- a/src/main/java/seedu/address/logic/commands/EditContactCommand.java +++ b/src/main/java/seedu/address/logic/commands/contact/EditContactCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.contact; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; @@ -17,6 +17,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.commons.util.CollectionUtil; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Address; diff --git a/src/main/java/seedu/address/logic/commands/FindContactCommand.java b/src/main/java/seedu/address/logic/commands/contact/FindContactCommand.java similarity index 91% rename from src/main/java/seedu/address/logic/commands/FindContactCommand.java rename to src/main/java/seedu/address/logic/commands/contact/FindContactCommand.java index 092639c112f..e8910c80940 100644 --- a/src/main/java/seedu/address/logic/commands/FindContactCommand.java +++ b/src/main/java/seedu/address/logic/commands/contact/FindContactCommand.java @@ -1,8 +1,10 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.contact; import static java.util.Objects.requireNonNull; import seedu.address.commons.core.Messages; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.model.Model; import seedu.address.model.person.PersonContainsKeywordsPredicate; diff --git a/src/main/java/seedu/address/logic/commands/ListContactCommand.java b/src/main/java/seedu/address/logic/commands/contact/ListContactCommand.java similarity index 81% rename from src/main/java/seedu/address/logic/commands/ListContactCommand.java rename to src/main/java/seedu/address/logic/commands/contact/ListContactCommand.java index bdf69bc67a6..6325c79d0bc 100644 --- a/src/main/java/seedu/address/logic/commands/ListContactCommand.java +++ b/src/main/java/seedu/address/logic/commands/contact/ListContactCommand.java @@ -1,8 +1,10 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.contact; import static java.util.Objects.requireNonNull; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.model.Model; /** diff --git a/src/main/java/seedu/address/logic/commands/AddTagCommand.java b/src/main/java/seedu/address/logic/commands/tag/AddTagCommand.java similarity index 98% rename from src/main/java/seedu/address/logic/commands/AddTagCommand.java rename to src/main/java/seedu/address/logic/commands/tag/AddTagCommand.java index 4a90243913a..8efcbbcf087 100644 --- a/src/main/java/seedu/address/logic/commands/AddTagCommand.java +++ b/src/main/java/seedu/address/logic/commands/tag/AddTagCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.tag; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -13,6 +13,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.commons.util.CollectionUtil; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Address; diff --git a/src/main/java/seedu/address/logic/commands/DeleteTagCommand.java b/src/main/java/seedu/address/logic/commands/tag/DeleteTagCommand.java similarity index 98% rename from src/main/java/seedu/address/logic/commands/DeleteTagCommand.java rename to src/main/java/seedu/address/logic/commands/tag/DeleteTagCommand.java index 169186ad22d..db0270e20f1 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteTagCommand.java +++ b/src/main/java/seedu/address/logic/commands/tag/DeleteTagCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.tag; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -13,6 +13,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.commons.util.CollectionUtil; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Address; diff --git a/src/main/java/seedu/address/logic/commands/AddTaskCommand.java b/src/main/java/seedu/address/logic/commands/task/AddTaskCommand.java similarity index 92% rename from src/main/java/seedu/address/logic/commands/AddTaskCommand.java rename to src/main/java/seedu/address/logic/commands/task/AddTaskCommand.java index 8db25b64c86..b709e36a5c6 100644 --- a/src/main/java/seedu/address/logic/commands/AddTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/task/AddTaskCommand.java @@ -1,9 +1,11 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.task; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK_DEADLINE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK_DESCRIPTION; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.task.Task; diff --git a/src/main/java/seedu/address/logic/commands/ListTaskCommand.java b/src/main/java/seedu/address/logic/commands/task/ListTaskCommand.java similarity index 80% rename from src/main/java/seedu/address/logic/commands/ListTaskCommand.java rename to src/main/java/seedu/address/logic/commands/task/ListTaskCommand.java index 41d1c9f2403..a4e1a7b153f 100644 --- a/src/main/java/seedu/address/logic/commands/ListTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/task/ListTaskCommand.java @@ -1,8 +1,10 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.task; import static java.util.Objects.requireNonNull; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TASKS; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.model.Model; /** diff --git a/src/main/java/seedu/address/logic/commands/MarkTaskCommand.java b/src/main/java/seedu/address/logic/commands/task/MarkTaskCommand.java similarity index 92% rename from src/main/java/seedu/address/logic/commands/MarkTaskCommand.java rename to src/main/java/seedu/address/logic/commands/task/MarkTaskCommand.java index 06d163df18c..afce0df08a5 100644 --- a/src/main/java/seedu/address/logic/commands/MarkTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/task/MarkTaskCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.task; import static java.util.Objects.requireNonNull; @@ -6,6 +6,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.task.Task; diff --git a/src/main/java/seedu/address/logic/commands/UnmarkTaskCommand.java b/src/main/java/seedu/address/logic/commands/task/UnmarkTaskCommand.java similarity index 92% rename from src/main/java/seedu/address/logic/commands/UnmarkTaskCommand.java rename to src/main/java/seedu/address/logic/commands/task/UnmarkTaskCommand.java index 73f04ef06cb..414b7238401 100644 --- a/src/main/java/seedu/address/logic/commands/UnmarkTaskCommand.java +++ b/src/main/java/seedu/address/logic/commands/task/UnmarkTaskCommand.java @@ -1,4 +1,4 @@ -package seedu.address.logic.commands; +package seedu.address.logic.commands.task; import static java.util.Objects.requireNonNull; @@ -6,6 +6,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.CommandResult; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.task.Task; diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 84010dac096..fca6949d2d0 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -6,21 +6,29 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import seedu.address.logic.commands.AddContactCommand; -import seedu.address.logic.commands.AddTagCommand; +import seedu.address.logic.commands.contact.AddContactCommand; +import seedu.address.logic.commands.tag.AddTagCommand; import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.Command; -import seedu.address.logic.commands.DeleteContactCommand; -import seedu.address.logic.commands.DeleteTagCommand; -import seedu.address.logic.commands.EditContactCommand; +import seedu.address.logic.commands.contact.DeleteContactCommand; +import seedu.address.logic.commands.tag.DeleteTagCommand; +import seedu.address.logic.commands.contact.EditContactCommand; import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.FindContactCommand; +import seedu.address.logic.commands.contact.FindContactCommand; import seedu.address.logic.commands.HelpCommand; -import seedu.address.logic.commands.ListContactCommand; -import seedu.address.logic.commands.ListTaskCommand; -import seedu.address.logic.commands.MarkTaskCommand; -import seedu.address.logic.commands.UnmarkTaskCommand; +import seedu.address.logic.commands.contact.ListContactCommand; +import seedu.address.logic.commands.task.ListTaskCommand; +import seedu.address.logic.commands.task.MarkTaskCommand; +import seedu.address.logic.commands.task.UnmarkTaskCommand; +import seedu.address.logic.parser.contact.AddContactCommandParser; +import seedu.address.logic.parser.contact.DeleteContactCommandParser; +import seedu.address.logic.parser.contact.EditContactCommandParser; +import seedu.address.logic.parser.contact.FindContactCommandParser; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.logic.parser.tag.AddTagCommandParser; +import seedu.address.logic.parser.tag.DeleteTagCommandParser; +import seedu.address.logic.parser.task.MarkTaskCommandParser; +import seedu.address.logic.parser.task.UnmarkTaskCommandParser; /** * Parses user input. diff --git a/src/main/java/seedu/address/logic/parser/AddContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java similarity index 94% rename from src/main/java/seedu/address/logic/parser/AddContactCommandParser.java rename to src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java index b3db32c6cbd..ad91434a4ce 100644 --- a/src/main/java/seedu/address/logic/parser/AddContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.contact; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; @@ -10,7 +10,8 @@ import java.util.Set; import java.util.stream.Stream; -import seedu.address.logic.commands.AddContactCommand; +import seedu.address.logic.commands.contact.AddContactCommand; +import seedu.address.logic.parser.*; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; diff --git a/src/main/java/seedu/address/logic/parser/DeleteContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/DeleteContactCommandParser.java similarity index 83% rename from src/main/java/seedu/address/logic/parser/DeleteContactCommandParser.java rename to src/main/java/seedu/address/logic/parser/contact/DeleteContactCommandParser.java index 6d348f2e5b6..33e6dee20f7 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/DeleteContactCommandParser.java @@ -1,9 +1,11 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.contact; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.DeleteContactCommand; +import seedu.address.logic.commands.contact.DeleteContactCommand; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; /** diff --git a/src/main/java/seedu/address/logic/parser/EditContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/EditContactCommandParser.java similarity index 89% rename from src/main/java/seedu/address/logic/parser/EditContactCommandParser.java rename to src/main/java/seedu/address/logic/parser/contact/EditContactCommandParser.java index 2fcdbf84aaa..e360e1998da 100644 --- a/src/main/java/seedu/address/logic/parser/EditContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/EditContactCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.contact; import static java.util.Objects.requireNonNull; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; @@ -14,8 +14,12 @@ import java.util.Set; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditContactCommand; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.EditContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.tag.Tag; diff --git a/src/main/java/seedu/address/logic/parser/FindContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java similarity index 96% rename from src/main/java/seedu/address/logic/parser/FindContactCommandParser.java rename to src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java index 1c7aaf258c3..d4285da0468 100644 --- a/src/main/java/seedu/address/logic/parser/FindContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.contact; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; @@ -10,7 +10,8 @@ import java.util.List; import java.util.stream.Stream; -import seedu.address.logic.commands.FindContactCommand; +import seedu.address.logic.commands.contact.FindContactCommand; +import seedu.address.logic.parser.*; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; diff --git a/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java b/src/main/java/seedu/address/logic/parser/tag/AddTagCommandParser.java similarity index 90% rename from src/main/java/seedu/address/logic/parser/AddTagCommandParser.java rename to src/main/java/seedu/address/logic/parser/tag/AddTagCommandParser.java index 7e563f15723..d687e353a68 100644 --- a/src/main/java/seedu/address/logic/parser/AddTagCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/tag/AddTagCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.tag; import static java.util.Objects.requireNonNull; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; @@ -14,8 +14,12 @@ import java.util.Set; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.AddTagCommand; -import seedu.address.logic.commands.AddTagCommand.EditPersonDescriptor; +import seedu.address.logic.commands.tag.AddTagCommand; +import seedu.address.logic.commands.tag.AddTagCommand.EditPersonDescriptor; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.tag.Tag; diff --git a/src/main/java/seedu/address/logic/parser/DeleteTagCommandParser.java b/src/main/java/seedu/address/logic/parser/tag/DeleteTagCommandParser.java similarity index 88% rename from src/main/java/seedu/address/logic/parser/DeleteTagCommandParser.java rename to src/main/java/seedu/address/logic/parser/tag/DeleteTagCommandParser.java index 58256ff1452..5c0980077c1 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteTagCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/tag/DeleteTagCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.tag; import static java.util.Objects.requireNonNull; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; @@ -14,9 +14,13 @@ import java.util.Set; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.AddTagCommand; -import seedu.address.logic.commands.DeleteTagCommand; -import seedu.address.logic.commands.DeleteTagCommand.EditPersonDescriptor; +import seedu.address.logic.commands.tag.AddTagCommand; +import seedu.address.logic.commands.tag.DeleteTagCommand; +import seedu.address.logic.commands.tag.DeleteTagCommand.EditPersonDescriptor; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.tag.Tag; diff --git a/src/main/java/seedu/address/logic/parser/AddTaskCommandParser.java b/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java similarity index 93% rename from src/main/java/seedu/address/logic/parser/AddTaskCommandParser.java rename to src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java index 69823640c58..7be0fa10b61 100644 --- a/src/main/java/seedu/address/logic/parser/AddTaskCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java @@ -1,4 +1,4 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.task; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK_DEADLINE; @@ -6,7 +6,8 @@ import java.util.stream.Stream; -import seedu.address.logic.commands.AddTaskCommand; +import seedu.address.logic.commands.task.AddTaskCommand; +import seedu.address.logic.parser.*; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.task.Description; import seedu.address.model.task.Task; diff --git a/src/main/java/seedu/address/logic/parser/MarkTaskCommandParser.java b/src/main/java/seedu/address/logic/parser/task/MarkTaskCommandParser.java similarity index 83% rename from src/main/java/seedu/address/logic/parser/MarkTaskCommandParser.java rename to src/main/java/seedu/address/logic/parser/task/MarkTaskCommandParser.java index 7638b822640..3961cf4d3c4 100644 --- a/src/main/java/seedu/address/logic/parser/MarkTaskCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/task/MarkTaskCommandParser.java @@ -1,9 +1,11 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.task; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.MarkTaskCommand; +import seedu.address.logic.commands.task.MarkTaskCommand; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; /** diff --git a/src/main/java/seedu/address/logic/parser/UnmarkTaskCommandParser.java b/src/main/java/seedu/address/logic/parser/task/UnmarkTaskCommandParser.java similarity index 83% rename from src/main/java/seedu/address/logic/parser/UnmarkTaskCommandParser.java rename to src/main/java/seedu/address/logic/parser/task/UnmarkTaskCommandParser.java index c807f2116b4..043885e913d 100644 --- a/src/main/java/seedu/address/logic/parser/UnmarkTaskCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/task/UnmarkTaskCommandParser.java @@ -1,9 +1,11 @@ -package seedu.address.logic.parser; +package seedu.address.logic.parser.task; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.UnmarkTaskCommand; +import seedu.address.logic.commands.task.UnmarkTaskCommand; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.parser.exceptions.ParseException; /** diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 044fb38ebae..b94e44b5b00 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -17,9 +17,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.logic.commands.AddContactCommand; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.CommandResult; -import seedu.address.logic.commands.ListContactCommand; +import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; diff --git a/src/test/java/seedu/address/logic/commands/AddContactCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddContactCommandIntegrationTest.java index 310f001d975..2e8d9a76cbf 100644 --- a/src/test/java/seedu/address/logic/commands/AddContactCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddContactCommandIntegrationTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; diff --git a/src/test/java/seedu/address/logic/commands/AddContactCommandTest.java b/src/test/java/seedu/address/logic/commands/AddContactCommandTest.java index 6d5f235a77a..5c9a38b958b 100644 --- a/src/test/java/seedu/address/logic/commands/AddContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddContactCommandTest.java @@ -15,6 +15,7 @@ import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index da3c961f9a5..c425ffda731 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -14,6 +14,7 @@ import java.util.List; import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.contact.EditContactCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; diff --git a/src/test/java/seedu/address/logic/commands/DeleteContactCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteContactCommandTest.java index 488c5ea81e4..61256ad37ed 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteContactCommandTest.java @@ -13,6 +13,7 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.contact.DeleteContactCommand; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; diff --git a/src/test/java/seedu/address/logic/commands/EditContactCommandTest.java b/src/test/java/seedu/address/logic/commands/EditContactCommandTest.java index ab4371301e0..7783ecef3c8 100644 --- a/src/test/java/seedu/address/logic/commands/EditContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditContactCommandTest.java @@ -18,7 +18,8 @@ import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.EditContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java index 9c6a3229db4..df031dc4353 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; import seedu.address.testutil.EditPersonDescriptorBuilder; public class EditPersonDescriptorTest { diff --git a/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java b/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java index 6691d201cc8..ae875d2a3fd 100644 --- a/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindContactCommandTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.Test; +import seedu.address.logic.commands.contact.FindContactCommand; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; diff --git a/src/test/java/seedu/address/logic/commands/ListContactCommandTest.java b/src/test/java/seedu/address/logic/commands/ListContactCommandTest.java index 81f4f5db7fb..91c22cce98f 100644 --- a/src/test/java/seedu/address/logic/commands/ListContactCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListContactCommandTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; diff --git a/src/test/java/seedu/address/logic/parser/AddContactCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddContactCommandParserTest.java index c06bda3c6c0..6fb7c909ae4 100644 --- a/src/test/java/seedu/address/logic/parser/AddContactCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddContactCommandParserTest.java @@ -31,7 +31,8 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.AddContactCommand; +import seedu.address.logic.commands.contact.AddContactCommand; +import seedu.address.logic.parser.contact.AddContactCommandParser; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 319ba3585f7..855a7dd4737 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -9,14 +9,14 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.AddContactCommand; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.ClearCommand; -import seedu.address.logic.commands.DeleteContactCommand; -import seedu.address.logic.commands.EditContactCommand; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.DeleteContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.HelpCommand; -import seedu.address.logic.commands.ListContactCommand; +import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Person; import seedu.address.testutil.EditPersonDescriptorBuilder; diff --git a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java index 7de2535395b..c0d7d1df32a 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java @@ -7,7 +7,8 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.DeleteContactCommand; +import seedu.address.logic.commands.contact.DeleteContactCommand; +import seedu.address.logic.parser.contact.DeleteContactCommandParser; /** * As we are only doing white-box testing, our test cases do not cover path variations diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 781da9a8f1b..512db21a335 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -34,8 +34,9 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.core.index.Index; -import seedu.address.logic.commands.EditContactCommand; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.EditContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.parser.contact.EditContactCommandParser; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index 6719d197278..a83af3e2eab 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -8,7 +8,8 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.FindContactCommand; +import seedu.address.logic.commands.contact.FindContactCommand; +import seedu.address.logic.parser.contact.FindContactCommandParser; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index a9b1eda8e66..f6bcce9e42f 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -4,7 +4,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; import seedu.address.model.person.Address; import seedu.address.model.person.Email; import seedu.address.model.person.Name; diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index b6098f78505..6dfca9a9b17 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -8,8 +8,8 @@ import java.util.Set; -import seedu.address.logic.commands.AddContactCommand; -import seedu.address.logic.commands.EditContactCommand.EditPersonDescriptor; +import seedu.address.logic.commands.contact.AddContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; import seedu.address.model.person.Person; import seedu.address.model.tag.Tag; From b0934e411d6a1fd63155cd92ac06bbdddff5bb62 Mon Sep 17 00:00:00 2001 From: junwei-tan Date: Fri, 7 Oct 2022 16:31:03 +0800 Subject: [PATCH 6/6] Update code format to comply with checkstyle --- .../java/seedu/address/logic/commands/HelpCommand.java | 6 +++++- .../seedu/address/logic/parser/AddressBookParser.java | 10 +++++----- .../logic/parser/contact/AddContactCommandParser.java | 6 +++++- .../logic/parser/contact/FindContactCommandParser.java | 6 +++++- .../logic/parser/task/AddTaskCommandParser.java | 6 +++++- .../java/seedu/address/logic/LogicManagerTest.java | 2 +- .../address/logic/parser/AddressBookParserTest.java | 6 +++--- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index 61d5e364a7f..2ae35c01065 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,6 +1,10 @@ package seedu.address.logic.commands; -import seedu.address.logic.commands.contact.*; +import seedu.address.logic.commands.contact.AddContactCommand; +import seedu.address.logic.commands.contact.DeleteContactCommand; +import seedu.address.logic.commands.contact.EditContactCommand; +import seedu.address.logic.commands.contact.FindContactCommand; +import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.model.Model; /** diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index fca6949d2d0..14380611554 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -6,17 +6,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import seedu.address.logic.commands.contact.AddContactCommand; -import seedu.address.logic.commands.tag.AddTagCommand; import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.ExitCommand; +import seedu.address.logic.commands.HelpCommand; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.contact.DeleteContactCommand; -import seedu.address.logic.commands.tag.DeleteTagCommand; import seedu.address.logic.commands.contact.EditContactCommand; -import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.contact.FindContactCommand; -import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.contact.ListContactCommand; +import seedu.address.logic.commands.tag.AddTagCommand; +import seedu.address.logic.commands.tag.DeleteTagCommand; import seedu.address.logic.commands.task.ListTaskCommand; import seedu.address.logic.commands.task.MarkTaskCommand; import seedu.address.logic.commands.task.UnmarkTaskCommand; diff --git a/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java index ad91434a4ce..65b385dc391 100644 --- a/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/AddContactCommandParser.java @@ -11,7 +11,11 @@ import java.util.stream.Stream; import seedu.address.logic.commands.contact.AddContactCommand; -import seedu.address.logic.parser.*; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; +import seedu.address.logic.parser.Prefix; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; diff --git a/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java b/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java index d4285da0468..5b6c886cb62 100644 --- a/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/contact/FindContactCommandParser.java @@ -11,7 +11,11 @@ import java.util.stream.Stream; import seedu.address.logic.commands.contact.FindContactCommand; -import seedu.address.logic.parser.*; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; +import seedu.address.logic.parser.Prefix; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Address; import seedu.address.model.person.Email; diff --git a/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java b/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java index 7be0fa10b61..28599890964 100644 --- a/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/task/AddTaskCommandParser.java @@ -7,7 +7,11 @@ import java.util.stream.Stream; import seedu.address.logic.commands.task.AddTaskCommand; -import seedu.address.logic.parser.*; +import seedu.address.logic.parser.ArgumentMultimap; +import seedu.address.logic.parser.ArgumentTokenizer; +import seedu.address.logic.parser.Parser; +import seedu.address.logic.parser.ParserUtil; +import seedu.address.logic.parser.Prefix; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.task.Description; import seedu.address.model.task.Task; diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index b94e44b5b00..f88d2a5f75f 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -17,8 +17,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.CommandResult; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 855a7dd4737..39cd6340349 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -9,13 +9,13 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.ClearCommand; +import seedu.address.logic.commands.ExitCommand; +import seedu.address.logic.commands.HelpCommand; +import seedu.address.logic.commands.contact.AddContactCommand; import seedu.address.logic.commands.contact.DeleteContactCommand; import seedu.address.logic.commands.contact.EditContactCommand; import seedu.address.logic.commands.contact.EditContactCommand.EditPersonDescriptor; -import seedu.address.logic.commands.ExitCommand; -import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.contact.ListContactCommand; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.person.Person;