Search in sources :

Example 16 with BpmnModelInstance

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));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 17 with BpmnModelInstance

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()));
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 18 with BpmnModelInstance

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));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 19 with BpmnModelInstance

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()));
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 20 with BpmnModelInstance

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) 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