예제 #1
0
        public virtual void testHistory()
        {
            // given
            Task compensationHandler = rule.taskQuery().singleResult();

            // when
            rule.TaskService.complete(compensationHandler.Id);

            // then history is written for the remaining activity instances
            HistoricProcessInstance historicProcessInstance = rule.historicProcessInstance();

            Assert.assertNotNull(historicProcessInstance);
            Assert.assertNotNull(historicProcessInstance.EndTime);

            HistoricActivityInstance subProcessInstance = rule.HistoryService.createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.Id).activityId("subProcess").singleResult();

            Assert.assertNotNull(subProcessInstance);
            Assert.assertNotNull(subProcessInstance.EndTime);
            Assert.assertEquals(historicProcessInstance.Id, subProcessInstance.ParentActivityInstanceId);

            HistoricActivityInstance compensationThrowInstance = rule.HistoryService.createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.Id).activityId("throwCompensate").singleResult();

            Assert.assertNotNull(compensationThrowInstance);
            Assert.assertNotNull(compensationThrowInstance.EndTime);
            Assert.assertEquals(subProcessInstance.Id, compensationThrowInstance.ParentActivityInstanceId);

            HistoricActivityInstance compensationHandlerInstance = rule.HistoryService.createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.Id).activityId("undoTask").singleResult();

            Assert.assertNotNull(compensationHandlerInstance);
            Assert.assertNotNull(compensationHandlerInstance.EndTime);
            Assert.assertEquals(subProcessInstance.Id, compensationHandlerInstance.ParentActivityInstanceId);
        }
예제 #2
0
        public virtual void testDefaultCompensationHandlerHistoryActivityInstance()
        {
            // given a process instance
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("defaultHandlerProcess");

            // when throwing compensation
            Task beforeCompensationTask = taskService.createTaskQuery().singleResult();

            taskService.complete(beforeCompensationTask.Id);

            ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id);
            string           compensationHandlerActivityInstanceId = tree.getActivityInstances("compensationHandler")[0].Id;

            string subProcessActivityInstanceId = tree.getActivityInstances("subProcess")[0].Id;

            // .. and completing compensation
            Task compensationHandler = taskService.createTaskQuery().singleResult();

            taskService.complete(compensationHandler.Id);

            // then there is a historic activity instance for the compensation handler
            HistoricActivityInstance historicCompensationHandlerInstance = historyService.createHistoricActivityInstanceQuery().activityId("compensationHandler").singleResult();

            assertNotNull(historicCompensationHandlerInstance);
            assertEquals(compensationHandlerActivityInstanceId, historicCompensationHandlerInstance.Id);
            assertEquals(subProcessActivityInstanceId, historicCompensationHandlerInstance.ParentActivityInstanceId);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpRuntimeData()
        public virtual void setUpRuntimeData()
        {
            historyServiceMock = mock(typeof(HistoryService));

            // runtime service
            when(processEngine.HistoryService).thenReturn(historyServiceMock);

            historicInstanceMock = MockProvider.createMockHistoricActivityInstance();
            historicQueryMock    = mock(typeof(HistoricActivityInstanceQuery));

            when(historyServiceMock.createHistoricActivityInstanceQuery()).thenReturn(historicQueryMock);
            when(historicQueryMock.activityInstanceId(anyString())).thenReturn(historicQueryMock);
            when(historicQueryMock.singleResult()).thenReturn(historicInstanceMock);
        }
예제 #4
0
        public virtual void testInitThrowCompensateCompletionHistory()
        {
            // given
            ProcessInstance processInstance = rule.processInstance();
            Task            undoTask        = rule.taskQuery().singleResult();

            // when
            rule.TaskService.complete(undoTask.Id);
            Task afterCompensateTask = rule.taskQuery().singleResult();

            rule.TaskService.complete(afterCompensateTask.Id);

            // then the historic throw compensate instance has an end time
            HistoricActivityInstance throwCompensateInstance = rule.HistoryService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.Id).activityId("throwCompensate").singleResult();

            Assert.assertNotNull(throwCompensateInstance.EndTime);
        }