Search in sources :

Example 16 with ChoiceDto

use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.

the class QuestionnaireServiceIntegrationTest method getSectionWithSmartSelectQuestion.

private SectionDetail getSectionWithSmartSelectQuestion(String name) throws SystemException {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    String questionTitle = "Question" + name + currentTimeMillis();
    ChoiceDto choiceDto1 = getChoiceDto("Ch1", "Tag1", "Tag2", "Tag3");
    ChoiceDto choiceDto2 = getChoiceDto("Ch2", "Tag11", "Tag22", "Tag33");
    ChoiceDto choiceDto3 = getChoiceDto("Ch3", "Tag111", "Tag222", "Tag333");
    QuestionDetail questionDetail = defineQuestionWithSmartSelect(questionTitle, asList(choiceDto1, choiceDto2, choiceDto3));
    section.addQuestion(new SectionQuestionDetail(questionDetail, true));
    return section;
}
Also used : ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto)

Example 17 with ChoiceDto

use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.

the class QuestionnaireServiceTest method getQuestionGroupDto.

private QuestionGroupDto getQuestionGroupDto() {
    QuestionDto question1 = new QuestionDtoBuilder().withText("Ques1").withMandatory(true).withType(QuestionType.FREETEXT).build();
    ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
    ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
    ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
    QuestionDto question2 = new QuestionDtoBuilder().withText("Ques2").withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).build();
    SectionDto section = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
    return new QuestionGroupDtoBuilder().withTitle("QG1").withEventSource("Create", "Client").addSections(section).build();
}
Also used : SectionDtoBuilder(org.mifos.platform.questionnaire.builders.SectionDtoBuilder) QuestionDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionDtoBuilder) SectionDto(org.mifos.platform.questionnaire.service.dtos.SectionDto) QuestionDto(org.mifos.platform.questionnaire.service.dtos.QuestionDto) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) ChoiceDetailBuilder(org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder) QuestionGroupDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder)

Example 18 with ChoiceDto

use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.

the class QuestionnaireValidatorForDtoTest method getQuestionGroupDto.

private QuestionGroupDto getQuestionGroupDto() {
    String ques1Title = "Ques1" + currentTimeMillis();
    String ques2Title = "Ques2" + currentTimeMillis();
    String ques3Title = "Ques3" + currentTimeMillis();
    String ques4Title = "Ques4" + currentTimeMillis();
    String qgTitle = "QG1" + currentTimeMillis();
    QuestionDto question1 = new QuestionDtoBuilder().withText(ques1Title).withMandatory(true).withType(QuestionType.FREETEXT).withOrder(1).build();
    ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
    ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
    ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
    QuestionDto question2 = new QuestionDtoBuilder().withText(ques2Title).withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).withOrder(2).build();
    SectionDto section1 = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
    QuestionDto question3 = new QuestionDtoBuilder().withText(ques3Title).withMandatory(false).withType(QuestionType.DATE).withOrder(1).build();
    QuestionDto question4 = new QuestionDtoBuilder().withText(ques4Title).withMandatory(true).withType(QuestionType.NUMERIC).withOrder(2).build();
    SectionDto section2 = new SectionDtoBuilder().withName("Sec2").withOrder(2).addQuestions(question3, question4).build();
    return new QuestionGroupDtoBuilder().withTitle(qgTitle).withEventSource("Create", "Client").addSections(section1, section2).build();
}
Also used : SectionDtoBuilder(org.mifos.platform.questionnaire.builders.SectionDtoBuilder) QuestionDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionDtoBuilder) SectionDto(org.mifos.platform.questionnaire.service.dtos.SectionDto) QuestionDto(org.mifos.platform.questionnaire.service.dtos.QuestionDto) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) ChoiceDetailBuilder(org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder) QuestionGroupDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder)

Example 19 with ChoiceDto

use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.

the class QuestionTest method assertQuestion.

private void assertQuestion(String text, QuestionType questionType, String questionTypeString, List<String> choices) {
    QuestionDetail questionDetail = new QuestionDetail(123, text, questionType, true, true);
    List<ChoiceDto> choiceDtos = getChoiceDetails(choices);
    questionDetail.setAnswerChoices(choiceDtos);
    Question question = new Question(questionDetail);
    assertThat(question.getText(), is(text));
    assertThat(question.getType(), is(questionTypeString));
    assertEquals(question.getChoices(), choiceDtos);
}
Also used : Question(org.mifos.platform.questionnaire.ui.model.Question) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail)

Example 20 with ChoiceDto

use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.

the class LoanAccountActionTest method getSectionDetail.

private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName(name);
    QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
    List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
    for (String answerChoice : answerChoices) {
        choiceDtos.add(new ChoiceDto(answerChoice));
    }
    questionDetail.setAnswerChoices(choiceDtos);
    sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Aggregations

ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)33 Test (org.junit.Test)14 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)13 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)11 QuestionDto (org.mifos.platform.questionnaire.service.dtos.QuestionDto)7 ArrayList (java.util.ArrayList)6 QuestionDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionDtoBuilder)6 ChoiceDetailBuilder (org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder)5 QuestionGroupDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder)5 SectionDtoBuilder (org.mifos.platform.questionnaire.builders.SectionDtoBuilder)5 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)5 SectionDto (org.mifos.platform.questionnaire.service.dtos.SectionDto)5 Question (org.mifos.platform.questionnaire.ui.model.Question)5 QuestionForm (org.mifos.platform.questionnaire.ui.model.QuestionForm)4 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)3 QuestionGroupDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto)3 HashSet (java.util.HashSet)2 SystemException (org.mifos.framework.exceptions.SystemException)2 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)2