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); }
protected internal virtual void AssertMigratedTo(IHistoricActivityInstance activityInstance, IProcessDefinition processDefinition, string activityId) { Assert.AreEqual(processDefinition.Id, activityInstance.ProcessDefinitionId); Assert.AreEqual(processDefinition.Key, activityInstance.ProcessDefinitionKey); Assert.AreEqual(activityId, activityInstance.ActivityId); }
// Todo: compensateEventDefinitionDone() //[Test] //public virtual void testTwoCompensateEventsInReverseOrder() //{ // //given // //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method: // IBpmnModelInstance model = Model.Bpmn.Bpmn.CreateExecutableProcess("Process_1") // .StartEvent() // .ServiceTask("serviceTask1") // .CamundaClass(typeof(IncreaseCurrentTimeServiceTask).FullName) // .BoundaryEvent("compensationBoundary1") // .CompensateEventDefinition() // .CompensateEventDefinitionDone() // .MoveToActivity("serviceTask1") // .ServiceTask("serviceTask2") // .CamundaClass(typeof(IncreaseCurrentTimeServiceTask).FullName) // .BoundaryEvent("compensationBoundary2") // .CompensateEventDefinition() // .CompensateEventDefinitionDone() // .MoveToActivity("serviceTask2") // .IntermediateThrowEvent("compensationEvent") // .CompensateEventDefinition() // .WaitForCompletion(true) // .CompensateEventDefinitionDone() // .EndEvent() // .Done(); // addServiceTaskCompensationHandler(model, "compensationBoundary1", "A"); // addServiceTaskCompensationHandler(model, "compensationBoundary2", "B"); // testHelper.Deploy(model); // //when // engineRule.RuntimeService.StartProcessInstanceByKey("Process_1", Variable.Variables.CreateVariables().PutValue("currentTime", DateTime.Now)); // //then compensation activities are executed in the reverse order // IList<IHistoricActivityInstance> list = engineRule.HistoryService.CreateHistoricActivityInstanceQuery()/*.OrderByHistoricActivityInstanceEndTime()*//*.Asc()*/.ToList(); // long indexA = searchForActivityIndex(list, "A"); // long indexB = searchForActivityIndex(list, "B"); // //AssertNotEquals(-1, indexA); // //AssertNotEquals(-1, indexB); // Assert.AreNotEqual(-1, indexA); // Assert.AreNotEqual(-1, indexB); // //Assert.True("Compensation activities were executed in wrong order.", indexA > indexB); // Assert.True(indexA>indexB, "Compensation activities were executed in wrong order."); //} private long searchForActivityIndex(IList <IHistoricActivityInstance> historicActivityInstances, string activityId) { for (int i = 0; i < historicActivityInstances.Count; i++) { IHistoricActivityInstance historicActivityInstance = historicActivityInstances[i]; if (historicActivityInstance.ActivityId.Equals(activityId)) { return(i); } } return(-1); }