use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupDefinitionToQuestionGroup.
@Test
public void shouldMapQuestionGroupDefinitionToQuestionGroup() {
when(eventSourceDao.retrieveByEventAndSource(anyString(), anyString())).thenReturn(new ArrayList<EventSourceEntity>());
when(questionDao.getDetails(12)).thenReturn(new QuestionEntity());
EventSourceDto eventSourceDto = getEventSource("Create", "Client");
List<SectionDetail> sectionDetails = asList(getSectionDefinition("S1", 12, TITLE), getSectionDefinition("S2", 0, TITLE));
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(0, TITLE, Arrays.asList(eventSourceDto), sectionDetails, true);
questionGroupDetail.setActive(false);
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
assertQuestionGroup(questionGroup, QuestionGroupState.INACTIVE);
assertThat(questionGroup.isEditable(), is(true));
verify(eventSourceDao, times(1)).retrieveByEventAndSource(anyString(), anyString());
verify(questionDao, times(1)).getDetails(12);
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method getSectionWithOneMultiSelectQuestion.
private Section getSectionWithOneMultiSelectQuestion(int sectionQuestionId, String sectionName, String questionName, String... choices) {
Section section = new Section(sectionName);
List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
SectionQuestion sectionQuestion = new SectionQuestion();
sectionQuestion.setId(sectionQuestionId);
sectionQuestion.setSection(section);
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionText(questionName);
questionEntity.setAnswerType(AnswerType.MULTISELECT);
LinkedList<QuestionChoiceEntity> questionChoiceEntities = new LinkedList<QuestionChoiceEntity>();
for (String choice : choices) {
QuestionChoiceEntity questionChoiceEntity = new QuestionChoiceEntity();
questionChoiceEntity.setChoiceText(choice);
questionChoiceEntities.add(questionChoiceEntity);
}
questionEntity.setChoices(questionChoiceEntities);
sectionQuestion.setQuestion(questionEntity);
sectionQuestions.add(sectionQuestion);
section.setQuestions(sectionQuestions);
return section;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestion.
@Override
public QuestionEntity mapToQuestion(QuestionDetail questionDetail) {
QuestionEntity question = getQuestion(questionDetail);
question.setQuestionId(questionDetail.getId() > 0 ? questionDetail.getId() : 0);
question.setNickname(questionDetail.getNickname());
question.setQuestionText(questionDetail.getText());
question.setAnswerType(mapToAnswerType(questionDetail.getType()));
question.setChoices(mapToChoices(questionDetail.getAnswerChoices()));
question.setQuestionState(QuestionState.getQuestionStateEnum(questionDetail.isActive(), questionDetail.isEditable()));
mapBoundsForNumericQuestionDetail(questionDetail, question);
return question;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireValidatorForDtoTest method getQuestionEntity.
private QuestionEntity getQuestionEntity(String questionTitle, AnswerType answerType, List<QuestionChoiceEntity> choices) {
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionText(questionTitle);
questionEntity.setAnswerType(answerType);
questionEntity.setChoices(choices);
return questionEntity;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionToQuestionDetail.
@Test
public void shouldMapQuestionToQuestionDetail() {
QuestionEntity question = getQuestion(TITLE, AnswerType.FREETEXT);
question.setQuestionState(QuestionState.INACTIVE);
QuestionDetail questionDetail = questionnaireMapper.mapToQuestionDetail(question);
assertQuestionDetail(questionDetail, TITLE, QuestionType.FREETEXT);
assertThat(questionDetail.isActive(), is(false));
question = getQuestion(TITLE, AnswerType.MULTISELECT, asList(new QuestionChoiceEntity("choice1"), new QuestionChoiceEntity("choice2")));
question.setQuestionState(QuestionState.ACTIVE);
questionDetail = questionnaireMapper.mapToQuestionDetail(question);
assertQuestionDetail(questionDetail, TITLE, QuestionType.MULTI_SELECT, asList("choice1", "choice2"));
assertThat(questionDetail.isActive(), is(true));
question = getQuestion(TITLE, AnswerType.NUMBER);
question.setNumericMin(10);
question.setNumericMax(100);
questionDetail = questionnaireMapper.mapToQuestionDetail(question);
assertQuestionDetail(questionDetail, TITLE, QuestionType.NUMERIC);
assertThat(questionDetail.getNumericMin(), is(10));
assertThat(questionDetail.getNumericMax(), is(100));
assertThat(questionDetail.isActive(), is(true));
}
Aggregations