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);
}
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"));
}
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));
}
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);
}
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);
}
Aggregations