use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testIntermediateTimerEvent.
@Deployment
public void testIntermediateTimerEvent() {
// given
final List<String> timerEvents = new ArrayList<String>();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution delegateExecution) {
String currentActivityId = delegateExecution.getCurrentActivityId();
String eventName = delegateExecution.getEventName();
if ("timer".equals(currentActivityId) && (ExecutionListener.EVENTNAME_START.equals(eventName) || ExecutionListener.EVENTNAME_END.equals(eventName))) {
timerEvents.add(delegateExecution.getEventName());
}
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// when
runtimeService.startProcessInstanceByKey("process");
String jobId = managementService.createJobQuery().singleResult().getId();
managementService.executeJob(jobId);
// then
assertEquals(2, timerEvents.size());
// "start" event listener
assertEquals(ExecutionListener.EVENTNAME_START, timerEvents.get(0));
// "end" event listener
assertEquals(ExecutionListener.EVENTNAME_END, timerEvents.get(1));
}
use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithTimerBoundaryEvent.
@Deployment
public void testExecutionListenerWithTimerBoundaryEvent() {
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)timerBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// fire timer event
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
assertEquals(12, eventCount.get());
}
use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.
the class DelegateExecutionContextTest method testDelegateExecutionContext.
@Test
public void testDelegateExecutionContext() {
// given
ProcessDefinition definition = testHelper.deployAndGetDefinition(DELEGATION_PROCESS);
// a process instance with a service task and a java delegate
ProcessInstance instance = engineRule.getRuntimeService().startProcessInstanceById(definition.getId());
// then delegation execution context is no more available
DelegateExecution execution = DelegateExecutionContext.getCurrentDelegationExecution();
assertNull(execution);
}
use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.
the class DelegateExecutionContextTest method testDelegateExecutionContextWithExecutionListener.
@Test
public void testDelegateExecutionContextWithExecutionListener() {
// given
ProcessDefinition definition = testHelper.deployAndGetDefinition(EXEUCTION_LISTENER_PROCESS);
// a process instance with a service task and an execution listener
engineRule.getRuntimeService().startProcessInstanceById(definition.getId());
// then delegation execution context is no more available
DelegateExecution execution = DelegateExecutionContext.getCurrentDelegationExecution();
assertNull(execution);
}
use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.
the class DelegateExecutionHierarchyTest method testTaskInsideEmbeddedSubprocess.
public void testTaskInsideEmbeddedSubprocess() {
deployment(Bpmn.createExecutableProcess("testProcess").startEvent().subProcess().embeddedSubProcess().startEvent().serviceTask().camundaClass(AssertingJavaDelegate.class.getName()).endEvent().subProcessDone().endEvent().done());
AssertingJavaDelegate.addAsserts(new DelegateExecutionAsserter() {
public void doAssert(DelegateExecution execution) {
assertFalse(execution.equals(execution.getProcessInstance()));
assertNull(execution.getSuperExecution());
}
});
runtimeService.startProcessInstanceByKey("testProcess");
}
Aggregations