@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());
  }
  @Before
  public void setUp() {
    decisionService = engineRule.getDecisionService();
    repositoryService = engineRule.getRepositoryService();
    historyService = engineRule.getHistoryService();
    identityService = engineRule.getIdentityService();

    testRule.deployForTenant(TENANT_ONE, DISH_DRG_DMN);

    decisionService
        .evaluateDecisionByKey(DISH_DECISION)
        .decisionDefinitionTenantId(TENANT_ONE)
        .variables(
            Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND))
        .evaluate();
  }
Ejemplo n.º 3
0
  /** CAM-3707 */
  @Deployment
  public void FAILING_testDeleteShouldNotInvokeListeners() {
    RecorderExecutionListener.clear();

    // given
    ProcessInstance instance =
        runtimeService.startProcessInstanceByKey(
            "asyncListener",
            Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    assertEquals(1, managementService.createJobQuery().count());

    // when deleting the process instance
    runtimeService.deleteProcessInstance(instance.getId(), "");

    // then no listeners for the async activity should have been invoked because
    // it was not active yet
    assertEquals(0, RecorderExecutionListener.getRecordedEvents().size());

    RecorderExecutionListener.clear();
  }
  @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();
  }