Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jessica2828 committed Oct 16, 2024
1 parent abfd797 commit 61e1760
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,29 @@ public void equals() {

@Test
public void test_courseContainsKeywords_returnsTrue() {
// One keyword
CourseContainsKeywordsPredicate predicate =
new CourseContainsKeywordsPredicate(Collections.singletonList("Computer Science"));
assertTrue(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Multiple keywords
predicate = new CourseContainsKeywordsPredicate(Arrays.asList("Computer", "Science"));
assertTrue(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Partial match (course starts with keyword)
predicate = new CourseContainsKeywordsPredicate(Collections.singletonList("Com"));
assertTrue(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Mixed-case keywords
predicate = new CourseContainsKeywordsPredicate(Arrays.asList("cOmPuTer", "sCiEnCe"));
assertTrue(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));
}

@Test
public void test_courseDoesNotContainKeywords_returnsFalse() {
// Zero keywords
CourseContainsKeywordsPredicate predicate =
new CourseContainsKeywordsPredicate(Collections.emptyList());
assertFalse(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Non-matching keyword
predicate = new CourseContainsKeywordsPredicate(Arrays.asList("Data"));
assertFalse(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Keywords match name, but do not match course
predicate = new CourseContainsKeywordsPredicate(Arrays.asList("Alice"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withCourse("Computer Science").build()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,27 @@ public void equals() {

@Test
public void test_nameContainsKeywords_returnsTrue() {
// One keyword
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.singletonList("Alice"));
assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));

// Multiple keywords
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob"));
assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));

// Only one matching keyword
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Bob", "Carol"));
assertTrue(predicate.test(new PersonBuilder().withName("Alice Carol").build()));

// Mixed-case keywords
predicate = new NameContainsKeywordsPredicate(Arrays.asList("aLIce", "bOB"));
assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));
}

@Test
public void test_nameDoesNotContainKeywords_returnsFalse() {
// Zero keywords
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.emptyList());
assertFalse(predicate.test(new PersonBuilder().withName("Alice").build()));

// Non-matching keyword
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Carol"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice Bob").build()));

// Keywords match phone, email and address, but does not match name
predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345", "[email protected]", "Main", "Street"));
assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345")
.withEmail("[email protected]").withAddress("Main Street").build()));
Expand Down

0 comments on commit 61e1760

Please sign in to comment.