public virtual void testDefaultCompensationHandlerHistoryActivityInstance() { // given a process instance IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("defaultHandlerProcess"); // when throwing compensation ITask beforeCompensationTask = taskService.CreateTaskQuery().First(); taskService.Complete(beforeCompensationTask.Id); IActivityInstance tree = runtimeService.GetActivityInstance(processInstance.Id); string compensationHandlerActivityInstanceId = tree.GetActivityInstances("compensationHandler")[0].Id; string subProcessActivityInstanceId = tree.GetActivityInstances("subProcess")[0].Id; // . and completing compensation ITask compensationHandler = taskService.CreateTaskQuery().First(); taskService.Complete(compensationHandler.Id); // then there is a historic activity instance for the compensation handler IHistoricActivityInstance historicCompensationHandlerInstance = historyService.CreateHistoricActivityInstanceQuery(c => c.ActivityId == "compensationHandler").First(); Assert.NotNull(historicCompensationHandlerInstance); Assert.AreEqual(compensationHandlerActivityInstanceId, historicCompensationHandlerInstance.Id); Assert.AreEqual(subProcessActivityInstanceId, historicCompensationHandlerInstance.ParentActivityInstanceId); }
public virtual void FAILING_testDefaultCompensationHandlerHistoryVariableInstance() { // given a process instance IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("defaultHandlerProcess"); // when throwing compensation ITask beforeCompensationTask = taskService.CreateTaskQuery().First(); taskService.Complete(beforeCompensationTask.Id); IActivityInstance tree = runtimeService.GetActivityInstance(processInstance.Id); string compensationHandlerActivityInstanceId = tree.GetActivityInstances("compensationHandler")[0].Id; // . setting a variable via task service API ITask compensationHandler = taskService.CreateTaskQuery().First(); runtimeService.SetVariableLocal(compensationHandler.ExecutionId, "apiVariable", "someValue"); // . and completing compensation taskService.Complete(compensationHandler.Id); // then there is a historic variable instance for the variable set by API IHistoricVariableInstance historicVariableInstance = historyService.CreateHistoricVariableInstanceQuery().First(); Assert.NotNull(historicVariableInstance); Assert.AreEqual(compensationHandlerActivityInstanceId, historicVariableInstance.ActivityInstanceId); }
public virtual IActivityInstance GetSingleActivityInstance( IActivityInstance tree, string activityId) { var activityInstances = tree.GetActivityInstances(activityId); if (activityInstances.Length == 1) { return(activityInstances[0]); } throw new System.Exception("There is not exactly one activity instance for activity " + activityId); }