use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class VariableListenerTest method testDelegateInstanceIsProcessEngineAware.
@Deployment
public void testDelegateInstanceIsProcessEngineAware() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
assertFalse(ProcessEngineAwareListener.hasFoundValidRuntimeService());
// when i set a variable that causes the listener to be notified
caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute();
// then the listener is invoked and has found process engine services
assertTrue(ProcessEngineAwareListener.hasFoundValidRuntimeService());
ProcessEngineAwareListener.reset();
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class VariableListenerTest method testChildListenersNotInvoked.
@Deployment
public void testChildListenersNotInvoked() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();
// when i set a variable on the parent scope
caseService.withCaseExecution(caseInstance.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute();
// then the listener is not invoked
assertEquals(0, LogVariableListener.getInvocations().size());
LogVariableListener.reset();
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class VariableListenerTest method testVariableListenerWithProcessTask.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/listener/VariableListenerTest.testVariableListenerWithProcessTask.cmmn", "org/camunda/bpm/engine/test/cmmn/listener/VariableListenerTest.testVariableListenerWithProcessTask.bpmn20.xml" })
public void testVariableListenerWithProcessTask() {
CaseInstance caseInstance = caseService.createCaseInstanceByKey("case");
CaseExecution processTask = caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult();
String processTaskId = processTask.getId();
caseService.withCaseExecution(processTaskId).manualStart();
// then the listener is invoked
assertEquals(1, LogVariableListener.getInvocations().size());
DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(processTask).event(VariableListener.CREATE).name("aVariable").value("aValue").matches(LogVariableListener.getInvocations().get(0));
LogVariableListener.reset();
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class VariableListenerTest method testAnyEventListenerByClass.
@Deployment
public 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.getId()).setVariable("anInstanceVariable", "anInstanceValue").execute();
// then the listener is not invoked
assertTrue(LogVariableListener.getInvocations().isEmpty());
// 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.getId()).setVariableLocal("aTaskVariable", "aTaskValue").execute();
// then the listener is invoked
assertEquals(1, LogVariableListener.getInvocations().size());
DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).event(VariableListener.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.getInvocations().get(0));
LogVariableListener.reset();
// when i update the variable on the human task
caseService.withCaseExecution(taskExecution.getId()).setVariable("aTaskVariable", "aNewTaskValue").execute();
// then the listener is invoked
assertEquals(1, LogVariableListener.getInvocations().size());
DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).event(VariableListener.UPDATE).name("aTaskVariable").value("aNewTaskValue").activityInstanceId(taskExecution.getId()).matches(LogVariableListener.getInvocations().get(0));
LogVariableListener.reset();
// when i remove the variable from the human task
caseService.withCaseExecution(taskExecution.getId()).removeVariable("aTaskVariable").execute();
// then the listener is invoked
assertEquals(1, LogVariableListener.getInvocations().size());
DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).event(VariableListener.DELETE).name("aTaskVariable").value(null).activityInstanceId(taskExecution.getId()).matches(LogVariableListener.getInvocations().get(0));
LogVariableListener.reset();
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class VariableListenerTest method testVariableListenerInvokedFromSourceScope.
@Deployment
public 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.getId()).setVariable("aTaskVariable", "aTaskValue").execute();
// then the listener is not invoked
assertEquals(0, LogVariableListener.getInvocations().size());
// when i update the variable from the task execution
caseService.withCaseExecution(taskExecution.getId()).setVariable("aTaskVariable", "aTaskValue").execute();
// then the listener is invoked
assertEquals(1, LogVariableListener.getInvocations().size());
DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(taskExecution).event(VariableListener.UPDATE).name("aTaskVariable").value("aTaskValue").activityInstanceId(caseInstance.getId()).matches(LogVariableListener.getInvocations().get(0));
LogVariableListener.reset();
}
Aggregations