Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- adding more tests for deadlines decorators

  • Loading branch information...
commit c2c80fccefb8b8a6c48c57f7066f9d504444466b 1 parent 5c5eff3
@Salaboy Salaboy authored
View
27 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/SubTasksStrategy.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jbpm.task;
+
+
+/**
+ *
+ *
+ */
+
+public enum SubTasksStrategy{
+ EndAllSubTasksOnParentEnd, EndAllSubTasksOnParentAbort
+}
View
56 jbpm-human-task/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/Task.java
@@ -73,9 +73,9 @@
@Embedded
private Deadlines deadlines;
-// @OneToMany(cascade = CascadeType.ALL)
-// @JoinColumn(name = "Task_Id", nullable = true)
-// private List<SubTasksStrategy> subTaskStrategies = Collections.emptyList();
+ @Enumerated(EnumType.STRING)
+ // Default Behaviour
+ private SubTasksStrategy subTaskStrategy = SubTasksStrategy.EndAllSubTasksOnParentEnd;
private String taskType;
@@ -95,6 +95,13 @@ public void writeExternal(ObjectOutput out) throws IOException {
CollectionUtils.writeI18NTextList( subjects, out );
CollectionUtils.writeI18NTextList( descriptions, out );
+ if (subTaskStrategy != null) {
+ out.writeBoolean(true);
+ out.writeUTF(subTaskStrategy.toString());
+ } else {
+ out.writeBoolean(false);
+ }
+
if ( peopleAssignments != null ) {
out.writeBoolean( true );
peopleAssignments.writeExternal( out );
@@ -123,11 +130,6 @@ public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean( false );
}
-// out.writeInt( subTaskStrategies.size() );
-// for( SubTasksStrategy strategy : subTaskStrategies ) {
-// out.writeUTF(strategy.getName());
-// strategy.writeExternal( out );
-// }
}
public void readExternal(ObjectInput in) throws IOException,
@@ -139,7 +141,11 @@ public void readExternal(ObjectInput in) throws IOException,
names = CollectionUtils.readI18NTextList( in );
subjects = CollectionUtils.readI18NTextList( in );
descriptions = CollectionUtils.readI18NTextList( in );
-
+
+ if (in.readBoolean()) {
+ subTaskStrategy = SubTasksStrategy.valueOf(in.readUTF());
+ }
+
if ( in.readBoolean() ) {
peopleAssignments = new PeopleAssignments();
peopleAssignments.readExternal( in );
@@ -160,16 +166,6 @@ public void readExternal(ObjectInput in) throws IOException,
deadlines.readExternal( in );
}
-// int size = in.readInt();
-// List<SubTasksStrategy> list = new ArrayList<SubTasksStrategy>(size);
-// for ( int i = 0; i < size; i++ ) {
-// String name = in.readUTF();
-// SubTasksStrategy strategy = SubTasksStrategyFactory.newStrategy(name) ;
-// strategy.readExternal( in );
-// list.add( strategy );
-// }
-// subTaskStrategies = list;
-
}
public Long getId() {
@@ -329,20 +325,12 @@ public boolean equals(Object obj) {
&& CollectionUtils.equals( subjects, other.subjects ));
}
-// /**
-// * @return the subTaskStrategies
-// */
-// public List<SubTasksStrategy> getSubTaskStrategies() {
-// return subTaskStrategies;
-// }
-//
-// /**
-// * @param subTaskStrategies the subTaskStrategies to set
-// */
-// public void setSubTaskStrategies(List<SubTasksStrategy> subTaskStrategies) {
-// this.subTaskStrategies = subTaskStrategies;
-// }
-//
-//
+ public SubTasksStrategy getSubTaskStrategy() {
+ return subTaskStrategy;
+ }
+
+ public void setSubTaskStrategy(SubTasksStrategy subTaskStrategy) {
+ this.subTaskStrategy = subTaskStrategy;
+ }
}
View
1  ...sk/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/deadlines/DeadlinesDecorator.java
@@ -117,6 +117,7 @@ public void exit(long taskId, String userId) {
public void fail(long taskId, String userId, Map<String, Object> faultData) {
instanceService.fail(taskId, userId, faultData);
+ clearDeadlines(taskId);
}
public void forward(long taskId, String userId, String targetEntityId) {
View
22 ...bpm-human-task-core-cdi/src/main/java/org/jbpm/task/deadlines/DeadlinesEventListener.java
@@ -1,22 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.jbpm.task.deadlines;
-
-import org.jbpm.task.Task;
-
-/**
- *
- */
-
-public interface DeadlinesEventListener {
- public void afterTaskAddedEvent(Task ti);
- public void afterTaskStartedEvent(Task ti);
- public void afterTaskSkippedEvent(Task ti);
- public void afterTaskStoppedEvent(Task ti);
- public void afterTaskCompletedEvent(Task ti);
- public void afterTaskFailedEvent(Task ti);
- public void afterTaskExitedEvent(Task ti);
-
-}
View
24 ...k/jbpm-human-task-core-cdi/src/main/java/org/jbpm/task/impl/TaskDeadlinesServiceImpl.java
@@ -55,12 +55,9 @@
protected List<Status> validStatuses = new ArrayList<Status>();
@Inject
private EntityManager em;
-
@Inject
private Event<NotificationEvent> notificationEvents;
-
-
-
+
public TaskDeadlinesServiceImpl() {
}
@@ -148,8 +145,7 @@ public void unschedule(long taskId) {
}
}
}
-
-
+
// public void executeEmailNotification(EmailNotification notification,
// Task task,
// Content content) {
@@ -177,7 +173,6 @@ public void unschedule(long taskId) {
// }
//
// Map<String, Object> doc = null;
-
// if ( content != null ) {
// Object objectFromBytes = null;
// try {
@@ -260,10 +255,8 @@ public void unschedule(long taskId) {
//
// handler.executeWorkItem( workItem,
// manager );
-
// }
// }
-
public class ScheduledTaskDeadline
implements
Callable {
@@ -287,12 +280,10 @@ public long getDeadlineId() {
}
public Object call() throws Exception {
- try {
- executeEscalatedDeadline(taskId,
- deadlineId);
- } catch (Exception e) {
- System.out.println("XXXX EX: " + e);
- }
+
+ executeEscalatedDeadline(taskId,
+ deadlineId);
+
return null;
}
@@ -326,7 +317,7 @@ public boolean equals(Object obj) {
return true;
}
}
-
+
// private void buildMapByLanguage(Map<String, List<User>> map,
// Group group) {
// for ( Iterator<OrganizationalEntity> it = userInfo.getMembersForGroup( group ); it.hasNext(); ) {
@@ -352,7 +343,6 @@ public boolean equals(Object obj) {
// }
// list.add( user );
// }
-
protected void setValidStatuses() {
validStatuses.add(Status.Created);
validStatuses.add(Status.Ready);
View
45 ...man-task-core-cdi/src/main/java/org/jbpm/task/impl/factories/SubTasksStrategyFactory.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jbpm.task.impl.factories;
+
+import org.jbpm.task.SubTasksStrategy;
+import org.jbpm.task.exception.IllegalTaskStateException;
+
+public class SubTasksStrategyFactory {
+
+ public SubTasksStrategyFactory() {
+
+ }
+
+ public static SubTasksStrategy newStrategy(String type){
+ if(type!= null && !type.equals("")){
+ if(type.equals("OnParentAbortAllSubTasksEnd")){
+ return SubTasksStrategy.EndAllSubTasksOnParentAbort;
+ }
+ if(type.equals("OnAllSubTasksEndParentEnd")){
+ return SubTasksStrategy.EndAllSubTasksOnParentEnd;
+ }
+ throw new IllegalTaskStateException("Unknown " + SubTasksStrategy.class.getSimpleName() + " type: " + type);
+ }
+
+ return null;
+ }
+
+
+
+
+}
View
8 ...-human-task/jbpm-human-task-core-cdi/src/test/filtered-resources/META-INF/persistence.xml
@@ -30,16 +30,12 @@
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
- <!--class>org.jbpm.task.SubTasksStrategy</class>
- <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
- <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class-->
+ <class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.User</class>
<!-- Event Classes -->
<class>org.jbpm.task.TaskEvent</class>
-
-
-
+
<properties>
<property name="hibernate.dialect" value="${maven.hibernate.dialect}" />
View
677 ...sk/jbpm-human-task-core-cdi/src/test/java/org/jbpm/task/TaskServiceDeadlinesBaseTest.java
@@ -18,8 +18,10 @@
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.inject.Inject;
@@ -44,7 +46,6 @@
@Inject
private NotificationListener notificationListener;
- private Properties conf;
@After
public void tearDown(){
@@ -56,9 +57,6 @@ public void tearDown(){
@Test
public void testDelayedEmailNotificationOnDeadline() throws Exception {
- //DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
- //WorkItemManager manager = new DefaultWorkItemManager(null);
- //notificationHandler.setManager(manager);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("now", new Date());
MockUserInfo userInfo = new MockUserInfo();
@@ -69,8 +67,6 @@ public void testDelayedEmailNotificationOnDeadline() throws Exception {
userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
taskService.setUserInfo(userInfo);
- //taskService.setEscalatedDeadlineHandler(notificationHandler);
-
Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
Task task = (Task) TaskFactory.evalTask(reader, vars);
@@ -106,6 +102,7 @@ public void testDelayedEmailNotificationOnDeadline() throws Exception {
// 1 email with two recipients should now exist
assertEquals(1, MockNotificationListener.getEventsRecieved().size());
assertEquals(2, MockNotificationListener.getEventsRecieved().get(0).getNotification().getRecipients().size());
+ //@TODO: validate events content
// List<String> list = new ArrayList<String>(2);
// list.add(getWiser().getMessages().get(0).getEnvelopeReceiver());
// list.add(getWiser().getMessages().get(1).getEnvelopeReceiver());
@@ -126,9 +123,6 @@ public void testDelayedEmailNotificationOnDeadline() throws Exception {
public void testDelayedEmailNotificationOnDeadlineContentSingleObject() throws Exception {
-// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-// WorkItemManager manager = new DefaultWorkItemManager(null);
-// notificationHandler.setManager(manager);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("now", new Date());
MockUserInfo userInfo = new MockUserInfo();
@@ -138,7 +132,6 @@ public void testDelayedEmailNotificationOnDeadlineContentSingleObject() throws E
userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
taskService.setUserInfo(userInfo);
-// taskService.setEscalatedDeadlineHandler(notificationHandler);
Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotificationContentSingleObject));
Task task = (Task) TaskFactory.evalTask(reader, vars);
@@ -169,6 +162,8 @@ public void testDelayedEmailNotificationOnDeadlineContentSingleObject() throws E
// 1 email with two recipients should now exist
assertEquals(1, MockNotificationListener.getEventsRecieved().size());
+
+ //@TODO: validate events content
// List<String> list = new ArrayList<String>(2);
// list.add(getWiser().getMessages().get(0).getEnvelopeReceiver());
// list.add(getWiser().getMessages().get(1).getEnvelopeReceiver());
@@ -185,352 +180,326 @@ public void testDelayedEmailNotificationOnDeadlineContentSingleObject() throws E
// assertEquals("darth@domain.com", ((InternetAddress) msg.getRecipients(RecipientType.TO)[1]).getAddress());
}
-// @Test
-// public void testDelayedEmailNotificationOnDeadlineTaskCompleted() throws Exception {
-//
-//// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-//// WorkItemManager manager = new DefaultWorkItemManager(null);
-//// notificationHandler.setManager(manager);
-//
-// Map<String, Object> vars = new HashMap<String, Object>();
-// vars.put("now", new Date());
-// MockUserInfo userInfo = new MockUserInfo();
-// userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
-// userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
-//
-// userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
-// userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
-// taskService.setUserInfo(userInfo);
-//
-//// taskService.setEscalatedDeadlineHandler(notificationHandler);
-//
-// Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
-// Task task = (Task) TaskFactory.evalTask(reader, vars);
-//
-// task.getTaskData().setSkipable(true);
-// PeopleAssignments assignments = new PeopleAssignments();
-// List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
-// ba.add(new User("Administrator"));
-// assignments.setBusinessAdministrators(ba);
-//
-// List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
-// po.add(new User("Administrator"));
-// assignments.setPotentialOwners(po);
-//
-// task.setPeopleAssignments(assignments);
-// taskService.addTask(task, new HashMap<String, Object>());
-// long taskId = task.getId();
-//
-// Content content = new Content();
-//
-// Map<String, String> params = fillMarshalSubjectAndBodyParams();
-// ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
-// content.setContent(marshalledObject.getContent());
-// taskService.addContent(taskId, content);
-// long contentId = content.getId();
-//
-// content = taskService.getContentById(contentId);
-// Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
-// checkContentSubjectAndBody(unmarshallObject);
-//
-// taskService.start(taskId, "Administrator");
-// taskService.complete(taskId, "Administrator", null);
-// // emails should not be set yet
-// assertEquals(0, getWiser().getMessages().size());
-// Thread.sleep(100);
-//
-// // nor yet
-// assertEquals(0, getWiser().getMessages().size());
-//
-// long time = 0;
-// while (getWiser().getMessages().size() != 2 && time < 15000) {
-// Thread.sleep(500);
-// time += 500;
-// }
-//
-// // no email should ne sent as task was completed before deadline was triggered
-// assertEquals(0, getWiser().getMessages().size());
-// task = taskService.getTaskById(taskId);
-// assertEquals(Status.Completed, task.getTaskData().getStatus());
-// assertEquals(0, task.getDeadlines().getStartDeadlines().size());
-// assertEquals(0, task.getDeadlines().getEndDeadlines().size());
-//
-//
-// }
-// @Test
-// public void testDelayedEmailNotificationOnDeadlineTaskFailed() throws Exception {
-//
-//
-//// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-//// WorkItemManager manager = new DefaultWorkItemManager(null);
-//// notificationHandler.setManager(manager);
-// Map<String, Object> vars = new HashMap<String, Object>();
-// vars.put("now", new Date());
-// MockUserInfo userInfo = new MockUserInfo();
-// userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
-// userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
-//
-// userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
-// userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
-// taskService.setUserInfo(userInfo);
-//
-//// taskService.setEscalatedDeadlineHandler(notificationHandler);
-//
-// Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
-// Task task = (Task) TaskFactory.evalTask(reader, vars);
-//
-// task.getTaskData().setSkipable(true);
-// PeopleAssignments assignments = new PeopleAssignments();
-// List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
-// ba.add(new User("Administrator"));
-// assignments.setBusinessAdministrators(ba);
-//
-// List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
-// po.add(new User("Administrator"));
-// assignments.setPotentialOwners(po);
-//
-// task.setPeopleAssignments(assignments);
-// taskService.addTask(task, new HashMap<String, Object>());
-// long taskId = task.getId();
-//
-// Content content = new Content();
-//
-// Map<String, String> params = fillMarshalSubjectAndBodyParams();
-// ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
-// content.setContent(marshalledObject.getContent());
-// taskService.addContent(taskId, content);
-// long contentId = content.getId();
-//
-// content = taskService.getContentById(contentId);
-// Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
-// checkContentSubjectAndBody(unmarshallObject);
-//
-// taskService.start(taskId, "Administrator");
-// taskService.fail(taskId, "Administrator", null);
-// // emails should not be set yet
-// assertEquals(0, getWiser().getMessages().size());
-// Thread.sleep(100);
-//
-// // nor yet
-// assertEquals(0, getWiser().getMessages().size());
-//
-// long time = 0;
-// while (getWiser().getMessages().size() != 2 && time < 15000) {
-// Thread.sleep(500);
-// time += 500;
-// }
-//
-// // no email should ne sent as task was completed before deadline was triggered
-// assertEquals(0, getWiser().getMessages().size());
-// task = taskService.getTaskById(taskId);
-// assertEquals(Status.Failed, task.getTaskData().getStatus());
-// assertEquals(0, task.getDeadlines().getStartDeadlines().size());
-// assertEquals(0, task.getDeadlines().getEndDeadlines().size());
-// }
-// @Test
-// public void testDelayedEmailNotificationOnDeadlineTaskSkipped() throws Exception {
-//
-//// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-//// WorkItemManager manager = new DefaultWorkItemManager(null);
-//// notificationHandler.setManager(manager);
-// Map<String, Object> vars = new HashMap<String, Object>();
-// vars.put("now", new Date());
-// MockUserInfo userInfo = new MockUserInfo();
-// userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
-// userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
-//
-// userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
-// userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
-// taskService.setUserInfo(userInfo);
-//
-//// taskService.setEscalatedDeadlineHandler(notificationHandler);
-//
-// Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
-// Task task = (Task) TaskFactory.evalTask(reader, vars);
-//
-// task.getTaskData().setSkipable(true);
-// PeopleAssignments assignments = new PeopleAssignments();
-// List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
-// ba.add(new User("Administrator"));
-// assignments.setBusinessAdministrators(ba);
-//
-// List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
-// po.add(new User("Administrator"));
-// assignments.setPotentialOwners(po);
-//
-// task.setPeopleAssignments(assignments);
-// taskService.addTask(task, new HashMap<String, Object>());
-// long taskId = task.getId();
-//
-// Content content = new Content();
-//
-// Map<String, String> params = fillMarshalSubjectAndBodyParams();
-// ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
-// content.setContent(marshalledObject.getContent());
-// taskService.addContent(taskId, content);
-// long contentId = content.getId();
-//
-// content = taskService.getContentById(contentId);
-// Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
-// checkContentSubjectAndBody(unmarshallObject);
-//
-// taskService.skip(taskId, "Administrator");
-// // emails should not be set yet
-// assertEquals(0, getWiser().getMessages().size());
-// Thread.sleep(100);
-//
-// // nor yet
-// assertEquals(0, getWiser().getMessages().size());
-//
-// long time = 0;
-// while (getWiser().getMessages().size() != 2 && time < 15000) {
-// Thread.sleep(500);
-// time += 500;
-// }
-//
-// // no email should ne sent as task was completed before deadline was triggered
-// assertEquals(0, getWiser().getMessages().size());
-// task = taskService.getTaskById(taskId);
-// assertEquals(Status.Obsolete, task.getTaskData().getStatus());
-// assertEquals(0, task.getDeadlines().getStartDeadlines().size());
-// assertEquals(0, task.getDeadlines().getEndDeadlines().size());
-// }
-// @Test
-// public void testDelayedEmailNotificationOnDeadlineTaskExited() throws Exception {
-//
-//
-//// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-//// WorkItemManager manager = new DefaultWorkItemManager(null);
-//// notificationHandler.setManager(manager);
-// Map<String, Object> vars = new HashMap<String, Object>();
-// vars.put("now", new Date());
-//
-// MockUserInfo userInfo = new MockUserInfo();
-// userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
-// userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
-//
-// userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
-// userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
-// taskService.setUserInfo(userInfo);
-//
-//// taskService.setEscalatedDeadlineHandler(notificationHandler);
-//
-// Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
-// Task task = (Task) TaskFactory.evalTask(reader, vars);
-//
-// task.getTaskData().setSkipable(true);
-// PeopleAssignments assignments = new PeopleAssignments();
-// List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
-// ba.add(new User("Administrator"));
-// assignments.setBusinessAdministrators(ba);
-//
-// List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
-// po.add(new User("Administrator"));
-// assignments.setPotentialOwners(po);
-//
-// task.setPeopleAssignments(assignments);
-// taskService.addTask(task, new HashMap<String, Object>());
-// long taskId = task.getId();
-//
-// Content content = new Content();
-//
-// Map<String, String> params = fillMarshalSubjectAndBodyParams();
-// ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
-// content.setContent(marshalledObject.getContent());
-// taskService.addContent(taskId, content);
-// long contentId = content.getId();
-//
-// content = taskService.getContentById(contentId);
-// Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
-// checkContentSubjectAndBody(unmarshallObject);
-//
-// taskService.exit(taskId, "Administrator");
-// // emails should not be set yet
-// assertEquals(0, getWiser().getMessages().size());
-// Thread.sleep(100);
-//
-// // nor yet
-// assertEquals(0, getWiser().getMessages().size());
-//
-// long time = 0;
-// while (getWiser().getMessages().size() != 2 && time < 15000) {
-// Thread.sleep(500);
-// time += 500;
-// }
-//
-// // no email should ne sent as task was completed before deadline was triggered
-// assertEquals(0, getWiser().getMessages().size());
-// task = taskService.getTaskById(taskId);
-// assertEquals(Status.Exited, task.getTaskData().getStatus());
-// assertEquals(0, task.getDeadlines().getStartDeadlines().size());
-// assertEquals(0, task.getDeadlines().getEndDeadlines().size());
-// }
-//
-// //TODO: this test is not working for the local implementation and needs to be fixed
-// public void FIXtestDelayedReassignmentOnDeadline() throws Exception {
-//
-//// DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf());
-//// WorkItemManager manager = new DefaultWorkItemManager(null);
-//// notificationHandler.setManager(manager);
-// Map<String, Object> vars = new HashMap<String, Object>();
-// vars.put("now", new Date());
-// MockUserInfo userInfo = new MockUserInfo();
-// userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
-// userInfo.getEmails().put(new User("Luke Cage"), "luke@domain.com");
-// userInfo.getEmails().put(new User("Bobba Fet"), "luke@domain.com");
-// userInfo.getEmails().put(new User("Jabba Hutt"), "luke@domain.com");
-//
-// userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
-// userInfo.getLanguages().put(new User("Luke Cage"), "en-UK");
-// userInfo.getLanguages().put(new User("Bobba Fet"), "en-UK");
-// userInfo.getLanguages().put(new User("Jabba Hutt"), "en-UK");
-// taskService.setUserInfo(userInfo);
-//
-//// taskService.setEscalatedDeadlineHandler(notificationHandler);
-//
-// Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithReassignment));
-// Task task = (Task) TaskFactory.evalTask(reader, vars);
-// taskService.addTask(task, new HashMap<String, Object>());
-// long taskId = task.getId();
-//
-// // Shouldn't have re-assigned yet
-// Thread.sleep(1000);
-//
-//
-// task = taskService.getTaskById(taskId);
-// List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners();
-// List<String> ids = new ArrayList<String>(potentialOwners.size());
-// for (OrganizationalEntity entity : potentialOwners) {
-// ids.add(entity.getId());
-// }
-// assertTrue(ids.contains("Tony Stark"));
-// assertTrue(ids.contains("Luke Cage"));
-//
-// // should have re-assigned by now
-// long time = 0;
-// while (getWiser().getMessages().size() != 2 && time < 15000) {
-// Thread.sleep(500);
-// time += 500;
-// }
-//
-// task = taskService.getTaskById(taskId);
-// assertEquals(Status.Ready, task.getTaskData().getStatus());
-// potentialOwners = task.getPeopleAssignments().getPotentialOwners();
-//
-// ids = new ArrayList<String>(potentialOwners.size());
-// for (OrganizationalEntity entity : potentialOwners) {
-// ids.add(entity.getId());
-// }
-// assertTrue(ids.contains("Bobba Fet"));
-// assertTrue(ids.contains("Jabba Hutt"));
-// }
-
- public void setConf(Properties conf) {
- this.conf = conf;
+ @Test
+ public void testDelayedEmailNotificationOnDeadlineTaskCompleted() throws Exception {
+
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("now", new Date());
+ MockUserInfo userInfo = new MockUserInfo();
+ userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
+ userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
+
+ userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
+ userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
+ taskService.setUserInfo(userInfo);
+
+ Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
+ Task task = (Task) TaskFactory.evalTask(reader, vars, false);
+
+ task.getTaskData().setSkipable(true);
+ PeopleAssignments assignments = new PeopleAssignments();
+ List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
+ ba.add(new User("Administrator"));
+ assignments.setBusinessAdministrators(ba);
+
+ List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
+ po.add(new User("Administrator"));
+ assignments.setPotentialOwners(po);
+
+ task.setPeopleAssignments(assignments);
+
+ TaskFactory.initializeTask(task);
+
+ taskService.addTask(task, new HashMap<String, Object>());
+ long taskId = task.getId();
+
+ Content content = new Content();
+
+ Map<String, String> params = fillMarshalSubjectAndBodyParams();
+ ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
+ content.setContent(marshalledObject.getContent());
+ taskService.addContent(taskId, content);
+ long contentId = content.getId();
+
+ content = taskService.getContentById(contentId);
+ Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
+ checkContentSubjectAndBody(unmarshallObject);
+
+ taskService.start(taskId, "Administrator");
+ taskService.complete(taskId, "Administrator", null);
+ // emails should not be set yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ Thread.sleep(100);
+
+ // nor yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+
+ long time = 0;
+ while (MockNotificationListener.getEventsRecieved().size() != 1 && time < 15000) {
+ Thread.sleep(500);
+ time += 500;
+ }
+
+ // no email should ne sent as task was completed before deadline was triggered
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ task = taskService.getTaskById(taskId);
+ assertEquals(Status.Completed, task.getTaskData().getStatus());
+ assertEquals(0, task.getDeadlines().getStartDeadlines().size());
+ assertEquals(0, task.getDeadlines().getEndDeadlines().size());
+
+
+ }
+ @Test
+ public void testDelayedEmailNotificationOnDeadlineTaskFailed() throws Exception {
+
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("now", new Date());
+ MockUserInfo userInfo = new MockUserInfo();
+ userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
+ userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
+
+ userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
+ userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
+ taskService.setUserInfo(userInfo);
+
+ Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
+ Task task = (Task) TaskFactory.evalTask(reader, vars, false);
+
+ task.getTaskData().setSkipable(true);
+ PeopleAssignments assignments = new PeopleAssignments();
+ List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
+ ba.add(new User("Administrator"));
+ assignments.setBusinessAdministrators(ba);
+
+ List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
+ po.add(new User("Administrator"));
+ assignments.setPotentialOwners(po);
+
+ task.setPeopleAssignments(assignments);
+
+ TaskFactory.initializeTask(task);
+
+ taskService.addTask(task, new HashMap<String, Object>());
+ long taskId = task.getId();
+
+ Content content = new Content();
+
+ Map<String, String> params = fillMarshalSubjectAndBodyParams();
+ ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
+ content.setContent(marshalledObject.getContent());
+ taskService.addContent(taskId, content);
+ long contentId = content.getId();
+
+ content = taskService.getContentById(contentId);
+ Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
+ checkContentSubjectAndBody(unmarshallObject);
+
+ taskService.start(taskId, "Administrator");
+ taskService.fail(taskId, "Administrator", null);
+ // emails should not be set yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ Thread.sleep(100);
+
+ // nor yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+
+ long time = 0;
+ while (MockNotificationListener.getEventsRecieved().size() != 1 && time < 15000) {
+ Thread.sleep(500);
+ time += 500;
+ }
+
+ // no email should ne sent as task was completed before deadline was triggered
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ task = taskService.getTaskById(taskId);
+ assertEquals(Status.Failed, task.getTaskData().getStatus());
+ assertEquals(0, task.getDeadlines().getStartDeadlines().size());
+ assertEquals(0, task.getDeadlines().getEndDeadlines().size());
+ }
+ @Test
+ public void testDelayedEmailNotificationOnDeadlineTaskSkipped() throws Exception {
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("now", new Date());
+ MockUserInfo userInfo = new MockUserInfo();
+ userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
+ userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
+
+ userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
+ userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
+ taskService.setUserInfo(userInfo);
+
+ Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
+ Task task = (Task) TaskFactory.evalTask(reader, vars);
+
+ task.getTaskData().setSkipable(true);
+ PeopleAssignments assignments = new PeopleAssignments();
+ List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
+ ba.add(new User("Administrator"));
+ assignments.setBusinessAdministrators(ba);
+
+ List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
+ po.add(new User("Administrator"));
+ assignments.setPotentialOwners(po);
+
+ task.setPeopleAssignments(assignments);
+ taskService.addTask(task, new HashMap<String, Object>());
+ long taskId = task.getId();
+
+ Content content = new Content();
+
+ Map<String, String> params = fillMarshalSubjectAndBodyParams();
+ ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
+ content.setContent(marshalledObject.getContent());
+ taskService.addContent(taskId, content);
+ long contentId = content.getId();
+
+ content = taskService.getContentById(contentId);
+ Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
+ checkContentSubjectAndBody(unmarshallObject);
+
+ taskService.skip(taskId, "Administrator");
+ // emails should not be set yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ Thread.sleep(100);
+
+ // nor yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+
+ long time = 0;
+ while (MockNotificationListener.getEventsRecieved().size() != 1 && time < 15000) {
+ Thread.sleep(500);
+ time += 500;
+ }
+
+ // no email should ne sent as task was completed before deadline was triggered
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ task = taskService.getTaskById(taskId);
+ assertEquals(Status.Obsolete, task.getTaskData().getStatus());
+ assertEquals(0, task.getDeadlines().getStartDeadlines().size());
+ assertEquals(0, task.getDeadlines().getEndDeadlines().size());
}
+ @Test
+ public void testDelayedEmailNotificationOnDeadlineTaskExited() throws Exception {
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("now", new Date());
+
+ MockUserInfo userInfo = new MockUserInfo();
+ userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
+ userInfo.getEmails().put(new User("Darth Vader"), "darth@domain.com");
- public Properties getConf() {
- return conf;
+ userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
+ userInfo.getLanguages().put(new User("Darth Vader"), "en-UK");
+ taskService.setUserInfo(userInfo);
+
+ Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithNotification));
+ Task task = (Task) TaskFactory.evalTask(reader, vars);
+
+ task.getTaskData().setSkipable(true);
+ PeopleAssignments assignments = new PeopleAssignments();
+ List<OrganizationalEntity> ba = new ArrayList<OrganizationalEntity>();
+ ba.add(new User("Administrator"));
+ assignments.setBusinessAdministrators(ba);
+
+ List<OrganizationalEntity> po = new ArrayList<OrganizationalEntity>();
+ po.add(new User("Administrator"));
+ assignments.setPotentialOwners(po);
+
+ task.setPeopleAssignments(assignments);
+ taskService.addTask(task, new HashMap<String, Object>());
+ long taskId = task.getId();
+
+ Content content = new Content();
+
+ Map<String, String> params = fillMarshalSubjectAndBodyParams();
+ ContentData marshalledObject = ContentMarshallerHelper.marshal(params, null);
+ content.setContent(marshalledObject.getContent());
+ taskService.addContent(taskId, content);
+ long contentId = content.getId();
+
+ content = taskService.getContentById(contentId);
+ Object unmarshallObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
+ checkContentSubjectAndBody(unmarshallObject);
+
+ taskService.exit(taskId, "Administrator");
+ // emails should not be set yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ Thread.sleep(100);
+
+ // nor yet
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+
+ long time = 0;
+ while (MockNotificationListener.getEventsRecieved().size() != 1 && time < 15000) {
+ Thread.sleep(500);
+ time += 500;
+ }
+
+ // no email should ne sent as task was completed before deadline was triggered
+ assertEquals(0, MockNotificationListener.getEventsRecieved().size());
+ task = taskService.getTaskById(taskId);
+ assertEquals(Status.Exited, task.getTaskData().getStatus());
+ assertEquals(0, task.getDeadlines().getStartDeadlines().size());
+ assertEquals(0, task.getDeadlines().getEndDeadlines().size());
+ }
+
+
+ @Test
+ public void testDelayedReassignmentOnDeadline() throws Exception {
+
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("now", new Date());
+ MockUserInfo userInfo = new MockUserInfo();
+ userInfo.getEmails().put(new User("Tony Stark"), "tony@domain.com");
+ userInfo.getEmails().put(new User("Luke Cage"), "luke@domain.com");
+ userInfo.getEmails().put(new User("Bobba Fet"), "luke@domain.com");
+ userInfo.getEmails().put(new User("Jabba Hutt"), "luke@domain.com");
+
+ userInfo.getLanguages().put(new User("Tony Stark"), "en-UK");
+ userInfo.getLanguages().put(new User("Luke Cage"), "en-UK");
+ userInfo.getLanguages().put(new User("Bobba Fet"), "en-UK");
+ userInfo.getLanguages().put(new User("Jabba Hutt"), "en-UK");
+ taskService.setUserInfo(userInfo);
+
+ Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.DeadlineWithReassignment));
+ Task task = (Task) TaskFactory.evalTask(reader, vars);
+ taskService.addTask(task, new HashMap<String, Object>());
+ long taskId = task.getId();
+
+ // Shouldn't have re-assigned yet
+ Thread.sleep(1000);
+
+
+ task = taskService.getTaskById(taskId);
+ List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners();
+ List<String> ids = new ArrayList<String>(potentialOwners.size());
+ for (OrganizationalEntity entity : potentialOwners) {
+ ids.add(entity.getId());
+ }
+ assertTrue(ids.contains("Tony Stark"));
+ assertTrue(ids.contains("Luke Cage"));
+
+ // should have re-assigned by now
+ long time = 0;
+ while (MockNotificationListener.getEventsRecieved().size() != 1 && time < 15000) {
+ Thread.sleep(500);
+ time += 500;
+ }
+
+ task = taskService.getTaskById(taskId);
+ assertEquals(Status.Ready, task.getTaskData().getStatus());
+ potentialOwners = task.getPeopleAssignments().getPotentialOwners();
+
+ ids = new ArrayList<String>(potentialOwners.size());
+ for (OrganizationalEntity entity : potentialOwners) {
+ ids.add(entity.getId());
+ }
+ assertTrue(ids.contains("Bobba Fet"));
+ assertTrue(ids.contains("Jabba Hutt"));
}
View
18 ...sk/jbpm-human-task-core-cdi/src/test/java/org/jbpm/task/TaskServiceLifeCycleBaseTest.java
@@ -1845,21 +1845,10 @@ public void testClaimConflictAndRetry() {
assertNotNull(ex);
}
-
-
-
-
-
-
}
@Test
public void testClaimNextAvailable() {
-
-
-
-
-
// Create a local instance of the TaskService
@@ -1867,9 +1856,6 @@ public void testClaimNextAvailable() {
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('salaboy'), new User('Bobba Fet') ], }),";
str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
-
-
-
// Deploy the Task Definition to the Task Component
taskService.addTask((Task) TaskFactory.evalTask(new StringReader(str)), new HashMap<String, Object>());
@@ -1883,9 +1869,5 @@ public void testClaimNextAvailable() {
List<TaskSummary> salaboyTasks = taskService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", status, "en-UK");
assertEquals(0, salaboyTasks.size());
-
-
-
-
}
}
View
274 ...ask/jbpm-human-task-core-cdi/src/test/java/org/jbpm/task/TaskServiceSubTasksBaseTest.java
@@ -0,0 +1,274 @@
+///*
+// * Copyright 2012 JBoss by Red Hat.
+// *
+// * Licensed under the Apache License, Version 2.0 (the "License");
+// * you may not use this file except in compliance with the License.
+// * You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//package org.jbpm.task;
+//
+//import java.util.List;
+//import org.drools.process.instance.impl.WorkItemImpl;
+//import org.jbpm.task.query.TaskSummary;
+//import org.junit.After;
+//import org.junit.AfterClass;
+//import org.junit.Before;
+//import org.junit.BeforeClass;
+//import org.junit.Test;
+//import static org.junit.Assert.*;
+//
+///**
+// *
+// */
+//public class TaskServiceSubTasksBaseTest {
+//
+// public TaskServiceSubTasksBaseTest() {
+// }
+//
+// @BeforeClass
+// public static void setUpClass() {
+// }
+//
+// @AfterClass
+// public static void tearDownClass() {
+// }
+//
+// @Before
+// public void setUp() {
+// }
+//
+// @After
+// public void tearDown() {
+// }
+//
+// @Test
+// public void testOnAllSubTasksEndParentEndStrategy() throws Exception {
+//
+// TestWorkItemManager manager = new TestWorkItemManager();
+// ksession.setWorkItemManager(manager);
+// //Create the parent task
+// WorkItemImpl workItem = new WorkItemImpl();
+// workItem.setName("Human Task");
+// workItem.setParameter("TaskName", "TaskNameParent");
+// workItem.setParameter("Comment", "CommentParent");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// //Set the subtask policy
+// workItem.setParameter("SubTaskStrategies", "OnAllSubTasksEndParentEnd");
+// getHandler().executeWorkItem(workItem, manager);
+//
+//
+// //Test if the task is succesfully created
+//
+//
+// List<TaskSummary> tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
+// assertEquals(1, tasks.size());
+// TaskSummary task = tasks.get(0);
+// assertEquals("TaskNameParent", task.getName());
+// assertEquals(10, task.getPriority());
+// assertEquals("CommentParent", task.getDescription());
+// assertEquals(Status.Reserved, task.getStatus());
+// assertEquals("Darth Vader", task.getActualOwner().getId());
+//
+// //Create the child task
+// workItem = new WorkItemImpl();
+// workItem.setName("Human Task");
+// workItem.setParameter("TaskName", "TaskNameChild1");
+// workItem.setParameter("Comment", "CommentChild1");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// workItem.setParameter("ParentId", task.getId());
+// getHandler().executeWorkItem(workItem, manager);
+//
+//
+// //Create the child task2
+// workItem = new WorkItemImpl();
+// workItem.setName("Human Task2");
+// workItem.setParameter("TaskName", "TaskNameChild2");
+// workItem.setParameter("Comment", "CommentChild2");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// workItem.setParameter("ParentId", task.getId());
+// getHandler().executeWorkItem(workItem, manager);
+//
+//
+// //Start the parent task
+// getClient().start(task.getId(), "Darth Vader");
+//
+// //Check if the parent task is InProgress
+//
+//
+// Task parentTask = getClient().getTask(task.getId());
+// assertEquals(Status.InProgress, parentTask.getTaskData().getStatus());
+// assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
+//
+// //Get all the subtask created for the parent task based on the potential owner
+//
+//
+// List<TaskSummary> subTasks = getClient().getSubTasksAssignedAsPotentialOwner(parentTask.getId(), "Darth Vader", "en-UK");
+// assertEquals(2, subTasks.size());
+// TaskSummary subTaskSummary1 = subTasks.get(0);
+// TaskSummary subTaskSummary2 = subTasks.get(1);
+// assertNotNull(subTaskSummary1);
+// assertNotNull(subTaskSummary2);
+//
+// //Starting the sub task 1
+// getClient().start(subTaskSummary1.getId(), "Darth Vader");
+//
+// //Starting the sub task 2
+// getClient().start(subTaskSummary2.getId(), "Darth Vader");
+//
+// //Check if the child task 1 is InProgress
+// Task subTask1 = getClient().getTask(subTaskSummary1.getId());
+// assertEquals(Status.InProgress, subTask1.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
+//
+// //Check if the child task 2 is InProgress
+//
+//
+// Task subTask2 = getClient().getTask(subTaskSummary2.getId());
+// assertEquals(Status.InProgress, subTask2.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
+//
+// // Complete the child task 1
+// getClient().complete(subTask1.getId(), "Darth Vader", null);
+//
+// // Complete the child task 2
+// getClient().complete(subTask2.getId(), "Darth Vader", null);
+//
+// //Check if the child task 1 is Completed
+//
+//
+//
+// subTask1 = getClient().getTask(subTask1.getId());
+// assertEquals(Status.Completed, subTask1.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
+//
+// //Check if the child task 2 is Completed
+// subTask2 = getClient().getTask(subTask2.getId());
+// assertEquals(Status.Completed, subTask2.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
+//
+// // Check is the parent task is Complete
+// parentTask = getClient().getTask(parentTask.getId());
+// assertEquals(Status.Completed, parentTask.getTaskData().getStatus());
+// assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
+//
+// assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
+// }
+//
+// @Test
+// public void testOnParentAbortAllSubTasksEndStrategy() throws Exception {
+//
+// TestWorkItemManager manager = new TestWorkItemManager();
+// ksession.setWorkItemManager(manager);
+// //Create the parent task
+// WorkItemImpl workItem = new WorkItemImpl();
+// workItem.setName("Human Task");
+// workItem.setParameter("TaskName", "TaskNameParent");
+// workItem.setParameter("Comment", "CommentParent");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// //Set the subtask policy
+// workItem.setParameter("SubTaskStrategies", "OnParentAbortAllSubTasksEnd");
+// getHandler().executeWorkItem(workItem, manager);
+//
+//
+// //Test if the task is succesfully created
+//
+//
+// List<TaskSummary> tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
+// assertEquals(1, tasks.size());
+// TaskSummary task = tasks.get(0);
+// assertEquals("TaskNameParent", task.getName());
+// assertEquals(10, task.getPriority());
+// assertEquals("CommentParent", task.getDescription());
+// assertEquals(Status.Reserved, task.getStatus());
+// assertEquals("Darth Vader", task.getActualOwner().getId());
+//
+// //Create the child task
+// workItem = new WorkItemImpl();
+// workItem.setName("Human Task");
+// workItem.setParameter("TaskName", "TaskNameChild1");
+// workItem.setParameter("Comment", "CommentChild1");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// workItem.setParameter("ParentId", task.getId());
+// getHandler().executeWorkItem(workItem, manager);
+//
+// //Create the child task2
+// workItem = new WorkItemImpl();
+// workItem.setName("Human Task2");
+// workItem.setParameter("TaskName", "TaskNameChild2");
+// workItem.setParameter("Comment", "CommentChild2");
+// workItem.setParameter("Priority", "10");
+// workItem.setParameter("ActorId", "Darth Vader");
+// workItem.setParameter("ParentId", task.getId());
+// getHandler().executeWorkItem(workItem, manager);
+//
+// //Start the parent task
+// getClient().start(task.getId(), "Darth Vader");
+//
+// //Check if the parent task is InProgress
+// Task parentTask = getClient().getTask(task.getId());
+// assertEquals(Status.InProgress, parentTask.getTaskData().getStatus());
+// assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
+//
+// //Get all the subtask created for the parent task based on the potential owner
+//
+//
+// List<TaskSummary> subTasks = getClient().getSubTasksAssignedAsPotentialOwner(parentTask.getId(), "Darth Vader", "en-UK");
+// assertEquals(2, subTasks.size());
+// TaskSummary subTaskSummary1 = subTasks.get(0);
+// TaskSummary subTaskSummary2 = subTasks.get(1);
+// assertNotNull(subTaskSummary1);
+// assertNotNull(subTaskSummary2);
+//
+// //Starting the sub task 1
+// getClient().start(subTaskSummary1.getId(), "Darth Vader");
+//
+// //Starting the sub task 2
+// getClient().start(subTaskSummary2.getId(), "Darth Vader");
+//
+// //Check if the child task 1 is InProgress
+//
+//
+// Task subTask1 = getClient().getTask(subTaskSummary1.getId());
+// assertEquals(Status.InProgress, subTask1.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
+//
+// //Check if the child task 2 is InProgress
+//
+//
+// Task subTask2 = getClient().getTask(subTaskSummary2.getId());
+// assertEquals(Status.InProgress, subTask2.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
+//
+// // Complete the parent task
+// getClient().skip(parentTask.getId(), "Darth Vader");
+//
+// //Check if the child task 1 is Completed
+//
+//
+// subTask1 = getClient().getTask(subTaskSummary1.getId());
+// assertEquals(Status.Completed, subTask1.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
+//
+// //Check if the child task 2 is Completed
+//
+//
+// subTask2 = getClient().getTask(subTaskSummary2.getId());
+// assertEquals(Status.Completed, subTask2.getTaskData().getStatus());
+// assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
+//
+// assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
+// }
+//}
View
2  jbpm-human-task/jbpm-human-task-core-cdi/src/test/resources/test-persistence.xml
@@ -29,7 +29,7 @@
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
-
+ <class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.User</class>
<!-- Event Classes -->
Please sign in to comment.
Something went wrong with that request. Please try again.