Search in sources :

Example 6 with QuestionDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder 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 7 with QuestionDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.

the class QuestionnaireServiceFacadeTest method testSaveQuestionDto.

@Test
public void testSaveQuestionDto() {
    QuestionDtoBuilder questionDtoBuilder = new QuestionDtoBuilder();
    QuestionDto questionDto = questionDtoBuilder.withText("Ques1").withType(QuestionType.FREETEXT).build();
    when(questionnaireService.defineQuestion(questionDto)).thenReturn(1234);
    Integer questionId = questionnaireServiceFacade.createQuestion(questionDto);
    assertThat(questionId, is(1234));
    verify(questionnaireService).defineQuestion(questionDto);
}
Also used : QuestionDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionDtoBuilder) QuestionDto(org.mifos.platform.questionnaire.service.dtos.QuestionDto) Test(org.junit.Test)

Example 8 with QuestionDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.

the class QuestionnaireMapperTest method shouldMapQuestionDtoToQuestionEntity.

@Test
public void shouldMapQuestionDtoToQuestionEntity() {
    String text = "question";
    String nickname = "nickname";
    QuestionDto questionDto = new QuestionDtoBuilder().withText(text).withNickname(nickname).withMandatory(true).withType(QuestionType.FREETEXT).withOrder(1).build();
    QuestionEntity questionEntity = questionnaireMapper.mapToQuestion(questionDto);
    assertThat(questionEntity.getQuestionText(), is(text));
    assertThat(questionEntity.getNickname(), is(nickname));
    assertThat(questionEntity.getAnswerTypeAsEnum(), is(AnswerType.FREETEXT));
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionDtoBuilder) QuestionDto(org.mifos.platform.questionnaire.service.dtos.QuestionDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

QuestionDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionDtoBuilder)8 QuestionDto (org.mifos.platform.questionnaire.service.dtos.QuestionDto)8 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)6 Test (org.junit.Test)5 ChoiceDetailBuilder (org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder)5 QuestionGroupDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder)5 SectionDtoBuilder (org.mifos.platform.questionnaire.builders.SectionDtoBuilder)5 SectionDto (org.mifos.platform.questionnaire.service.dtos.SectionDto)5 QuestionGroupDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto)2 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Transactional (org.springframework.transaction.annotation.Transactional)1