提交 cdf63fb9 编写于 作者: M meyerd

ACT-1072 improving AtomicOpertaionAcivityEnd such that it ends the process...

ACT-1072 improving AtomicOpertaionAcivityEnd such that it ends the process instance if we end a scope under the process definition with no outgoing sequence flows
上级 b8410776
...@@ -74,9 +74,18 @@ public class AtomicOperationActivityEnd extends AbstractEventAtomicOperation { ...@@ -74,9 +74,18 @@ public class AtomicOperationActivityEnd extends AbstractEventAtomicOperation {
// default destroy scope behavior // default destroy scope behavior
InterpretableExecution parentScopeExecution = (InterpretableExecution) execution.getParent(); InterpretableExecution parentScopeExecution = (InterpretableExecution) execution.getParent();
execution.destroy(); execution.destroy();
execution.remove(); execution.remove();
parentScopeExecution.setActivity(parentActivity); // if we are a scope under the process instance
parentScopeExecution.performOperation(ACTIVITY_END); // and have no outgoing transitions: end the process instance here
if(activity.getParent() == activity.getProcessDefinition()
&& activity.getOutgoingTransitions().isEmpty()) {
parentScopeExecution.setActivity(activity);
// we call end() because it sets isEnded on the execution
parentScopeExecution.end();
} else {
parentScopeExecution.setActivity(parentActivity);
parentScopeExecution.performOperation(ACTIVITY_END);
}
} }
} else { // execution.isConcurrent() && !execution.isScope() } else { // execution.isConcurrent() && !execution.isScope()
......
...@@ -340,7 +340,7 @@ public class SubProcessTest extends PluggableActivitiTestCase { ...@@ -340,7 +340,7 @@ public class SubProcessTest extends PluggableActivitiTestCase {
* @see http://jira.codehaus.org/browse/ACT-1072 * @see http://jira.codehaus.org/browse/ACT-1072
*/ */
@Deployment @Deployment
public void FAILING_testSimpleSubProcessWithoutEndEvent() { public void testSimpleSubProcessWithoutEndEvent() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testSimpleSubProcessWithoutEndEvent"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testSimpleSubProcessWithoutEndEvent");
assertProcessEnded(pi.getId()); assertProcessEnded(pi.getId());
} }
...@@ -349,7 +349,7 @@ public class SubProcessTest extends PluggableActivitiTestCase { ...@@ -349,7 +349,7 @@ public class SubProcessTest extends PluggableActivitiTestCase {
* @see http://jira.codehaus.org/browse/ACT-1072 * @see http://jira.codehaus.org/browse/ACT-1072
*/ */
@Deployment @Deployment
public void FAILING_testNestedSubProcessesWithoutEndEvents() { public void testNestedSubProcessesWithoutEndEvents() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testNestedSubProcessesWithoutEndEvents"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testNestedSubProcessesWithoutEndEvents");
assertProcessEnded(pi.getId()); assertProcessEnded(pi.getId());
} }
......
...@@ -249,14 +249,44 @@ public class PvmEmbeddedSubProcessTest extends PvmTestCase { ...@@ -249,14 +249,44 @@ public class PvmEmbeddedSubProcessTest extends PvmTestCase {
assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds()); assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
} }
/**
* +------------------------------+
* | embedded subprocess |
* +-----+ | +-----------+ |
* |start|-->| |startInside| |
* +-----+ | +-----------+ |
* +------------------------------+
*/
public void testEmbeddedSubProcessWithoutEndEvents() {
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
.createActivity("start")
.initial()
.behavior(new Automatic())
.transition("embeddedsubprocess")
.endActivity()
.createActivity("embeddedsubprocess")
.scope()
.behavior(new EmbeddedSubProcess())
.createActivity("startInside")
.behavior(new Automatic())
.endActivity()
.endActivity()
.buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
assertTrue(processInstance.isEnded());
}
/** /**
* +-------------------------------------------------------+ * +-------------------------------------------------------+
* | embedded subprocess | * | embedded subprocess |
* | +--------------------------------+ | * | +--------------------------------+ |
* | | nested embedded subprocess | | * | | nested embedded subprocess | |
* +-----+ | +-----------+ | +-----------+ | | +---+ * +-----+ | +-----------+ | +-----------+ | |
* |start|-->| |startInside|--> | |startInside| | |-->|end| * |start|-->| |startInside|--> | |startInside| | |
* +-----+ | +-----------+ | +-----------+ | | +---+ * +-----+ | +-----------+ | +-----------+ | |
* | +--------------------------------+ | * | +--------------------------------+ |
* | | * | |
* +-------------------------------------------------------+ * +-------------------------------------------------------+
...@@ -282,20 +312,48 @@ public class PvmEmbeddedSubProcessTest extends PvmTestCase { ...@@ -282,20 +312,48 @@ public class PvmEmbeddedSubProcessTest extends PvmTestCase {
.behavior(new Automatic()) .behavior(new Automatic())
.endActivity() .endActivity()
.endActivity() .endActivity()
.transition("end") .endActivity()
.endActivity() .buildProcessDefinition();
.createActivity("end")
.behavior(new WaitState()) PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
assertTrue(processInstance.isEnded());
}
/**
* +------------------------------+
* | embedded subprocess |
* +-----+ | +-----------+ +---------+ |
* |start|-->| |startInside|-->|endInside| |
* +-----+ | +-----------+ +---------+ |
* +------------------------------+
*/
public void testEmbeddedSubProcessNoEnd() {
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
.createActivity("start")
.initial()
.behavior(new Automatic())
.transition("embeddedsubprocess")
.endActivity() .endActivity()
.createActivity("embeddedsubprocess")
.scope()
.behavior(new EmbeddedSubProcess())
.createActivity("startInside")
.behavior(new Automatic())
.transition("endInside")
.endActivity()
.createActivity("endInside")
.behavior(new End())
.endActivity()
.endActivity()
.buildProcessDefinition(); .buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance(); PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start(); processInstance.start();
List<String> expectedActiveActivityIds = new ArrayList<String>(); assertTrue(processInstance.isEnded());
expectedActiveActivityIds.add("end");
assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册