[jbpm-commits] JBoss JBPM SVN: r6136 - jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/usertask.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jan 26 13:45:02 EST 2010
Author: jbarrez
Date: 2010-01-26 13:45:01 -0500 (Tue, 26 Jan 2010)
New Revision: 6136
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/usertask/UserTaskTest.java
Log:
User Task test wasn't committed yet
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/usertask/UserTaskTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/usertask/UserTaskTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/usertask/UserTaskTest.java 2010-01-26 18:45:01 UTC (rev 6136)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.bpmn.usertask;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class UserTaskTest extends JbpmTestCase {
+
+ private static String[] PROCESS_LOCATIONS =
+ {"org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_user.bpmn.xml",
+ "org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_group.bpmn.xml",
+ "org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_user.bpmn.xml",
+ "org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_variable.bpmn.xml"};
+
+ private static final String PETER = "peter";
+ private static final String MARY = "mary";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ for (String processLocation: PROCESS_LOCATIONS) {
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath(processLocation);
+ registerDeployment(deployment.deploy());
+ }
+
+ identityService.createGroup("management");
+
+ identityService.createUser(PETER, "Peter", "Pan");
+ identityService.createMembership(PETER, "management");
+
+ identityService.createUser(MARY, "Mary", "Littlelamb");
+ identityService.createMembership(MARY, "management");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ identityService.deleteGroup("management");
+ identityService.deleteUser(PETER);
+ identityService.deleteUser(MARY);
+ super.tearDown();
+ }
+
+ public void testPotentialOwnerUser() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("userTaskPotentialOwnerUser");
+ Task task = taskService.createTaskQuery().candidate(PETER).uniqueResult();
+ assertEquals("My User task", task.getName());
+ taskService.completeTask(task.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
+ public void testPotentialOwnerGroup() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("userTaskPotentialOwnerGroup");
+
+ // Peter and Mary are both part of management, so they both should see the task
+ List<Task> tasks = taskService.findGroupTasks(PETER);
+ assertEquals(1, tasks.size());
+ tasks = taskService.findGroupTasks(MARY);
+ assertEquals(1, tasks.size());
+
+ // Mary claims the task
+ Task task = tasks.get(0);
+ taskService.takeTask(task.getId(), MARY);
+ assertNull(taskService.createTaskQuery().candidate(PETER).uniqueResult());
+
+ taskService.completeTask(task.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
+ public void testHumanPerformerUser() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("userTaskHumanPerformerUser");
+ Task task = taskService.findPersonalTasks(MARY).get(0);
+ assertNotNull(task);
+ taskService.completeTask(task.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
+ public void testHumanPerformerVariableExpression() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("user", PETER);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("userTaskHumanPerformerVariable", variables);
+ Task task = taskService.createTaskQuery().assignee(PETER).uniqueResult();
+ assertNotNull(task);
+ assertNull(taskService.createTaskQuery().assignee(MARY).uniqueResult());
+ taskService.completeTask(task.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
+
+}
More information about the jbpm-commits
mailing list