Search in sources :

Example 51 with BpmnModelInstance

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

the class MigrationUserTaskTest method testAccessModelInTaskListenerAfterMigration.

@Test
public void testAccessModelInTaskListenerAfterMigration() {
    BpmnModelInstance targetModel = modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("userTask", "newUserTask");
    addTaskListener(targetModel, "newUserTask", TaskListener.EVENTNAME_ASSIGNMENT, AccessModelInstanceTaskListener.class.getName());
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetModel);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "newUserTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // when
    Task task = rule.getTaskService().createTaskQuery().singleResult();
    rule.getTaskService().setAssignee(task.getId(), "foo");
    // then the task listener was able to access the bpmn model instance and set a variable
    String variableValue = (String) rule.getRuntimeService().getVariable(processInstance.getId(), AccessModelInstanceTaskListener.VARIABLE_NAME);
    Assert.assertEquals("newUserTask", variableValue);
}
Also used : UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 52 with BpmnModelInstance

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

the class MigrationWithoutTriggerConditionTest method tesConditionalEventSubProcessWithSetVariableOnStartListener.

@Test
public void tesConditionalEventSubProcessWithSetVariableOnStartListener() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).addSubProcessTo(PROC_DEF_KEY).triggerByEvent().embeddedSubProcess().startEvent(EVENT_SUB_PROCESS_START_ID).condition(VAR_CONDITION).userTask(TASK_AFTER_CONDITION_ID).endEvent().done());
    BpmnModelInstance targetModel = modify(Bpmn.createExecutableProcess(PROC_DEF_KEY).startEvent().subProcess(SUB_PROCESS_ID).camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, SetVariableDelegate.class.getName()).embeddedSubProcess().startEvent().userTask(USER_TASK_ID).endEvent().subProcessDone().endEvent().done()).addSubProcessTo(SUB_PROCESS_ID).triggerByEvent().embeddedSubProcess().startEvent().condition(VAR_CONDITION).endEvent().done();
    targetModel = modify(targetModel).addSubProcessTo(PROC_DEF_KEY).triggerByEvent().embeddedSubProcess().startEvent(EVENT_SUB_PROCESS_START_ID).condition(VAR_CONDITION).userTask(TASK_AFTER_CONDITION_ID).endEvent().done();
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetModel);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).updateEventTrigger().build();
    // when sub process is added, start listener is called and sets variable
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID, null);
    assertEquals(1, rule.getRuntimeService().getVariable(processInstance.getId(), VARIABLE_NAME));
    // then conditional event is not triggered
    assertEquals(USER_TASK_ID, rule.getTaskService().createTaskQuery().singleResult().getTaskDefinitionKey());
    // when any var is set
    testHelper.setAnyVariable(processInstance.getId());
    // then condition is satisfied, since variable is already set which satisfies condition
    testHelper.completeTask(TASK_AFTER_CONDITION_ID);
    testHelper.assertProcessEnded(processInstance.getId());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 53 with BpmnModelInstance

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

the class MigrationPlanGenerationTest method testNotMigrateMultiInstanceOfDifferentType.

@Test
public void testNotMigrateMultiInstanceOfDifferentType() {
    BpmnModelInstance sourceProcess = MultiInstanceProcessModels.SEQ_MI_ONE_TASK_PROCESS;
    BpmnModelInstance targetProcess = MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS;
    assertGeneratedMigrationPlan(sourceProcess, targetProcess).hasEmptyInstructions();
}
Also used : BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 54 with BpmnModelInstance

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

the class MigrationPlanGenerationTest method testNotMigrateBoundaryEventsOfDifferentType.

@Test
public void testNotMigrateBoundaryEventsOfDifferentType() {
    BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder("userTask").boundaryEvent("boundary").message(MESSAGE_NAME).done();
    BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder("userTask").boundaryEvent("boundary").signal(SIGNAL_NAME).done();
    assertGeneratedMigrationPlan(sourceProcess, targetProcess).hasInstructions(migrate("userTask").to("userTask"));
}
Also used : BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 55 with BpmnModelInstance

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

the class MigrationPlanGenerationTest method testMapEmbeddedSubProcessToTransaction.

@Test
public void testMapEmbeddedSubProcessToTransaction() {
    BpmnModelInstance sourceProcess = ProcessModels.SUBPROCESS_PROCESS;
    BpmnModelInstance targetProcess = modify(TransactionModels.ONE_TASK_TRANSACTION).changeElementId("transaction", "subProcess");
    assertGeneratedMigrationPlan(sourceProcess, targetProcess).hasInstructions(migrate("subProcess").to("subProcess"), migrate("userTask").to("userTask"));
}
Also used : 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