/** * Load all questions. * * @return List of {@link QuestionBean} * @throws EnMeExpcetion exception */ public List<QuestionBean> loadAllQuestions() throws EnMeExpcetion { final List<QuestionBean> listQuestionBean = new LinkedList<QuestionBean>(); try { final List<Question> questionsList = getQuestionDao().loadAllQuestions(); if (questionsList.size() > 0) { for (Question questions : questionsList) { final QuestionBean q = new QuestionBean(); q.setId(Long.valueOf(questions.getQid().toString())); q.setQuestionName(questions.getQuestion()); listQuestionBean.add(q); } } } catch (HibernateException e) { throw new EnMeExpcetion(e); } catch (Exception e) { throw new EnMeExpcetion(e); } return listQuestionBean; }
/** Test create question. */ @Test public void testCreateQuestion() { final Question question = createQuestion("Why encuestame is better than polldady?", this.user); final Question retrieveQuestion = getQuestionDaoImp().retrieveQuestionById(question.getQid()); assertEquals("Questions should be equals", question.getQid(), retrieveQuestion.getQid()); }