public virtual void testTaskDeleteListenerByProcessDeletion() { TaskDeleteListener.Clear(); IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("taskListenerProcess"); Assert.AreEqual(0, TaskDeleteListener.EventCounter); Assert.IsNull(TaskDeleteListener.LastTaskDefinitionKey); Assert.IsNull(TaskDeleteListener.LastDeleteReason); // Delete process instance to Delete task ITask task = taskService.CreateTaskQuery().First(); runtimeService.DeleteProcessInstance(processInstance.ProcessInstanceId, "test Delete task listener"); Assert.AreEqual(1, TaskDeleteListener.EventCounter); Assert.AreEqual(task.TaskDefinitionKey, TaskDeleteListener.LastTaskDefinitionKey); Assert.AreEqual("test Delete task listener", TaskDeleteListener.LastDeleteReason); }
public virtual void testTaskDeleteListenerByBoundaryEvent() { TaskDeleteListener.Clear(); IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("taskListenerProcess"); Assert.AreEqual(0, TaskDeleteListener.EventCounter); Assert.IsNull(TaskDeleteListener.LastTaskDefinitionKey); Assert.IsNull(TaskDeleteListener.LastDeleteReason); // correlate message to Delete task ITask task = taskService.CreateTaskQuery(c => c.ProcessInstanceId == processInstance.Id).First(); runtimeService.CorrelateMessage("message"); Assert.AreEqual(1, TaskDeleteListener.EventCounter); Assert.AreEqual(task.TaskDefinitionKey, TaskDeleteListener.LastTaskDefinitionKey); Assert.AreEqual("deleted", TaskDeleteListener.LastDeleteReason); }
public virtual void testTaskCompleteListener() { TaskDeleteListener.Clear(); IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("taskListenerProcess"); Assert.AreEqual(null, runtimeService.GetVariable(processInstance.Id, "greeting")); Assert.AreEqual(null, runtimeService.GetVariable(processInstance.Id, "expressionValue")); // Completing first task will change the description ITask task = taskService.CreateTaskQuery(c => c.ProcessInstanceId == processInstance.Id).First(); taskService.Complete(task.Id); // Check that the completion did not execute the Delete listener Assert.AreEqual(0, TaskDeleteListener.EventCounter); Assert.IsNull(TaskDeleteListener.LastTaskDefinitionKey); Assert.IsNull(TaskDeleteListener.LastDeleteReason); Assert.AreEqual("Hello from The Process", runtimeService.GetVariable(processInstance.Id, "greeting")); Assert.AreEqual("Act", runtimeService.GetVariable(processInstance.Id, "shortName")); }