示例#1
0
 private Question createMockQuestion(long id) {
   Question question = new Question();
   question.setId(id);
   question.setDescription("xxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyy yyyyyyyy ssssssssss");
   question.setShortName("How is this unit test?");
   question.setAnswers(createAnswers());
   question.setForm(createMockQuestionForm(1l, 2));
   return question;
 }
示例#2
0
 @Test
 public void test_question_setAnswers() {
   // GIVEN
   Question q = new Question();
   List<Answer> lAns = new ArrayList<Answer>();
   // WHEN
   q.setAnswers(lAns);
   // THEN
   assertEquals(q.getAnswers(), lAns);
 }
 @Test
 public void test() {
   final List<Answer> ANSWERS = new ArrayList<>();
   final String CODE = "CODE";
   final String TEXT = "TEXT";
   Question question = new Question(CODE);
   question.setAnswers(ANSWERS);
   question.setText(TEXT);
   assertTrue(
       "Question not working",
       CODE.equals(question.getCode())
           && TEXT.equals(question.getText())
           && ANSWERS.equals(question.getAnswers()));
 }
  private Assessment createAssessment(Group g, int questionCount, int reinforcementCount) {
    Assessment a = new Assessment();
    a.setGroup(g);

    List<AssessmentMessage> messages = new ArrayList<AssessmentMessage>();
    for (int i = 0; i < Math.max(questionCount, reinforcementCount); ++i) {
      if (i < questionCount) {
        Question q = new Question();
        q.setAnswers(new String[3]);
        questionDao.save(q);
        messages.add(new AssessmentMessage(q));
      }
      if (i < reinforcementCount) {
        Reinforcement r = new Reinforcement();
        reinforcementDao.save(r);
        messages.add(new AssessmentMessage(r));
      }
    }
    a.setMessages(messages);

    assessmentDao.save(a);

    return a;
  }