[jbpm-commits] JBoss JBPM SVN: r3674 - in jbpm4/trunk/modules: test-pojo/src/main/java/org/jbpm/test/activities and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 19 09:00:29 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-01-19 09:00:29 -0500 (Mon, 19 Jan 2009)
New Revision: 3674
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
Log:
migrations of process factory to process definition builder
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -25,6 +25,7 @@
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.model.ProcessFactory;
/**
* @author Tom Baeyens
@@ -109,4 +110,9 @@
node.setPreviousNeeded(true);
return this;
}
+
+ public ActivityBuilder scope() {
+ node.setLocalScope(true);
+ return this;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -36,8 +36,6 @@
*/
public abstract class CompositeBuilder {
- private static final Class<?>[] ACTIVITYBUILDER_PARAMTYPES = new Class<?>[]{CompositeBuilder.class, String.class};
-
protected CompositeElementImpl compositeElement;
public abstract ProcessDefinitionImpl endProcess();
@@ -52,8 +50,15 @@
return compositeElement.createEvent(eventName);
}
+ public CompositeBuilder variable(String name) {
+ return startVariable(name)
+ .endVariable();
+ }
+
public CompositeBuilder variable(String name, String type) {
- return startVariable(name, type).endVariable();
+ return startVariable(name)
+ .type(type)
+ .endVariable();
}
public TimerBuilder startTimer() {
@@ -64,8 +69,9 @@
return new TimerBuilder(this, eventName);
}
- public VariableBuilder startVariable(String name, String type) {
- return new VariableBuilder(this);
+ public VariableBuilder startVariable(String name) {
+ return new VariableBuilder(this)
+ .name(name);
}
public ActivityBuilder startActivity() {
@@ -114,8 +120,8 @@
return new EventBuilder(this, eventName);
}
- public ExceptionHandlerBuilder startExceptionHandler(Class<? extends Throwable> exceptionType) {
- return new ExceptionHandlerBuilder(this, exceptionType);
+ public CompositeExceptionHandlerBuilder startExceptionHandler(Class<? extends Throwable> exceptionType) {
+ return new CompositeExceptionHandlerBuilder(this, exceptionType);
}
public CompositeBuilder property(String name, String value) {
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -0,0 +1,64 @@
+/*
+ * 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.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CompositeExceptionHandlerBuilder extends ExceptionHandlerBuilder {
+
+ protected CompositeBuilder compositeBuilder;
+
+ public CompositeExceptionHandlerBuilder(CompositeBuilder compositeBuilder, Class<? extends Throwable> exceptionType) {
+ this.compositeBuilder = compositeBuilder;
+ exceptionHandler = compositeBuilder.compositeElement.createExceptionHandler();
+ exceptionClass(exceptionType);
+ }
+
+ public CompositeExceptionHandlerBuilder exceptionClass(Class<? extends Throwable> exceptionType) {
+ super.setExceptionClass(exceptionType);
+ return this;
+ }
+
+ public CompositeExceptionHandlerBuilder listener(EventListener eventListener) {
+ super.addListener(eventListener);
+ return this;
+ }
+
+ public CompositeExceptionHandlerBuilder listener(Descriptor descriptor) {
+ super.addListener(descriptor);
+ return this;
+ }
+
+ public CompositeExceptionHandlerBuilder listener(String expression) {
+ super.addListener(expression);
+ return this;
+ }
+
+ public CompositeBuilder endExceptionHandler() {
+ return compositeBuilder;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/CompositeExceptionHandlerBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -73,7 +73,11 @@
getEvent().addProperty(descriptor);
return this;
}
-
+
+ public EventExceptionHandlerBuilder startExceptionHandler(Class<? extends Throwable> exceptionType) {
+ return new EventExceptionHandlerBuilder(this, exceptionType);
+ }
+
public CompositeBuilder endEvent() {
return compositeBuilder;
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -0,0 +1,65 @@
+/*
+ * 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.pvm.internal.builder;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventExceptionHandlerBuilder extends ExceptionHandlerBuilder {
+
+ protected EventBuilder eventBuilder;
+
+ public EventExceptionHandlerBuilder(EventBuilder eventBuilder, Class<? extends Throwable> exceptionType) {
+ this.eventBuilder = eventBuilder;
+ exceptionHandler = eventBuilder.getEvent().createExceptionHandler();
+ exceptionClass(exceptionType);
+ }
+
+ public EventExceptionHandlerBuilder exceptionClass(Class<? extends Throwable> exceptionType) {
+ super.setExceptionClass(exceptionType);
+ return this;
+ }
+
+ public EventExceptionHandlerBuilder listener(EventListener eventListener) {
+ super.addListener(eventListener);
+ return this;
+ }
+
+ public EventExceptionHandlerBuilder listener(Descriptor descriptor) {
+ super.addListener(descriptor);
+ return this;
+ }
+
+ public EventExceptionHandlerBuilder listener(String expression) {
+ super.addListener(expression);
+ return this;
+ }
+
+ public EventBuilder endExceptionHandler() {
+ return eventBuilder;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/EventExceptionHandlerBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ExceptionHandlerBuilder.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -31,33 +31,23 @@
*/
public class ExceptionHandlerBuilder {
- protected CompositeBuilder compositeBuilder;
protected ExceptionHandlerImpl exceptionHandler;
- public ExceptionHandlerBuilder(CompositeBuilder compositeBuilder, Class<? extends Throwable> exceptionType) {
- this.compositeBuilder = compositeBuilder;
- exceptionHandler = compositeBuilder.compositeElement.createExceptionHandler();
+ protected void setExceptionClass(Class<? extends Throwable> exceptionType) {
exceptionHandler.setExceptionClassName(exceptionType.getName());
}
- public ExceptionHandlerBuilder listener(EventListener eventListener) {
+ protected void addListener(EventListener eventListener) {
exceptionHandler.createEventListenerReference(eventListener);
- return this;
}
- public ExceptionHandlerBuilder listener(Descriptor descriptor) {
+ protected void addListener(Descriptor descriptor) {
exceptionHandler.createEventListenerReference(descriptor);
- return this;
}
- public ExceptionHandlerBuilder listener(String expression) {
+ protected void addListener(String expression) {
exceptionHandler
.createEventListenerReference()
.setExpression(expression);
- return this;
}
-
- public CompositeBuilder endExceptionHandler() {
- return compositeBuilder;
- }
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -30,7 +30,7 @@
import org.jbpm.listener.EventListener;
import org.jbpm.listener.EventListenerExecution;
import org.jbpm.model.Event;
-import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.test.JbpmTestCase;
/**
@@ -65,16 +65,21 @@
public void testExceptionHandlerOnProcessDefinition() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .exceptionHandler(RuntimeException.class)
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startExceptionHandler(RuntimeException.class)
.listener(catcher)
- .exceptionHandlerEnd()
- .startActivity("initial").initial().behaviour(new WaitState())
+ .endExceptionHandler()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
.listener(new Batter())
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -87,16 +92,21 @@
public void testExceptionHandlerOnEvent() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
- .exceptionHandler(RuntimeException.class)
+ .startExceptionHandler(RuntimeException.class)
.listener(catcher)
- .exceptionHandlerEnd()
+ .endExceptionHandler()
.listener(new Batter())
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -109,16 +119,21 @@
public void testExceptionHandlerOnAction() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
.listener(new Batter())
- .exceptionHandler(RuntimeException.class)
- .listener(catcher)
- .exceptionHandlerEnd()
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
+ .startExceptionHandler(RuntimeException.class)
+ .listener(catcher)
+ .endExceptionHandler()
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -131,16 +146,21 @@
public void testExceptionHandlerOnOtherNode() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial",new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
.listener(new Batter())
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .exceptionHandler(RuntimeException.class)
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .startExceptionHandler(RuntimeException.class)
.listener(catcher)
- .exceptionHandlerEnd()
- .endProcess();
+ .endExceptionHandler()
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -156,17 +176,22 @@
public void testExceptionHandlerOnOtherEvent() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent("other")
- .exceptionHandler(RuntimeException.class)
+ .startExceptionHandler(RuntimeException.class)
.listener(catcher)
- .exceptionHandlerEnd()
+ .endExceptionHandler()
+ .endEvent()
.startEvent(Event.NODE_END)
.listener(new Batter())
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -186,43 +211,22 @@
}
}
- public void testExceptionHandlerOnOtherAction() {
- Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
- .startEvent(Event.NODE_END)
- .listener(new BehavedAction())
- .exceptionHandler(RuntimeException.class)
- .listener(catcher)
- .exceptionHandlerEnd()
- .listener(new Batter())
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- assertEquals("initial", execution.getNode().getName());
- try {
- execution.signal();
- fail("expected exception");
- } catch (RuntimeException e) {
- // OK
- }
- }
-
public void testUnmatchedExceptionHandlerOnAction() {
Catcher catcher = new Catcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
+ .startExceptionHandler(NullPointerException.class)
+ .listener(catcher)
+ .endExceptionHandler()
.listener(new Batter())
- .exceptionHandler(NullPointerException.class)
- .listener(catcher)
- .exceptionHandlerEnd()
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
@@ -246,17 +250,21 @@
public void testRethrowingExceptionHandler() {
RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("initial", new WaitState())
+ .initial()
+ .flow("end")
.startEvent(Event.NODE_END)
+ .startExceptionHandler(RuntimeException.class)
+ .listener(rethrowingCatcher)
+ .endExceptionHandler()
.listener(new Batter())
- .exceptionHandler(RuntimeException.class)
- .listener(rethrowingCatcher)
- .exceptionHandlerEnd()
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
-
+ .endEvent()
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
+ .endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
try {
@@ -266,60 +274,4 @@
assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
}
}
-
- public void testRethrowingExceptionHandlerCaughtByTheOuterExceptionHandler() {
-
- // just like in java, when an exception handler rethrows, the search
- // for a matching exception handler will continue in the outer scope
- // (=the surrounding process element)
-
- RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
- .startEvent(Event.NODE_END)
- .exceptionHandler(RuntimeException.class)
- .listener(new Catcher())
- .exceptionHandlerEnd()
- .listener(new Batter())
- .exceptionHandler(RuntimeException.class)
- .listener(rethrowingCatcher)
- .exceptionHandlerEnd()
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
-
- ClientExecution execution = processDefinition.startProcessInstance();
-
- assertEquals("initial", execution.getNode().getName());
- execution.signal();
- }
-
- public void testRethrowingExceptionHandlerIgnoredByTheSubsequentExceptionHandlerInTheSameScope() {
-
- // just like in java, subsequent exception handlers will be skipped when the
- // an exception handler rethrows
-
- RethrowingCatcher rethrowingCatcher = new RethrowingCatcher();
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("initial").initial().behaviour(new WaitState())
- .startEvent(Event.NODE_END)
- .listener(new Batter())
- .exceptionHandler(RuntimeException.class)
- .listener(rethrowingCatcher)
- .exceptionHandlerEnd()
- .exceptionHandler(RuntimeException.class)
- .listener(new Catcher())
- .exceptionHandlerEnd()
- .flow().to("end")
- .startActivity("end").behaviour(new WaitState())
- .endProcess();
-
- ClientExecution execution = processDefinition.startProcessInstance();
- try {
- execution.signal();
- fail("expected exception");
- } catch (RuntimeException e) {
- assertTextPresent("greetz from the retrhowing catcher", e.getMessage());
- }
- }
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -30,6 +30,7 @@
import org.jbpm.activity.ExternalActivity;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.test.JbpmTestCase;
@@ -77,12 +78,16 @@
}
public void testBasicState() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
- .startActivity("b").behaviour(new WaitState())
- .flow().to("c")
- .startActivity("c").behaviour(new AutomaticActivity())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", new WaitState())
+ .flow("c")
+ .endActivity()
+ .startActivity("c", new AutomaticActivity())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
@@ -99,13 +104,17 @@
}
public void testSignalOnInactiveExecution() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
- .startActivity("b").behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", new WaitState())
.scope()
- .flow().to("c")
- .startActivity("c").behaviour(new AutomaticActivity())
+ .flow("c")
+ .endActivity()
+ .startActivity("c", new AutomaticActivity())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
@@ -123,12 +132,16 @@
}
public void testCustomEndState() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
- .startActivity("b").behaviour(new WaitState())
- .flow().to("c")
- .startActivity("c").behaviour(new AutomaticActivity())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", new WaitState())
+ .flow("c")
+ .endActivity()
+ .startActivity("c", new AutomaticActivity())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
@@ -147,12 +160,17 @@
}
public void testInvalidCustomStates() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
- .startActivity("b").behaviour(new WaitState())
- .flow().to("c")
- .startActivity("c").behaviour(new AutomaticActivity())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", new WaitState())
+ .flow("c")
+ .endActivity()
+ .startActivity("c", new AutomaticActivity())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -29,6 +29,7 @@
import org.jbpm.activity.ExternalActivity;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.model.ProcessFactory;
@@ -58,14 +59,20 @@
}
public static ClientProcessDefinition createCreditProcess() {
- return ProcessFactory.startProcess()
- .startActivity("creditRate?").initial().behaviour(new ExternalDecision())
- .flow("good").to("priority delivery")
- .flow("average").to("bulk delivery")
- .flow("bad").to("payment upfront")
- .startActivity("priority delivery").behaviour(new WaitState())
- .startActivity("bulk delivery").behaviour(new WaitState())
- .startActivity("payment upfront").behaviour(new WaitState())
+ return ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("creditRate?", new ExternalDecision())
+ .initial()
+ .flow("priority delivery", "good")
+ .flow("bulk delivery", "average")
+ .flow("payment upfront", "bad")
+ .endActivity()
+ .startActivity("priority delivery", new WaitState())
+ .endActivity()
+ .startActivity("bulk delivery", new WaitState())
+ .endActivity()
+ .startActivity("payment upfront", new WaitState())
+ .endActivity()
.endProcess();
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -34,6 +34,7 @@
import org.jbpm.listener.EventListenerExecution;
import org.jbpm.model.Node;
import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.test.JbpmTestCase;
@@ -73,12 +74,17 @@
List<String> recordedEvents = new ArrayList<String>();
FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(functionalActivity)
- .flow().to("b")
- .startActivity("b").behaviour(functionalActivity)
- .flow().to("c")
- .startActivity("c").behaviour(functionalActivity)
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("a", functionalActivity)
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", functionalActivity)
+ .flow("c")
+ .endActivity()
+ .startActivity("c", functionalActivity)
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
@@ -109,11 +115,16 @@
List<String> recordedEvents = new ArrayList<String>();
FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .startFlow("b")
.listener(functionalActivity)
- .startActivity("b").behaviour(new AutomaticActivity())
+ .endFlow()
+ .endActivity()
+ .startActivity("b", new AutomaticActivity())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
@@ -139,10 +150,13 @@
List<String> recordedEvents = new ArrayList<String>();
FunctionalActivity functionalActivity = new FunctionalActivity(recordedEvents);
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .compositeNode("a").initial().behaviour(new Composite())
- .startActivity().behaviour(functionalActivity)
- .compositeEnd()
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("a", new Composite())
+ .initial()
+ .startActivity(functionalActivity)
+ .endActivity()
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -9,6 +9,7 @@
import org.jbpm.activity.ExternalActivity;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.test.JbpmTestCase;
@@ -84,13 +85,18 @@
public void testWhile() {
int loops = 20;
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("for").initial().behaviour(new For(loops))
- .flow("loop").to("recorder")
- .flow("done").to("end")
- .startActivity("recorder").behaviour(new Recorder())
- .flow().to("for")
- .startActivity("end").behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("for", new For(loops))
+ .initial()
+ .flow("recorder", "loop")
+ .flow("end", "done")
+ .endActivity()
+ .startActivity("recorder", new Recorder())
+ .flow("for")
+ .endActivity()
+ .startActivity("end", new WaitState())
+ .endActivity()
.endProcess();
ClientExecution execution = processDefinition.startProcessInstance();
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -29,6 +29,7 @@
import org.jbpm.activity.ExternalActivity;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.test.JbpmTestCase;
@@ -58,13 +59,18 @@
}
public void testInactivationWhenCreatingNestedExecution() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .startActivity("a").initial().behaviour(new AutomaticActivity())
- .flow().to("b")
- .startActivity("b").behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startActivity("a", new AutomaticActivity())
+ .initial()
+ .flow("b")
+ .endActivity()
+ .startActivity("b", new WaitState())
.scope()
- .flow().to("c")
- .startActivity("c").behaviour(new WaitState())
+ .flow("c")
+ .endActivity()
+ .startActivity("c", new WaitState())
+ .endActivity()
.endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-01-19 13:14:53 UTC (rev 3673)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-01-19 14:00:29 UTC (rev 3674)
@@ -30,7 +30,8 @@
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.model.Node;
import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
import org.jbpm.test.JbpmTestCase;
@@ -60,9 +61,12 @@
}
public void testProcessInstanceVariableDeclaration() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
.variable("flight")
- .startActivity("a").initial().behaviour(new WaitState())
+ .startActivity("a", new WaitState())
+ .initial()
+ .endActivity()
.endProcess();
ClientExecution processInstance = processDefinition.startProcessInstance();
@@ -72,9 +76,13 @@
}
public void testProcessInstanceVariableDeclarationWithInitialValue() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .variable("flight", "B52")
- .startActivity("a").initial().behaviour(new WaitState())
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("B52"))
+ .endVariable()
+ .startActivity("a", new WaitState())
+ .initial()
+ .endActivity()
.endProcess();
ClientExecution processInstance = processDefinition.startProcessInstance();
@@ -84,20 +92,35 @@
}
public void testNestedScopeDeclarations() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .variable("flight", "B52")
- .compositeNode("outer").behaviour(new Composite())
- .variable("duration", "22 minutes")
- .compositeNode("middle").behaviour(new Composite())
- .variable("altitude", "31000 ft")
- .compositeNode("inner").behaviour(new Composite())
- .variable("passengers", "52")
- .compositeNode("start").initial().behaviour(new WaitState())
- .variable("fuel", "kerosine")
- .compositeEnd()
- .compositeEnd()
- .compositeEnd()
- .compositeEnd()
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("B52"))
+ .endVariable()
+ .startActivity("outer", new Composite())
+ .scope()
+ .startVariable("duration")
+ .initialValue(new StringDescriptor("22 minutes"))
+ .endVariable()
+ .startActivity("middle", new Composite())
+ .scope()
+ .startVariable("altitude")
+ .initialValue(new StringDescriptor("31000 ft"))
+ .endVariable()
+ .startActivity("inner", new Composite())
+ .scope()
+ .startVariable("passengers")
+ .initialValue(new StringDescriptor("52"))
+ .endVariable()
+ .startActivity("start", new WaitState())
+ .initial()
+ .scope()
+ .startVariable("fuel")
+ .initialValue(new StringDescriptor("kerosine"))
+ .endVariable()
+ .endActivity()
+ .endActivity()
+ .endActivity()
+ .endActivity()
.endProcess();
Map<String, Object> expectedVariables = new HashMap<String, Object>();
@@ -125,13 +148,24 @@
}
public void testHiddenVariable() {
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .variable("flight", "B52")
- .compositeNode("c").behaviour(new Composite())
- .variable("flight", "U2")
- .startActivity("i").initial().behaviour(new WaitState())
- .variable("flight", "C130")
- .compositeEnd()
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
+ .startProcess()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("B52"))
+ .endVariable()
+ .startActivity("c", new Composite())
+ .scope()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("U2"))
+ .endVariable()
+ .startActivity("i", new WaitState())
+ .scope()
+ .initial()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("C130"))
+ .endVariable()
+ .endActivity()
+ .endActivity()
.endProcess();
ClientExecution processInstance = processDefinition.startProcessInstance();
@@ -163,27 +197,48 @@
| | +---------------------------+ | +----------------------------+ |
+--------------------------------------------------------------------+
*/
- ClientProcessDefinition processDefinition = ProcessFactory.startProcess()
- .variable("flight", "B52")
- .compositeNode("outer").behaviour(new Composite())
- .variable("duration", "22 minutes")
- .compositeNode("left-middle").behaviour(new Composite())
- .variable("altitude", "31000 ft")
- .compositeNode("left-inner").behaviour(new Composite())
- .variable("passengers", "52")
- .compositeNode("left-start").initial().behaviour(new WaitState())
- .variable("fuel", "kerosine")
- .flow().to("right-inner")
- .compositeEnd()
- .compositeEnd()
- .compositeEnd()
- .compositeNode("right-middle").behaviour(new Composite())
- .variable("customer", "coca-cola")
- .compositeNode("right-inner").behaviour(new WaitState())
- .variable("date", "today")
- .compositeEnd()
- .compositeEnd()
- .compositeEnd()
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess()
+ .startVariable("flight")
+ .initialValue(new StringDescriptor("B52"))
+ .endVariable()
+ .startActivity("outer", new Composite())
+ .scope()
+ .startVariable("duration")
+ .initialValue(new StringDescriptor("22 minutes"))
+ .endVariable()
+ .startActivity("left-middle", new Composite())
+ .scope()
+ .startVariable("altitude")
+ .initialValue(new StringDescriptor("31000 ft"))
+ .endVariable()
+ .startActivity("left-inner", new Composite())
+ .scope()
+ .startVariable("passengers")
+ .initialValue(new StringDescriptor("52"))
+ .endVariable()
+ .startActivity("left-start", new WaitState())
+ .initial()
+ .scope()
+ .flow("right-inner")
+ .startVariable("fuel")
+ .initialValue(new StringDescriptor("kerosine"))
+ .endVariable()
+ .endActivity()
+ .endActivity()
+ .endActivity()
+ .startActivity("right-middle", new Composite())
+ .scope()
+ .startVariable("customer")
+ .initialValue(new StringDescriptor("coca-cola"))
+ .endVariable()
+ .startActivity("right-inner", new WaitState())
+ .scope()
+ .startVariable("date")
+ .initialValue(new StringDescriptor("today"))
+ .endVariable()
+ .endActivity()
+ .endActivity()
+ .endActivity()
.endProcess();
ClientExecution processInstance = processDefinition.startProcessInstance();
More information about the jbpm-commits
mailing list