Search in sources :

Example 91 with BpmnModelInstance

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

the class MigrationPlanCreationTest method testMapBoundaryToParentActivity.

@Test
public void testMapBoundaryToParentActivity() {
    BpmnModelInstance sourceProcess = modify(ProcessModels.SUBPROCESS_PROCESS).activityBuilder("userTask").boundaryEvent("boundary").message(MESSAGE_NAME).done();
    BpmnModelInstance targetProcess = modify(ProcessModels.SUBPROCESS_PROCESS).activityBuilder("subProcess").boundaryEvent("boundary").message(MESSAGE_NAME).done();
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    try {
        runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "subProcess").mapActivities("userTask", "userTask").mapActivities("boundary", "boundary").build();
        fail("Should not succeed");
    } catch (MigrationPlanValidationException e) {
        assertThat(e.getValidationReport()).hasInstructionFailures("boundary", "The source activity's event scope (userTask) must be mapped to the target activity's event scope (subProcess)", "The closest mapped ancestor 'subProcess' is mapped to scope 'subProcess' which is not an ancestor of target scope 'boundary'");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 92 with BpmnModelInstance

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

the class MigrationPlanCreationTest method testMapBoundaryEventsWithDifferentId.

@Test
public void testMapBoundaryEventsWithDifferentId() {
    BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder("userTask").boundaryEvent("boundary").message(MESSAGE_NAME).done();
    BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId("boundary", "newBoundary");
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").mapActivities("boundary", "newBoundary").build();
    assertThat(migrationPlan).hasSourceProcessDefinition(sourceProcessDefinition).hasTargetProcessDefinition(targetProcessDefinition).hasInstructions(migrate("userTask").to("userTask"), migrate("boundary").to("newBoundary"));
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 93 with BpmnModelInstance

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

the class MigrationPlanCreationTest method testMapUserTaskInEventSubProcess.

@Test
public void testMapUserTaskInEventSubProcess() {
    BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS).addSubProcessTo("subProcess").triggerByEvent().embeddedSubProcess().startEvent().message(MESSAGE_NAME).userTask("innerTask").endEvent().subProcessDone().done();
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").mapActivities("innerTask", "innerTask").build();
    assertThat(migrationPlan).hasSourceProcessDefinition(sourceProcessDefinition).hasTargetProcessDefinition(targetProcessDefinition).hasInstructions(migrate("userTask").to("userTask"), migrate("innerTask").to("innerTask"));
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 94 with BpmnModelInstance

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

the class BoundaryConditionalEventTest method testSetVariableInTakeListener.

@Test
public void testSetVariableInTakeListener() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).endEvent().done();
    CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
    listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
    listener.setCamundaExpression(EXPR_SET_VARIABLE);
    modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
    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 take listener sets variable
    // non interrupting boundary event is triggered with default evaluation behavior
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
Also used : Task(org.camunda.bpm.engine.task.Task) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CamundaExecutionListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 95 with BpmnModelInstance

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

the class BoundaryConditionalEventTest method testSetVariableInInMappingOfCallActivity.

@Test
public void testSetVariableInInMappingOfCallActivity() {
    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).camundaIn(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 in mapping from call activity sets variable
    // -> interrupting conditional event is not triggered, since variable is only locally
    tasksAfterVariableIsSet = taskQuery.list();
    assertEquals(TASK_AFTER_OUTPUT_MAPPING, 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