use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallCmmnCaseParallelMultiInstance.
@Test
public void testCallCmmnCaseParallelMultiInstance() {
// given
BpmnModelInstance model = modify(CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase")).activityBuilder("callActivity").multiInstance().parallel().cardinality("1").done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity#multiInstanceBody", "callActivity#multiInstanceBody").mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity#multiInstanceBody")).child("callActivity").concurrent().noScope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginMiBody("callActivity").activity("callActivity", testHelper.getSingleActivityInstanceBeforeMigration("callActivity").getId()).done());
// and the link between calling and called instance is maintained correctly
testHelper.assertSuperExecutionOfCaseInstance(rule.getCaseService().createCaseInstanceQuery().caseDefinitionKey("oneTaskCase").singleResult().getId(), testHelper.getSingleExecutionIdForActivityAfterMigration("callActivity"));
// and it is possible to complete the called case instance
CaseExecution caseExecution = rule.getCaseService().createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
testHelper.completeTask("PI_HumanTask_1");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
// and close the called case instance
rule.getCaseService().withCaseExecution(caseExecution.getCaseInstanceId()).close();
testHelper.assertCaseEnded(caseExecution.getCaseInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallBpmnProcessReconfigureCallActivity.
@Test
public void testCallBpmnProcessReconfigureCallActivity() {
// given
BpmnModelInstance model = CallActivityModels.oneBpmnCallActivityProcess("oneTaskProcess");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(model).callActivityBuilder("callActivity").calledElement("foo").done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then the called instance has not changed (e.g. not been migrated to a different process definition)
ProcessInstance calledInstance = rule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").singleResult();
Assert.assertNotNull(calledInstance);
// and it is possible to complete the called process instance
testHelper.completeTask("userTask");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallCmmnCaseSimpleMigration.
@Test
public void testCallCmmnCaseSimpleMigration() {
// given
BpmnModelInstance model = CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("callActivity").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("callActivity", testHelper.getSingleActivityInstanceBeforeMigration("callActivity").getId()).done());
// and it is possible to complete the called case instance
CaseExecution caseExecution = rule.getCaseService().createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
testHelper.completeTask("PI_HumanTask_1");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
// and close the called case instance
rule.getCaseService().withCaseExecution(caseExecution.getCaseInstanceId()).close();
testHelper.assertCaseEnded(caseExecution.getCaseInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCannotMapCompensateStartEventWithoutMappingEventScopeCase2.
@Test
public void testCannotMapCompensateStartEventWithoutMappingEventScopeCase2() {
// given
BpmnModelInstance model = modify(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL).removeFlowNode("compensationBoundary");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
try {
// when
rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventSubProcessStart", "eventSubProcessStart").build();
Assert.fail("exception expected");
} catch (MigrationPlanValidationException e) {
// then
assertThat(e.getValidationReport()).hasInstructionFailures("eventSubProcessStart", "The source activity's event scope (subProcess) must be mapped to the target activity's event scope (subProcess)");
}
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method testCustomIncidentMigration.
@Test
public void testCustomIncidentMigration() {
// given
RuntimeService runtimeService = engineRule.getRuntimeService();
BpmnModelInstance instance1 = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
BpmnModelInstance instance2 = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();
testHelper.deploy(instance1, instance2);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processInstance1.getProcessDefinitionId(), processInstance2.getProcessDefinitionId()).mapActivities("u1", "u2").build();
runtimeService.createIncident("custom", processInstance1.getId(), "foo");
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId()).execute();
// then
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertEquals(processInstance2.getProcessDefinitionId(), incident.getProcessDefinitionId());
assertEquals("custom", incident.getIncidentType());
assertEquals(processInstance1.getId(), incident.getExecutionId());
}
Aggregations