@Test public void getCoursesReturnsValidCoursesOnSuccefullHttpRequest() throws Exception { CourseList cl = buildMockCourseList(); String mockJson = gson.toJson(cl); when(rb.getForText(any(String.class))).thenReturn(mockJson); List<Course> returnedCourses = server.getCourses(); for (int i = 1; i < cl.getCourses().length; i++) { Course c = cl.getCourses()[i]; boolean found = false; for (Course returned : returnedCourses) { if (returned.getName().equals(c.getName())) { found = true; } } assertTrue("Didn't find all courses that should have been present, based on the JSON", found); } assertEquals(cl.getCourses().length, returnedCourses.size()); assertEquals("7", cl.getApiVersion()); }
public List<Course> getCourses() { String url = connectionBuilder.getUrl(UrlExtension.COURSES.getExtension()); String bodyText = getString(url); CourseList cl = mapper.fromJson(bodyText, CourseList.class); if (cl == null) { return new ArrayList<Course>(); } return Arrays.asList(cl.getCourses()); }
ServerManager { public List<Course> getCourses() { String url = connectionBuilder.getUrl(UrlExtension.COURSES.getExtension()); String bodyText = getString(url); CourseList cl = mapper.fromJson(bodyText, CourseList.class); if (cl == null) { return new ArrayList<Course>(); } return Arrays.asList(cl.getCourses()); } }
ServerManager { public List<Course> getCourses() { String url = connectionBuilder.getUrl(UrlExtension.COURSES.getExtension()); String bodyText = getString(url); CourseList cl = mapper.fromJson(bodyText, CourseList.class); if (cl == null) { return new ArrayList<Course>(); } return Arrays.asList(cl.getCourses()); } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); }
ServerManager { public List<Course> getCourses() { String url = connectionBuilder.getUrl(UrlExtension.COURSES.getExtension()); String bodyText = getString(url); CourseList cl = mapper.fromJson(bodyText, CourseList.class); if (cl == null) { return new ArrayList<Course>(); } return Arrays.asList(cl.getCourses()); } 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<Course> getCourses() { String url = connectionBuilder.getUrl(UrlExtension.COURSES.getExtension()); String bodyText = getString(url); CourseList cl = mapper.fromJson(bodyText, CourseList.class); if (cl == null) { return new ArrayList<Course>(); } return Arrays.asList(cl.getCourses()); } 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);  }