use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent in project camunda-bpm-platform by camunda.
the class AsyncTaskTest method testDeleteInScopeShouldNotInvokeListeners.
/**
* CAM-3707
*/
@Deployment
public void testDeleteInScopeShouldNotInvokeListeners() {
RecorderExecutionListener.clear();
// given
ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncListenerSubProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
assertEquals(1, managementService.createJobQuery().count());
// when deleting the process instance
runtimeService.deleteProcessInstance(instance.getId(), "");
// then the async task end listener has not been executed but the listeners of the sub
// process and the process
List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
assertEquals(2, recordedEvents.size());
assertEquals("subProcess", recordedEvents.get(0).getActivityId());
// process instance end event has no activity id
assertNull(recordedEvents.get(1).getActivityId());
RecorderExecutionListener.clear();
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent 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.RecordedEvent 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.RecordedEvent 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.RecordedEvent 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