use of org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder in project head by mifos.
the class PPITestDataGenerator method createSurveyInstance.
private void createSurveyInstance(CustomerBO customer, Properties properties, QuestionGroupDetail qg, int surveyNum) {
Integer creatorId = 1;
QuestionGroupInstanceDtoBuilder instanceBuilder = new QuestionGroupInstanceDtoBuilder();
instanceBuilder.withQuestionGroup(qg.getId()).withCompleted(true).withCreator(creatorId).withEventSource(1).withEntity(customer.getCustomerId()).withVersion(1);
List<SectionQuestionDetail> questions = qg.getSectionDetail(0).getQuestions();
for (SectionQuestionDetail question : questions) {
String responseKey = "survey." + surveyNum + ".question." + question.getSequenceNumber() + ".response.text";
String questionResponse = properties.getProperty(responseKey);
QuestionGroupResponseDtoBuilder responseBuilder = new QuestionGroupResponseDtoBuilder();
responseBuilder.withSectionQuestion(question.getQuestionId()).withResponse(questionResponse);
instanceBuilder.addResponses(responseBuilder.build());
}
questionnaireServiceFacade.saveQuestionGroupInstance(instanceBuilder.build());
}
use of org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder in project head by mifos.
the class QuestionnaireMapperTest method getQuestionGroupInstanceDto.
private QuestionGroupInstanceDto getQuestionGroupInstanceDto() {
QuestionGroupInstanceDtoBuilder instanceBuilder = new QuestionGroupInstanceDtoBuilder();
QuestionGroupResponseDtoBuilder responseBuilder = new QuestionGroupResponseDtoBuilder();
responseBuilder.withResponse("Answer1").withSectionQuestion(999);
QuestionGroupResponseDto questionGroupResponseDto = responseBuilder.build();
instanceBuilder.withQuestionGroup(123).withCompleted(true).withCreator(111).withEventSource(1).withEntity(12345).withVersion(1).addResponses(questionGroupResponseDto);
return instanceBuilder.build();
}
use of org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder in project head by mifos.
the class QuestionnaireServiceTest method shouldSaveQuestionGroupInstance.
@Test
public void shouldSaveQuestionGroupInstance() {
QuestionGroupInstanceDtoBuilder instanceBuilder = new QuestionGroupInstanceDtoBuilder();
QuestionGroupResponseDtoBuilder responseBuilder = new QuestionGroupResponseDtoBuilder();
responseBuilder.withResponse("Answer1").withSectionQuestion(999);
QuestionGroupResponseDto questionGroupResponseDto = responseBuilder.build();
instanceBuilder.withQuestionGroup(123).withCompleted(true).withCreator(111).withEventSource(1).withEntity(12345).withVersion(1).addResponses(questionGroupResponseDto);
QuestionGroupInstanceDto questionGroupInstanceDto = instanceBuilder.build();
when(questionGroupInstanceDao.create(Matchers.<QuestionGroupInstance>any())).thenReturn(789);
Integer qgInstanceId = questionnaireService.saveQuestionGroupInstance(questionGroupInstanceDto);
assertThat(qgInstanceId, is(789));
verify(questionGroupInstanceDao).create(any(QuestionGroupInstance.class));
}
use of org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder in project head by mifos.
the class QuestionnaireServiceIntegrationTest method getQuestionGroupInstanceDto.
private QuestionGroupInstanceDto getQuestionGroupInstanceDto(String response, Integer creatorId, Integer entityId, Integer questionGroupId, Integer sectionQuestionId) {
QuestionGroupInstanceDtoBuilder instanceBuilder = new QuestionGroupInstanceDtoBuilder();
QuestionGroupResponseDtoBuilder responseBuilder = new QuestionGroupResponseDtoBuilder();
responseBuilder.withResponse(response).withSectionQuestion(sectionQuestionId);
QuestionGroupResponseDto questionGroupResponseDto = responseBuilder.build();
instanceBuilder.withQuestionGroup(questionGroupId).withCompleted(true).withCreator(creatorId).withEventSource(1).withEntity(entityId).withVersion(1).addResponses(questionGroupResponseDto);
return instanceBuilder.build();
}
Aggregations