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);
}
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());
}
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();
}
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"));
}
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"));
}
Aggregations