use of org.mifos.framework.util.helpers.Flow in project head by mifos.
the class MifosMockStrutsTestCase method createFlow.
protected String createFlow(HttpServletRequest request, Class<?> flowClass) {
Flow flow = new Flow();
String flowKey = String.valueOf(System.currentTimeMillis());
FlowManager flowManager = new FlowManager();
flowManager.addFLow(flowKey, flow, flowClass.getName());
request.getSession(false).setAttribute(Constants.FLOWMANAGER, flowManager);
return flowKey;
}
use of org.mifos.framework.util.helpers.Flow in project head by mifos.
the class FlowKeyInterceptor method createToken.
private void createToken(HttpServletRequest request) {
String flowKey = String.valueOf(new DateTimeService().getCurrentDateTime().getMillis());
FlowManager flowManager = (FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER);
if (flowManager == null) {
flowManager = new FlowManager();
request.getSession(false).setAttribute(Constants.FLOWMANAGER, flowManager);
}
flowManager.addFLow(flowKey, new Flow(), this.getClass().getName());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
use of org.mifos.framework.util.helpers.Flow 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);
}
use of org.mifos.framework.util.helpers.Flow 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);
}
use of org.mifos.framework.util.helpers.Flow in project head by mifos.
the class LoanPrdActionTest method shouldSetSelectedQuestionGroupsOnSession.
@Test
public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", false));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(1)).thenReturn(questionGroupDetails.get(0));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(2)).thenReturn(questionGroupDetails.get(1));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(3)).thenReturn(questionGroupDetails.get(2));
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);
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(1, 2, 3));
loanPrdAction.setSelectedQuestionGroupsOnSession(request, loanOfferingBO, questionnaireServiceFacade);
List<QuestionGroupDetail> questionGroupDetailList = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
assertThat(questionGroupDetailList, is(notNullValue()));
assertThat(questionGroupDetailList.size(), is(2));
assertQuestionGroup(questionGroupDetailList.get(0), 1, "QG1");
assertQuestionGroup(questionGroupDetailList.get(1), 2, "QG2");
verify(questionnaireServiceFacade, times(3)).getQuestionGroupDetailForLoanPrd(anyInt());
verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
verify(request, times(1)).getSession();
verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
Aggregations