I have the following test:
@Test
void verifyCorrectLimitForGroups() throws SQLException {
AbstractDAO<StudentModel, Long> studentsDAO = new StudentDAO(myDatasource);
List<StudentModel> students = studentsDAO.findAll();
for(int a=1;a<11;a++) {
assertTrue(students.stream().filter(i->i.getGroupID()==a).count()<30);
}
}
My goal is to test if the limit of 30 for students with groupIDs
from 1 to 10 was never exceeded. For this purpose, I decided to use java 8 API streams and a simple for loop. Unfortunately, I get a compilation problem: Local variable a defined in an enclosing scope must be final or effectively final.
Does it mean I can not do it in this way and I should find a different approach?