[jbpm-commits] JBoss JBPM SVN: r6727 - jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Oct 2 20:13:02 EDT 2010
Author: rebody
Date: 2010-10-02 20:13:00 -0400 (Sat, 02 Oct 2010)
New Revision: 6727
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
Log:
add testcase for return type is boolean,
related forum post is here: http://community.jboss.org/thread/157117?tstart=0
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java 2010-10-02 03:18:25 UTC (rev 6726)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java 2010-10-03 00:13:00 UTC (rev 6727)
@@ -21,6 +21,10 @@
*/
package org.jbpm.pvm.internal.expr;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
@@ -34,7 +38,7 @@
* @author Tom Baeyens
*/
public class UelExpressionTest extends JbpmTestCase {
-
+
public void testUelExpression() {
ExecutionImpl execution = (ExecutionImpl) ProcessDefinitionBuilder
.startProcess()
@@ -43,12 +47,54 @@
.endActivity()
.endProcess()
.startProcessInstance();
-
+
Expression expression = Expression.create("#{pv}", Expression.LANGUAGE_UEL_VALUE);
UelValueExpression uve = ((UelValueExpression) expression);
-
- execution.setVariable("pv", null);
-
+
+ execution.setVariable("pv", null);
+
assertEquals(null, uve.evaluate(execution));
- }
+ }
+
+ public void testBooleanResult() {
+ ExecutionImpl execution = (ExecutionImpl) ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .endActivity()
+ .endProcess()
+ .startProcessInstance();
+
+ Expression expression = Expression.create("#{pv}", Expression.LANGUAGE_UEL_VALUE);
+ UelValueExpression uve = ((UelValueExpression) expression);
+
+ execution.setVariable("pv", Boolean.TRUE);
+
+ assertEquals(Boolean.TRUE, uve.evaluate(execution));
+ }
+
+ public void testBooleanResultWithComplexCondition() {
+ ExecutionImpl execution = (ExecutionImpl) ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .endActivity()
+ .endProcess()
+ .startProcessInstance();
+
+ Expression expression = Expression.create("#{response['resultSet'] != null && response['resultSet'][0][3] > 0}",
+ Expression.LANGUAGE_UEL_VALUE);
+ UelValueExpression uve = ((UelValueExpression) expression);
+
+ Map response = new HashMap();
+ List resultSet = new ArrayList();
+ int[] array = new int[]{0, 1, 2, 3};
+
+ response.put("resultSet", resultSet);
+ resultSet.add(array);
+ execution.setVariable("response", response);
+
+ assertEquals(Boolean.TRUE, uve.evaluate(execution));
+ }
+
}
More information about the jbpm-commits
mailing list