@Test(expected = ObsoleteClientException.class) public void submitFeedbackThrowsObsoleteClientExceptionWhenStatusCodeIs404AndIsObsolete() throws Exception { FailedHttpResponseException exception = mock(FailedHttpResponseException.class); when(exception.getStatusCode()).thenReturn(404); when(exception.getEntityAsString()).thenReturn("{obsolete_client:true}"); when(rb.postForText(Mockito.anyString(), anyMap())).thenThrow(exception); server.submitFeedback("url", new ArrayList<FeedbackAnswer>()); }
public String submitFeedback(String answerUrl, List<FeedbackAnswer> answers) { final String submitUrl = connectionBuilder.addApiCallQueryParameters(answerUrl); Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < answers.size(); ++i) { String keyPrefix = "answers[" + i + "]"; FeedbackAnswer answer = answers.get(i); params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId()); params.put(keyPrefix + "[answer]", answer.getAnswer()); } try { return connectionBuilder.createConnection().postForText(submitUrl, params); } catch (FailedHttpResponseException e) { return checkForObsoleteClient(e); } catch (Exception e) { throw new RuntimeException("An error occured while submitting feedback: " + e.getMessage()); } }
ServerManager { public String submitFeedback(String answerUrl, List<FeedbackAnswer> answers) { final String submitUrl = connectionBuilder.addApiCallQueryParameters(answerUrl); Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < answers.size(); ++i) { String keyPrefix = "answers[" + i + "]"; FeedbackAnswer answer = answers.get(i); params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId()); params.put(keyPrefix + "[answer]", answer.getAnswer()); } try { return connectionBuilder.createConnection().postForText(submitUrl, params); } catch (FailedHttpResponseException e) { return checkForObsoleteClient(e); } catch (Exception e) { throw new RuntimeException("An error occured while submitting feedback: " + e.getMessage()); } } }
ServerManager { public String submitFeedback(String answerUrl, List<FeedbackAnswer> answers) { final String submitUrl = connectionBuilder.addApiCallQueryParameters(answerUrl); Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < answers.size(); ++i) { String keyPrefix = "answers[" + i + "]"; FeedbackAnswer answer = answers.get(i); params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId()); params.put(keyPrefix + "[answer]", answer.getAnswer()); } try { return connectionBuilder.createConnection().postForText(submitUrl, params); } catch (FailedHttpResponseException e) { return checkForObsoleteClient(e); } catch (Exception e) { throw new RuntimeException("An error occured while submitting feedback: " + e.getMessage()); } } ServerManager(Gson mapper, ConnectionBuilder connectionBuilder, Settings settings);  ServerManager(Settings settings); }
ServerManager { public String submitFeedback(String answerUrl, List<FeedbackAnswer> answers) { final String submitUrl = connectionBuilder.addApiCallQueryParameters(answerUrl); Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < answers.size(); ++i) { String keyPrefix = "answers[" + i + "]"; FeedbackAnswer answer = answers.get(i); params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId()); params.put(keyPrefix + "[answer]", answer.getAnswer()); } try { return connectionBuilder.createConnection().postForText(submitUrl, params); } catch (FailedHttpResponseException e) { return checkForObsoleteClient(e); } catch (Exception e) { throw new RuntimeException("An error occured while submitting feedback: " + e.getMessage()); } } 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 String submitFeedback(String answerUrl, List<FeedbackAnswer> answers) { final String submitUrl = connectionBuilder.addApiCallQueryParameters(answerUrl); Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < answers.size(); ++i) { String keyPrefix = "answers[" + i + "]"; FeedbackAnswer answer = answers.get(i); params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId()); params.put(keyPrefix + "[answer]", answer.getAnswer()); } try { return connectionBuilder.createConnection().postForText(submitUrl, params); } catch (FailedHttpResponseException e) { return checkForObsoleteClient(e); } catch (Exception e) { throw new RuntimeException("An error occured while submitting feedback: " + e.getMessage()); } } 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);  }