Source:
public void testValueOf_textQuestions_shouldDeserializeCorrectly() throws InvalidParametersException { ______TS("legacy data: plain text: single word, should deserialize correctly"); FeedbackQuestion qn = new FeedbackQuestion("session", "course", "singleWord", "description", 1, FeedbackQuestionType.TEXT, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.STUDENTS, Const.MAX_POSSIBLE_RECIPIENTS, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); qn.setFeedbackQuestionId(1L); FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(qn); assertEquals("singleWord", fqa.questionDetails.getQuestionText()); assertEquals(null, ((FeedbackTextQuestionDetails) fqa.questionDetails).getRecommendedLength()); ______TS("legacy data: plain text: multiple words, should deserialize correctly"); qn.setQuestionText("multiple words text"); FeedbackQuestionAttributes fqaMulti = FeedbackQuestionAttributes.valueOf(qn); assertEquals("multiple words text", fqaMulti.questionDetails.getQuestionText()); assertEquals(null, ((FeedbackTextQuestionDetails) fqaMulti.questionDetails).getRecommendedLength()); ______TS("json text: should deserialize as json"); String jsonQuestionText = "{\n" + " \"recommendedLength\": 70,\n" + " \"questionType\": \"TEXT\",\n" + " \"questionText\": \"normal question\"\n" + "}"; qn.setQuestionText(jsonQuestionText); FeedbackQuestionAttributes fqaJson = FeedbackQuestionAttributes.valueOf(qn); assertEquals("normal question", fqaJson.questionDetails.getQuestionText()); assertEquals(70, ((FeedbackTextQuestionDetails) fqaJson.questionDetails).getRecommendedLength().intValue()); }

Target:
public void testValueOf_textQuestions_shouldDeserializeCorrectly() throws InvalidParametersException { ______TS("legacy data: plain text: single word, should deserialize correctly"); FeedbackQuestion qn = new FeedbackQuestion("session", "course", "singleWord", "description", 1, FeedbackQuestionType.TEXT, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.STUDENTS, Const.MAX_POSSIBLE_RECIPIENTS, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); qn.setFeedbackQuestionId(1L); FeedbackQuestionAttributes fqa = FeedbackQuestionAttributes.valueOf(qn); assertEquals("singleWord", fqa.questionDetails.getQuestionText()); assertNull(((FeedbackTextQuestionDetails) fqa.questionDetails).getRecommendedLength()); ______TS("legacy data: plain text: multiple words, should deserialize correctly"); qn.setQuestionText("multiple words text"); FeedbackQuestionAttributes fqaMulti = FeedbackQuestionAttributes.valueOf(qn); assertEquals("multiple words text", fqaMulti.questionDetails.getQuestionText()); assertNull(((FeedbackTextQuestionDetails) fqaMulti.questionDetails).getRecommendedLength()); ______TS("json text: should deserialize as json"); String jsonQuestionText = "{\n" + " \"recommendedLength\": 70,\n" + " \"questionType\": \"TEXT\",\n" + " \"questionText\": \"normal question\"\n" + "}"; qn.setQuestionText(jsonQuestionText); FeedbackQuestionAttributes fqaJson = FeedbackQuestionAttributes.valueOf(qn); assertEquals("normal question", fqaJson.questionDetails.getQuestionText()); assertEquals(70, ((FeedbackTextQuestionDetails) fqaJson.questionDetails).getRecommendedLength().intValue()); }