Search in sources :

Example 21 with BpmnModelInstance

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

the class RuntimeServiceTest method testGetActivityInstanceForCompletedInstanceInDelegate.

@Test
public void testGetActivityInstanceForCompletedInstanceInDelegate() {
    // given
    BpmnModelInstance deletingProcess = Bpmn.createExecutableProcess("process1").startEvent().userTask().serviceTask().camundaClass(DeleteInstanceDelegate.class.getName()).userTask().endEvent().done();
    BpmnModelInstance processToDelete = Bpmn.createExecutableProcess("process2").startEvent().userTask().endEvent().done();
    testRule.deploy(deletingProcess, processToDelete);
    ProcessInstance instanceToDelete = runtimeService.startProcessInstanceByKey("process2");
    ProcessInstance deletingInstance = runtimeService.startProcessInstanceByKey("process1", Variables.createVariables().putValue("instanceToComplete", instanceToDelete.getId()));
    Task deleteTrigger = taskService.createTaskQuery().processInstanceId(deletingInstance.getId()).singleResult();
    // when
    taskService.complete(deleteTrigger.getId());
    // then
    boolean activityInstanceNull = (Boolean) runtimeService.getVariable(deletingInstance.getId(), "activityInstanceNull");
    assertTrue(activityInstanceNull);
}
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 22 with BpmnModelInstance

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

the class RuntimeServiceTest method testDeleteProcessInstanceWithSubprocessInstances.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testDeleteProcessInstanceWithSubprocessInstances() {
    // given a process instance with subprocesses
    BpmnModelInstance calling = prepareComplexProcess("A", "B", "A");
    BpmnModelInstance calledA = prepareSimpleProcess("A");
    BpmnModelInstance calledB = prepareSimpleProcess("B");
    testRule.deploy(calling, calledA, calledB);
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling");
    List<ProcessInstance> subInstances = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).list();
    // when the process instance is deleted and we do not skip sub processes
    String id = instance.getId();
    runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, false);
    // then
    testRule.assertProcessEnded(id);
    for (ProcessInstance subInstance : subInstances) {
        testRule.assertProcessEnded(subInstance.getId());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 23 with BpmnModelInstance

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

the class RuntimeServiceTest method testDeleteProcessInstancesWithSubprocessInstances.

@Test
public void testDeleteProcessInstancesWithSubprocessInstances() {
    // given a process instance with subprocess
    String callingProcessKey = "calling";
    String calledProcessKey = "called";
    BpmnModelInstance calling = prepareCallingProcess(callingProcessKey, calledProcessKey);
    BpmnModelInstance called = prepareSimpleProcess(calledProcessKey);
    testRule.deploy(calling, called);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(callingProcessKey);
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey(callingProcessKey);
    List<ProcessInstance> subprocessList = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).list();
    subprocessList.addAll(runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance2.getId()).list());
    // when
    runtimeService.deleteProcessInstances(Arrays.asList(processInstance.getId(), processInstance2.getId()), null, false, false, false);
    // then
    testRule.assertProcessEnded(processInstance.getId());
    testRule.assertProcessEnded(processInstance2.getId());
    for (ProcessInstance subprocess : subprocessList) {
        testRule.assertProcessEnded(subprocess.getId());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 24 with BpmnModelInstance

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

the class RuntimeServiceTest method testDeleteProcessInstancesManyParallelSubprocesses.

/**
 * CAM-8005 - StackOverflowError must not happen.
 */
@Test
public void testDeleteProcessInstancesManyParallelSubprocesses() {
    final BpmnModelInstance multiInstanceWithSubprocess = Bpmn.createExecutableProcess("multiInstanceWithSubprocess").startEvent().subProcess().embeddedSubProcess().startEvent().userTask("userTask").endEvent().subProcessDone().multiInstance().cardinality("300").multiInstanceDone().endEvent().done();
    testRule.deploy(multiInstanceWithSubprocess);
    final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("multiInstanceWithSubprocess");
    runtimeService.deleteProcessInstance(processInstance.getId(), "some reason");
    assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 25 with BpmnModelInstance

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

the class RuntimeServiceTest method testDeleteCalledSubprocess.

@Test
@RequiredHistoryLevel(ProcessEngineConfigurationImpl.HISTORY_AUDIT)
public void testDeleteCalledSubprocess() {
    // given
    BpmnModelInstance callingInstance = ProcessModels.newModel("oneTaskProcess").startEvent().callActivity().calledElement("called").endEvent().done();
    BpmnModelInstance calledInstance = ProcessModels.newModel("called").startEvent().userTask().endEvent().done();
    testRule.deploy(callingInstance, calledInstance);
    final String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getProcessInstanceId();
    String subprocessId = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").singleResult().getId();
    runtimeService.deleteProcessInstance(subprocessId, TESTING_INSTANCE_DELETION);
    assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(subprocessId).singleResult().getDeleteReason());
    assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getDeleteReason());
}
Also used : BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

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