use of org.mifos.platform.questionnaire.domain.EventSourceEntity in project head by mifos.
the class QuestionnaireMapperTest method getEventSources.
private HashSet<EventSourceEntity> getEventSources(String event, String source) {
EventSourceEntity eventSourceEntity = new EventSourceEntity();
EventEntity eventEntity = new EventEntity();
eventEntity.setName(event);
eventSourceEntity.setEvent(eventEntity);
EntityMaster entityMaster = new EntityMaster();
entityMaster.setEntityType(source);
eventSourceEntity.setSource(entityMaster);
HashSet<EventSourceEntity> eventSources = new HashSet<EventSourceEntity>();
eventSources.add(eventSourceEntity);
return eventSources;
}
use of org.mifos.platform.questionnaire.domain.EventSourceEntity in project head by mifos.
the class QuestionnaireMapperTest method assertQuestionGroupEntity.
private void assertQuestionGroupEntity(QuestionGroup questionGroup) {
assertThat(questionGroup, is(notNullValue()));
assertThat(questionGroup.getTitle(), is("QG1"));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(notNullValue()));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is("Create"));
assertThat(eventSourceEntity.getSource().getEntityType(), is("Client"));
assertThat(questionGroup.getState(), is(QuestionGroupState.ACTIVE));
List<Section> sections = questionGroup.getSections();
assertThat(sections, is(notNullValue()));
assertThat(sections.size(), is(1));
Section section = sections.get(0);
assertThat(section.getName(), is("Sec1"));
List<SectionQuestion> questions = section.getQuestions();
assertThat(questions, is(notNullValue()));
assertThat(questions.size(), is(2));
SectionQuestion sectionQuestion1 = questions.get(0);
assertThat(sectionQuestion1.getSequenceNumber(), is(1));
assertThat(sectionQuestion1.getSection(), is(notNullValue()));
assertThat(sectionQuestion1.getSection().getName(), is("Sec1"));
assertThat(sectionQuestion1.getSection().getSequenceNumber(), is(1));
assertThat(sectionQuestion1.getQuestion(), is(notNullValue()));
assertThat(sectionQuestion1.getQuestion().getQuestionText(), is("Ques1"));
assertThat(sectionQuestion1.getQuestion().getAnswerTypeAsEnum(), is(AnswerType.FREETEXT));
SectionQuestion sectionQuestion2 = questions.get(1);
assertThat(sectionQuestion2.getSequenceNumber(), is(2));
assertThat(sectionQuestion2.getSection(), is(notNullValue()));
assertThat(sectionQuestion2.getSection().getName(), is("Sec1"));
assertThat(sectionQuestion2.getSection().getSequenceNumber(), is(1));
assertThat(sectionQuestion2.getQuestion(), is(notNullValue()));
assertThat(sectionQuestion2.getQuestion().getQuestionText(), is("Ques2"));
assertThat(sectionQuestion2.getQuestion().getAnswerTypeAsEnum(), is(AnswerType.SINGLESELECT));
assertThat(sectionQuestion2.getQuestion().getChoices(), is(notNullValue()));
assertThat(sectionQuestion2.getQuestion().getChoices().size(), is(3));
assertThat(sectionQuestion2.getQuestion().getChoices().get(0).getChoiceText(), is("Ch1"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(0).getChoiceOrder(), is(1));
assertThat(sectionQuestion2.getQuestion().getChoices().get(1).getChoiceText(), is("Ch2"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(1).getChoiceOrder(), is(2));
assertThat(sectionQuestion2.getQuestion().getChoices().get(2).getChoiceText(), is("Ch3"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(2).getChoiceOrder(), is(3));
}
use of org.mifos.platform.questionnaire.domain.EventSourceEntity in project head by mifos.
the class QuestionnaireMapperTest method getEventSourceEntities.
private List<EventSourceEntity> getEventSourceEntities(String event, String source, String description) {
List<EventSourceEntity> events = new ArrayList<EventSourceEntity>();
EventSourceEntity eventSourceEntity = new EventSourceEntity();
eventSourceEntity.setDescription(description);
EventEntity eventEntity = new EventEntity();
eventEntity.setName(event);
eventSourceEntity.setEvent(eventEntity);
EntityMaster entityMaster = new EntityMaster();
entityMaster.setEntityType(source);
eventSourceEntity.setSource(entityMaster);
events.add(eventSourceEntity);
return events;
}
use of org.mifos.platform.questionnaire.domain.EventSourceEntity in project head by mifos.
the class QuestionnaireMapperTest method getEventSourceEntity.
private EventSourceEntity getEventSourceEntity(String event, String source) {
EventSourceEntity eventSource = new EventSourceEntity();
EventEntity eventEntity = new EventEntity();
eventEntity.setName(event);
eventSource.setEvent(eventEntity);
EntityMaster entityMaster = new EntityMaster();
entityMaster.setEntityType(source);
eventSource.setSource(entityMaster);
return eventSource;
}
use of org.mifos.platform.questionnaire.domain.EventSourceEntity in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupToExistingQuestionGroupWhileAddingQuestionToOldSection.
@Test
public void shouldMapQuestionGroupToExistingQuestionGroupWhileAddingQuestionToOldSection() {
Integer questionGroupId = 123;
EventSourceDto eventSourceDto = getEventSource("Create", "Client");
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName("Misc");
SectionQuestionDetail sectionQuestionDetail1 = getSectionQuestionDetail(111, 999, "Ques1");
SectionQuestionDetail sectionQuestionDetail2 = getSectionQuestionDetail(0, 0, "Ques2");
sectionDetail.setQuestionDetails(asList(sectionQuestionDetail1, sectionQuestionDetail2));
List<SectionDetail> sectionDetails = asList(sectionDetail);
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(questionGroupId, TITLE, Arrays.asList(eventSourceDto), sectionDetails, true, true);
SectionQuestion sectionQuestion = getSectionQuestion(getQuestionEntity(999, "Ques1"), 333);
Section section = getSection(sectionQuestion, 222, "Misc");
when(questionGroupDao.retrieveSectionByNameAndQuestionGroupId("Misc", 123)).thenReturn(asList(section));
when(questionGroupDao.getDetails(questionGroupId)).thenReturn(getQuestionGroup(questionGroupId, "QG Title", section));
when(sectionQuestionDao.retrieveFromQuestionIdSectionId(222, 999)).thenReturn(asList(sectionQuestion));
when(eventSourceDao.retrieveByEventAndSource(anyString(), anyString())).thenReturn(new ArrayList<EventSourceEntity>());
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
assertQuestionGroupForExistingQuestion(questionGroup, QuestionGroupState.ACTIVE);
verify(questionGroupDao).retrieveSectionByNameAndQuestionGroupId("Misc", 123);
verify(questionGroupDao).getDetails(questionGroupId);
verify(sectionQuestionDao).retrieveFromQuestionIdSectionId(222, 999);
verify(eventSourceDao).retrieveByEventAndSource(anyString(), anyString());
}
Aggregations