[jbpm-commits] JBoss JBPM SVN: r4841 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/task and 12 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue May 19 05:08:49 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-05-19 05:08:49 -0400 (Tue, 19 May 2009)
New Revision: 4841

Added:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java
Removed:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCandidatesTest.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskService.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java
   jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompleteTaskCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
   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/query/ProcessInstanceQueryImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
Log:
JBPM-2221 improved matching of outcome with outgoing transitions and added test case

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -42,6 +42,6 @@
 
   ProcessInstanceQuery page(int firstResult, int maxResults);
 
-  List<Execution> list();
-  Execution uniqueResult();
+  List<ProcessInstance> list();
+  ProcessInstance uniqueResult();
 }

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskService.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskService.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -168,6 +168,7 @@
   /** retrieves a map of variables */
   Map<String, Object> getVariables(long taskDbid, Set<String> variableNames);
   
-  /** the set of possible valid outcomes for this task */ 
+  /** the set of possible valid outcomes for this task.
+   * An empty set means that any value is possible. */ 
   // Set<String> getOutcomes(long taskDbid);
 }

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -30,6 +30,9 @@
  */
 public interface Task extends Serializable {
   
+  public static final String STATE_OPEN = "open";
+  public static final String STATE_COMPLETED = "completed";
+  public static final String STATE_SUSPENDED = "suspended";
   long getDbid();
 
   String getName();

Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -32,6 +32,7 @@
 import org.jbpm.api.ExecutionService;
 import org.jbpm.api.ProcessDefinition;
 import org.jbpm.api.ProcessDefinitionQuery;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.ProcessInstanceQuery;
 import org.jbpm.api.RepositoryService;
 import org.jbpm.api.env.Environment;
@@ -125,9 +126,9 @@
       ProcessInstanceQuery query = execService.createProcessInstanceQuery();
       query.processDefinitionId(String.valueOf(procDefId));
 
-      List<Execution> executions = query.list();
+      List<ProcessInstance> processInstances = query.list();
 
-      List<ProcessInstanceRef> results = adoptTopLevelExecutions(executions);
+      List<ProcessInstanceRef> results = adoptProcessInstances(processInstances);
 
       return results;
     }
@@ -137,7 +138,7 @@
     }
   }
 
-  private List<ProcessInstanceRef> adoptTopLevelExecutions(List<Execution> executions)
+  private List<ProcessInstanceRef> adoptProcessInstances(List<ProcessInstance> processInstances)
   {
     Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
 
@@ -145,18 +146,18 @@
     {
 
       List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
-      for(Execution exec : executions)
+      for(ProcessInstance processInstance : processInstances)
       {
-        if(exec.isEnded())
+        if(processInstance.isEnded())
         {
-          System.out.println("*** JBPM-2055: Execution ("+exec.getId()+") is already ended. " +
+          System.out.println("*** JBPM-2055: Execution ("+processInstance.getId()+") is already ended. " +
               "Should not show up in query");
           continue;
         }
 
-        if(exec.isProcessInstance()) // parent execution
+        if(processInstance.isProcessInstance()) // parent execution
         {
-          results.add( ModelAdaptor.adoptExecution((OpenExecution)exec) );
+          results.add( ModelAdaptor.adoptExecution((OpenExecution)processInstance) );
         }
       }
       return results;
@@ -177,12 +178,12 @@
       ExecutionService execService = this.processEngine.getExecutionService();
       ProcessInstanceQuery query = execService.createProcessInstanceQuery();
       query.processInstanceId(instanceId);
-      List<Execution> executions = query.list();
+      List<ProcessInstance> processInstances = query.list();
 
-      if(executions.size()>1 || executions.isEmpty())
-        throw new IllegalStateException("No precise match for instanceId " + instanceId +". Num results "+executions);
+      if(processInstances.size()>1 || processInstances.isEmpty())
+        throw new IllegalStateException("No precise match for instanceId " + instanceId +". Num results "+processInstances);
 
-      return ModelAdaptor.adoptExecution( (OpenExecution)executions.get(0));
+      return ModelAdaptor.adoptExecution( (OpenExecution)processInstances.get(0));
     }
     finally
     {

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -29,8 +29,10 @@
 import org.jbpm.api.model.Activity;
 import org.jbpm.api.model.Transition;
 import org.jbpm.api.session.TaskDbSession;
+import org.jbpm.api.task.Task;
 import org.jbpm.api.task.TaskHandler;
 import org.jbpm.jpdl.internal.model.JpdlExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
@@ -75,17 +77,28 @@
     
     Transition transition = null;
     List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
-    if (outgoingTransitions!=null) {
-      if (outgoingTransitions.size()==1) {
-        transition = outgoingTransitions.get(0);
-      } else {
-        transition = activity.findOutgoingTransition(signalName);
+    if ( (outgoingTransitions!=null)
+         && (!outgoingTransitions.isEmpty())
+       ) {
+      transition = activity.findOutgoingTransition(signalName);
+      if (transition==null) {
+        if (Task.STATE_COMPLETED.equals(signalName)) {
+          if (outgoingTransitions.size()==1) {
+            transition = outgoingTransitions.get(0);
+          } else {
+            transition = activity.getDefaultOutgoingTransition();
+          }
+        } else {
+          // if a user specified outcome was provided and it doesn't
+          // match with an outgoing transition name, then the process 
+          // instance is suspended.  parked for admin intervention.
+          ((ExecutionImpl)execution.getProcessInstance()).suspend();
+        }
       }
+      if (transition!=null) {
+        execution.take(transition);
+      }
     }
-    
-    if (transition!=null) {
-      execution.take(transition);
-    }
   }
 
   public TaskDefinitionImpl getTaskDefinition() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompleteTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompleteTaskCmd.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CompleteTaskCmd.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -43,7 +43,11 @@
   public Void execute(Environment environment) throws Exception {
     TaskDbSession taskDbession = environment.get(TaskDbSession.class);
     TaskImpl task = (TaskImpl) taskDbession.findTaskByDbid(taskDbid);
-    task.complete(outcome);
+    if (outcome==null) {
+      task.complete();
+    } else {
+      task.complete(outcome);
+    }
     taskDbession.delete(task);
     return null;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -35,6 +35,7 @@
 import org.jbpm.api.job.Message;
 import org.jbpm.api.job.Timer;
 import org.jbpm.api.session.PvmDbSession;
+import org.jbpm.api.task.Task;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
 import org.jbpm.pvm.internal.job.JobImpl;
@@ -284,7 +285,7 @@
       "select task " +
       "from "+TaskImpl.class.getName()+" as task " +
       "where task.execution = :execution " +
-      "  and task.state != '"+TaskImpl.STATE_SUSPENDED+"' "
+      "  and task.state != '"+Task.STATE_SUSPENDED+"' "
     );
     query.setEntity("execution", execution);
     List<TaskImpl> tasks = query.list();
@@ -299,7 +300,7 @@
       "select job " +
       "from "+JobImpl.class.getName()+" as job " +
       "where job.execution = :execution " +
-      "  and job.state = '"+TaskImpl.STATE_SUSPENDED+"' "
+      "  and job.state = '"+Task.STATE_SUSPENDED+"' "
     );
     query.setEntity("execution", execution);
     List<JobImpl> jobs = query.list();
@@ -312,7 +313,7 @@
       "select task " +
       "from "+TaskImpl.class.getName()+" as task " +
       "where task.execution = :execution " +
-      "  and task.state = '"+TaskImpl.STATE_SUSPENDED+"' "
+      "  and task.state = '"+Task.STATE_SUSPENDED+"' "
     );
     query.setEntity("execution", execution);
     List<TaskImpl> tasks = query.list();

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	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -862,6 +862,7 @@
   /** @see Execution#suspend() */
   public void suspend() {
     super.suspend();
+    this.propagation = Propagation.EXPLICIT;
     HibernatePvmDbSession hibernatePvmDbSession = Environment.getFromCurrent(HibernatePvmDbSession.class, false);
     if (hibernatePvmDbSession!=null) {
       hibernatePvmDbSession.cascadeExecutionSuspend(this);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -25,6 +25,7 @@
 
 import org.hibernate.Query;
 import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.ProcessInstanceQuery;
 import org.jbpm.api.cmd.CommandService;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -45,12 +46,12 @@
     super(commandService);
   }
 
-  public Execution uniqueResult() {
-    return (Execution)untypedUniqueResult();
+  public ProcessInstance uniqueResult() {
+    return (ProcessInstance)untypedUniqueResult();
   }
 
-  public List<Execution> list() {
-    return (List<Execution>) untypedList();
+  public List<ProcessInstance> list() {
+    return (List<ProcessInstance>) untypedList();
   }
 
   public String hql() {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -64,10 +64,6 @@
   
   private static final TaskHandler DEFAULT_TASK_HANDLER = new TaskHandler();
 
-  public static final String STATE_OPEN = "open"; 
-  public static final String STATE_COMPLETED = "completed"; 
-  public static final String STATE_SUSPENDED = "suspended"; 
-  
   protected String name;
   protected String description;
 
@@ -85,7 +81,7 @@
 
   protected int priority = Priority.NORMAL;
 
-  protected String state = STATE_OPEN;
+  protected String state = Task.STATE_OPEN;
 
   protected String taskDefinitionName;
   protected TaskDefinitionImpl taskDefinition;
@@ -193,7 +189,7 @@
   // completion ///////////////////////////////////////////////////////////////
 
   public void complete() {
-    complete(STATE_COMPLETED);
+    complete(Task.STATE_COMPLETED);
   }
 
   public void complete(String outcome) {
@@ -214,11 +210,11 @@
   // state ////////////////////////////////////////////////////////////////////
   
   public boolean isCompleted() {
-    if (STATE_COMPLETED.equals(state)) {
+    if (Task.STATE_COMPLETED.equals(state)) {
       return true;
     }
-    if ( (STATE_OPEN.equals(state))
-         || (STATE_SUSPENDED.equals(state))
+    if ( (Task.STATE_OPEN.equals(state))
+         || (Task.STATE_SUSPENDED.equals(state))
        ) {
       return false;
     }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -144,7 +144,7 @@
       }
     }
 
-    appendWhereClause("task.state != '"+TaskImpl.STATE_SUSPENDED+"' ", hql);
+    appendWhereClause("task.state != '"+Task.STATE_SUSPENDED+"' ", hql);
 
     if (assignee == UNASSIGNED) {
       appendWhereClause("task.assignee is null ", hql);

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -27,6 +27,7 @@
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.test.JbpmTestCase;
 
 
@@ -83,7 +84,7 @@
     executionService.startProcessInstanceByKey("fire");
     executionService.startProcessInstanceByKey("fire");
     
-    List<Execution> processInstances = executionService
+    List<ProcessInstance> processInstances = executionService
       .createProcessInstanceQuery()
       .list();
     
@@ -132,7 +133,7 @@
     assertEquals(6, processInstances.size());
   }
 
-  int countProcessInstancesFor(List<Execution> processInstances, String processDefinitionKey) {
+  int countProcessInstancesFor(List<ProcessInstance> processInstances, String processDefinitionKey) {
     int count = 0;
     for (Execution processInstance: processInstances) {
       if (processInstance.getProcessDefinitionId().startsWith(processDefinitionKey)) {

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.test.JbpmTestCase;
 
@@ -50,10 +51,10 @@
     String processInstanceId = execution.getId();
     executionService.endProcessInstance(processInstanceId, "cancel");
 
-    List<Execution> executions = executionService.createProcessInstanceQuery()
+    List<ProcessInstance> processInstances = executionService.createProcessInstanceQuery()
         .processInstanceId(processInstanceId)
         .list();
-    assertEquals(0, executions.size());
+    assertEquals(0, processInstances.size());
 
     HistoryProcessInstance historyProcessInstance = historyService.createHistoryProcessInstanceQuery()
       .processInstanceId(processInstanceId)

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -23,7 +23,7 @@
 
 import java.util.List;
 
-import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstanceQuery;
 import org.jbpm.test.JbpmTestCase;
@@ -66,11 +66,11 @@
     
     // also check that the ended process instances have been removed from the 
     // runtime database
-    List<Execution> executions = executionService
+    List<ProcessInstance> processInstances = executionService
       .createProcessInstanceQuery()
       .processDefinitionId("ICL-1")
       .list();
 
-    assertEquals(0, executions.size());
+    assertEquals(0, processInstances.size());
   }
 }

Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCandidatesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCandidatesTest.java	2009-05-19 08:31:00 UTC (rev 4840)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCandidatesTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -1,208 +0,0 @@
-/*
- * 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.task;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.JbpmException;
-import org.jbpm.api.task.Task;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskCandidatesTest extends JbpmTestCase {
-
-  public void testCommaSeparatedTaskCandidates() {
-    deployJpdlXmlString(
-      "<process name='TaskCandidates'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review' " +
-      "        candidate-users='johndoe, joesmoe'>" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    Execution execution = executionService.startProcessInstanceByKey("TaskCandidates");
-    String executionId = execution.getId();
-
-    // both johndoe and joesmoe will see the task in their *takable* task list 
-    List<Task> taskList = taskService.findTakableTasks("johndoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    Task task = taskList.get(0);
-    assertEquals("review", task.getName());
-    
-    taskList = taskService.findTakableTasks("joesmoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    task = taskList.get(0);
-    assertEquals("review", task.getName());
-
-    // johndoe and joesmoe will NOT see the task in their *assigned* task list 
-
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    taskList = taskService.findAssignedTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // lets assume that johndoe takes the task
-    taskService.takeTask(task.getDbid(), "johndoe");
-    
-    // johndoe's and joesmoe's takable task list is now empty  
-    taskList = taskService.findTakableTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    taskList = taskService.findTakableTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // johndoe's assigned task list has the task in it
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    task = taskList.get(0);
-    assertEquals("review", task.getName());
-    assertEquals("johndoe", task.getAssignee());
-    
-    // joesmoe will not see the task in the assigned task list
-    taskList = taskService.findAssignedTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // now johndoe completes the task
-    taskService.completeTask(task.getDbid());
-    
-    // verify that the task list is now empty
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    // verify that process moved to the next state
-    execution = executionService.findExecutionById(executionId);
-    assertEquals("wait", execution.getActivityName());
-  }
-
-  public void testTaskCandidatesExpression() {
-    deployJpdlXmlString(
-      "<process name='TaskCandidates'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review' " +
-      "        candidate-users='#{userone}, #{usertwo}'>" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    Map<String, Object> variables = new HashMap<String, Object>(); 
-    variables.put("userone", "johndoe");
-    variables.put("usertwo", "joesmoe");
-    Execution execution = executionService.startProcessInstanceByKey("TaskCandidates", variables);
-    String executionId = execution.getId();
-    
-    // both johndoe and joesmoe will see the task in their *takable* task list 
-    List<Task> taskList = taskService.findTakableTasks("johndoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    Task task = taskList.get(0);
-    assertEquals("review", task.getName());
-    
-    taskList = taskService.findTakableTasks("joesmoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    task = taskList.get(0);
-    assertEquals("review", task.getName());
-
-    // johndoe and joesmoe will NOT see the task in their *assigned* task list 
-
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    taskList = taskService.findAssignedTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // lets assume that johndoe takes the task
-    taskService.takeTask(task.getDbid(), "johndoe");
-    
-    // johndoe's and joesmoe's takable task list is now empty  
-    taskList = taskService.findTakableTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    taskList = taskService.findTakableTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // johndoe's assigned task list has the task in it
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals("Expected a single task being created", 1, taskList.size());
-    task = taskList.get(0);
-    assertEquals("review", task.getName());
-    assertEquals("johndoe", task.getAssignee());
-    
-    // joesmoe will not see the task in the assigned task list
-    taskList = taskService.findAssignedTasks("joesmoe");
-    assertEquals(0, taskList.size());
-
-    // now johndoe completes the task
-    taskService.completeTask(task.getDbid());
-    
-    // verify that the task list is now empty
-    taskList = taskService.findAssignedTasks("johndoe");
-    assertEquals(0, taskList.size());
-
-    // verify that process moved to the next state
-    execution = executionService.findExecutionById(executionId);
-    assertEquals("wait", execution.getActivityName());
-  }
-
-  public void testDoubleTake() {
-    deployJpdlXmlString(
-      "<process name='DoubleTake'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review' " +
-      "        candidate-users='johndoe, joesmoe'>" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    Execution execution = executionService.startProcessInstanceByKey("DoubleTake");
-    String executionId = execution.getId();
-    
-    // both johndoe and joesmoe will see the task in their *takable* task list 
-    long taskDbid = taskService.findTakableTasks("johndoe").get(0).getDbid();
-
-    taskService.takeTask(taskDbid, "johndoe");
-
-    try {
-      taskService.takeTask(taskDbid, "joesmoe");
-    } catch (JbpmException e) {
-      assertTextPresent("task already taken by johndoe", e.getMessage());
-    }
-  }
-}

Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java (from rev 4838, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskCandidatesTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -0,0 +1,208 @@
+/*
+ * 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.taskactivity;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskCandidatesTest extends JbpmTestCase {
+
+  public void testCommaSeparatedTaskCandidates() {
+    deployJpdlXmlString(
+      "<process name='TaskCandidates'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        candidate-users='johndoe, joesmoe'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    Execution execution = executionService.startProcessInstanceByKey("TaskCandidates");
+    String executionId = execution.getId();
+
+    // both johndoe and joesmoe will see the task in their *takable* task list 
+    List<Task> taskList = taskService.findTakableTasks("johndoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    Task task = taskList.get(0);
+    assertEquals("review", task.getName());
+    
+    taskList = taskService.findTakableTasks("joesmoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    task = taskList.get(0);
+    assertEquals("review", task.getName());
+
+    // johndoe and joesmoe will NOT see the task in their *assigned* task list 
+
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    taskList = taskService.findAssignedTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // lets assume that johndoe takes the task
+    taskService.takeTask(task.getDbid(), "johndoe");
+    
+    // johndoe's and joesmoe's takable task list is now empty  
+    taskList = taskService.findTakableTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    taskList = taskService.findTakableTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // johndoe's assigned task list has the task in it
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    task = taskList.get(0);
+    assertEquals("review", task.getName());
+    assertEquals("johndoe", task.getAssignee());
+    
+    // joesmoe will not see the task in the assigned task list
+    taskList = taskService.findAssignedTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // now johndoe completes the task
+    taskService.completeTask(task.getDbid());
+    
+    // verify that the task list is now empty
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    // verify that process moved to the next state
+    execution = executionService.findExecutionById(executionId);
+    assertEquals("wait", execution.getActivityName());
+  }
+
+  public void testTaskCandidatesExpression() {
+    deployJpdlXmlString(
+      "<process name='TaskCandidates'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        candidate-users='#{userone}, #{usertwo}'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    Map<String, Object> variables = new HashMap<String, Object>(); 
+    variables.put("userone", "johndoe");
+    variables.put("usertwo", "joesmoe");
+    Execution execution = executionService.startProcessInstanceByKey("TaskCandidates", variables);
+    String executionId = execution.getId();
+    
+    // both johndoe and joesmoe will see the task in their *takable* task list 
+    List<Task> taskList = taskService.findTakableTasks("johndoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    Task task = taskList.get(0);
+    assertEquals("review", task.getName());
+    
+    taskList = taskService.findTakableTasks("joesmoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    task = taskList.get(0);
+    assertEquals("review", task.getName());
+
+    // johndoe and joesmoe will NOT see the task in their *assigned* task list 
+
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    taskList = taskService.findAssignedTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // lets assume that johndoe takes the task
+    taskService.takeTask(task.getDbid(), "johndoe");
+    
+    // johndoe's and joesmoe's takable task list is now empty  
+    taskList = taskService.findTakableTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    taskList = taskService.findTakableTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // johndoe's assigned task list has the task in it
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals("Expected a single task being created", 1, taskList.size());
+    task = taskList.get(0);
+    assertEquals("review", task.getName());
+    assertEquals("johndoe", task.getAssignee());
+    
+    // joesmoe will not see the task in the assigned task list
+    taskList = taskService.findAssignedTasks("joesmoe");
+    assertEquals(0, taskList.size());
+
+    // now johndoe completes the task
+    taskService.completeTask(task.getDbid());
+    
+    // verify that the task list is now empty
+    taskList = taskService.findAssignedTasks("johndoe");
+    assertEquals(0, taskList.size());
+
+    // verify that process moved to the next state
+    execution = executionService.findExecutionById(executionId);
+    assertEquals("wait", execution.getActivityName());
+  }
+
+  public void testDoubleTake() {
+    deployJpdlXmlString(
+      "<process name='DoubleTake'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        candidate-users='johndoe, joesmoe'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    Execution execution = executionService.startProcessInstanceByKey("DoubleTake");
+    String executionId = execution.getId();
+    
+    // both johndoe and joesmoe will see the task in their *takable* task list 
+    long taskDbid = taskService.findTakableTasks("johndoe").get(0).getDbid();
+
+    taskService.takeTask(taskDbid, "johndoe");
+
+    try {
+      taskService.takeTask(taskDbid, "joesmoe");
+    } catch (JbpmException e) {
+      assertTextPresent("task already taken by johndoe", e.getMessage());
+    }
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java	2009-05-19 09:08:49 UTC (rev 4841)
@@ -0,0 +1,150 @@
+/*
+ * 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.taskactivity;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskOutcomesTest extends JbpmTestCase {
+
+  public void testTaskSingleUnnamedTransition() {
+    deployJpdlXmlString(
+      "<process name='UnnamedTransition'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        assignee='johndoe'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnnamedTransition");
+    
+    Task task = taskService
+      .createTaskQuery()
+      .assignee("johndoe")
+      .uniqueResult();
+    
+    taskService.completeTask(task.getDbid());
+    
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    
+    assertNotNull(processInstance.findActiveExecutionIn("wait"));
+  }
+
+  public void testTaskTakeSingleNamedTransition() {
+    deployJpdlXmlString(
+      "<process name='NamedTransition'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        assignee='johndoe'>" +
+      "    <transition name='theOneAndOnly' to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("NamedTransition");
+    
+    Task task = taskService
+      .createTaskQuery()
+      .assignee("johndoe")
+      .uniqueResult();
+    
+    taskService.completeTask(task.getDbid());
+    
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    
+    assertNotNull(processInstance.findActiveExecutionIn("wait"));
+  }
+
+  public void testTaskTakeSingleNamedTransitionWithMatchingOutcome() {
+    deployJpdlXmlString(
+      "<process name='MatchingOutdome'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        assignee='johndoe'>" +
+      "    <transition name='theOneAndOnly' to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("MatchingOutdome");
+    
+    Task task = taskService
+      .createTaskQuery()
+      .assignee("johndoe")
+      .uniqueResult();
+    
+    taskService.completeTask(task.getDbid(), "theOneAndOnly");
+    
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    
+    assertNotNull(processInstance.findActiveExecutionIn("wait"));
+  }
+
+  public void testTaskTakeSingleNamedTransitionWithUnmatchingOutcome() {
+    deployJpdlXmlString(
+      "<process name='UnmatchingOutcome'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        assignee='johndoe'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+    
+    Task task = taskService
+      .createTaskQuery()
+      .assignee("johndoe")
+      .uniqueResult();
+    
+    taskService.completeTask(task.getDbid(), "Refused");
+    
+    processInstance = executionService.
+      createProcessInstanceQuery()
+      .suspended()
+      .processInstanceId(processInstance.getId())
+      .uniqueResult();
+    
+    assertTrue(processInstance.isSuspended());
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the jbpm-commits mailing list