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