@Deployment(resources = NESTED_ASYNC_BEFORE_IO_LISTENER_PROCESS) public void testCancelTransitionInstanceShouldNotInvokeIoMappingAndListenersOfTargetActivity() { RecorderExecutionListener.clear(); // given a process instance with an async task in a subprocess ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( "nestedOneTaskProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener())); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); assertEquals(1, managementService.createJobQuery().count()); // when the async task is cancelled via cancelTransitionInstance runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelTransitionInstance( getChildTransitionInstanceForTargetActivity(tree, "innerTask").getId()) .execute(); // then no io mapping is executed and no end listener is executed assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty()); assertEquals( 0, runtimeService.createVariableInstanceQuery().variableName("outputMappingExecuted").count()); // and the process can be completed successfully completeTasksInOrder("outerTask"); assertProcessEnded(processInstance.getId()); }
@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(); }