@Test public void testUpdateExercisesCallsCourseAndServer() { Course course = mock(Course.class); when(course.getId()).thenReturn(1); when(course.getExercises()).thenReturn(new ArrayList<Exercise>()); updater.updateExercises(course); verify(server, times(1)).getExercises("1"); verify(course, times(1)).getExercises(); }
public void updateExercises(Course course) { if (course == null) { throw new UserVisibleException("Remember to select your course from TMC -> Settings"); } List<Exercise> oldExercises = course.getExercises(); List<Exercise> newExercises = server.getExercises(course.getId() + ""); for (Exercise newExercise : newExercises) { Exercise oldExercise = findEqualExercise(oldExercises, newExercise); if (oldExercise != null) { updateExercise(oldExercise, newExercise); } } course.setExercises(newExercises); }
Updater { public void updateExercises(Course course) { if (course == null) { throw new UserVisibleException("Remember to select your course from TMC -> Settings"); } List<Exercise> oldExercises = course.getExercises(); List<Exercise> newExercises = server.getExercises(course.getId() + ""); for (Exercise newExercise : newExercises) { Exercise oldExercise = findEqualExercise(oldExercises, newExercise); if (oldExercise != null) { updateExercise(oldExercise, newExercise); } } course.setExercises(newExercises); } }
Updater { public void updateExercises(Course course) { if (course == null) { throw new UserVisibleException("Remember to select your course from TMC -> Settings"); } List<Exercise> oldExercises = course.getExercises(); List<Exercise> newExercises = server.getExercises(course.getId() + ""); for (Exercise newExercise : newExercises) { Exercise oldExercise = findEqualExercise(oldExercises, newExercise); if (oldExercise != null) { updateExercise(oldExercise, newExercise); } } course.setExercises(newExercises); } Updater(ServerManager server, CourseDAO courseDAO, ProjectDAO projectDAO); }
Updater { public void updateExercises(Course course) { if (course == null) { throw new UserVisibleException("Remember to select your course from TMC -> Settings"); } List<Exercise> oldExercises = course.getExercises(); List<Exercise> newExercises = server.getExercises(course.getId() + ""); for (Exercise newExercise : newExercises) { Exercise oldExercise = findEqualExercise(oldExercises, newExercise); if (oldExercise != null) { updateExercise(oldExercise, newExercise); } } course.setExercises(newExercises); } Updater(ServerManager server, CourseDAO courseDAO, ProjectDAO projectDAO); void updateCourses(); void updateExercises(Course course); }
Updater { public void updateExercises(Course course) { if (course == null) { throw new UserVisibleException("Remember to select your course from TMC -> Settings"); } List<Exercise> oldExercises = course.getExercises(); List<Exercise> newExercises = server.getExercises(course.getId() + ""); for (Exercise newExercise : newExercises) { Exercise oldExercise = findEqualExercise(oldExercises, newExercise); if (oldExercise != null) { updateExercise(oldExercise, newExercise); } } course.setExercises(newExercises); } Updater(ServerManager server, CourseDAO courseDAO, ProjectDAO projectDAO); void updateCourses(); void updateExercises(Course course);  }