myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1444308 - in /myfaces/core/branches/2.2.x/impl/src: main/java/org/apache/myfaces/flow/ main/java/org/apache/myfaces/flow/builder/ test/java/org/apache/myfaces/flow/
Date Sat, 09 Feb 2013 01:18:37 GMT
Author: lu4242
Date: Sat Feb  9 01:18:36 2013
New Revision: 1444308

URL: http://svn.apache.org/r1444308
Log:
MYFACES-3691 Implement Faces Flows (FlowBuilder support)

Added:
    myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/   (with props)
    myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java
  (with props)
Modified:
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/FlowCallNodeImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/SwitchCaseImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowBuilderImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowCallBuilderImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/MethodCallBuilderImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchBuilderImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchCaseBuilderImpl.java

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/FlowCallNodeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/FlowCallNodeImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/FlowCallNodeImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/FlowCallNodeImpl.java
Sat Feb  9 01:18:36 2013
@@ -21,6 +21,7 @@ package org.apache.myfaces.flow;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import javax.el.ValueExpression;
 import javax.faces.context.FacesContext;
 import javax.faces.flow.FlowCallNode;
 import javax.faces.flow.Parameter;
@@ -34,7 +35,9 @@ public class FlowCallNodeImpl extends Fl
 {
     private String _id;
     private String _calledFlowId;
+    private ValueExpression _calledFlowIdEL;
     private String _calledFlowDocumentId;
+    private ValueExpression _calledFlowDocumentIdEL;
     
     private Map<String, Parameter> _outboundParametersMap;
     private Map<String, Parameter>_unmodifiableOutboundParametersMap;
@@ -63,12 +66,20 @@ public class FlowCallNodeImpl extends Fl
     @Override
     public String getCalledFlowDocumentId(FacesContext context)
     {
+        if (_calledFlowDocumentIdEL != null)
+        {
+            return (String) _calledFlowDocumentIdEL.getValue(context.getELContext());
+        }
         return _calledFlowDocumentId;
     }
 
     @Override
     public String getCalledFlowId(FacesContext context)
     {
+        if (_calledFlowIdEL != null)
+        {
+            return (String) _calledFlowIdEL.getValue(context.getELContext());
+        }
         return _calledFlowId;
     }
 
@@ -88,12 +99,14 @@ public class FlowCallNodeImpl extends Fl
     {
         checkInitialized();
         this._calledFlowId = calledFlowId;
+        this._calledFlowIdEL = null;
     }
 
     public void setCalledFlowDocumentId(String calledFlowDocumentId)
     {
         checkInitialized();
         this._calledFlowDocumentId = calledFlowDocumentId;
+        this._calledFlowDocumentIdEL = null;
     }
     
     public void freeze()
@@ -116,4 +129,22 @@ public class FlowCallNodeImpl extends Fl
             throw new IllegalStateException("Flow is inmutable once initialized");
         }
     }
+
+    /**
+     * @param calledFlowIdEL the _calledFlowIdEL to set
+     */
+    public void setCalledFlowId(ValueExpression calledFlowIdEL)
+    {
+        this._calledFlowIdEL = calledFlowIdEL;
+        this._calledFlowId = null;
+    }
+
+    /**
+     * @param calledFlowDocumentIdEL the _calledFlowDocumentIdEL to set
+     */
+    public void setCalledFlowDocumentId(ValueExpression calledFlowDocumentIdEL)
+    {
+        this._calledFlowDocumentIdEL = calledFlowDocumentIdEL;
+        this._calledFlowDocumentId = null;
+    }
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/SwitchCaseImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/SwitchCaseImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/SwitchCaseImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/SwitchCaseImpl.java
Sat Feb  9 01:18:36 2013
@@ -45,7 +45,7 @@ public class SwitchCaseImpl extends Swit
     @Override
     public Boolean getCondition(FacesContext context)
     {
-        if (_condition != null)
+        if (_conditionEL != null)
         {
             Object value = _conditionEL.getValue(context.getELContext());
             if (value instanceof String)

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowBuilderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowBuilderImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowBuilderImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowBuilderImpl.java
Sat Feb  9 01:18:36 2013
@@ -104,10 +104,7 @@ public class FlowBuilderImpl extends Flo
     @Override
     public FlowBuilder initializer(String methodExpression)
     {
-        FacesContext facesContext = getFacesContext();
-        _facesFlow.setInitializer(
-            getFacesContext().getApplication().getExpressionFactory().createMethodExpression(
-            facesContext.getELContext(), methodExpression, null, EMPTY_PARAMS));
+        _facesFlow.setInitializer(createMethodExpression(methodExpression));
         return this;
     }
 
@@ -121,10 +118,7 @@ public class FlowBuilderImpl extends Flo
     @Override
     public FlowBuilder finalizer(String methodExpression)
     {
-        FacesContext facesContext = getFacesContext();
-        _facesFlow.setFinalizer(
-            facesContext.getApplication().getExpressionFactory().createMethodExpression(
-            facesContext.getELContext(), methodExpression, null, EMPTY_PARAMS));
+        _facesFlow.setFinalizer(createMethodExpression(methodExpression));
         return this;
     }
 
@@ -138,10 +132,8 @@ public class FlowBuilderImpl extends Flo
     @Override
     public FlowBuilder inboundParameter(String name, String value)
     {
-        FacesContext facesContext = getFacesContext();
         _facesFlow.putInboundParameter(name, new ParameterImpl(name,
-            facesContext.getApplication().getExpressionFactory()
-            .createValueExpression(facesContext.getELContext(), value, Object.class)));
+            createValueExpression(value)));
         return this;
     }
 

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowCallBuilderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowCallBuilderImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowCallBuilderImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/FlowCallBuilderImpl.java
Sat Feb  9 01:18:36 2013
@@ -23,6 +23,7 @@ import javax.faces.flow.builder.FlowCall
 import org.apache.myfaces.flow.FlowCallNodeImpl;
 import org.apache.myfaces.flow.FlowImpl;
 import org.apache.myfaces.flow.ParameterImpl;
+import org.apache.myfaces.view.facelets.el.ELText;
 
 /**
  *
@@ -46,8 +47,22 @@ public class FlowCallBuilderImpl extends
     @Override
     public FlowCallBuilder flowReference(String flowDocumentId, String flowId)
     {
-        this._flowCallNode.setCalledFlowDocumentId(flowDocumentId);
-        this._flowCallNode.setCalledFlowId(flowId);
+        if (ELText.isLiteral(flowDocumentId))
+        {
+            this._flowCallNode.setCalledFlowDocumentId(flowDocumentId);
+        }
+        else
+        {
+            this._flowCallNode.setCalledFlowDocumentId(_flowBuilder.createValueExpression(flowDocumentId));
+        }
+        if (ELText.isLiteral(flowId))
+        {
+            this._flowCallNode.setCalledFlowId(flowId);
+        }
+        else
+        {
+            this._flowCallNode.setCalledFlowId(_flowBuilder.createValueExpression(flowId));
+        }
         return this;
     }
 

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/MethodCallBuilderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/MethodCallBuilderImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/MethodCallBuilderImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/MethodCallBuilderImpl.java
Sat Feb  9 01:18:36 2013
@@ -39,6 +39,7 @@ public class MethodCallBuilderImpl exten
 
     public MethodCallBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow, String
methodCallNodeId)
     {
+        this._flowBuilder = flowBuilder;
         this._facesFlow = facesFlow;
         this._methodCallNode = new MethodCallNodeImpl(methodCallNodeId);
         this._facesFlow.addMethodCall(_methodCallNode);

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchBuilderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchBuilderImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchBuilderImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchBuilderImpl.java
Sat Feb  9 01:18:36 2013
@@ -23,6 +23,7 @@ import javax.faces.flow.builder.SwitchBu
 import javax.faces.flow.builder.SwitchCaseBuilder;
 import org.apache.myfaces.flow.FlowImpl;
 import org.apache.myfaces.flow.SwitchNodeImpl;
+import org.apache.myfaces.view.facelets.el.ELText;
 
 /**
  *
@@ -42,20 +43,27 @@ public class SwitchBuilderImpl extends S
         this._facesFlow = facesFlow;
         this._switchNodeImpl = new SwitchNodeImpl(switchNodeId);
         this._facesFlow.putSwitch(switchNodeId, _switchNodeImpl);
+        this._lastSwitchCaseBuilderImpl = new SwitchCaseBuilderImpl(
+            this._flowBuilder, this._facesFlow, this, this._switchNodeImpl);
     }
 
     @Override
     public SwitchCaseBuilder switchCase()
     {
-        this._lastSwitchCaseBuilderImpl = new SwitchCaseBuilderImpl(
-            this._flowBuilder, this._facesFlow, this, this._switchNodeImpl);
         return this._lastSwitchCaseBuilderImpl.switchCase();
     }
 
     @Override
     public SwitchCaseBuilder defaultOutcome(String outcome)
     {
-        this._switchNodeImpl.setDefaultOutcome(outcome);
+        if (ELText.isLiteral(outcome))
+        {
+            this._switchNodeImpl.setDefaultOutcome(outcome);
+        }
+        else
+        {
+            this._switchNodeImpl.setDefaultOutcome(_flowBuilder.createValueExpression(outcome));
+        }
         return _lastSwitchCaseBuilderImpl;
     }
 

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchCaseBuilderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchCaseBuilderImpl.java?rev=1444308&r1=1444307&r2=1444308&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchCaseBuilderImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/flow/builder/SwitchCaseBuilderImpl.java
Sat Feb  9 01:18:36 2013
@@ -23,6 +23,7 @@ import javax.faces.flow.builder.SwitchCa
 import org.apache.myfaces.flow.FlowImpl;
 import org.apache.myfaces.flow.SwitchCaseImpl;
 import org.apache.myfaces.flow.SwitchNodeImpl;
+import org.apache.myfaces.view.facelets.el.ELText;
 
 /**
  *
@@ -44,13 +45,20 @@ public class SwitchCaseBuilderImpl exten
         this._facesFlow = facesFlow;
         this._switchBuilderImpl = switchBuilderImpl;
         this._switchNodeImpl = switchNode;
-        this._switchCase = new SwitchCaseImpl();
+        this._switchCase = null;
     }
     
     @Override
     public SwitchCaseBuilder condition(String expression)
     {
-        this._switchCase.setCondition(Boolean.valueOf(expression));
+        if (ELText.isLiteral(expression))
+        {
+            this._switchCase.setCondition(Boolean.valueOf(expression));
+        }
+        else
+        {
+            this._switchCase.setCondition(_flowBuilder.createValueExpression(expression));
+        }
         return this;
     }
 
@@ -71,6 +79,7 @@ public class SwitchCaseBuilderImpl exten
     @Override
     public SwitchCaseBuilder switchCase()
     {
+        this._switchCase =  new SwitchCaseImpl();
         this._switchNodeImpl.addCase(this._switchCase);
         return this;
     }

Propchange: myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java?rev=1444308&view=auto
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java
(added)
+++ myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java
Sat Feb  9 01:18:36 2013
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.flow;
+
+import javax.faces.context.FacesContext;
+import javax.faces.flow.Flow;
+import javax.faces.flow.FlowCallNode;
+import javax.faces.flow.MethodCallNode;
+import javax.faces.flow.Parameter;
+import javax.faces.flow.ReturnNode;
+import javax.faces.flow.SwitchCase;
+import javax.faces.flow.SwitchNode;
+import javax.faces.flow.ViewNode;
+import javax.faces.flow.builder.FlowBuilder;
+import javax.faces.flow.builder.SwitchCaseBuilder;
+import org.apache.myfaces.flow.builder.FlowBuilderImpl;
+import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author lu4242
+ */
+public class FlowBuilderTestCase extends AbstractJsfTestCase
+{
+    
+    @Test
+    public void testFlowBuilderSimple()
+    {
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1").
+            initializer("#{bean.init}").finalizer("#{bean.destroy}");
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("flow1", flow.getId());
+        Assert.assertEquals("faces-flow1.xhtml", flow.getDefiningDocumentId());
+        Assert.assertEquals("#{bean.init}", flow.getInitializer().getExpressionString());
+        Assert.assertEquals("#{bean.destroy}", flow.getFinalizer().getExpressionString());
+    }
+    
+    @Test
+    public void testFlowBuilderReturn()
+    {
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+        flowBuilder.returnNode("returnNode").markAsStartNode().fromOutcome("mynode");
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("returnNode", flow.getStartNodeId());
+        
+        ReturnNode returnNode = flow.getReturns().get("returnNode");
+        Assert.assertNotNull(returnNode);
+        Assert.assertEquals("returnNode", returnNode.getId());
+        Assert.assertEquals("mynode", returnNode.getFromOutcome(facesContext));
+    }    
+
+    @Test
+    public void testFlowBuilderSwitch()
+    {
+        externalContext.getRequestMap().put("bean", new SimpleBean());
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+        SwitchCaseBuilder switchCaseBuilder = flowBuilder.switchNode("switch1")
+            .markAsStartNode().defaultOutcome("#{bean.outcome1}");
+        switchCaseBuilder
+            .switchCase().condition("true").fromOutcome("case1");
+        switchCaseBuilder
+            .switchCase().condition("#{bean.checkCond}").fromOutcome("caseB");
+        switchCaseBuilder
+            .switchCase().condition(
+                application.getExpressionFactory().createValueExpression(Boolean.TRUE, Boolean.class))
+                    .fromOutcome("caseC");
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("switch1", flow.getStartNodeId());
+        
+        SwitchNode switchNode = flow.getSwitches().get("switch1");
+        Assert.assertNotNull(switchNode);
+        Assert.assertEquals("exit", switchNode.getDefaultOutcome(facesContext));
+        
+        SwitchCase scn = switchNode.getCases().get(0);
+        Assert.assertTrue(scn.getCondition(facesContext));
+        Assert.assertEquals("case1", scn.getFromOutcome());
+        
+        scn = switchNode.getCases().get(1);
+        Assert.assertTrue(scn.getCondition(facesContext));
+        Assert.assertEquals("caseB", scn.getFromOutcome());
+
+        scn = switchNode.getCases().get(2);
+        Assert.assertTrue(scn.getCondition(facesContext));
+        Assert.assertEquals("caseC", scn.getFromOutcome());
+    }
+
+    public static class SimpleBean {
+        public boolean isCheckCond()
+        {
+            return true;
+        }
+        public String getOutcome1()
+        {
+            return "exit";
+        }
+        public String getValue()
+        {
+            return "asdf";
+        }
+        public void check()
+        {
+        }
+        public void checkTo(FacesContext context)
+        {
+        }
+    }
+    
+    @Test
+    public void testFlowBuilderView()
+    {
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+        flowBuilder.viewNode("x", "x.xhtml");
+        flowBuilder.viewNode("y", "y.xhtml").markAsStartNode();
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("y", flow.getStartNodeId());
+        
+        ViewNode viewNode = flow.getViews().get(0);
+        Assert.assertEquals("x", viewNode.getId());
+        Assert.assertEquals("x.xhtml", viewNode.getVdlDocumentId());
+        
+        viewNode = flow.getViews().get(1);
+        Assert.assertEquals("y", viewNode.getId());
+        Assert.assertEquals("y.xhtml", viewNode.getVdlDocumentId());
+    }
+    
+    @Test
+    public void testFlowBuilderInboundParameter()
+    {
+        externalContext.getRequestMap().put("bean", new SimpleBean());
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+        flowBuilder.inboundParameter("name1", "value1");
+        flowBuilder.inboundParameter("name2", "#{bean.value}");
+        flowBuilder.inboundParameter("name3", 
+            application.getExpressionFactory().createValueExpression("value3", String.class));
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+
+        Parameter param = flow.getInboundParameters().get("name1");
+        Assert.assertEquals("name1", param.getName());
+        Assert.assertEquals("value1", param.getValue().getValue(facesContext.getELContext()));
+        
+        param = flow.getInboundParameters().get("name2");
+        Assert.assertEquals("name2", param.getName());
+        Assert.assertEquals("asdf", param.getValue().getValue(facesContext.getELContext()));
       
+        
+        param = flow.getInboundParameters().get("name3");
+        Assert.assertEquals("name3", param.getName());
+        Assert.assertEquals("value3", param.getValue().getValue(facesContext.getELContext()));
       
+    }
+
+    @Test
+    public void testFlowBuilderMethodCall()
+    {
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+        flowBuilder.methodCallNode("method1").expression("#{bean.check}").defaultOutcome("case1").markAsStartNode();
+        flowBuilder.methodCallNode("method2").expression("#{bean.checkTo}",
+            new Class[]{FacesContext.class}).defaultOutcome("case2");
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("method1", flow.getStartNodeId());
+        
+        MethodCallNode mcn = flow.getMethodCalls().get(0);
+        Assert.assertEquals("method1", mcn.getId());
+        Assert.assertEquals("case1", mcn.getOutcome().getValue(facesContext.getELContext()));
+        Assert.assertEquals("#{bean.check}", mcn.getMethodExpression().getExpressionString());
+        
+        mcn = flow.getMethodCalls().get(1);
+        Assert.assertEquals("method2", mcn.getId());
+        Assert.assertEquals("case2", mcn.getOutcome().getValue(facesContext.getELContext()));
+        Assert.assertEquals("#{bean.checkTo}", mcn.getMethodExpression().getExpressionString());
+    }
+    
+    @Test
+    public void testFlowBuilderFlowCall()
+    {
+        FlowBuilder flowBuilder = new FlowBuilderImpl();
+        flowBuilder.id("faces-flow1.xhtml", "flow1");
+
+        flowBuilder.flowCallNode("goToFlow2").outboundParameter("name1", "value1").
+            flowReference("faces-flow2.xhtml", "flow2").markAsStartNode();
+        
+        Flow flow = flowBuilder.getFlow();
+        Assert.assertNotNull(flow);
+        Assert.assertEquals("goToFlow2", flow.getStartNodeId());
+        
+        FlowCallNode flowCallNode = flow.getFlowCalls().get("goToFlow2");
+        Assert.assertNotNull(flowCallNode);
+        Assert.assertEquals("flow2", flowCallNode.getCalledFlowId(facesContext));
+        Assert.assertEquals("faces-flow2.xhtml", flowCallNode.getCalledFlowDocumentId(facesContext));
+        
+        Parameter param = flowCallNode.getOutboundParameters().get("name1");
+        Assert.assertEquals("name1", param.getName());
+        Assert.assertEquals("value1", param.getValue().getValue(facesContext.getELContext()));
+    }
+
+}

Propchange: myfaces/core/branches/2.2.x/impl/src/test/java/org/apache/myfaces/flow/FlowBuilderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message