Exemple #1
0
        public virtual void testStartAfterActivityListenerInvocation()
        {
            RecorderExecutionListener.clear();

            ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));

            Batch modificationBatch = runtimeService.createProcessInstanceModification(instance.Id).startTransition("flow2").executeAsync();

            assertNotNull(modificationBatch);
            executeSeedAndBatchJobs(modificationBatch);

            // transition listener should have been invoked
            IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents;

            assertEquals(1, events.Count);

            RecorderExecutionListener.RecordedEvent @event = events[0];
            assertEquals("flow2", @event.TransitionId);

            RecorderExecutionListener.clear();

            ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.Id);

            assertNotNull(updatedTree);
            assertEquals(instance.Id, updatedTree.ProcessInstanceId);

            assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.ProcessDefinitionId).activity("task1").activity("task2").done());

            ExecutionTree executionTree = ExecutionTree.forExecution(instance.Id, processEngine);

            assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());

            completeTasksInOrder("task1", "task2", "task2");
            assertProcessEnded(instance.Id);
        }
Exemple #2
0
        public virtual void testListenerInvocation()
        {
            RecorderExecutionListener.clear();

            // when
            ProcessInstance instance = runtimeService.createProcessInstanceByKey("listenerProcess").startBeforeActivity("innerTask").execute();

            // then
            ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.Id);

            assertNotNull(updatedTree);

            assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.ProcessDefinitionId).beginScope("subProcess").activity("innerTask").done());

            IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents;

            assertEquals(3, events.Count);

            RecorderExecutionListener.RecordedEvent processStartEvent = events[0];
            assertEquals([email protected]_Fields.EVENTNAME_START, processStartEvent.EventName);
            assertEquals("innerTask", processStartEvent.ActivityId);

            RecorderExecutionListener.RecordedEvent subProcessStartEvent = events[1];
            assertEquals([email protected]_Fields.EVENTNAME_START, subProcessStartEvent.EventName);
            assertEquals("subProcess", subProcessStartEvent.ActivityId);

            RecorderExecutionListener.RecordedEvent innerTaskStartEvent = events[2];
            assertEquals([email protected]_Fields.EVENTNAME_START, innerTaskStartEvent.EventName);
            assertEquals("innerTask", innerTaskStartEvent.ActivityId);
        }
Exemple #3
0
        /// <summary>
        /// CAM-4067
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testTerminateInSubProcessConcurrentShouldNotInvokeProcessEndListeners()
        public virtual void testTerminateInSubProcessConcurrentShouldNotInvokeProcessEndListeners()
        {
            RecorderExecutionListener.clear();

            // when process instance is started and terminate end event in subprocess executed
            runtimeService.startProcessInstanceByKey("terminateEndEventExample");

            // then the outer task still exists
            Task outerTask = taskService.createTaskQuery().singleResult();

            assertNotNull(outerTask);
            assertEquals("outerTask", outerTask.TaskDefinitionKey);

            // and the process end listener was not invoked
            assertTrue(RecorderExecutionListener.RecordedEvents.Count == 0);
        }
Exemple #4
0
        public virtual void testTerminateInSubProcessShouldNotInvokeProcessEndListeners()
        {
            RecorderExecutionListener.Clear();

            // when process instance is started and terminate end event in subprocess executed
            runtimeService.StartProcessInstanceByKey("terminateEndEventExample");

            // then the outer task still exists
            ITask outerTask = taskService.CreateTaskQuery().First();

            Assert.NotNull(outerTask);
            Assert.AreEqual("outerTask", outerTask.TaskDefinitionKey);

            // and the process end listener was not invoked
            Assert.True(RecorderExecutionListener.RecordedEvents.Count == 0);
        }
        public virtual void testStartMultipleTasksInSyncProcess()
        {
            RecorderExecutionListener.Clear();

            // when
            var instance = runtimeService.CreateProcessInstanceByKey("syncProcess")
                           .StartBeforeActivity("syncTask")
                           .StartBeforeActivity("syncTask")
                           .StartBeforeActivity("syncTask")
                           .Execute();

            // then the request was successful even though the process instance has already ended
            Assert.NotNull(instance);
            AssertProcessEnded(instance.Id);

            // and the execution listener was invoked correctly
            var events = RecorderExecutionListener.RecordedEvents;

            Assert.AreEqual(8, events.Count);

            // process start event
            Assert.AreEqual(ExecutionListenerFields.EventNameStart, events[0].EventName);
            Assert.AreEqual("syncTask", events[0].ActivityId);

            // start instruction 1
            Assert.AreEqual(ExecutionListenerFields.EventNameStart, events[1].EventName);
            Assert.AreEqual("syncTask", events[1].ActivityId);
            Assert.AreEqual(ExecutionListenerFields.EventNameEnd, events[2].EventName);
            Assert.AreEqual("syncTask", events[2].ActivityId);

            // start instruction 2
            Assert.AreEqual(ExecutionListenerFields.EventNameStart, events[3].EventName);
            Assert.AreEqual("syncTask", events[3].ActivityId);
            Assert.AreEqual(ExecutionListenerFields.EventNameEnd, events[4].EventName);
            Assert.AreEqual("syncTask", events[4].ActivityId);

            // start instruction 3
            Assert.AreEqual(ExecutionListenerFields.EventNameStart, events[5].EventName);
            Assert.AreEqual("syncTask", events[5].ActivityId);
            Assert.AreEqual(ExecutionListenerFields.EventNameEnd, events[6].EventName);
            Assert.AreEqual("syncTask", events[6].ActivityId);

            // process end event
            Assert.AreEqual(ExecutionListenerFields.EventNameEnd, events[7].EventName);
            Assert.AreEqual("end", events[7].ActivityId);
        }
Exemple #6
0
        public virtual void testIntermediateThrowSignalMultipleCancellingReceivers()
        {
            RecorderExecutionListener.clear();

            runtimeService.startProcessInstanceByKey("catchAlertTwiceAndTerminate");

            // event subscriptions for intermediate events
            assertEquals(2, runtimeService.createEventSubscriptionQuery().eventType("signal").eventName("alert").count());

            // started process instance try to send 'alert' signal to both executions
            runtimeService.startProcessInstanceByKey("throwSignal");

            // then only one terminate end event was executed
            assertEquals(1, RecorderExecutionListener.RecordedEvents.Count);

            // and both instances ended successfully
            assertEquals(0, runtimeService.createProcessInstanceQuery().count());
        }
Exemple #7
0
        /// <summary>
        /// CAM-3707
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testDeleteShouldNotInvokeListeners()
        public virtual void testDeleteShouldNotInvokeListeners()
        {
            RecorderExecutionListener.clear();

            // given
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncListener", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));

            assertEquals(1, managementService.createJobQuery().count());

            // when deleting the process instance
            runtimeService.deleteProcessInstance(instance.Id, "");

            // then no listeners for the async activity should have been invoked because
            // it was not active yet
            assertEquals(0, RecorderExecutionListener.RecordedEvents.Count);

            RecorderExecutionListener.clear();
        }
Exemple #8
0
        public virtual void testIntermediateThrowSignalMultipleCancellingReceivers()
        {
            RecorderExecutionListener.Clear();

            runtimeService.StartProcessInstanceByKey("catchAlertTwiceAndTerminate");

            // event subscriptions for intermediate events
            Assert.AreEqual(2, runtimeService.CreateEventSubscriptionQuery(c => c.EventType == "signal" && c.EventName == "alert").Count());

            // started process instance try to send 'alert' signal to both executions
            runtimeService.StartProcessInstanceByKey("throwSignal");

            // then only one terminate end event was executed
            Assert.AreEqual(1, RecorderExecutionListener.RecordedEvents.Count);

            // and both instances ended successfully
            Assert.AreEqual(0, CreateProcessInstanceQuery(runtimeService).Count());
        }
Exemple #9
0
        public virtual void testSkipListenerInvocation()
        {
            RecorderExecutionListener.clear();

            // when
            ProcessInstance instance = runtimeService.createProcessInstanceByKey("listenerProcess").startBeforeActivity("innerTask").execute(true, true);

            // then
            ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.Id);

            assertNotNull(updatedTree);

            assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.ProcessDefinitionId).beginScope("subProcess").activity("innerTask").done());

            IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents;

            assertEquals(0, events.Count);
        }
Exemple #10
0
        public virtual void testDeleteShouldNotInvokeListeners()
        {
            RecorderExecutionListener.Clear();

            // given
            IProcessInstance instance = runtimeService.StartProcessInstanceByKey("asyncListener", Variables.CreateVariables().PutValue("listener", new RecorderExecutionListener()) as
                                                                                 IDictionary <string, ITypedValue>);

            Assert.AreEqual(1, managementService.CreateJobQuery().Count());

            // when deleting the process instance
            runtimeService.DeleteProcessInstance(instance.Id, "");

            // then no listeners for the async activity should have been invoked because
            // it was not active yet
            Assert.AreEqual(0, RecorderExecutionListener.RecordedEvents.Count);

            RecorderExecutionListener.Clear();
        }
Exemple #11
0
        public virtual void testStartMultipleTasksInSyncProcess()
        {
            RecorderExecutionListener.clear();

            // when
            ProcessInstance instance = runtimeService.createProcessInstanceByKey("syncProcess").startBeforeActivity("syncTask").startBeforeActivity("syncTask").startBeforeActivity("syncTask").execute();

            // then the request was successful even though the process instance has already ended
            assertNotNull(instance);
            assertProcessEnded(instance.Id);

            // and the execution listener was invoked correctly
            IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents;

            assertEquals(8, events.Count);

            // process start event
            assertEquals([email protected]_Fields.EVENTNAME_START, events[0].EventName);
            assertEquals("syncTask", events[0].ActivityId);

            // start instruction 1
            assertEquals([email protected]_Fields.EVENTNAME_START, events[1].EventName);
            assertEquals("syncTask", events[1].ActivityId);
            assertEquals([email protected]_Fields.EVENTNAME_END, events[2].EventName);
            assertEquals("syncTask", events[2].ActivityId);

            // start instruction 2
            assertEquals([email protected]_Fields.EVENTNAME_START, events[3].EventName);
            assertEquals("syncTask", events[3].ActivityId);
            assertEquals([email protected]_Fields.EVENTNAME_END, events[4].EventName);
            assertEquals("syncTask", events[4].ActivityId);

            // start instruction 3
            assertEquals([email protected]_Fields.EVENTNAME_START, events[5].EventName);
            assertEquals("syncTask", events[5].ActivityId);
            assertEquals([email protected]_Fields.EVENTNAME_END, events[6].EventName);
            assertEquals("syncTask", events[6].ActivityId);

            // process end event
            assertEquals([email protected]_Fields.EVENTNAME_END, events[7].EventName);
            assertEquals("end", events[7].ActivityId);
        }
        public virtual void testListenerInvocation()
        {
            RecorderExecutionListener.Clear();

            // when
            var instance = runtimeService.CreateProcessInstanceByKey("listenerProcess")
                           .StartBeforeActivity("innerTask")
                           .Execute();

            // then
            var updatedTree = runtimeService.GetActivityInstance(instance.Id);

            Assert.NotNull(updatedTree);

            ActivityInstanceAssert.That(updatedTree)
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(instance.ProcessDefinitionId)
                          .BeginScope("subProcess")
                          .Activity("innerTask")
                          .Done());

            var events = RecorderExecutionListener.RecordedEvents;

            Assert.AreEqual(3, events.Count);

            var processStartEvent = events[0];

            Assert.AreEqual(ExecutionListenerFields.EventNameStart, processStartEvent.EventName);
            Assert.AreEqual("innerTask", processStartEvent.ActivityId);

            var subProcessStartEvent = events[1];

            Assert.AreEqual(ExecutionListenerFields.EventNameStart, subProcessStartEvent.EventName);
            Assert.AreEqual("subProcess", subProcessStartEvent.ActivityId);

            var innerTaskStartEvent = events[2];

            Assert.AreEqual(ExecutionListenerFields.EventNameStart, innerTaskStartEvent.EventName);
            Assert.AreEqual("innerTask", innerTaskStartEvent.ActivityId);
        }
Exemple #13
0
        /// <summary>
        /// CAM-3707
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testDeleteInScopeShouldNotInvokeListeners()
        public virtual void testDeleteInScopeShouldNotInvokeListeners()
        {
            RecorderExecutionListener.clear();

            // given
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncListenerSubProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));

            assertEquals(1, managementService.createJobQuery().count());

            // when deleting the process instance
            runtimeService.deleteProcessInstance(instance.Id, "");

            // then the async task end listener has not been executed but the listeners of the sub
            // process and the process

            IList <RecorderExecutionListener.RecordedEvent> recordedEvents = RecorderExecutionListener.RecordedEvents;

            assertEquals(2, recordedEvents.Count);
            assertEquals("subProcess", recordedEvents[0].ActivityId);
            assertNull(recordedEvents[1].ActivityId);     // process instance end event has no activity id

            RecorderExecutionListener.clear();
        }
Exemple #14
0
        public virtual void testDeleteInScopeShouldNotInvokeListeners()
        {
            RecorderExecutionListener.Clear();

            // given
            IProcessInstance instance = runtimeService.StartProcessInstanceByKey("asyncListenerSubProcess", Variables.CreateVariables().PutValue("listener", new RecorderExecutionListener()) as IDictionary <string, ITypedValue>);

            Assert.AreEqual(1, managementService.CreateJobQuery().Count());

            // when deleting the process instance
            runtimeService.DeleteProcessInstance(instance.Id, "");

            // then the async task end listener has not been executed but the listeners of the sub
            // process and the process

            IList <RecorderExecutionListener.RecordedEvent> recordedEvents = RecorderExecutionListener.RecordedEvents;

            Assert.AreEqual(2, recordedEvents.Count);
            Assert.AreEqual("subProcess", recordedEvents[0].ActivityId);
            Assert.IsNull(recordedEvents[1].ActivityId); // process instance end event has no activity id

            RecorderExecutionListener.Clear();
        }
 public virtual void clearExecutionListener()
 {
     RecorderExecutionListener.Clear();
 }