use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto in project head by mifos.
the class QuestionGroupForm method getEventSourceIds.
public List<String> getEventSourceIds() {
List<String> eventSources = new ArrayList<String>();
List<EventSourceDto> eventSourcesDtos = this.questionGroupDetail.getEventSources();
if (eventSourcesDtos == null) {
return eventSources;
}
for (EventSourceDto eventSourceDto : eventSourcesDtos) {
if (eventSourceDto == null || isEmpty(eventSourceDto.getEvent()) || isEmpty(eventSourceDto.getSource())) {
continue;
}
eventSources.add(format("%s.%s", eventSourceDto.getEvent(), eventSourceDto.getSource()));
}
return eventSources;
}
use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto in project head by mifos.
the class QuestionGroupForm method setEventSourceIds.
public void setEventSourceIds(List<String> eventSourceIds) {
List<EventSourceDto> eventSourceDtos = new ArrayList<EventSourceDto>();
if (eventSourceIds != null) {
for (String eventSourceId : eventSourceIds) {
if (StringUtils.isNotEmpty(eventSourceId) && !StringUtils.equals(DEFAULT_APPLIES_TO_OPTION, eventSourceId)) {
String[] parts = eventSourceId.split("\\.");
eventSourceDtos.add(new EventSourceDto(parts[0], parts[1], eventSourceId));
}
}
}
this.questionGroupDetail.setEventSources(eventSourceDtos);
}
use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto in project head by mifos.
the class QuestionGroupDefinitionParserTest method shouldParseQuestionDefinitionXml.
@Test
public void shouldParseQuestionDefinitionXml() throws Exception {
QuestionGroupDefinitionParser questionGroupDefinitionParser = new QuestionGroupDefinitionParserImpl();
String questionGroupDefXml = "/org/mifos/platform/questionnaire/QuestionGroupDefinition.xml";
InputStream inputStream = getClass().getResourceAsStream(questionGroupDefXml);
QuestionGroupDto questionGroupDto = questionGroupDefinitionParser.parse(inputStream);
assertQuestionGroupDto(questionGroupDto);
EventSourceDto eventSourceDto = questionGroupDto.getEventSourceDtos().get(0);
assertEventSource(eventSourceDto);
List<SectionDto> sectionDtos = questionGroupDto.getSections();
assertSections(sectionDtos);
}
use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto in project head by mifos.
the class QuestionnaireMapperIntegrationTest method testMapEventSource.
private void testMapEventSource(String event, String source, String description) {
EventSourceDto eventSourceDto = new EventSourceDto(event, source, description);
List<SectionDetail> sectionDetails = getSectionDefinitions();
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(new QuestionGroupDetail(0, "Title", Arrays.asList(eventSourceDto), sectionDetails, false));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(not(nullValue())));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
}
use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto in project head by mifos.
the class QuestionnaireServiceTest method shouldGetAllQuestionGroupsByEventSource.
@Test
public void shouldGetAllQuestionGroupsByEventSource() throws SystemException {
List<QuestionGroup> questionGroups = asList(getQuestionGroup(1, "Title1", "View", "Loan", QuestionGroupState.ACTIVE, true, getSections("Section1")), getQuestionGroup(2, "Title2", "View", "Loan", QuestionGroupState.ACTIVE, true, getSections("Section2")));
when(questionGroupDao.retrieveQuestionGroupsByEventSource("Create", "Client")).thenReturn(questionGroups);
List<QuestionGroupDetail> questionGroupDetails = questionnaireService.getQuestionGroups(new EventSourceDto("Create", "Client", "Create.Client"));
assertThat(questionGroupDetails, is(notNullValue()));
assertThat(questionGroupDetails.size(), is(2));
assertThat(questionGroupDetails.get(0).getTitle(), is("Title1"));
assertThat(questionGroupDetails.get(1).getTitle(), is("Title2"));
verify(questionnaireValidator, times(1)).validateForEventSource(any(EventSourceDto.class));
verify(questionGroupDao, times(1)).retrieveQuestionGroupsByEventSource("Create", "Client");
}
Aggregations