コード例 #1
0
        public virtual void testQueryByEventSubscriptionId()
        {
            createExampleEventSubscriptions();

            IList <EventSubscription> list = runtimeService.createEventSubscriptionQuery().eventName("messageName2").list();

            assertEquals(1, list.Count);

            EventSubscription eventSubscription = list[0];

            EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().eventSubscriptionId(eventSubscription.Id);

            assertEquals(1, query.count());
            assertEquals(1, query.list().size());
            assertNotNull(query.singleResult());

            try
            {
                runtimeService.createEventSubscriptionQuery().eventSubscriptionId(null).list();
                fail("Expected ProcessEngineException");
            }
            catch (ProcessEngineException)
            {
            }

            cleanDb();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCatchSignalAndMessageAndTimer()
        public virtual void testCatchSignalAndMessageAndTimer()
        {
            runtimeService.startProcessInstanceByKey("catchSignal");

            assertEquals(2, runtimeService.createEventSubscriptionQuery().count());
            EventSubscriptionQuery messageEventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().eventType("message");

            assertEquals(1, messageEventSubscriptionQuery.count());
            assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("signal").count());
            assertEquals(1, runtimeService.createProcessInstanceQuery().count());
            assertEquals(1, managementService.createJobQuery().count());

            // we can query for an execution with has both a signal AND message subscription
            Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("newInvoice").signalEventSubscriptionName("alert").singleResult();

            assertNotNull(execution);

            ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Ticks + 10000);
            try
            {
                EventSubscription messageEventSubscription = messageEventSubscriptionQuery.singleResult();
                runtimeService.messageEventReceived(messageEventSubscription.EventName, messageEventSubscription.ExecutionId);

                assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
                assertEquals(1, runtimeService.createProcessInstanceQuery().count());
                assertEquals(0, managementService.createJobQuery().count());

                Task task = taskService.createTaskQuery().taskName("afterMessage").singleResult();

                assertNotNull(task);

                taskService.complete(task.Id);
            }
            finally
            {
                ClockUtil.CurrentTime = DateTime.Now;
            }
        }