服务类中的方法:
@Override
@Transactional(readOnly = true)
public Collection<Account> searchAccounts(String partOfName) {
Collection<Account> accounts = accountDao.getAll();
CollectionUtils.filter(accounts, account ->
account.getName().toLowerCase().contains(partOfName.toLowerCase()) ||
account.getSurname().toLowerCase().equalsIgnoreCase(partOfName.toLowerCase()));
return accounts;
}
我不明白我必须对 CollectionUtils.filter 做什么。也嘲笑这个?现在我在测试课上有这个:
@Test
public void searchAccountsByPartOfName() {
service.searchAccounts("test");
verify(accountDao, times(1)).getAll();
}
ABOUTYOU
九州编程
相关分类