[jbpm-commits] JBoss JBPM SVN: r3381 - in jbpm4/trunk/modules/examples/src/test: java/org/jbpm/examples/hql and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Dec 14 14:09:59 EST 2008


Author: tom.baeyens at jboss.com
Date: 2008-12-14 14:09:58 -0500 (Sun, 14 Dec 2008)
New Revision: 3381

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/hql/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml
Log:
added hql activity example

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	2008-12-14 19:09:58 UTC (rev 3381)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.hql;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlTest extends DbTestCase {
+
+  public void testStateChoiceAccept() {
+    deployJpdlResource("org/jbpm/examples/hql/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("Hql");
+    String executionId = execution.getId();
+    
+    Set<String> variableNames = executionService.getVariableNames(executionId);
+    Map<String, Object> variables = executionService.getVariables(executionId, variableNames);
+
+    Map<String, Object> expectedVariables = new HashMap<String, Object>();
+    List<String> nodeNames = new ArrayList<String>();
+    nodeNames.add("get process names");
+    nodeNames.add("count nodes");
+    expectedVariables.put("nodes with o", nodeNames);
+
+    expectedVariables.put("nodes", new Long(4));
+
+    assertEquals(expectedVariables, variables);
+  }
+}

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/hql/process.jpdl.xml	2008-12-14 19:09:58 UTC (rev 3381)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Hql">
+
+  <start>
+    <flow to="get process names" />
+  </start>
+
+  <hql name="get process names"
+       var="nodes with o">
+    <query>
+      select node.name
+      from org.jbpm.pvm.internal.model.NodeImpl as node
+      where node.name like :nodeName
+    </query>
+    <parameters>
+      <string name="nodeName" value="%o%" />
+    </parameters>
+    <flow to="count nodes" />
+  </hql>
+  
+  <hql name="count nodes"
+       var="nodes"
+       unique="true">
+    <query>
+      select count(*)
+      from org.jbpm.pvm.internal.model.NodeImpl
+    </query>
+    <flow to="wait" />
+  </hql>
+
+  <state name="wait" />
+
+</process>




More information about the jbpm-commits mailing list