@Deployment public 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.getId()).setVariableLocal("testVariable", "value1").execute(); // then the listener is invoked assertEquals(1, LogExecutionContextListener.getCaseExecutionContexts().size()); CaseExecutionContext executionContext = LogExecutionContextListener.getCaseExecutionContexts().get(0); assertNotNull(executionContext); // although this is not inside a command, checking for IDs should be ok assertEquals(caseInstance.getId(), executionContext.getCaseInstance().getId()); assertEquals(taskExecution.getId(), executionContext.getExecution().getId()); LogExecutionContextListener.reset(); }
@Deployment public 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.getId()).setVariableLocal("testVariable", "value1").execute(); // then the listener is invoked assertEquals(1, LogExecutionContextListener.getCaseExecutionContexts().size()); CaseExecutionContext executionContext = LogExecutionContextListener.getCaseExecutionContexts().get(0); assertNotNull(executionContext); // although this is not inside a command, checking for IDs should be ok assertEquals(caseInstance.getId(), executionContext.getCaseInstance().getId()); assertEquals(taskExecution.getId(), executionContext.getExecution().getId()); LogExecutionContextListener.reset(); }