UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
client.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");
// Check the bean with @FlowScoped annotation can be instantiated
Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow1Bean}", Flow1Bean.class);
Assert.assertNotNull(bean1);
Assert.assertEquals(bean1.getPostConstructCalled(), "true");
bean1.setName("John");
renderResponse();
UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
client.submit(button2);
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");
Flow2Bean bean2 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow2Bean}", Flow2Bean.class);
Assert.assertNotNull(bean2);
Assert.assertEquals(bean2.getPostConstructCalled(), "true");
Flow1Bean bean1_1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow1Bean}", Flow1Bean.class);
Assert.assertEquals(bean1_1.getName(), "John");
Flow21Bean bean2_1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow21Bean}", Flow21Bean.class);
Assert.assertNotNull(bean2_1);
Assert.assertEquals(bean2_1.getPostConstructCalled(), "true");
Assert.assertNotNull(bean2_1.getFlow1Bean());
renderResponse();
//Check current view is the begin of flow2
Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
client.submit(button3);
processLifecycleExecute();
renderResponse();
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow2", currentFlow.getId());
NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end");
Assert.assertNotNull(endCase);
UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");