[jbpm-commits] JBoss JBPM SVN: r6382 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/model and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun May 30 14:53:45 EDT 2010


Author: swiderski.maciej
Date: 2010-05-30 14:53:44 -0400 (Sun, 30 May 2010)
New Revision: 6382

Added:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessSignalTest.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
JBPM-2874: exposed subProcessInstance via Execution interface and ensure that signal cannot be mode on process instance that has  active subprocess + test case

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java	2010-05-28 06:19:37 UTC (rev 6381)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java	2010-05-30 18:53:44 UTC (rev 6382)
@@ -184,6 +184,12 @@
    * structure</a>.  Null will be returned in case this execution itself is the 
    * main execution path.  */
   Execution getProcessInstance();
+  
+  /**
+   * the sub path of execution in the <a href="package-summary.html#basicexecutionstructure">execution 
+   * structure</a>. Null will be returned in case there is no sub process execution. 
+   */
+  Execution getSubProcessInstance();
 
   /** the parent execution in the <a href="package-summary.html#basicexecutionstructure">execution 
    * structure</a>.  Null will be returned in case this execution itself is the 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-05-28 06:19:37 UTC (rev 6381)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-05-30 18:53:44 UTC (rev 6382)
@@ -1069,6 +1069,9 @@
   protected void checkActive() {
     if (!isActive()) {
       throw new JbpmException(toString()+" is not active: "+state);
+    } else if (this.subProcessInstance != null && !Execution.STATE_ENDED.equals(this.subProcessInstance.getState())) {
+      throw new JbpmException(toString() + " has running subprocess: " 
+              + this.subProcessInstance.toString() + " in state " + this.subProcessInstance.getState());
     }
   }
   

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessSignalTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessSignalTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessSignalTest.java	2010-05-30 18:53:44 UTC (rev 6382)
@@ -0,0 +1,125 @@
+/*
+ * 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.test.activity.subprocess;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Test case for signal of subprocess state activities.
+ * 
+ * @author Maciej Swiderski
+ */
+public class SubProcessSignalTest extends JbpmTestCase {
+  
+  
+  
+  private static final String SUB_PROCESS_WITH_WAIT_STATE =
+    "<process name='SubProcessReview'>" +
+    "  <start>" +
+    "    <transition to='wait'/>" +
+    "  </start>" +
+    "  <state name='wait'>" +
+    "    <transition name='wait2' to='wait2'/>" +
+    "  </state>" +
+    "  <state name='wait2'>" +
+    "    <transition name='ok' to='ok'/>" +
+    "  </state>" +
+    "  <end name='ok' />" +
+    "</process>";  
+  
+  
+  
+  private static final String MAIN_PROCESS_SUB_EL_ID =
+    "<process name='mainProcess'>" +
+    "  <!
 start>" +
+    "    <transition to='review' />" +
+    "  </st!
 art>" +
+    "  <sub-process name='review' sub-process-id='#{dynamic_subprocess}'>" +
+    "    <transition name='ok' to='next step'/>" +
+    "    <transition name='nok' to='update'/>" +
+    "    <transition name='reject' to='close'/>" +
+    "  </sub-process>" +
+    "  <state name='next step'>" +
+    "    <transition name='close' to='close'/>" +
+    "  </state>" +
+    "  <state name='update'>" +
+    "    <transition name='close' to='close'/>" +
+    "  </state>" +
+    "  <end name='close'/>" +
+    "</process>"; 
+  
+  
+  public void testSubProcessWithStateFailure() {
+    deployJpdlXmlString(SUB_PROCESS_WITH_WAIT_STATE);
+    deployJpdlXmlString(MAIN_PROCESS_SUB_EL_ID);
+    
+    Map<String, String> vars = new HashMap<String, String>();
+    vars.put("dynamic_subprocess", "SubProcessReview-1");
+  
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess", vars);
+   
+    try {
+      processInstance = executionService.signalExecut!
 ionById(processInstance.getId());
+      
+      fail("Should fail since signal was made on a process with subprocess stil active");
+     } catch (Exception e) {
+       
+       //expected exception since we are signaling main process while sub process is not finished
+       assertTrue(e.getMessage().indexOf("has running subprocess") != -1);
+       
+       // clean up to let other tests execute
+       executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
+       executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
+       
+       processInstance = executionService.signalExecutionById(processInstance.getId());
+       
+    }
+    
+  }
+  
+  public void testSubProcessWithStateSuccess() {
+    deployJpdlXmlString(SUB_PROCESS_WITH_WAIT_STATE);
+    deployJpdlXmlString(MAIN_PROCESS_SUB_EL_ID);
+    
+    Map<String, String> vars = new HashMap<String, String>();
+    vars.put("dynamic_subprocess", "SubPr!
 ocessReview-1");
+   
+    ProcessInstance processInstance = e!
 xecution
Service.startProcessInstanceByKey("mainProcess", vars);
+    String subId = processInstance.getSubProcessInstance().getId();
+    executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
+    executionService.signalExecutionById(processInstance.getSubProcessInstance().getId());
+    
+    processInstance = executionService.signalExecutionById(processInstance.getId());
+    
+    assertProcessInstanceEnded(processInstance); 
+    ProcessInstance subProcessInstance = executionService.findProcessInstanceById(subId);
+    assertNull(subProcessInstance);
+    
+  }
+  
+}


More information about the jbpm-commits mailing list