Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCreateEventListenerByClass()
        public virtual void testCreateEventListenerByClass()
        {
            caseService.withCaseDefinitionByKey("case").create();

            CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();

            assertNotNull(taskExecution);

            // when i create a variable on the human task
            caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();

            // when i update the variable on the human task
            caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aNewTaskValue").execute();

            // then the listener is not invoked
            assertTrue(LogVariableListener.Invocations.Count == 0);

            // when i remove the variable from the human task
            caseService.withCaseExecution(taskExecution.Id).removeVariable("aTaskVariable").execute();

            // then the listener is not invoked
            assertTrue(LogVariableListener.Invocations.Count == 0);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testInvokeBuiltinListenersOnly()
        public virtual void testInvokeBuiltinListenersOnly()
        {
            // disable custom variable listener invocation
            processEngineConfiguration.InvokeCustomVariableListeners = false;

            // add a builtin variable listener the hard way
            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();

            processEngineConfiguration.DeploymentCache.getCaseDefinitionById(caseDefinition.Id).findActivity("PI_HumanTask_1").addBuiltInVariableListener([email protected]_Fields.CREATE, new LogVariableListener());

            caseService.withCaseDefinitionByKey("case").create();

            CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();

            assertNotNull(taskExecution);

            // when i set a variable
            caseService.withCaseExecution(taskExecution.Id).setVariableLocal("testVariable", "value1").execute();

            // then the builtin listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            // but the custom listener is not invoked
            assertEquals(0, LogExecutionContextListener.CaseExecutionContexts.Count);

            LogVariableListener.reset();
            LogExecutionContextListener.reset();

            // restore configuration
            processEngineConfiguration.InvokeCustomVariableListeners = true;
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void setUp() throws Exception
        protected internal virtual void setUp()
        {
            base.setUp();

            LogVariableListener.reset();
            beans = processEngineConfiguration.Beans;
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testChildListenersNotInvoked()
        public virtual void testChildListenersNotInvoked()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();

            // when i set a variable on the parent scope
            caseService.withCaseExecution(caseInstance.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute();

            // then the listener is not invoked
            assertEquals(0, LogVariableListener.Invocations.Count);

            LogVariableListener.reset();
        }
Exemplo n.º 5
0
        public virtual void testVariableListenerWithProcessTask()
        {
            CaseInstance caseInstance = caseService.createCaseInstanceByKey("case");

            CaseExecution processTask = caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult();

            string processTaskId = processTask.Id;

            caseService.withCaseExecution(processTaskId).manualStart();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(processTask).@event([email protected]_Fields.CREATE).name("aVariable").value("aValue").matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testListenerOnParentScope()
        public virtual void testListenerOnParentScope()
        {
            caseService.withCaseDefinitionByKey("case").create();

            CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();

            assertNotNull(taskExecution);

            // when i set a variable on a deeper scope
            caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testAnyEventListenerByClass()
        public virtual void testAnyEventListenerByClass()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();

            CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();

            assertNotNull(taskExecution);

            // when i set a variable on a higher scope
            caseService.withCaseExecution(caseInstance.Id).setVariable("anInstanceVariable", "anInstanceValue").execute();

            // then the listener is not invoked
            assertTrue(LogVariableListener.Invocations.Count == 0);

            // when i set a variable on the human task (ie the source execution matters although the variable ends up in the same place)
            caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();

            // when i update the variable on the human task
            caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aNewTaskValue").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);
            DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.UPDATE).name("aTaskVariable").value("aNewTaskValue").activityInstanceId(taskExecution.Id).matches(LogVariableListener.Invocations[0]);
            LogVariableListener.reset();

            // when i remove the variable from the human task
            caseService.withCaseExecution(taskExecution.Id).removeVariable("aTaskVariable").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);
            DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.DELETE).name("aTaskVariable").value(null).activityInstanceId(taskExecution.Id).matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testVariableListenerInvokedFromSourceScope()
        public virtual void testVariableListenerInvokedFromSourceScope()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();

            CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();

            assertNotNull(taskExecution);

            // when i create a variable on the case instance
            caseService.withCaseExecution(caseInstance.Id).setVariable("aTaskVariable", "aTaskValue").execute();

            // then the listener is not invoked
            assertEquals(0, LogVariableListener.Invocations.Count);

            // when i update the variable from the task execution
            caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aTaskValue").execute();

            // then the listener is invoked
            assertEquals(1, LogVariableListener.Invocations.Count);

            DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(taskExecution).@event([email protected]_Fields.UPDATE).name("aTaskVariable").value("aTaskValue").activityInstanceId(caseInstance.Id).matches(LogVariableListener.Invocations[0]);

            LogVariableListener.reset();
        }