@Test(expected = NotFoundException.class) public void ensureThatGettingANonExistingResultThrowsAnException() throws NotFoundException { User user = new User(); given(learnerResultRepository.findOneByProject_IdAndTestNo(PROJECT_ID, 0L)) .willReturn(null); learnerResultDAO.get(user, PROJECT_ID, 0L); }
public LearnerResult get(User user, Long projectId, Long testNo) throws NotFoundException { final Project project = projectDAO.getByID(user, projectId); final LearnerResult result = learnerResultRepository.findOneByProject_IdAndTestNo(projectId, testNo); checkAccess(user, project, result); initializeLazyRelations(result); return result; }
LearnerResultDAO { public LearnerResult get(User user, Long projectId, Long testNo) throws NotFoundException { final Project project = projectDAO.getByID(user, projectId); final LearnerResult result = learnerResultRepository.findOneByProject_IdAndTestNo(projectId, testNo); checkAccess(user, project, result); initializeLazyRelations(result); return result; } }
LearnerResultDAO { public LearnerResult get(User user, Long projectId, Long testNo) throws NotFoundException { final Project project = projectDAO.getByID(user, projectId); final LearnerResult result = learnerResultRepository.findOneByProject_IdAndTestNo(projectId, testNo); checkAccess(user, project, result); initializeLazyRelations(result); return result; } @Autowired  LearnerResultDAO(ProjectDAO projectDAO, LearnerResultRepository learnerResultRepository,
                            LearnerResultStepRepository learnerResultStepRepository, EntityManager entityManager,
                            LearnerSetupDAO learnerSetupDAO); }
LearnerResultDAO { public LearnerResult get(User user, Long projectId, Long testNo) throws NotFoundException { final Project project = projectDAO.getByID(user, projectId); final LearnerResult result = learnerResultRepository.findOneByProject_IdAndTestNo(projectId, testNo); checkAccess(user, project, result); initializeLazyRelations(result); return result; } @Autowired  LearnerResultDAO(ProjectDAO projectDAO, LearnerResultRepository learnerResultRepository,
                            LearnerResultStepRepository learnerResultStepRepository, EntityManager entityManager,
                            LearnerSetupDAO learnerSetupDAO); LearnerResult create(User user, Project project, LearnerResult learnerResult); List<LearnerResult> getAll(User user, Long projectId); List<LearnerResult> getAll(User user, Long projectId, List<Long> testNos); Page<LearnerResult> getAll(User user, Long projectId, PageRequest pr); LearnerResult getLatest(User user, Long projectId); LearnerResult get(User user, Long projectId, Long testNo); LearnerResultStep createStep(LearnerResult result); LearnerResult copy(User user, Long projectId, Long testNo); LearnerResultStep createStep(LearnerResult result, LearnerResultStep step); LearnerResultStep updateStep(LearnerResultStep step); void deleteAll(User user, Long projectId, List<Long> testNos); void initializeLazyRelations(LearnerResult result); void checkAccess(User user, Project project, LearnerResult learnerResult); }
LearnerResultDAO { public LearnerResult get(User user, Long projectId, Long testNo) throws NotFoundException { final Project project = projectDAO.getByID(user, projectId); final LearnerResult result = learnerResultRepository.findOneByProject_IdAndTestNo(projectId, testNo); checkAccess(user, project, result); initializeLazyRelations(result); return result; } @Autowired  LearnerResultDAO(ProjectDAO projectDAO, LearnerResultRepository learnerResultRepository,
                            LearnerResultStepRepository learnerResultStepRepository, EntityManager entityManager,
                            LearnerSetupDAO learnerSetupDAO); LearnerResult create(User user, Project project, LearnerResult learnerResult); List<LearnerResult> getAll(User user, Long projectId); List<LearnerResult> getAll(User user, Long projectId, List<Long> testNos); Page<LearnerResult> getAll(User user, Long projectId, PageRequest pr); LearnerResult getLatest(User user, Long projectId); LearnerResult get(User user, Long projectId, Long testNo); LearnerResultStep createStep(LearnerResult result); LearnerResult copy(User user, Long projectId, Long testNo); LearnerResultStep createStep(LearnerResult result, LearnerResultStep step); LearnerResultStep updateStep(LearnerResultStep step); void deleteAll(User user, Long projectId, List<Long> testNos); void initializeLazyRelations(LearnerResult result); void checkAccess(User user, Project project, LearnerResult learnerResult);  }