forked from nus-cs2103-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor predicates in Model & Improve the test structure #233
Merged
UncleGrandpa925
merged 15 commits into
AY2021S1-CS2103T-W13-4:master
from
UncleGrandpa925:write-more-testcases
Nov 1, 2020
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
89fa64a
Merge TypicalData with SampleDataUtil
UncleGrandpa925 46ac5e2
Add testcases to Lessons & make Lesson's Parser more versatile
UncleGrandpa925 b381f4c
Add testcases to Lesson & fix a bug of the existing testset
UncleGrandpa925 2307b32
Move some variables from low-level classes to ParserUtil & Messages
UncleGrandpa925 da2de3e
For EditTaskCommand: add tests & improve handling of null
UncleGrandpa925 fd4abd1
Add tests to Task & fix a wrong exception message
UncleGrandpa925 b6d6155
Partly refactor predicates in ModelManager to individual classes
UncleGrandpa925 e39e0f9
Add DeleteLessonCommandTest
UncleGrandpa925 1f524ac
Improve the test structure for Lessons
UncleGrandpa925 4273073
Modify TypicalLessons's constants to be static final
UncleGrandpa925 65285fd
Add in some static tasks to use with Json Serialize tests
UncleGrandpa925 acea8d2
Wrap all LocalDate.parse to catch possible unchecked exception
UncleGrandpa925 bfccba3
Edit some feedback messages
UncleGrandpa925 85a9fbe
Edit an exception message
UncleGrandpa925 bd38d23
Edit an exception message
UncleGrandpa925 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/trackitnus/model/contact/ContactHasTagPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package trackitnus.model.contact; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import trackitnus.model.tag.Tag; | ||
|
||
public class ContactHasTagPredicate implements Predicate<Contact> { | ||
|
||
private final Tag tag; | ||
|
||
public ContactHasTagPredicate(Tag tag) { | ||
this.tag = tag; | ||
} | ||
|
||
@Override | ||
public boolean test(Contact contact) { | ||
return contact.getTags().contains(tag); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof ContactHasTagPredicate // instanceof handles nulls | ||
&& tag.equals(((ContactHasTagPredicate) other).tag)); // state check | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/trackitnus/model/lesson/LessonHasCodePredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package trackitnus.model.lesson; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import trackitnus.model.commons.Code; | ||
|
||
public class LessonHasCodePredicate implements Predicate<Lesson> { | ||
|
||
private final Code code; | ||
|
||
public LessonHasCodePredicate(Code code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public boolean test(Lesson lesson) { | ||
return lesson.getCode().equals(code); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof LessonHasCodePredicate // instanceof handles nulls | ||
&& code.equals(((LessonHasCodePredicate) other).code)); // state check | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/trackitnus/model/lesson/LessonOnWeekdayPredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package trackitnus.model.lesson; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class LessonOnWeekdayPredicate implements Predicate<Lesson> { | ||
|
||
private final DayOfWeek weekday; | ||
|
||
public LessonOnWeekdayPredicate(DayOfWeek weekday) { | ||
this.weekday = weekday; | ||
} | ||
|
||
@Override | ||
public boolean test(Lesson lesson) { | ||
return lesson.getWeekday().equals(weekday); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof LessonOnWeekdayPredicate // instanceof handles nulls | ||
&& weekday.equals(((LessonOnWeekdayPredicate) other).weekday)); // state check | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove
!argMultimap.getPreamble().isEmpty()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because argMultimap.getPreamble() is actually to check if index is present, which is unnecessary in this case (in fact this is leftovers of copying from AB3 commands)