我的方法如下:
@Transactional
public List<EmployeeBean> getEmployeeList(HashMap<String, String> searchCriteria) {
return employeeDAO.findAll(new Specification<EmployeeBean>() {
@Override
public Predicate toPredicate(Root<EmployeeBean> root, CriteriaQuery<?> criteria, CriteriaBuilder builder) {
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(builder.equal(root.get("company"), userAuthenticationService.getCurrentUserDetails().getCompanyBean()));
Set<Entry<String, String>> searchEntrySet = searchCriteria.entrySet();
for (Entry<String, String> entry : searchEntrySet) {
String value = entry.getValue();
if (StringUtils.isNotEmpty(value)) {
predicates.add(builder.equal(root.get(entry.getKey()), value));
}
}
return builder.and(predicates.toArray(new Predicate[] {}));
}
});
}
现在我想mockIto为这个方法编写测试用例,我想验证覆盖的toPredicate方法的返回值。这该怎么做?请帮忙。