use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testSkipListenerInvocation.
@Deployment(resources = SUBPROCESS_LISTENER_PROCESS)
public void testSkipListenerInvocation() {
RecorderExecutionListener.clear();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess", Collections.<String, Object>singletonMap("listener", new RecorderExecutionListener()));
String processInstanceId = processInstance.getId();
assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
// when I start an activity with "skip listeners" setting
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("innerTask").execute(true, false);
// then no listeners are invoked
assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
// when I cancel an activity with "skip listeners" setting
ActivityInstance activityInstanceTree = runtimeService.getActivityInstance(processInstanceId);
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getChildInstanceForActivity(activityInstanceTree, "innerTask").getId()).execute(true, false);
// then no listeners are invoked
assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
// when I cancel an activity that ends the process instance
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getChildInstanceForActivity(activityInstanceTree, "outerTask").getId()).execute(true, false);
// then no listeners are invoked
assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testActivityExecutionListenerInvocation.
@Deployment(resources = SUBPROCESS_LISTENER_PROCESS)
public void testActivityExecutionListenerInvocation() {
RecorderExecutionListener.clear();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess", Collections.<String, Object>singletonMap("listener", new RecorderExecutionListener()));
String processInstanceId = processInstance.getId();
assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").execute();
// assert activity instance tree
ActivityInstance activityInstanceTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(activityInstanceTree);
assertEquals(processInstanceId, activityInstanceTree.getProcessInstanceId());
assertThat(activityInstanceTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").beginScope("subProcess").activity("innerTask").done());
// assert listener invocations
List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
assertEquals(2, recordedEvents.size());
ActivityInstance subprocessInstance = getChildInstanceForActivity(activityInstanceTree, "subProcess");
ActivityInstance innerTaskInstance = getChildInstanceForActivity(subprocessInstance, "innerTask");
RecordedEvent firstEvent = recordedEvents.get(0);
RecordedEvent secondEvent = recordedEvents.get(1);
assertEquals("subProcess", firstEvent.getActivityId());
assertEquals(subprocessInstance.getId(), firstEvent.getActivityInstanceId());
assertEquals(ExecutionListener.EVENTNAME_START, secondEvent.getEventName());
assertEquals("innerTask", secondEvent.getActivityId());
assertEquals(innerTaskInstance.getId(), secondEvent.getActivityInstanceId());
assertEquals(ExecutionListener.EVENTNAME_START, secondEvent.getEventName());
RecorderExecutionListener.clear();
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(innerTaskInstance.getId()).execute();
assertEquals(2, RecorderExecutionListener.getRecordedEvents().size());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartTransitionListenerInvocation.
@Deployment(resources = TRANSITION_LISTENER_PROCESS)
public void testStartTransitionListenerInvocation() {
RecorderExecutionListener.clear();
ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
runtimeService.createProcessInstanceModification(instance.getId()).startTransition("flow2").execute();
// transition listener should have been invoked
List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
assertEquals(1, events.size());
RecordedEvent event = events.get(0);
assertEquals("flow2", event.getTransitionId());
RecorderExecutionListener.clear();
ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.getId());
assertNotNull(updatedTree);
assertEquals(instance.getId(), updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());
completeTasksInOrder("task1", "task2", "task2");
assertProcessEnded(instance.getId());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAfterActivityListenerInvocation.
@Deployment(resources = TRANSITION_LISTENER_PROCESS)
public void testStartAfterActivityListenerInvocation() {
RecorderExecutionListener.clear();
ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
runtimeService.createProcessInstanceModification(instance.getId()).startTransition("flow2").execute();
// transition listener should have been invoked
List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
assertEquals(1, events.size());
RecordedEvent event = events.get(0);
assertEquals("flow2", event.getTransitionId());
RecorderExecutionListener.clear();
ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.getId());
assertNotNull(updatedTree);
assertEquals(instance.getId(), updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());
completeTasksInOrder("task1", "task2", "task2");
assertProcessEnded(instance.getId());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testCancelAsyncAfterTransitionInstanceInvokesParentListeners.
@Deployment
public void testCancelAsyncAfterTransitionInstanceInvokesParentListeners() {
RecorderExecutionListener.clear();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
String processInstanceId = processInstance.getId();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstanceId).cancelTransitionInstance(getChildTransitionInstanceForTargetActivity(tree, "subProcessEnd").getId()).execute();
assertEquals(1, RecorderExecutionListener.getRecordedEvents().size());
RecordedEvent event = RecorderExecutionListener.getRecordedEvents().get(0);
assertEquals("subProcess", event.getActivityId());
RecorderExecutionListener.clear();
}
Aggregations