ProjectDAO { public List<Project> getAll(User user) { List<Project> projects = projectRepository.findAllByUser_Id(user.getId()); projects.forEach(this::loadLazyRelations); return projects; } @Autowired  ProjectDAO(ProjectRepository projectRepository,
                      LearnerResultRepository learnerResultRepository,
                      TestReportRepository testReportRepository,
                      @Lazy FileDAO fileDAO,
                      ParameterizedSymbolRepository parameterizedSymbolRepository,
                      SymbolStepRepository symbolStepRepository,
                      SymbolActionRepository symbolActionRepository,
                      @Lazy ProjectEnvironmentDAO projectEnvironmentDAO,
                      ProjectUrlRepository projectUrlRepository,
                      TestExecutionConfigRepository testExecutionConfigRepository,
                      @Lazy TestDAO testDAO,
                      @Lazy UserDAO userDAO,
                      ProjectEnvironmentRepository environmentRepository,
                      @Lazy SymbolGroupDAO symbolGroupDAO,
                      TestRepository testRepository,
                      SymbolParameterRepository symbolParameterRepository,
                      UploadableFileRepository uploadableFileRepository,
                      LearnerSetupRepository learnerSetupRepository); Project create(final User user, final CreateProjectForm projectForm); List<Project> getAll(User user); Project getByID(User user, Long projectId); Project update(User user, Long projectId, Project project); void delete(User user, Long projectId); void delete(User user, List<Long> projectIds); Project importProject(User user, ProjectExportableEntity projectExportableEntity); void checkAccess(User user, Project project); Project addOwners(User user, Long projectId, List<Long> ownerIds); Project addMembers(User user, Long projectId, List<Long> memberIds); Project removeOwners(User user, Long projectId, List<Long> ownerIds); Project removeMembers(User user, Long projectId, List<Long> memberIds);  }
@Test public void shouldGetAllProjectsOfAnUser() { User user = new User(); user.setId(USER_ID); List<Project> projects = createProjectList(); given(projectRepository.findAllByUser_Id(USER_ID)).willReturn(projects); List<Project> allProjects = projectDAO.getAll(user); MatcherAssert.assertThat(allProjects.size(), is(equalTo(projects.size()))); for (Project p : allProjects) { assertTrue(projects.contains(p)); } }