I am trying to write unit tests for a class that returns a lamda of Specification object. I'm unable to get the line coverage using Mockito and 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();
}
}
}
when running the class under test the compiler exits with out checking anything.
Not sure how to mock the objects of ClassesForFall, criteriaBuilder, criteriaQuery