PostRepository extends AbstractRepository<Post, Long> { public List<Post> findByKeyword(String keyword) { return stream().filter(p -> p.getTitle().contains(keyword) || p.getContent().contains(keyword)) .collect(toList()); }  List<Post> findByKeyword(String keyword); long countByKeyword(String keyword);  }
@Test public void testFindByKeyword() { List<Post> foundPosts = posts.findByKeyword("test"); assertEquals(1, foundPosts.size()); }
@Test public void testFindByKeywordNotFound() { List<Post> foundPosts = posts.findByKeyword("test123"); assertEquals(0, foundPosts.size()); }