@Test public void getExercisesReturnsValidObjectOnSuccesfullHttpRequest() throws Exception { ExerciseList el = buildMockExerciseList(); String mockJson = gson.toJson(el); when(rb.getForText(any(String.class))).thenReturn(mockJson); List<Exercise> returned = server.getExercises("11"); for (Exercise orig : el.getExercises()) { boolean found = false; for (Exercise ret : returned) { if (ret.getName().equals(orig.getName())) { found = true; } } assertTrue("The returned list of exercises should contain all exercises of the original list", found); } }
public List<Exercise> getExercises(String courseId) { String url = connectionBuilder.getUrl(UrlExtension.EXERCISES.getExtension(courseId)); String bodyText = getString(url); ExerciseList el = mapper.fromJson(bodyText, ExerciseList.class); List<Exercise> exercises = el.getExercises(); for (Exercise e : exercises) { e.finalizeDeserialization(); } return exercises; }
ServerManager { public List<Exercise> getExercises(String courseId) { String url = connectionBuilder.getUrl(UrlExtension.EXERCISES.getExtension(courseId)); String bodyText = getString(url); ExerciseList el = mapper.fromJson(bodyText, ExerciseList.class); List<Exercise> exercises = el.getExercises(); for (Exercise e : exercises) { e.finalizeDeserialization(); } return exercises; } }
ServerManager { public List<Exercise> getExercises(String courseId) { String url = connectionBuilder.getUrl(UrlExtension.EXERCISES.getExtension(courseId)); String bodyText = getString(url); ExerciseList el = mapper.fromJson(bodyText, ExerciseList.class); List<Exercise> exercises = el.getExercises(); for (Exercise e : exercises) { e.finalizeDeserialization(); } return exercises; } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); }
ServerManager { public List<Exercise> getExercises(String courseId) { String url = connectionBuilder.getUrl(UrlExtension.EXERCISES.getExtension(courseId)); String bodyText = getString(url); ExerciseList el = mapper.fromJson(bodyText, ExerciseList.class); List<Exercise> exercises = el.getExercises(); for (Exercise e : exercises) { e.finalizeDeserialization(); } return exercises; } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); List<Course> getCourses(); List<Exercise> getExercises(String courseId); ZippedProject getExerciseZip(String zipUrl); SubmissionResponse uploadFile(Exercise exercise, byte[] data); SubmissionResponse uploadFile(Exercise exercise, byte[] data, Map<String, String> extraParams); SubmissionResult getSubmissionResult(URI resultURI); String submitFeedback(String answerUrl, List<FeedbackAnswer> answers); void sendEventLogs(String url, List<LoggableEvent> events); List<Review> downloadReviews(Course course); boolean markReviewAsRead(Review review); }
ServerManager { public List<Exercise> getExercises(String courseId) { String url = connectionBuilder.getUrl(UrlExtension.EXERCISES.getExtension(courseId)); String bodyText = getString(url); ExerciseList el = mapper.fromJson(bodyText, ExerciseList.class); List<Exercise> exercises = el.getExercises(); for (Exercise e : exercises) { e.finalizeDeserialization(); } return exercises; } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); List<Course> getCourses(); List<Exercise> getExercises(String courseId); ZippedProject getExerciseZip(String zipUrl); SubmissionResponse uploadFile(Exercise exercise, byte[] data); SubmissionResponse uploadFile(Exercise exercise, byte[] data, Map<String, String> extraParams); SubmissionResult getSubmissionResult(URI resultURI); String submitFeedback(String answerUrl, List<FeedbackAnswer> answers); void sendEventLogs(String url, List<LoggableEvent> events); List<Review> downloadReviews(Course course); boolean markReviewAsRead(Review review);  }