assertEquals(survey.isActive(), actual.isActive());
assertEquals(survey.isCheckCookie(), actual.isCheckCookie());
assertEquals(survey.isCheckIpAddress(), actual.isCheckIpAddress());
assertEquals(survey.getQuestions().size(), actual.getQuestions().size());
for (Question currentQuestion: survey.getQuestions()) {
Question actualQuestion = actual.getQuestion(currentQuestion.getId());
assertNotNull(actualQuestion);
assertEquals(currentQuestion.getPos(), actualQuestion.getPos());
assertEquals(currentQuestion.isSingleChoice(), actualQuestion.isSingleChoice());
assertEquals(currentQuestion.getMaxResponseNumber(), actualQuestion.getMaxResponseNumber());
assertEquals(currentQuestion.getMinResponseNumber(), actualQuestion.getMinResponseNumber());
assertEquals(currentQuestion.getQuestions(), actualQuestion.getQuestions());
for (Choice currentChoice: currentQuestion.getChoices()) {
Choice actualChoice = actual.getQuestion(currentQuestion.getId()).getChoice(currentChoice.getId());
assertNotNull(actualChoice);
assertEquals(currentChoice.isFreeText(), actualChoice.isFreeText());
assertEquals(currentChoice.getPos(), actualChoice.getPos());
assertEquals(currentChoice.getChoices(), actualChoice.getChoices());
// System.out.println(" QUID "+currentQuestion.getId()+" CID "+currentChoice.getId());
}
}
// test a survey with no choices
this.getSurveyManager().deleteSurvey(survey.getId());
for (Question i: survey.getQuestions()) {
i.setChoices(new ArrayList<Choice>());
}
this.getSurveyManager().saveSurvey(survey);
actual = this.getSurveyManager().loadSurvey(survey.getId());
assertNotNull(actual);
assertEquals(survey.getId(), actual.getId());
assertEquals(survey.getGroupName(), actual.getGroupName());
assertEquals(survey.getImageId(), actual.getImageId());
assertEquals(survey.getDescriptions(), actual.getDescriptions());
assertEquals(survey.getEndDate(), actual.getEndDate());
assertEquals(survey.getImageDescriptions(), actual.getImageDescriptions());
assertEquals(startDate, actual.getStartDate());
assertEquals(survey.getTitles(), actual.getTitles());
assertEquals(survey.isActive(), actual.isActive());
assertEquals(survey.isCheckCookie(), actual.isCheckCookie());
assertEquals(survey.isCheckIpAddress(), actual.isCheckIpAddress());
assertEquals(survey.getQuestions().size(), actual.getQuestions().size());
for (Question currentQuestion: survey.getQuestions()) {
Question actualQuestion = actual.getQuestion(currentQuestion.getId());
assertNotNull(actualQuestion);
assertEquals(currentQuestion.getPos(), actualQuestion.getPos());
assertEquals(currentQuestion.isSingleChoice(), actualQuestion.isSingleChoice());
assertEquals(currentQuestion.getMaxResponseNumber(), actualQuestion.getMaxResponseNumber());
assertEquals(currentQuestion.getMinResponseNumber(), actualQuestion.getMinResponseNumber());
assertEquals(currentQuestion.getQuestions(), actualQuestion.getQuestions());
assertNotNull(currentQuestion.getChoices());
assertEquals(currentQuestion.getChoices().isEmpty(), actualQuestion.getChoices().isEmpty());
// System.out.println(" QUID "+currentQuestion.getId());
}
// test a survey with no questions
this.getSurveyManager().deleteSurvey(survey.getId());
survey.getQuestions().clear();