use of org.camunda.bpm.engine.delegate.ExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testShouldNotIncrementExecutionListenerCountOnStartAndEndOfProcessInstance.
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldNotIncrementExecutionListenerCountOnStartAndEndOfProcessInstance() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if (!(((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity))
eventCount.incrementAndGet();
}
};
}
};
// register app so that it receives events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// Start process instance.
runtimeService.startProcessInstanceByKey("startToEnd");
assertEquals(5, eventCount.get());
}
use of org.camunda.bpm.engine.delegate.ExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithSignalBoundaryEvent.
@Deployment
public void testExecutionListenerWithSignalBoundaryEvent() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
eventCount.incrementAndGet();
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// 1. (start)startEvent(end) -(take)-> (start)userTask(end) -(take)-> (start)endEvent(end) (8 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// complete task
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertEquals(10, eventCount.get());
// reset counter
eventCount.set(0);
// 2. (start)startEvent(end) -(take)-> (start)userTask(end)/(start)signalBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// signal event
runtimeService.signalEventReceived("signal");
assertEquals(12, eventCount.get());
}
use of org.camunda.bpm.engine.delegate.ExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance.
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance() {
final AtomicInteger processDefinitionEventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if (((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity)
processDefinitionEventCount.incrementAndGet();
}
};
}
};
// register app so that it receives events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// Start process instance.
runtimeService.startProcessInstanceByKey("startToEnd");
// Start and end of the process
assertEquals(2, processDefinitionEventCount.get());
}
Aggregations