use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationSubProcessTest method shouldCompleteParentProcessWithMultiInstanceInsideEmbeddedSubProcess.
@Test
public void shouldCompleteParentProcessWithMultiInstanceInsideEmbeddedSubProcess() {
final BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().subProcess().embeddedSubProcess().startEvent().callActivity("callActivity").calledElement("subprocess").multiInstance().cardinality("3").multiInstanceDone().endEvent().subProcessDone().endEvent().done();
final BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done();
testHelper.deploy(parentProcessInstance, subprocessInstance);
final String subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().getId();
// given I start the process, which waits at user task inside multiinstance subprocess
runtimeService.startProcessInstanceByKey("parentProcess");
final List<ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list();
assertEquals(3, subprocesses.size());
// when I do process instance modification
runtimeService.createModification(subprocessPrDefId).cancelAllForActivity("userTask").startAfterActivity("userTask").processInstanceIds(collectIds(subprocesses)).execute();
// then the process should be finished
assertThat(runtimeService.createProcessInstanceQuery().count(), is(0L));
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationSubProcessTest method shouldContinueParentProcessWithMultiInstanceInsideEmbeddedSubProcess.
@Test
public void shouldContinueParentProcessWithMultiInstanceInsideEmbeddedSubProcess() {
final BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().subProcess().embeddedSubProcess().startEvent().callActivity("callActivity").calledElement("subprocess").multiInstance().cardinality("3").multiInstanceDone().endEvent().subProcessDone().userTask().endEvent().done();
final BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done();
testHelper.deploy(parentProcessInstance, subprocessInstance);
final String subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().getId();
// given I start the process, which waits at user task inside multiinstance subprocess
ProcessInstance parentPI = runtimeService.startProcessInstanceByKey("parentProcess");
final List<ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list();
assertEquals(3, subprocesses.size());
// when I do process instance modification
runtimeService.createModification(subprocessPrDefId).cancelAllForActivity("userTask").startAfterActivity("userTask").processInstanceIds(collectIds(subprocesses)).execute();
// then the parent process instance is still active
assertThat(runtimeService.createProcessInstanceQuery().count(), is(1L));
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getProcessInstanceId(), is(parentPI.getId()));
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationSubProcessTest method shouldCompleteParentProcessWithMultiInstance.
@Test
public void shouldCompleteParentProcessWithMultiInstance() {
final BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().callActivity("callActivity").calledElement("subprocess").multiInstance().cardinality("3").multiInstanceDone().endEvent().done();
final BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done();
testHelper.deploy(parentProcessInstance, subprocessInstance);
final String subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().getId();
// given I start the process, which waits at user task inside multiinstance subprocess
runtimeService.startProcessInstanceByKey("parentProcess");
final List<ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list();
assertEquals(3, subprocesses.size());
// when I do process instance modification
runtimeService.createModification(subprocessPrDefId).cancelAllForActivity("userTask").startAfterActivity("userTask").processInstanceIds(collectIds(subprocesses)).execute();
// then the process should be finished
assertThat(runtimeService.createProcessInstanceQuery().count(), is(0L));
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationSubProcessTest method shouldContinueParentProcessWithMultiInstanceEmbeddedSubProcess.
@Test
public void shouldContinueParentProcessWithMultiInstanceEmbeddedSubProcess() {
final BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().subProcess().embeddedSubProcess().startEvent().callActivity("callActivity").calledElement("subprocess").endEvent().subProcessDone().multiInstance().cardinality("3").multiInstanceDone().userTask().endEvent().done();
final BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done();
testHelper.deploy(parentProcessInstance, subprocessInstance);
final String subprocessPrDefId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("subprocess").singleResult().getId();
// given I start the process, which waits at user task inside multiinstance subprocess
ProcessInstance parentPI = runtimeService.startProcessInstanceByKey("parentProcess");
final List<ProcessInstance> subprocesses = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").list();
assertEquals(3, subprocesses.size());
// when I do process instance modification
runtimeService.createModification(subprocessPrDefId).cancelAllForActivity("userTask").startAfterActivity("userTask").processInstanceIds(collectIds(subprocesses)).execute();
// then the parent process instance is still active
assertThat(runtimeService.createProcessInstanceQuery().count(), is(1L));
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getProcessInstanceId(), is(parentPI.getId()));
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationVariableTest method modifyAProcessInstanceWithLocalVariableCreation.
@Test
public void modifyAProcessInstanceWithLocalVariableCreation() {
// given a process that sets a local variable when entering the user task
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().userTask("userTask").camundaTaskListenerClass("create", "org.camunda.bpm.engine.test.api.runtime.util.CreateLocalVariableEventListener").endEvent().done();
testHelper.deployAndGetDefinition(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
// when I start another activity and delete the old one
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("userTask").cancelActivityInstance(updatedTree.getActivityInstances("userTask")[0].getId()).execute(false, false);
// then migration was successful and I can finish the process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
testHelper.assertProcessEnded(processInstance.getId());
}
Aggregations