Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Find Command #83

Merged

Conversation

jonahtanjz
Copy link
Collaborator

@jonahtanjz jonahtanjz commented Oct 20, 2020

  • Tokenize Find command
  • Make each prefix in Find command optional
  • Add ExpirySearchPredicate, PrioritySearchPredicate and TagSearchPredicate
  • Parse arguments in Find command to generate the respective Predicates
  • Add JUnit tests for new Find command feature
  • Add JUnit tests for ExpirySearchPredicate, PrioritySearchPredicate and TagSearchPredicate

@jonahtanjz jonahtanjz self-assigned this Oct 20, 2020
@codecov-io
Copy link

Codecov Report

Merging #83 into master will increase coverage by 0.46%.
The diff coverage is 82.60%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #83      +/-   ##
============================================
+ Coverage     71.62%   72.08%   +0.46%     
- Complexity      398      435      +37     
============================================
  Files            69       72       +3     
  Lines          1237     1322      +85     
  Branches        121      144      +23     
============================================
+ Hits            886      953      +67     
  Misses          319      319              
- Partials         32       50      +18     
Impacted Files Coverage Δ Complexity Δ
...del/food/DescriptionContainsKeywordsPredicate.java 80.00% <0.00%> (-20.00%) 8.00 <0.00> (+1.00) ⬇️
...eedu/simplykitchen/logic/commands/FindCommand.java 73.33% <72.00%> (-26.67%) 8.00 <2.00> (+2.00) ⬇️
...ykitchen/model/food/ExpiryDateSearchPredicate.java 75.00% <75.00%> (ø) 6.00 <6.00> (?)
...plykitchen/model/food/PrioritySearchPredicate.java 75.00% <75.00%> (ø) 7.00 <7.00> (?)
...du/simplykitchen/model/tag/TagSearchPredicate.java 78.57% <78.57%> (ø) 9.00 <9.00> (?)
.../simplykitchen/logic/parser/FindCommandParser.java 100.00% <100.00%> (ø) 15.00 <14.00> (+12.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2a7f17...9f48473. Read the comment docs.

@jonahtanjz jonahtanjz added this to the v1.3 milestone Oct 20, 2020
@bchenghi bchenghi self-requested a review October 21, 2020 07:13
Copy link
Collaborator

@bchenghi bchenghi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look great! I left a few comments below.

return tagsToFind.stream()
.anyMatch(tagToFind -> {
for (Tag tag : food.getTags()) {
if (StringUtil.containsWordIgnoreCase(tag.tagName, tagToFind.tagName)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since a single tag can have multiple words, so containsWordIgnoreCase will throw an error if its argument has multiple words?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup good catch! Fixed

* Tests that a {@code Food}'s {@code Priority} matches the search given.
*/
public class ExpiryDateSearchPredicate implements Predicate<Food> {
private static Logger logger = Logger.getLogger("ExpiryDateSearchPredicate.class");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be LogsCenter.getLogger(ExpiryDateSearchPredicate.Class) instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright changed.

@@ -57,28 +89,142 @@ public void equals() {
@Test
public void execute_zeroKeywords_noFoodFound() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor, but for consistency, do you think this should be execute_zeroDescriptionKeywords_noFoodFound()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Thanks

}

@Test
public void execute_multipleTagsSearch_multipleFoodsFound() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include tags with spaces as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Added new tests

Copy link
Collaborator

@bchenghi bchenghi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bchenghi bchenghi merged commit 391aeb4 into AY2021S1-CS2103T-F13-4:master Oct 22, 2020
Week 10 automation moved this from In Progress (Jonah) to Done Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment