From 10609e97f3abd37c729126668df670146df14e13 Mon Sep 17 00:00:00 2001 From: nicolengk Date: Sun, 29 Oct 2023 17:58:01 +0800 Subject: [PATCH 1/5] Add findprop feature --- .../address/commons/util/StringUtil.java | 26 ++++++ .../java/seedu/address/logic/Messages.java | 2 + .../logic/commands/FindPropertyCommand.java | 59 ++++++++++++ .../logic/parser/AddressBookParser.java | 6 +- .../parser/FindPropertyCommandParser.java | 34 +++++++ .../PropNameContainsKeywordsPredicate.java | 4 +- .../commands/FindPropertyCommandTest.java | 91 +++++++++++++++++++ 7 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 src/main/java/seedu/address/logic/commands/FindPropertyCommand.java create mode 100644 src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java create mode 100644 src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java diff --git a/src/main/java/seedu/address/commons/util/StringUtil.java b/src/main/java/seedu/address/commons/util/StringUtil.java index 5e2993045f7..cd65c1ed0e0 100644 --- a/src/main/java/seedu/address/commons/util/StringUtil.java +++ b/src/main/java/seedu/address/commons/util/StringUtil.java @@ -38,6 +38,32 @@ public static boolean containsWordIgnoreCase(String sentence, String word) { .anyMatch(preppedWord::equalsIgnoreCase); } + /** + * Returns true if the {@code sentence} contains the {@code word}. + * Ignores case and a full word match is NOT required. + *
examples:
+     *       containsWordIgnoreCase("ABc def", "abc") == true
+     *       containsWordIgnoreCase("ABc def", "DEF") == true
+     *       containsWordIgnoreCase("ABc def", "AB") == true // full word match not needed
+     *       
+ * @param sentence cannot be null + * @param word cannot be null, cannot be empty, must be a single word + */ + public static boolean containsWordIgnoreCaseWithoutFullMatch(String sentence, String word) { + requireNonNull(sentence); + requireNonNull(word); + + String preppedWord = word.trim(); + checkArgument(!preppedWord.isEmpty(), "Word parameter cannot be empty"); + checkArgument(preppedWord.split("\\s+").length == 1, "Word parameter should be a single word"); + + String preppedSentence = sentence; + String[] wordsInPreppedSentence = preppedSentence.split("\\s+"); + + return Arrays.stream(wordsInPreppedSentence) + .anyMatch(w -> w.toLowerCase().contains(preppedWord.toLowerCase())); + } + /** * Returns a detailed message of the t, including the stack trace. */ diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 2ef635b1dfb..a5f5cdb0d79 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -20,6 +20,8 @@ public class Messages { public static final String MESSAGE_INVALID_PROPERTY_DISPLAYED_INDEX = "The property index provided is invalid"; public static final String MESSAGE_CUSTOMERS_LISTED_OVERVIEW = "%1$d customers listed!"; + + public static final String MESSAGE_PROPERTIES_LISTED_OVERVIEW = "%1$d properties listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; diff --git a/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java b/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java new file mode 100644 index 00000000000..1a14b383bcf --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java @@ -0,0 +1,59 @@ +package seedu.address.logic.commands; + +import seedu.address.commons.util.ToStringBuilder; +import seedu.address.logic.Messages; +import seedu.address.model.Model; +import seedu.address.model.customer.NameContainsKeywordsPredicate; +import seedu.address.model.property.PropNameContainsKeywordsPredicate; + +import static java.util.Objects.requireNonNull; + +/** + * Finds and lists all properties in address book whose name contains any of the argument keywords. + * Keyword matching is case insensitive. + */ +public class FindPropertyCommand extends Command { + + public static final String COMMAND_WORD = "findprop"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all properties whose names contain any of " + + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" + + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + + "Example: " + COMMAND_WORD + " Aquavista Luxeloft"; + + private final PropNameContainsKeywordsPredicate predicate; + + public FindPropertyCommand(PropNameContainsKeywordsPredicate predicate) { + this.predicate = predicate; + } + + @Override + public CommandResult execute(Model model) { + requireNonNull(model); + model.updateFilteredPropertyList(predicate); + return new CommandResult( + String.format(Messages.MESSAGE_PROPERTIES_LISTED_OVERVIEW, model.getFilteredPropertyList().size())); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof FindPropertyCommand)) { + return false; + } + + FindPropertyCommand otherFindCommand = (FindPropertyCommand) other; + return predicate.equals(otherFindCommand.predicate); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .add("predicate", predicate) + .toString(); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index e8591b1ca97..21d2f0135ff 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -18,7 +18,7 @@ import seedu.address.logic.commands.EditPropertyCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FilterCustomerCommand; -import seedu.address.logic.commands.FindCommand; +import seedu.address.logic.commands.FindPropertyCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCustomerCommand; import seedu.address.logic.commands.ListPropertyCommand; @@ -79,8 +79,8 @@ public Command parseCommand(String userInput) throws ParseException { case ClearCommand.COMMAND_WORD: return new ClearCommand(); - case FindCommand.COMMAND_WORD: - return new FindCommandParser().parse(arguments); + case FindPropertyCommand.COMMAND_WORD: + return new FindPropertyCommandParser().parse(arguments); case FilterCustomerCommand.COMMAND_WORD: return new FilterCustomerCommandParser().parse(arguments); diff --git a/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java b/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java new file mode 100644 index 00000000000..bf01fcb7469 --- /dev/null +++ b/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java @@ -0,0 +1,34 @@ +package seedu.address.logic.parser; + +import seedu.address.logic.commands.FindCommand; +import seedu.address.logic.commands.FindPropertyCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.property.PropNameContainsKeywordsPredicate; + +import java.util.Arrays; + +import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; + +/** + * Parses input arguments and creates a new FindCommand object + */ +public class FindPropertyCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the FindPropertyCommand + * and returns a FindPropertyCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public FindPropertyCommand parse(String args) throws ParseException { + String trimmedArgs = args.trim(); + if (trimmedArgs.isEmpty()) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindPropertyCommand.MESSAGE_USAGE)); + } + + String[] nameKeywords = trimmedArgs.split("\\s+"); + + return new FindPropertyCommand(new PropNameContainsKeywordsPredicate(Arrays.asList(nameKeywords))); + } + +} diff --git a/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java index 7e7992bd5c4..5d93a61c39b 100644 --- a/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java @@ -19,9 +19,9 @@ public PropNameContainsKeywordsPredicate(List keywords) { @Override public boolean test(Property property) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(property.getName().fullName, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCaseWithoutFullMatch(property.getName().fullName, + keyword)); } - @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java b/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java new file mode 100644 index 00000000000..bb50e054c7b --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java @@ -0,0 +1,91 @@ +package seedu.address.logic.commands; + +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.property.PropNameContainsKeywordsPredicate; + +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.logic.Messages.MESSAGE_PROPERTIES_LISTED_OVERVIEW; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.testutil.TypicalCustomers.getTypicalAddressBook; +import static seedu.address.testutil.TypicalProperties.AQUAVISTA; +import static seedu.address.testutil.TypicalProperties.HORIZONVIEW; +import static seedu.address.testutil.TypicalProperties.SKYVISTA; +import static seedu.address.testutil.TypicalProperties.getTypicalPropertyBook; + +/** + * Contains integration tests (interaction with the Model) for {@code FindPropertyCommand}. + */ +public class FindPropertyCommandTest { + private Model model = new ModelManager(getTypicalAddressBook(), getTypicalPropertyBook(), new UserPrefs()); + private Model expectedModel = new ModelManager(getTypicalAddressBook(), getTypicalPropertyBook(), new UserPrefs()); + + @Test + public void equals() { + PropNameContainsKeywordsPredicate firstPredicate = + new PropNameContainsKeywordsPredicate(Collections.singletonList("first")); + PropNameContainsKeywordsPredicate secondPredicate = + new PropNameContainsKeywordsPredicate(Collections.singletonList("second")); + + FindPropertyCommand findFirstCommand = new FindPropertyCommand(firstPredicate); + FindPropertyCommand findSecondCommand = new FindPropertyCommand(secondPredicate); + + // same object -> returns true + assertTrue(findFirstCommand.equals(findFirstCommand)); + + // same values -> returns true + FindPropertyCommand findFirstCommandCopy = new FindPropertyCommand(firstPredicate); + assertTrue(findFirstCommand.equals(findFirstCommandCopy)); + + // different types -> returns false + assertFalse(findFirstCommand.equals(1)); + + // null -> returns false + assertFalse(findFirstCommand.equals(null)); + + // different customer -> returns false + assertFalse(findFirstCommand.equals(findSecondCommand)); + } + + @Test + public void execute_zeroKeywords_noPropertyFound() { + String expectedMessage = String.format(MESSAGE_PROPERTIES_LISTED_OVERVIEW, 0); + PropNameContainsKeywordsPredicate predicate = preparePredicate(" "); + FindPropertyCommand command = new FindPropertyCommand(predicate); + expectedModel.updateFilteredPropertyList(predicate); + assertCommandSuccess(command, model, expectedMessage, expectedModel); + assertEquals(Collections.emptyList(), model.getFilteredPropertyList()); + } + + @Test + public void execute_multipleKeywords_multiplePropertiesFound() { + String expectedMessage = String.format(MESSAGE_PROPERTIES_LISTED_OVERVIEW, 3); + PropNameContainsKeywordsPredicate predicate = preparePredicate("Aquavista Skyvista Horizonview"); + FindPropertyCommand command = new FindPropertyCommand(predicate); + expectedModel.updateFilteredPropertyList(predicate); + assertCommandSuccess(command, model, expectedMessage, expectedModel); + assertEquals(Arrays.asList(AQUAVISTA, SKYVISTA, HORIZONVIEW), model.getFilteredPropertyList()); + } + + @Test + public void toStringMethod() { + PropNameContainsKeywordsPredicate predicate = new PropNameContainsKeywordsPredicate(Arrays.asList("keyword")); + FindPropertyCommand findCommand = new FindPropertyCommand(predicate); + String expected = FindPropertyCommand.class.getCanonicalName() + "{predicate=" + predicate + "}"; + assertEquals(expected, findCommand.toString()); + } + + /** + * Parses {@code userInput} into a {@code PropNameContainsKeywordsPredicate}. + */ + private PropNameContainsKeywordsPredicate preparePredicate(String userInput) { + return new PropNameContainsKeywordsPredicate(Arrays.asList(userInput.split("\\s+"))); + } +} From e67718207f6bcd4223056b68c659fb4f6eabca75 Mon Sep 17 00:00:00 2001 From: nicolengk Date: Mon, 30 Oct 2023 20:10:59 +0800 Subject: [PATCH 2/5] Add findprop feature --- .../address/commons/util/StringUtil.java | 21 +++++++ .../logic/commands/FindPropertyCommand.java | 4 +- .../logic/parser/AddressBookParser.java | 62 ++++++++++--------- .../parser/FindPropertyCommandParser.java | 9 ++- .../PropNameContainsKeywordsPredicate.java | 2 +- .../commands/FindPropertyCommandTest.java | 24 +++---- .../address/testutil/TypicalProperties.java | 2 +- 7 files changed, 75 insertions(+), 49 deletions(-) diff --git a/src/main/java/seedu/address/commons/util/StringUtil.java b/src/main/java/seedu/address/commons/util/StringUtil.java index cd65c1ed0e0..36945e7bdcf 100644 --- a/src/main/java/seedu/address/commons/util/StringUtil.java +++ b/src/main/java/seedu/address/commons/util/StringUtil.java @@ -64,6 +64,27 @@ public static boolean containsWordIgnoreCaseWithoutFullMatch(String sentence, St .anyMatch(w -> w.toLowerCase().contains(preppedWord.toLowerCase())); } + /** + * Returns true if the {@code sentence} start with the {@code word}. + * Ignores case and a full word match is NOT required. + * @param sentence cannot be null + * @param word cannot be null, cannot be empty, must be a single word + */ + public static boolean startsWithWordIgnoreCaseWithoutFullMatch(String sentence, String word) { + requireNonNull(sentence); + requireNonNull(word); + + String preppedWord = word.trim(); + checkArgument(!preppedWord.isEmpty(), "Word parameter cannot be empty"); + checkArgument(preppedWord.split("\\s+").length == 1, "Word parameter should be a single word"); + + String preppedSentence = sentence; + String[] wordsInPreppedSentence = preppedSentence.split("\\s+"); + + return Arrays.stream(wordsInPreppedSentence) + .anyMatch(w -> w.toLowerCase().startsWith(preppedWord.toLowerCase())); + } + /** * Returns a detailed message of the t, including the stack trace. */ diff --git a/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java b/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java index 1a14b383bcf..67324a915ad 100644 --- a/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindPropertyCommand.java @@ -1,12 +1,12 @@ package seedu.address.logic.commands; +import static java.util.Objects.requireNonNull; + import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.model.Model; -import seedu.address.model.customer.NameContainsKeywordsPredicate; import seedu.address.model.property.PropNameContainsKeywordsPredicate; -import static java.util.Objects.requireNonNull; /** * Finds and lists all properties in address book whose name contains any of the argument keywords. diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 21d2f0135ff..e5ae3cd908e 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -18,6 +18,7 @@ import seedu.address.logic.commands.EditPropertyCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FilterCustomerCommand; +import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.FindPropertyCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCustomerCommand; @@ -58,48 +59,51 @@ public Command parseCommand(String userInput) throws ParseException { switch (commandWord) { - case AddCustomerCommand.COMMAND_WORD: - return new AddCustomerCommandParser().parse(arguments); + case AddCustomerCommand.COMMAND_WORD: + return new AddCustomerCommandParser().parse(arguments); - case AddPropertyCommand.COMMAND_WORD: - return new AddPropertyCommandParser().parse(arguments); + case AddPropertyCommand.COMMAND_WORD: + return new AddPropertyCommandParser().parse(arguments); - case EditCommand.COMMAND_WORD: - return new EditCommandParser().parse(arguments); + case EditCommand.COMMAND_WORD: + return new EditCommandParser().parse(arguments); - case EditPropertyCommand.COMMAND_WORD: - return new EditPropertyCommandParser().parse(arguments); + case EditPropertyCommand.COMMAND_WORD: + return new EditPropertyCommandParser().parse(arguments); - case DeletePropertyCommand.COMMAND_WORD: - return new DeletePropertyCommandParser().parse(arguments); + case DeletePropertyCommand.COMMAND_WORD: + return new DeletePropertyCommandParser().parse(arguments); - case DeleteCustomerCommand.COMMAND_WORD: - return new DeleteCustomerCommandParser().parse(arguments); + case DeleteCustomerCommand.COMMAND_WORD: + return new DeleteCustomerCommandParser().parse(arguments); - case ClearCommand.COMMAND_WORD: - return new ClearCommand(); + case ClearCommand.COMMAND_WORD: + return new ClearCommand(); - case FindPropertyCommand.COMMAND_WORD: - return new FindPropertyCommandParser().parse(arguments); + case FindCommand.COMMAND_WORD: + return new FindCommandParser().parse(arguments); - case FilterCustomerCommand.COMMAND_WORD: - return new FilterCustomerCommandParser().parse(arguments); + case FindPropertyCommand.COMMAND_WORD: + return new FindPropertyCommandParser().parse(arguments); - case ListCustomerCommand.COMMAND_WORD: - return new ListCustomerCommand(); + case FilterCustomerCommand.COMMAND_WORD: + return new FilterCustomerCommandParser().parse(arguments); - case ListPropertyCommand.COMMAND_WORD: - return new ListPropertyCommand(); + case ListCustomerCommand.COMMAND_WORD: + return new ListCustomerCommand(); - case ExitCommand.COMMAND_WORD: - return new ExitCommand(); + case ListPropertyCommand.COMMAND_WORD: + return new ListPropertyCommand(); - case HelpCommand.COMMAND_WORD: - return new HelpCommand(); + case ExitCommand.COMMAND_WORD: + return new ExitCommand(); - default: - logger.finer("This user input caused a ParseException: " + userInput); - throw new ParseException(MESSAGE_UNKNOWN_COMMAND); + case HelpCommand.COMMAND_WORD: + return new HelpCommand(); + + default: + logger.finer("This user input caused a ParseException: " + userInput); + throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } } diff --git a/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java b/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java index bf01fcb7469..dec19dc60da 100644 --- a/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindPropertyCommandParser.java @@ -1,13 +1,12 @@ package seedu.address.logic.parser; -import seedu.address.logic.commands.FindCommand; -import seedu.address.logic.commands.FindPropertyCommand; -import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.property.PropNameContainsKeywordsPredicate; +import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import java.util.Arrays; -import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import seedu.address.logic.commands.FindPropertyCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.property.PropNameContainsKeywordsPredicate; /** * Parses input arguments and creates a new FindCommand object diff --git a/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java index 5d93a61c39b..d97c261d499 100644 --- a/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/property/PropNameContainsKeywordsPredicate.java @@ -19,7 +19,7 @@ public PropNameContainsKeywordsPredicate(List keywords) { @Override public boolean test(Property property) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCaseWithoutFullMatch(property.getName().fullName, + .anyMatch(keyword -> StringUtil.startsWithWordIgnoreCaseWithoutFullMatch(property.getName().fullName, keyword)); } @Override diff --git a/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java b/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java index bb50e054c7b..c20c3d968ca 100644 --- a/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindPropertyCommandTest.java @@ -1,25 +1,27 @@ package seedu.address.logic.commands; -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.property.PropNameContainsKeywordsPredicate; - -import java.util.Arrays; -import java.util.Collections; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.Messages.MESSAGE_PROPERTIES_LISTED_OVERVIEW; -import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.CommandPropertyTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalCustomers.getTypicalAddressBook; import static seedu.address.testutil.TypicalProperties.AQUAVISTA; import static seedu.address.testutil.TypicalProperties.HORIZONVIEW; import static seedu.address.testutil.TypicalProperties.SKYVISTA; import static seedu.address.testutil.TypicalProperties.getTypicalPropertyBook; +import java.util.Arrays; +import java.util.Collections; + +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.property.PropNameContainsKeywordsPredicate; + + /** * Contains integration tests (interaction with the Model) for {@code FindPropertyCommand}. */ @@ -67,7 +69,7 @@ public void execute_zeroKeywords_noPropertyFound() { @Test public void execute_multipleKeywords_multiplePropertiesFound() { String expectedMessage = String.format(MESSAGE_PROPERTIES_LISTED_OVERVIEW, 3); - PropNameContainsKeywordsPredicate predicate = preparePredicate("Aquavista Skyvista Horizonview"); + PropNameContainsKeywordsPredicate predicate = preparePredicate("Aquavi Skyvista Horizonview"); FindPropertyCommand command = new FindPropertyCommand(predicate); expectedModel.updateFilteredPropertyList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); diff --git a/src/test/java/seedu/address/testutil/TypicalProperties.java b/src/test/java/seedu/address/testutil/TypicalProperties.java index bd626812577..fadd4fbb37c 100644 --- a/src/test/java/seedu/address/testutil/TypicalProperties.java +++ b/src/test/java/seedu/address/testutil/TypicalProperties.java @@ -72,6 +72,6 @@ public static PropertyBook getTypicalPropertyBook() { } public static List getTypicalProperties() { - return new ArrayList<>(Arrays.asList(AQUAVIEW, SKYVISTA, HORIZONVIEW, LUXELOFT, RIVERIA, AZURE, TRANQUILIS)); + return new ArrayList<>(Arrays.asList(AQUAVISTA, SKYVISTA, HORIZONVIEW, LUXELOFT, RIVERIA, AZURE, TRANQUILIS)); } } From 5b1f7913a5c5f12d9d20ffdc521852466d08c5ec Mon Sep 17 00:00:00 2001 From: nicolengk Date: Mon, 30 Oct 2023 20:15:11 +0800 Subject: [PATCH 3/5] Fix checkstyle for findprop feature --- .../logic/parser/AddressBookParser.java | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index e5ae3cd908e..425381cc4bf 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -59,51 +59,51 @@ public Command parseCommand(String userInput) throws ParseException { switch (commandWord) { - case AddCustomerCommand.COMMAND_WORD: - return new AddCustomerCommandParser().parse(arguments); + case AddCustomerCommand.COMMAND_WORD: + return new AddCustomerCommandParser().parse(arguments); - case AddPropertyCommand.COMMAND_WORD: - return new AddPropertyCommandParser().parse(arguments); + case AddPropertyCommand.COMMAND_WORD: + return new AddPropertyCommandParser().parse(arguments); - case EditCommand.COMMAND_WORD: - return new EditCommandParser().parse(arguments); + case EditCommand.COMMAND_WORD: + return new EditCommandParser().parse(arguments); - case EditPropertyCommand.COMMAND_WORD: - return new EditPropertyCommandParser().parse(arguments); + case EditPropertyCommand.COMMAND_WORD: + return new EditPropertyCommandParser().parse(arguments); - case DeletePropertyCommand.COMMAND_WORD: - return new DeletePropertyCommandParser().parse(arguments); + case DeletePropertyCommand.COMMAND_WORD: + return new DeletePropertyCommandParser().parse(arguments); - case DeleteCustomerCommand.COMMAND_WORD: - return new DeleteCustomerCommandParser().parse(arguments); + case DeleteCustomerCommand.COMMAND_WORD: + return new DeleteCustomerCommandParser().parse(arguments); - case ClearCommand.COMMAND_WORD: - return new ClearCommand(); + case ClearCommand.COMMAND_WORD: + return new ClearCommand(); - case FindCommand.COMMAND_WORD: - return new FindCommandParser().parse(arguments); + case FindCommand.COMMAND_WORD: + return new FindCommandParser().parse(arguments); - case FindPropertyCommand.COMMAND_WORD: - return new FindPropertyCommandParser().parse(arguments); + case FindPropertyCommand.COMMAND_WORD: + return new FindPropertyCommandParser().parse(arguments); - case FilterCustomerCommand.COMMAND_WORD: - return new FilterCustomerCommandParser().parse(arguments); + case FilterCustomerCommand.COMMAND_WORD: + return new FilterCustomerCommandParser().parse(arguments); - case ListCustomerCommand.COMMAND_WORD: - return new ListCustomerCommand(); + case ListCustomerCommand.COMMAND_WORD: + return new ListCustomerCommand(); - case ListPropertyCommand.COMMAND_WORD: - return new ListPropertyCommand(); + case ListPropertyCommand.COMMAND_WORD: + return new ListPropertyCommand(); - case ExitCommand.COMMAND_WORD: - return new ExitCommand(); + case ExitCommand.COMMAND_WORD: + return new ExitCommand(); - case HelpCommand.COMMAND_WORD: - return new HelpCommand(); + case HelpCommand.COMMAND_WORD: + return new HelpCommand(); - default: - logger.finer("This user input caused a ParseException: " + userInput); - throw new ParseException(MESSAGE_UNKNOWN_COMMAND); + default: + logger.finer("This user input caused a ParseException: " + userInput); + throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } } From db82f1902cec3a4c9b4fb9695ea22e8744dd5b2c Mon Sep 17 00:00:00 2001 From: nicolengk Date: Mon, 30 Oct 2023 21:51:10 +0800 Subject: [PATCH 4/5] Removed unused command and import --- .../java/seedu/address/logic/parser/AddressBookParser.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 425381cc4bf..21d2f0135ff 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -18,7 +18,6 @@ import seedu.address.logic.commands.EditPropertyCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FilterCustomerCommand; -import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.FindPropertyCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCustomerCommand; @@ -80,9 +79,6 @@ public Command parseCommand(String userInput) throws ParseException { case ClearCommand.COMMAND_WORD: return new ClearCommand(); - case FindCommand.COMMAND_WORD: - return new FindCommandParser().parse(arguments); - case FindPropertyCommand.COMMAND_WORD: return new FindPropertyCommandParser().parse(arguments); From e5508e5aabe7a368a72afcdfaef0c321b21a12ef Mon Sep 17 00:00:00 2001 From: nicolengk Date: Tue, 31 Oct 2023 13:55:02 +0800 Subject: [PATCH 5/5] Fix checkstyle error --- src/main/java/seedu/address/logic/parser/AddressBookParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 9c8ae4487f3..3026bd1cadc 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -18,8 +18,8 @@ import seedu.address.logic.commands.EditPropertyCommand; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FilterCustomerCommand; -import seedu.address.logic.commands.FindPropertyCommand; import seedu.address.logic.commands.FindCustomerCommand; +import seedu.address.logic.commands.FindPropertyCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCustomerCommand; import seedu.address.logic.commands.ListPropertyCommand;