use of org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto in project head by mifos.
the class QuestionnaireServiceFacadeTest method testSaveQuestionGroupInstance.
@Test
public void testSaveQuestionGroupInstance() {
QuestionGroupInstanceDto questionGroupInstanceDto = new QuestionGroupInstanceDto();
when(questionnaireService.saveQuestionGroupInstance(questionGroupInstanceDto)).thenReturn(1234);
Integer qgInstanceId = questionnaireServiceFacade.saveQuestionGroupInstance(questionGroupInstanceDto);
assertThat(qgInstanceId, is(1234));
verify(questionnaireService).saveQuestionGroupInstance(questionGroupInstanceDto);
}
use of org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto in project head by mifos.
the class QuestionnaireMapperTest method shouldMapToQuestionGroupInstance.
@Test
public void shouldMapToQuestionGroupInstance() {
QuestionGroupInstanceDto questionGroupInstanceDto = getQuestionGroupInstanceDto();
QuestionGroup questionGroup = new QuestionGroup();
when(questionGroupDao.getDetails(123)).thenReturn(questionGroup);
SectionQuestion sectionQuestion = new SectionQuestion();
when(sectionQuestionDao.getDetails(999)).thenReturn(sectionQuestion);
QuestionGroupInstance questionGroupInstance = questionnaireMapper.mapToQuestionGroupInstance(questionGroupInstanceDto);
assertThat(questionGroupInstance, is(notNullValue()));
assertThat(questionGroupInstance.getCompletedStatus(), is(1));
assertThat(questionGroupInstance.getCreatorId(), is(111));
assertThat(questionGroupInstance.getEntityId(), is(12345));
assertThat(questionGroupInstance.getVersionNum(), is(1));
assertThat(questionGroupInstance.getQuestionGroup(), is(questionGroup));
List<QuestionGroupResponse> questionGroupResponses = questionGroupInstance.getQuestionGroupResponses();
assertThat(questionGroupResponses, is(notNullValue()));
assertThat(questionGroupResponses.size(), is(1));
QuestionGroupResponse questionGroupResponse = questionGroupResponses.get(0);
assertThat(questionGroupResponse.getResponse(), is("Answer1"));
assertThat(questionGroupResponse.getSectionQuestion(), is(sectionQuestion));
verify(questionGroupDao).getDetails(123);
verify(sectionQuestionDao).getDetails(999);
}
use of org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto 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.service.dtos.QuestionGroupInstanceDto in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldSaveQuestionGroupInstance.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldSaveQuestionGroupInstance() {
String title = "QG1" + currentTimeMillis();
QuestionGroupDetail qgDetail = defineQuestionGroup(title, "Create", "Client", asList(getSection("S1")), true);
Integer sectionQuestionId = qgDetail.getSectionDetail(0).getQuestionDetail(0).getId();
QuestionGroupInstanceDto qgInstanceDto = getQuestionGroupInstanceDto("1234", 121, 567, qgDetail.getId(), sectionQuestionId);
Integer qgInstanceId = questionnaireService.saveQuestionGroupInstance(qgInstanceDto);
assertThat(qgInstanceId, is(notNullValue()));
QuestionGroupInstance instance = questionGroupInstanceDao.getDetails(qgInstanceId);
assertThat(instance, is(notNullValue()));
assertThat(instance.getCreatorId(), is(121));
assertThat(instance.getEntityId(), is(567));
List<QuestionGroupResponse> questionGroupResponses = instance.getQuestionGroupResponses();
assertThat(questionGroupResponses, is(notNullValue()));
assertThat(questionGroupResponses.size(), is(1));
assertThat(questionGroupResponses.get(0).getResponse(), is("1234"));
}
Aggregations