Search in sources :

Example 11 with QuestionGroupInstanceDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail in project head by mifos.

the class LoanAccountAction method viewAndEditAdditionalInformation.

public ActionForward viewAndEditAdditionalInformation(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    Integer entityId = Integer.valueOf(request.getParameter("entityId"));
    questionGroupFilter.setLoanOfferingBO(getLoan(entityId).getLoanOffering());
    List<QuestionGroupInstanceDetail> questionGroupInstances = createLoanQuestionnaire.getQuestionGroupInstances(request, entityId);
    request.getSession().setAttribute(LoanConstants.QUESTION_GROUP_INSTANCES, questionGroupInstances);
    ActionForward forward = mapping.findForward(ActionForwards.viewAndEditAdditionalInformation.toString());
    return new ActionForward(forward.getPath(), forward.getRedirect());
}
Also used : ActionForward(org.apache.struts.action.ActionForward) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 12 with QuestionGroupInstanceDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail in project head by mifos.

the class LoanAccountActionTest method getQuestionGroupInstanceDetail.

private QuestionGroupInstanceDetail getQuestionGroupInstanceDetail(String questionGroupTitle) {
    QuestionGroupInstanceDetail detail = new QuestionGroupInstanceDetail();
    detail.setDateCompleted(Calendar.getInstance().getTime());
    detail.setQuestionGroupDetail(getQuestionGroupDetail(questionGroupTitle, asList("red", "green", "blue")));
    return detail;
}
Also used : QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 13 with QuestionGroupInstanceDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail in project head by mifos.

the class QuestionnaireMapperImpl method mapToQuestionGroupInstanceDetail.

@Override
public QuestionGroupInstanceDetail mapToQuestionGroupInstanceDetail(QuestionGroupInstance questionGroupInstance) {
    QuestionGroupDetail questionGroupDetail = mapToQuestionGroupDetail(questionGroupInstance.getQuestionGroup());
    QuestionGroupInstanceDetail questionGroupInstanceDetail = new QuestionGroupInstanceDetail();
    questionGroupInstanceDetail.setId(questionGroupInstance.getId());
    questionGroupInstanceDetail.setDateCompleted(questionGroupInstance.getDateConducted());
    questionGroupInstanceDetail.setQuestionGroupDetail(questionGroupDetail);
    mapQuestionResponses(questionGroupInstance.getQuestionGroupResponses(), questionGroupInstanceDetail.getQuestionGroupDetail());
    return questionGroupInstanceDetail;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 14 with QuestionGroupInstanceDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail in project head by mifos.

the class GroupCustActionTest method shouldSetQuestionGroupInstanceDetailsInSession.

@Test
public void shouldSetQuestionGroupInstanceDetailsInSession() throws PageExpiredException {
    List<QuestionGroupInstanceDetail> instanceDetails = asList(getQuestionGroupInstanceDetail("QG1"), getQuestionGroupInstanceDetail("QG2"));
    when(questionnaireServiceFacade.getQuestionGroupInstances(101, "View", "Group")).thenReturn(instanceDetails);
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    Flow flow = new Flow();
    when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    groupCustAction.setQuestionGroupInstances(questionnaireServiceFacade, request, 101);
    assertThat((List<QuestionGroupInstanceDetail>) flow.getObjectFromSession("questionGroupInstances"), is(instanceDetails));
    verify(questionnaireServiceFacade, times(1)).getQuestionGroupInstances(101, "View", "Group");
    verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
    verify(request, times(1)).getSession();
    verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
Also used : QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 15 with QuestionGroupInstanceDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail in project head by mifos.

the class ClientCustActionTest method shouldSetQuestionGroupInstanceDetailsInSession.

@Test
public void shouldSetQuestionGroupInstanceDetailsInSession() throws PageExpiredException {
    List<QuestionGroupInstanceDetail> instanceDetails = asList(getQuestionGroupInstanceDetail("QG1"), getQuestionGroupInstanceDetail("QG2"));
    when(questionnaireServiceFacade.getQuestionGroupInstances(101, "View", "Client")).thenReturn(instanceDetails);
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    Flow flow = new Flow();
    when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    clientCustAction.setQuestionGroupInstances(questionnaireServiceFacade, request, 101);
    assertThat((List<QuestionGroupInstanceDetail>) flow.getObjectFromSession("questionGroupInstances"), is(instanceDetails));
    verify(questionnaireServiceFacade, times(1)).getQuestionGroupInstances(101, "View", "Client");
    verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
    verify(request, times(1)).getSession();
    verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
Also used : QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Aggregations

QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)23 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 Flow (org.mifos.framework.util.helpers.Flow)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)4 HashSet (java.util.HashSet)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)3 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)3 MessageLookup (org.mifos.application.master.MessageLookup)3 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)3 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 UserContext (org.mifos.security.util.UserContext)3