@Test public void testByUserId() throws Exception { // get students table IDataSet databaseDataSet = getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("STUDENT"); // tacking student id with user id = 3 long studentId = (Long) actualTable.getValue(2, "id"); // get student by tested method and check result while (studentDaoImpl.findByUserId(3) == null) {} Student student = studentDaoImpl.findByUserId(3); Assert.assertEquals(studentId, student.getId()); }
// STUDENT CONTROLLER CALL @Override public List<CourseDTO> allCoursesInDateRange4Student(Principal user, Date from, Date till) { // take courses form schedule // add to DTO base info long userId = Long.parseLong(user.getName()); Student student = studentDao.findByUserId(userId); List<Group> additionalGroups = student.getAdditionGroups(); Group mainGroup = student.getGroup(); List<Group> allGroups = new ArrayList<Group>(); allGroups.add(mainGroup); allGroups.addAll(additionalGroups); List<Course> allCoursesFromAllGroups = new ArrayList<Course>(); for (Group group : allGroups) { allCoursesFromAllGroups.addAll(getCourseForGroup(group, from, till)); } return fillCourseDTO(allCoursesFromAllGroups, from, till); }