如何为界面对象创建和声明编写mockIto测试用例

时间:2016-07-24 16:07:16

标签: mockito

我的方法如下:

@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方法的返回值。这该怎么做?请帮忙。

0 个答案:

没有答案