@Test public void downloadReviewsReadCreatesConnection() { Course course = mock(Course.class); when(course.getReviewsUrl()).thenReturn("url"); server.downloadReviews(course); verify(connectionBuilder, times(1)).createConnection(); }
public List<Review> downloadReviews(Course course) { String fullUrl = connectionBuilder.addApiCallQueryParameters(course.getReviewsUrl()); try { String json = connectionBuilder.createConnection().getForText(fullUrl); Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssX").create(); ReviewList reviews = g.fromJson(json, new TypeToken<ReviewList>() { }.getType()); return Arrays.asList(reviews.reviews); } catch (Exception e) { } return null; }
ServerManager { public List<Review> downloadReviews(Course course) { String fullUrl = connectionBuilder.addApiCallQueryParameters(course.getReviewsUrl()); try { String json = connectionBuilder.createConnection().getForText(fullUrl); Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssX").create(); ReviewList reviews = g.fromJson(json, new TypeToken<ReviewList>() { }.getType()); return Arrays.asList(reviews.reviews); } catch (Exception e) { } return null; } }
ServerManager { public List<Review> downloadReviews(Course course) { String fullUrl = connectionBuilder.addApiCallQueryParameters(course.getReviewsUrl()); try { String json = connectionBuilder.createConnection().getForText(fullUrl); Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssX").create(); ReviewList reviews = g.fromJson(json, new TypeToken<ReviewList>() { }.getType()); return Arrays.asList(reviews.reviews); } catch (Exception e) { } return null; } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); }
ServerManager { public List<Review> downloadReviews(Course course) { String fullUrl = connectionBuilder.addApiCallQueryParameters(course.getReviewsUrl()); try { String json = connectionBuilder.createConnection().getForText(fullUrl); Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssX").create(); ReviewList reviews = g.fromJson(json, new TypeToken<ReviewList>() { }.getType()); return Arrays.asList(reviews.reviews); } catch (Exception e) { } return null; } 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<Review> downloadReviews(Course course) { String fullUrl = connectionBuilder.addApiCallQueryParameters(course.getReviewsUrl()); try { String json = connectionBuilder.createConnection().getForText(fullUrl); Gson g = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ssX").create(); ReviewList reviews = g.fromJson(json, new TypeToken<ReviewList>() { }.getType()); return Arrays.asList(reviews.reviews); } catch (Exception e) { } return null; } 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);  }