Exemple #1
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;
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testVariableListenerExecutionContext()
        public virtual void testVariableListenerExecutionContext()
        {
            CaseInstance caseInstance = 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 listener is invoked
            assertEquals(1, LogExecutionContextListener.CaseExecutionContexts.Count);
            CaseExecutionContext executionContext = LogExecutionContextListener.CaseExecutionContexts[0];

            assertNotNull(executionContext);

            // although this is not inside a command, checking for IDs should be ok
            assertEquals(caseInstance.Id, executionContext.CaseInstance.Id);
            assertEquals(taskExecution.Id, executionContext.Execution.Id);

            LogExecutionContextListener.reset();
        }