Search in sources :

Example 1 with QuestionGroupInstanceDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder 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());
}
Also used : QuestionGroupResponseDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder) QuestionGroupInstanceDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 2 with QuestionGroupInstanceDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder 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();
}
Also used : QuestionGroupResponseDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder) QuestionGroupInstanceDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder) QuestionGroupResponseDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupResponseDto)

Example 3 with QuestionGroupInstanceDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder 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));
}
Also used : QuestionGroupResponseDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder) QuestionGroupInstanceDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto) QuestionGroupInstanceDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder) QuestionGroupResponseDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupResponseDto) Test(org.junit.Test)

Example 4 with QuestionGroupInstanceDtoBuilder

use of org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder 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();
}
Also used : QuestionGroupResponseDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder) QuestionGroupInstanceDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder) QuestionGroupResponseDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupResponseDto)

Aggregations

QuestionGroupInstanceDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder)4 QuestionGroupResponseDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupResponseDtoBuilder)4 QuestionGroupResponseDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupResponseDto)3 Test (org.junit.Test)1 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 QuestionGroupInstanceDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto)1