//UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
//submit(button);
processLifecycleExecute();
Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow1", currentFlow.getId());
facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
processRender();
//UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
//submit(button2);
navCase = handler.getNavigationCase(facesContext, null, "call_flow2");
clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
setupRequest(navCase.getToViewId(facesContext));
request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, navCase.getToFlowDocumentId());
request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, navCase.getFromOutcome());
request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
processLifecycleExecute();
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow2", currentFlow.getId());
Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
processRender();
//Check current view is the begin of flow2
Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
submit(button3);
processLifecycleExecute();
processRender();
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow2", currentFlow.getId());
NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back");
Assert.assertNotNull(endCase);
String toViewId = endCase.getToViewId(facesContext);
String fromOutcome = endCase.getFromOutcome();
clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
tearDownRequest();
setupRequest(toViewId);
request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
processLifecycleExecute();
// Check it should go back to flow1
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow1", currentFlow.getId());
Assert.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
// Check lastDisplayedViewId (since it was GET, it should be the start viewId)
Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
processRender();