springjpa规范api单元测试

xggvc2p6  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(269)

我试图为一个返回lamda规范对象的类编写单元测试。我无法使用mockito和junit5获得线路覆盖率

final class StudentRecordsSpecification{
public static Specification<ClassesForFall> findByStudentRegisteredforClasses(Student student){
    return(fallClasses, criteriaQuery, criteriaBuilder) ->{
         List<Predicate> sqlCriteria = new ArrayList<>();
         sqlCriteria.add(criteriaBuilder.equal(fallClasses.get("profile"), student.getProfile()));
         if (!student.getSubjectTeachers().isEmpty()) {
            student
              .getSubjectTeachers()
              .forEach(
                (subject, teacher) ->
                sqlCriteria.add(criteriaBuilder.equal(fallClasses.get(subject), teacher)));
        }
         criteriaQuery.where(criteriaBuilder.and(sqlCriteria.toArray(new Predicate[] {})));
      return criteriaQuery.getRestriction();
    }
  }
}

当运行被测试的类时,编译器退出而不检查任何内容。不知道如何模仿 ClassesForFall , criteriaBuilder , criteriaQuery

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题