Search in sources :

Example 96 with BpmnModelInstance

use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.

the class BoundaryConditionalEventTest method testSetVariableInOutMappingOfCallActivity.

@Test
public void testSetVariableInOutMappingOfCallActivity() {
    engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, DELEGATED_PROCESS).deploy());
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).callActivity(TASK_WITH_CONDITION_ID).calledElement(DELEGATED_PROCESS_KEY).camundaOut(VARIABLE_NAME, VARIABLE_NAME).userTask().name(TASK_AFTER_OUTPUT_MAPPING).endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, true);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    Task task = taskQuery.singleResult();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then out mapping from call activity sets variable
    // -> interrupting conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 97 with BpmnModelInstance

use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.

the class BoundaryConditionalEventTest method testSetVariableInSubProcessInDelegatedCode.

@Test
public void testSetVariableInSubProcessInDelegatedCode() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().serviceTask().camundaExpression(EXPR_SET_VARIABLE).userTask().name(TASK_AFTER_SERVICE_TASK).endEvent().subProcessDone().endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, SUB_PROCESS_ID, true);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    Task task = taskQuery.singleResult();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then service task in sub process sets variable
    // conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 98 with BpmnModelInstance

use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.

the class BoundaryConditionalEventTest method testSetVariableInDelegateWithSynchronousEvent.

@Test
public void testSetVariableInDelegateWithSynchronousEvent() {
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask().name(TASK_BEFORE_CONDITION).serviceTask(TASK_WITH_CONDITION_ID).camundaClass(SetVariableDelegate.class.getName()).endEvent().done();
    modelInstance = modify(modelInstance).serviceTaskBuilder(TASK_WITH_CONDITION_ID).boundaryEvent().cancelActivity(true).conditionalEventDefinition(CONDITIONAL_EVENT).condition(CONDITION_EXPR).conditionalEventDefinitionDone().done();
    engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    // when task is completed
    taskService.complete(taskQuery.singleResult().getId());
    // then service task with delegated code is called and variable is set
    // -> conditional event is triggered and process instance ends
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(0, tasksAfterVariableIsSet.size());
    assertEquals(0, conditionEventSubscriptionQuery.list().size());
    assertNull(runtimeService.createProcessInstanceQuery().singleResult());
}
Also used : TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 99 with BpmnModelInstance

use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.

the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInSubProcessInDelegatedCode.

@Test
public void testNonInterruptingSetVariableInSubProcessInDelegatedCode() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().serviceTask().camundaExpression(EXPR_SET_VARIABLE).userTask().name(TASK_AFTER_SERVICE_TASK).endEvent().subProcessDone().endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, SUB_PROCESS_ID, false);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    Task task = taskQuery.singleResult();
    assertNotNull(task);
    assertEquals(TASK_BEFORE_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then service task in sub process sets variable
    // conditional event is triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(2, tasksAfterVariableIsSet.size());
    assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 100 with BpmnModelInstance

use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.

the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInEndListener.

@Test
public void testNonInterruptingSetVariableInEndListener() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_END, EXPR_SET_VARIABLE).userTask().name(AFTER_TASK).endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, false);
    // given
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
    Task task = taskQuery.singleResult();
    assertNotNull(task);
    assertEquals(TASK_WITH_CONDITION, task.getName());
    // when task is completed
    taskService.complete(task.getId());
    // then end listener sets variable
    // non interrupting boundary event is not triggered
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(AFTER_TASK, tasksAfterVariableIsSet.get(0).getName());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)587 Test (org.junit.Test)408 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)258 Task (org.camunda.bpm.engine.task.Task)139 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)124 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)119 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)67 ProcessApplicationDeployment (org.camunda.bpm.engine.repository.ProcessApplicationDeployment)47 Deployment (org.camunda.bpm.engine.repository.Deployment)39 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)27 Job (org.camunda.bpm.engine.runtime.Job)24 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)22 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)21 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)16 Date (java.util.Date)15 HashMap (java.util.HashMap)15 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)14 Execution (org.camunda.bpm.engine.runtime.Execution)14 MigratingBpmnEventTrigger (org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger)14 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)14