use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.
the class QuestionnaireServiceTest method shouldSaveQuestionDto.
@Test
public void shouldSaveQuestionDto() {
QuestionDtoBuilder questionDtoBuilder = new QuestionDtoBuilder();
QuestionDto questionDto = questionDtoBuilder.withText("Ques1").withType(QuestionType.SMART_SELECT).addChoices(new ChoiceDto("Ch1"), new ChoiceDto("Ch2")).build();
when(questionDao.create(any(QuestionEntity.class))).thenReturn(1234);
Integer questionId = questionnaireService.defineQuestion(questionDto);
assertThat(questionId, is(1234));
verify(questionnaireValidator).validateForDefineQuestion(questionDto);
verify(questionDao).create(any(QuestionEntity.class));
}
use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.
the class QuestionnaireMapperTest method shouldMapToQuestionGroupFromDto.
@Test
public void shouldMapToQuestionGroupFromDto() {
when(eventSourceDao.retrieveByEventAndSource("Create", "Client")).thenReturn(asList(getEventSourceEntity("Create", "Client")));
QuestionDto question1 = new QuestionDtoBuilder().withText("Ques1").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("Ques2").withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).withOrder(2).build();
SectionDto section1 = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
QuestionGroupDto questionGroupDto = new QuestionGroupDtoBuilder().withTitle("QG1").withEventSource("Create", "Client").addSections(section1).build();
assertQuestionGroupEntity(questionnaireMapper.mapToQuestionGroup(questionGroupDto));
verify(eventSourceDao, times(1)).retrieveByEventAndSource(anyString(), anyString());
}
use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.
the class QuestionnaireServiceTest method getQuestionGroupDtoWithNicknames.
private QuestionGroupDto getQuestionGroupDtoWithNicknames() {
QuestionDto question1 = new QuestionDtoBuilder().withText("Ques1").withNickname("Ques1_nick").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").withNickname("Ques2_nick").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();
}
use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldSaveQuestionGroupFromDto.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldSaveQuestionGroupFromDto() {
String ques1Title = "Ques1" + currentTimeMillis();
String ques2Title = "Ques2" + currentTimeMillis();
String qgTitle = "QG1" + currentTimeMillis();
createSingleSelectQuestion(ques2Title);
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();
QuestionGroupDto questionGroupDto = new QuestionGroupDtoBuilder().withTitle(qgTitle).withEventSource("Create", "Client").addSections(section1).build();
Integer questionGroupId = questionnaireService.defineQuestionGroup(questionGroupDto);
assertQuestionGroup(questionGroupDao.getDetails(questionGroupId), qgTitle, ques1Title, ques2Title);
}
use of org.mifos.platform.questionnaire.builders.QuestionDtoBuilder 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();
}
Aggregations