-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add unit tests for FindCommand class #110 #120
Conversation
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.
Some prelim comments added. Can modify based on those comments first. Also watchout for other similar PRs going on in parallel as we want all test classes to be written in a similar style.
return other == this // short circuit if same object | ||
|| (other instanceof AddressBook // instanceof handles nulls | ||
&& this.allPersons.equals(((AddressBook) other).allPersons) | ||
&& this.allTags.equals(((AddressBook) other).allTags)); |
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.
These two lines should be indented further because it is misleading to align ||
with &&
(they are not at the same level in the condition tree)
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.
Okay fixed!
public class FindCommandTest extends CommandTest { | ||
|
||
@Test | ||
public void execute_find_isCaseSensitive() throws IllegalValueException { |
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.
This name does not follow the convention. For example, the 3rd part of the name should be the expected result.
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.
Okay changed to execute_find_matchesOnlyIfCaseSensitive
/** | ||
* Test class for Main | ||
*/ | ||
public class TestMain { |
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.
This PR is for testing the FindCommand
class, not the 'find
command' as typed by the user. Hence, I don't see the need for this class. Compare with #118
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.
Okay removed!
|
||
hopper = new PersonBuilder().withName("Grace Hopper").withPhone("83434567", true) | ||
.withEmail("gh@gmail.com", true).withAddress("5 Clementi Road", true).build(); | ||
|
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.
When defining test data, try to follow a pattern that is easy to remember. For example, the first person's name has initials A. B. (e.g. Alice Betsy), second person's name has initials B. C. (Ben Charles) and so on. When things always follow a pattern, anything going out of that pattern (e.g. Ben suddenly appears at the start of the list) gets noticed immediately and sometimes can lead to discover bugs.
return this; | ||
} | ||
|
||
public PersonBuilder withPhone(String phone, boolean isPrivate) throws IllegalValueException { |
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.
While we are at it, we can also have a withPrivatePhone
method.
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.
Okay. Implemented two methods for each field.
For example withPublicPhone and withPrivatePhone.
Seems like you have unrelated commits in this branch. |
Sorry, I rebased the commits wrongly! Have rectified. |
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.
A few more comments added.
} | ||
|
||
@Test | ||
public void execute_find_matchesOnlyIfCaseSensitive() throws IllegalValueException { |
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.
As we are testing FindCommand
, execute
implies find
.
The method name can be execute_sameWordDifferentCase_notMatched()
. In that case, this method needs to be split into two. Alternatively, you can name it execute_caseSensitivity()
and test all cases of case sensitivity within the same method. In that case, use comments inside the method to describe each case.
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.
Okay! I have split the original method into 2.
@Test | ||
public void execute_find_matchesOnlyIfCaseSensitive() throws IllegalValueException { | ||
List<ReadOnlyPerson> expectedOne = TestUtil.createList(new Person(TypicalTestPersons.amy)); | ||
List<ReadOnlyPerson> expectedZero = Collections.emptyList(); |
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.
Define the variable closer to where it will be used.
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.
You can use the same variable expected
instead of declaring two variables with somewhat 'odd' names. :-)
assertCommandBehavior(command, Command.getMessageForPersonListShownSummary(expectedZero), | ||
unmutatedAddressBook, addressBook); | ||
|
||
|
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 two blank lines?
List<ReadOnlyPerson> expectedOne = TestUtil.createList(new Person(TypicalTestPersons.amy)); | ||
List<ReadOnlyPerson> expectedZero = Collections.emptyList(); | ||
|
||
String[] caseSensitiveKeywords = {"Amy"}; |
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.
The name doesn't do a very good job of describing what the variable is. A word by itself is not 'case sensitive'. keyWordsWithMatchingCase
?
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
|
||
public class TestPerson implements ReadOnlyPerson { |
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 do we need this class? In any case, there should be a header comment to explain what it is.
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.
Okay I removed this class. PersonBuilder now builds an instance of the Person class.
public TypicalTestPersons() { | ||
try { | ||
amy = new PersonBuilder().withName("Amy Buck").withPublicPhone("91234567") | ||
.withPublicEmail("cs@gmail.com").withPublicAddress("1 Clementi Road").build(); |
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.
telephone 91119111
and email ab@gmail.com
instead of random values? (for the same reasons as before; if we follow patterns, it's easy to detect when things go wrong)
Implemented the requested changes! |
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.
On the right track. A further set of revisions suggested.
public class FindCommandTest { | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); |
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.
Is this used anywhere?
@@ -124,11 +124,12 @@ public void clear() { | |||
public Iterator<Person> iterator() { | |||
return internalList.iterator(); | |||
} | |||
|
|||
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.
Blank lines should not contain spaces.
} | ||
|
||
|
||
|
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 3 blank lines here?
|
||
|
||
@Test | ||
public void execute_find_matchesOnlyFullWordsInNames() throws IllegalValueException { |
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.
Renames this method and subsequent methods to to be consistent with the previous two methods.
|
||
FindCommand command = createFindCommand(keywords); | ||
assertCommandBehavior(command, Command.getMessageForPersonListShownSummary(expected), | ||
unmutatedAddressBook, addressBook); |
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.
Increasing indentation like this can improve readability (the opening and closing brackets appear on extreme left and extreme right respectively of the parameter text)
assertCommandBehavior(command, Command.getMessageForPersonListShownSummary(expected),
unmutatedAddressBook, addressBook);
|
||
|
||
/** | ||
* Creates a new find command. |
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.
FindCommand
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.
Anyway, can be omitted as it doesn't add any value. It's the same as the method name.
} | ||
} | ||
|
||
public void loadAddressBookWithSampleData(AddressBook ab) { |
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.
does this need to be public?
@KnewYouWereTrouble what's the status of this PR? |
Ready for review! |
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.
Nearly there. Some cosmetic changes suggested, mainly to reduce verbosity of the code.
|
||
FindCommand command = createFindCommand(keywordsWithMatchingCase); | ||
assertCommandBehavior(command, Command.getMessageForPersonListShownSummary(expected), | ||
unmutatedAddressBook, addressBook); |
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.
Command.getMessageForPersonListShownSummary
seems to be repeated every time. May be you can put that part inside the assertCommandBehavior
method itself?
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.
Same thing for unmutatedAddressBook
. It can be inside the method itself instead of passing as a parameter every time?
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.
Okay! I moved them into the assertCommandBehavior
method!
|
||
@Test | ||
public void execute_sameWordDifferentCase_notMatched() throws IllegalValueException { | ||
List<ReadOnlyPerson> expected = Collections.emptyList(); |
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.
Declare this as a constant EMPTY_LIST
and use it everywhere?
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.
Alternatively, you can create this utility method:
public void assertNoResults(...){
assertCommandBehavior(..., Collections.emptyList(), ...);
}
In that case you may want to rename assertCommandBehavior
as assertResults
(for symmetry)
List<ReadOnlyPerson> expected = TestUtil.createList(new Person(TypicalPersons.amy), | ||
new Person(TypicalPersons.bill)); | ||
|
||
String[] keywords = {"Amy", "Bill"}; |
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.
You seem to be testing the first name only. What if there is a bug that limits the string matching to the first word of the name only?
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.
Okay! added another keyword that is the last name of the person
|
||
private void loadAddressBookWithSampleData(AddressBook ab) { | ||
try { | ||
for (Person t : getTypicalPersons()) { |
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 t
and not p
?
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.
Edited!
Ready for review! |
*/ | ||
public class TypicalPersons { | ||
|
||
public static Person amy, bill, candy, donald, grace; |
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.
May be use static methods instead e.g. amy(), bill()
etc. to create new objects every time? That way, we ensure that tests cannot influence each other via shared test objects.
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.
@damithc Addressbook-Level4 has the same problem too. I'll open up an issue there.
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.
Shouldn't we just copy over the code from AddressBook-Level4 in order to share as much code as possible?
In AddressBook-Level4 we have alice, benson, carl etc. but here we have amy, bill, candy etc. Seems like it will cause trouble when we want to share tests across different levels in the future.
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.
@pyokagan I agree. But I don't mind doing it as a separate issue. The extra work caused by duplication of code is a good source of 'low hanging fruit' issues for new contributors to do.
On a somewhat related note, at the moment I'm not too eager to unify similarities between the levels. At our final steady state it may be desirable to have different levels doing the same thing in different ways, so that students get to see more ways of doing the same thing. As we are not yet certain what our final steady state is going to be, I don't mind if levels evolved somewhat independently for now.
In hindsight, I'm not sure if we should use the Builder pattern in level 2. It would be good for one level (level 2?) to not use the Builder pattern so that it can be contrasted with the next level (level 3?) that improves the situation by applying the Builder pattern. Anyway, that's something we can consider on a future day. We can leave it be for now. :-p
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.
@damithc says:
The extra work caused by duplication of code is a good source of 'low hanging fruit' issues for new contributors to do.
It's more work for reviewers through, and will slow down the project. Reviewers may not be happy that they have to review the same things over and over again, but subtly different each time due to differences in code bases.
at the moment I'm not too eager to unify similarities between the levels.
I understand. However I hope that until there is a clear direction on how the different levels are going to differ from each other, we try to prevent them from diverging unnecessarily, simply because it is much easier to make code bases diverge rather than converge.
For an example of "diverging unnecessarily", for this PR I hope that the test data is kept exactly the same as the other levels, because future tests will be written for the test data. Having test data that is different will just cause unnecessary friction in the future should we ever try to bring tests from one level to another. Just try to cover our bases here :-)
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.
A step in the right direction. I think we can push harder to reduce verbosity of the code.
@@ -131,4 +131,5 @@ public boolean equals(Object other) { | |||
|| (other instanceof UniquePersonList // instanceof handles nulls | |||
&& this.internalList.equals(((UniquePersonList) other).internalList)); | |||
} | |||
|
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.
Unrelated change?
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.
Need to remove this
String[] keywordsWithMatchingCase = {"Amy"}; | ||
|
||
FindCommand command = createFindCommand(keywordsWithMatchingCase); | ||
assertCommandBehavior(command, expected, addressBook); |
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.
Still too verbose. Out of this 4 lines, the only things that are specific to this test case is Amy
and amy
. Everything else is just boilerplate and can be pushed into the utility method.
|
||
private final List<ReadOnlyPerson> EMPTY_LIST = Collections.emptyList(); | ||
|
||
@Before public void setUp() { |
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.
Annotation should be in a separate line.
@KnewYouWereTrouble reminder |
Ready for review! |
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.
Better now. Some more changes requested.
@@ -131,4 +131,5 @@ public boolean equals(Object other) { | |||
|| (other instanceof UniquePersonList // instanceof handles nulls | |||
&& this.internalList.equals(((UniquePersonList) other).internalList)); | |||
} | |||
|
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.
Need to remove this
/** | ||
* Class to generate typical test persons | ||
*/ | ||
public class TypicalPersons { |
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.
We did some tweaks to Typical persons in level 4 (see this)
Let's follow the same here.
/** | ||
* Factory class for building TestPerson | ||
*/ | ||
public class PersonBuilder { |
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.
I think we can do without a PersonBuilder. Level 2 a bit too early to do this kind of thing. Sorry I didn't think about it earlier.
String[] keywordsWithMatchingCase = {"Amy"}; | ||
|
||
assertFindCommandBehavior(keywordsWithMatchingCase, expected, addressBook); | ||
} |
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.
Can be made even more concise:
public void execute() throws exception {
//same word, same case: matched
assertFindCommandBehavior( {"Amy"}, TypicalPersons.amy());
//same word, different case: not matched
assertFindCommandBehavior( {"amy"});
...
}
private void assertFindCommandBehavior(String[] keywords, Person... expectedPersons){
...
}
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.
Or even this (slightly better):
public void execute() throws exception {
//same word, same case: matched
assertFindCommandBehavior( {"Amy"}, {TypicalPersons.amy()});
//same word, different case: not matched
assertFindCommandBehavior( {"amy"}, {});
...
}
private void assertFindCommandBehavior(String[] keywords, Person[] expectedPersons){
...
}
Ready for review |
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.
A few more minor comments added. Nearly there 👍
assertFindCommandBehavior(new String[]{"my"}, EMPTY_LIST); | ||
|
||
//multiple words: matched | ||
assertFindCommandBehavior(new String[]{"Amy", "Bill", "Destiny"}, TestUtil.createList(td.amy, td.bill, td.candy)); |
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.
You have a case of matching first name only, and second name only. How about a case of matching both names? i.e. "Amy", "Bill", "Candy", "Destiny"
assertFindCommandBehavior(new String[]{"Amy", "Bill", "Destiny"}, TestUtil.createList(td.amy, td.bill, td.candy)); | ||
} | ||
|
||
|
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.
Extra blank line
|
||
|
||
/** | ||
* Executes the find command, and checks that the execution was what we had expected. |
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.
Can be more specific. e.g. Executes the find command for the given keywords and verifies the result matches the persons in the expectedPersonList exactly
|
||
//multiple words: matched | ||
assertFindCommandBehavior(new String[]{"Amy", "Bill", "Destiny"}, TestUtil.createList(td.amy, td.bill, td.candy)); | ||
} |
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.
Other interesting cases to test:
- Repeated keyword
- Keyword matching a word in address
|
||
/** | ||
* Test class for the Find Command | ||
*/ |
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.
This header comment doesn't add any value. Can be removed.
Reviewed 1 of 15 files at r1, 4 of 14 files at r2, 1 of 5 files at r4, 3 of 4 files at r9. Comments from Reviewable |
… FindCommandTest to asserCommandBehavior method
Ready for review! |
Reviewed 2 of 2 files at r11. src/seedu/addressbook/data/tag/UniqueTagList.java, line 169 at r2 (raw file):
Why was this line deleted? Usually we leave a blank line (or two) between last method and the closing brace of the class. Comments from Reviewable |
@pyokagan any further inputs? |
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.
Please fix these style errors as well:
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/src/seedu/addressbook/data/AddressBook.java:146: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/src/seedu/addressbook/data/tag/UniqueTagList.java:162: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:24: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [WARN] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:25:40: Name 'EMPTY_LIST' must match pattern '^[a-z][a-zA-Z0-9]*$'. [MemberName]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:27: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:37: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:40: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:43: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:45: Line is longer than 120 characters (found 131). [LineLength]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:46: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:49: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:55: Line is longer than 120 characters (found 134). [LineLength]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/commands/FindCommandTest.java:60: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:18: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:21: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:23: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:25: Line is longer than 120 characters (found 123). [LineLength]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:25: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:31: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:32: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:34: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:35: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:42: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:44: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
[ant:checkstyle] [ERROR] /home/pyokagan/pyk/addressbook-level2/test/java/seedu/addressbook/util/TypicalPersons.java:48: Line matches the illegal pattern 'Trailing whitespace'. [Regexp]
private AddressBook addressBook; | ||
private TypicalPersons td; | ||
|
||
private final List<ReadOnlyPerson> EMPTY_LIST = Collections.emptyList(); |
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.
Naming doesn't add a lot of value. I think you can just inline Collections.emptyList()
directly.
@Test | ||
public void execute() throws IllegalValueException { | ||
//same word, same case: matched | ||
assertFindCommandBehavior(new String[]{"Amy"}, TestUtil.createList(td.amy)); |
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.
Use Arrays.asList()
instead? I'm not sure why TestUtil.createList()
exists, actually. @yamgent ?
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.
createList()
is redundant, my bad.
(I was under the impression that Arrays.asList()
was returning List<Person>
instead of List<ReadOnlyPerson>
, because my parameters were all Person
s. Looks like I was wrong.)
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.
@yamgent create an issue to get rid of the unused method? We can leave it for new contributors.
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.
assert false : "not possible"; | ||
} | ||
|
||
|
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.
Remove these empty lines.
|
||
public TypicalPersons() { | ||
try { | ||
amy = new Person(new Name("Amy Buck"), new Phone("91119111", false), new Email("ab@gmail.com", false), |
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.
One space between the =
only.
public class FindCommandTest { | ||
|
||
private AddressBook addressBook; | ||
private TypicalPersons td; |
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.
Can make these final as well.
Actually, I think you can just assign the fields here and do without the setUp()
method (JUnit constructs a new instance for every test).
Ready for review! |
@KnewYouWereTrouble Just fix these problems below. Configure your IDE to automatically trim trailing whitespace so you won't have this problem any more. Everything else looks good.
|
Ready for review! |
Fixes #110
Ready for review.
This change is