Search in sources :

Example 1 with Flow

use of org.mifos.framework.util.helpers.Flow in project head by mifos.

the class LoanPrdActionTest method shouldSetQuestionGroupsOnSession.

@Test
public void shouldSetQuestionGroupsOnSession() throws PageExpiredException {
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", true));
    when(questionnaireServiceFacade.getQuestionGroups("Create", "Loan")).thenReturn(questionGroupDetails);
    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);
    loanPrdAction.setQuestionGroupsOnSession(request, questionnaireServiceFacade);
    assertThat((List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SRCQGLIST), is(questionGroupDetails));
    verify(questionnaireServiceFacade, times(1)).getQuestionGroups("Create", "Loan");
    verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
    verify(request, times(1)).getSession();
    verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 2 with Flow

use of org.mifos.framework.util.helpers.Flow in project head by mifos.

the class LoanPrdActionFormTest method shouldSetSelectedQuestionGroupsOnSession.

@Test
public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
    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);
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
    when(flowManager.getFromFlow(FLOW_KEY, ProductDefinitionConstants.SRCQGLIST)).thenReturn(questionGroupDetails);
    loanPrdActionForm.setLoanOfferingQGs(new String[] { "1", "4" });
    loanPrdActionForm.setSelectedQuestionGroups(request);
    List<QuestionGroupDetail> selectedQGDetails = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
    assertThat(selectedQGDetails, is(notNullValue()));
    assertThat(selectedQGDetails.get(0).getId(), is(1));
    assertThat(selectedQGDetails.get(0).getTitle(), is("QG1"));
    assertThat(selectedQGDetails.get(1).getId(), is(4));
    assertThat(selectedQGDetails.get(1).getTitle(), is("QG4"));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 3 with Flow

use of org.mifos.framework.util.helpers.Flow in project head by mifos.

the class LoanPrdActionFormTest method shouldSetSelectedQuestionGroupsOnSessionForNoQGs.

@Test
public void shouldSetSelectedQuestionGroupsOnSessionForNoQGs() throws PageExpiredException {
    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);
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
    when(flowManager.getFromFlow(FLOW_KEY, ProductDefinitionConstants.SRCQGLIST)).thenReturn(questionGroupDetails);
    loanPrdActionForm.setLoanOfferingQGs(null);
    loanPrdActionForm.setSelectedQuestionGroups(request);
    List<QuestionGroupDetail> selectedQGDetails = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
    assertThat(selectedQGDetails, is(notNullValue()));
    assertThat(selectedQGDetails.isEmpty(), is(true));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Flow(org.mifos.framework.util.helpers.Flow) Test(org.junit.Test)

Example 4 with Flow

use of org.mifos.framework.util.helpers.Flow in project head by mifos.

the class CenterCustActionTest method shouldSetQuestionGroupInstanceDetailsInSession.

@Test
public void shouldSetQuestionGroupInstanceDetailsInSession() throws PageExpiredException {
    List<QuestionGroupInstanceDetail> instanceDetails = asList(getQuestionGroupInstanceDetail("QG1"), getQuestionGroupInstanceDetail("QG2"));
    when(questionnaireServiceFacade.getQuestionGroupInstances(101, "View", "Center")).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);
    centerCustAction.setQuestionGroupInstances(questionnaireServiceFacade, request, 101);
    assertThat((List<QuestionGroupInstanceDetail>) flow.getObjectFromSession("questionGroupInstances"), is(instanceDetails));
    verify(questionnaireServiceFacade, times(1)).getQuestionGroupInstances(101, "View", "Center");
    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 5 with Flow

use of org.mifos.framework.util.helpers.Flow in project head by mifos.

the class LoanAccountActionTest method setUp.

@Before
public void setUp() throws PageExpiredException {
    loanAccountAction = new LoanAccountAction(null, loanBusinessService, null, loanPrdBusinessService, null, null, null, null) {

        @SuppressWarnings("unused")
        @Override
        LoanBO getLoan(Integer loanId) {
            return loanBO;
        }

        @Override
        protected UserContext getUserContext(@SuppressWarnings("unused") HttpServletRequest request) {
            return userContext;
        }

        @Override
        QuestionnaireFlowAdapter getCreateLoanQuestionnaire() {
            return createLoanQuestionnaire;
        }
    };
    loanAccountAction.setLoanServiceFacade(loanServiceFacade);
    loanAccountAction.setLoanAccountServiceFacade(loanAccountServiceFacade);
    loanAccountAction.setCustomerDao(customerDao);
    when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
    when(request.getSession()).thenReturn(session);
    when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
    flow = new Flow();
    when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
    when(userContext.getLocaleId()).thenReturn(localeId);
    when(userContext.getPreferredLocale()).thenReturn(Locale.US);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) QuestionnaireFlowAdapter(org.mifos.application.questionnaire.struts.QuestionnaireFlowAdapter) Flow(org.mifos.framework.util.helpers.Flow) Before(org.junit.Before)

Aggregations

Flow (org.mifos.framework.util.helpers.Flow)15 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)4 FlowManager (org.mifos.framework.util.helpers.FlowManager)4 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)4 Arrays.asList (java.util.Arrays.asList)3 List (java.util.List)3 DateTimeService (org.mifos.framework.util.DateTimeService)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)2 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)2 UserContext (org.mifos.security.util.UserContext)2 Locale (java.util.Locale)1 Random (java.util.Random)1 HttpSession (javax.servlet.http.HttpSession)1 Before (org.junit.Before)1 FeeDto (org.mifos.accounts.fees.business.FeeDto)1 FeeFrequencyEntity (org.mifos.accounts.fees.business.FeeFrequencyEntity)1