Search in sources :

Example 1 with CaseExecutionContext

use of org.camunda.bpm.engine.impl.context.CaseExecutionContext in project camunda-bpm-platform by camunda.

the class VariableListenerTest method testVariableListenerExecutionContext.

@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();
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseExecutionContext(org.camunda.bpm.engine.impl.context.CaseExecutionContext) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseExecutionContext (org.camunda.bpm.engine.impl.context.CaseExecutionContext)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)1 Deployment (org.camunda.bpm.engine.test.Deployment)1