forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Harithhh06/branch-find-address
Update FindAddress Command
- Loading branch information
Showing
7 changed files
with
34 additions
and
56 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,6 @@ | |
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.testutil.PersonBuilder; | ||
|
@@ -16,20 +12,20 @@ public class AddressContainsKeywordsPredicateTest { | |
|
||
@Test | ||
public void equals() { | ||
List<String> firstPredicateKeywordList = Collections.singletonList("Tampines"); | ||
List<String> secondPredicateKeywordList = Arrays.asList("Tampines", "Street 1"); | ||
String firstPredicateKeyword = "Tampines"; | ||
String secondPredicateKeywords = "Tampines Street 1"; | ||
|
||
AddressContainsKeywordsPredicate firstPredicate = | ||
new AddressContainsKeywordsPredicate(firstPredicateKeywordList); | ||
new AddressContainsKeywordsPredicate(firstPredicateKeyword); | ||
AddressContainsKeywordsPredicate secondPredicate = | ||
new AddressContainsKeywordsPredicate(secondPredicateKeywordList); | ||
new AddressContainsKeywordsPredicate(secondPredicateKeywords); | ||
|
||
// same object -> returns true | ||
assertTrue(firstPredicate.equals(firstPredicate)); | ||
|
||
// same values -> returns true | ||
AddressContainsKeywordsPredicate firstPredicateCopy = | ||
new AddressContainsKeywordsPredicate(firstPredicateKeywordList); | ||
new AddressContainsKeywordsPredicate(firstPredicateKeyword); | ||
assertTrue(firstPredicate.equals(firstPredicateCopy)); | ||
|
||
// different types -> returns false | ||
|
@@ -45,42 +41,36 @@ public void equals() { | |
@Test | ||
public void test_addressContainsKeywords_returnsTrue() { | ||
// One keyword | ||
AddressContainsKeywordsPredicate predicate = | ||
new AddressContainsKeywordsPredicate(Collections.singletonList("Tampines")); | ||
AddressContainsKeywordsPredicate predicate = new AddressContainsKeywordsPredicate("Tampines"); | ||
assertTrue(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
|
||
// Multiple keywords | ||
predicate = new AddressContainsKeywordsPredicate(Arrays.asList("Tampines", "Street 1")); | ||
assertTrue(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
|
||
// Only one matching keyword | ||
predicate = new AddressContainsKeywordsPredicate(Arrays.asList("Tampines", "Street 2")); | ||
predicate = new AddressContainsKeywordsPredicate("Tampines Street 1"); | ||
assertTrue(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
|
||
// Mixed-case keywords | ||
predicate = new AddressContainsKeywordsPredicate(Arrays.asList("tAmPiNeS", "StReEt 1")); | ||
predicate = new AddressContainsKeywordsPredicate("tAmPiNeS StReEt 1"); | ||
assertTrue(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
} | ||
|
||
@Test | ||
public void test_addressDoesNotContainKeywords_returnsFalse() { | ||
// Zero keywords | ||
AddressContainsKeywordsPredicate predicate = new AddressContainsKeywordsPredicate(Collections.emptyList()); | ||
AddressContainsKeywordsPredicate predicate = new AddressContainsKeywordsPredicate(""); | ||
assertFalse(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
|
||
// Non-matching keyword | ||
predicate = new AddressContainsKeywordsPredicate(Arrays.asList("Jurong")); | ||
predicate = new AddressContainsKeywordsPredicate("Jurong"); | ||
assertFalse(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
|
||
// Keywords match name, phone, and email, but does not match address | ||
predicate = new AddressContainsKeywordsPredicate(Arrays.asList("12345", "[email protected]", "Main")); | ||
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345") | ||
.withEmail("[email protected]").withAddress("Tampines Street 1 #01-01").build())); | ||
// Not all matching keywords | ||
predicate = new AddressContainsKeywordsPredicate("Tampines Street 2"); | ||
assertFalse(predicate.test(new PersonBuilder().withAddress("Tampines Street 1 #01-01").build())); | ||
} | ||
|
||
@Test | ||
public void toStringMethod() { | ||
List<String> keywords = List.of("Tampines", "Street 1"); | ||
String keywords = "Tampines Street 1"; | ||
AddressContainsKeywordsPredicate predicate = new AddressContainsKeywordsPredicate(keywords); | ||
|
||
String expected = AddressContainsKeywordsPredicate.class.getCanonicalName() + "{keywords=" + keywords + "}"; | ||
|