@Test public void toJsonTest() { answer.setAnswer("answer1"); answer.setQuestion(new FeedbackQuestion(1, "question2", "kind2")); assertEquals(answer.toJson(), "{\"question_id\":1,\"answer\":\"answer1\"}"); }
public String toJson() { JsonObject obj = new JsonObject(); obj.addProperty("question_id", question.getId()); obj.addProperty("answer", answer); return new Gson().toJson(obj); }
FeedbackAnswer { public String toJson() { JsonObject obj = new JsonObject(); obj.addProperty("question_id", question.getId()); obj.addProperty("answer", answer); return new Gson().toJson(obj); } }
FeedbackAnswer { public String toJson() { JsonObject obj = new JsonObject(); obj.addProperty("question_id", question.getId()); obj.addProperty("answer", answer); return new Gson().toJson(obj); } FeedbackAnswer(FeedbackQuestion question);  FeedbackAnswer(FeedbackQuestion question, String answer); }
FeedbackAnswer { public String toJson() { JsonObject obj = new JsonObject(); obj.addProperty("question_id", question.getId()); obj.addProperty("answer", answer); return new Gson().toJson(obj); } FeedbackAnswer(FeedbackQuestion question);  FeedbackAnswer(FeedbackQuestion question, String answer); FeedbackQuestion getQuestion(); void setQuestion(FeedbackQuestion question); String getAnswer(); void setAnswer(String answer); String toJson(); }
FeedbackAnswer { public String toJson() { JsonObject obj = new JsonObject(); obj.addProperty("question_id", question.getId()); obj.addProperty("answer", answer); return new Gson().toJson(obj); } FeedbackAnswer(FeedbackQuestion question);  FeedbackAnswer(FeedbackQuestion question, String answer); FeedbackQuestion getQuestion(); void setQuestion(FeedbackQuestion question); String getAnswer(); void setAnswer(String answer); String toJson();  }