use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldRestartProcessInstanceWithParallelGateway.
@Test
public void shouldRestartProcessInstanceWithParallelGateway() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").startBeforeActivity("userTask2").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().active().list();
for (ProcessInstance restartedProcessInstance : restartedProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(restartedProcessInstance.getId());
assertNotNull(updatedTree);
assertEquals(restartedProcessInstance.getId(), updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("userTask1").activity("userTask2").done());
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceAsyncStartEvent.
@Deployment(resources = ASYNC_PROCESS)
public void testHistoricProcessInstanceAsyncStartEvent() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task2").setVariable("aVar", "aValue").execute();
// then
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(historicInstance);
assertEquals(instance.getId(), historicInstance.getId());
assertNotNull(historicInstance.getStartTime());
assertNull(historicInstance.getEndTime());
// should be the first activity started
assertEquals("task2", historicInstance.getStartActivityId());
// task2 wasn't entered yet
assertEquals(0, historyService.createHistoricActivityInstanceQuery().count());
// history events for variables exist already
ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult();
assertNotNull(historicVariable);
assertEquals(instance.getId(), historicVariable.getProcessInstanceId());
assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId());
assertEquals("aVar", historicVariable.getName());
assertEquals("aValue", historicVariable.getValue());
HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.getId()).singleResult();
assertEquals(instance.getId(), historicDetail.getProcessInstanceId());
assertNotNull(historicDetail);
// TODO: fix if this is not ok due to CAM-3886
assertNull(historicDetail.getActivityInstanceId());
assertTrue(historicDetail instanceof HistoricVariableUpdate);
assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceWithSubProcess.
@Test
public void shouldRestartProcessInstanceWithSubProcess() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("subProcess").processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().active().singleResult();
ActivityInstance updatedTree = runtimeService.getActivityInstance(restartedProcessInstance.getId());
assertNotNull(updatedTree);
assertEquals(restartedProcessInstance.getId(), updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).beginScope("subProcess").activity("userTask").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery.
@Test
public void shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId());
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").historicProcessInstanceQuery(historicProcessInstanceQuery).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().active().singleResult();
ActivityInstance updatedTree = runtimeService.getActivityInstance(restartedProcessInstance.getId());
assertNotNull(updatedTree);
assertEquals(restartedProcessInstance.getId(), updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("userTask1").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationRemoveSubProcessTest method testCanOnlyTriggerCompensationInParentOfRemovedScope.
@Test
public void testCanOnlyTriggerCompensationInParentOfRemovedScope() {
BpmnModelInstance sourceModel = ProcessModels.newModel().startEvent().subProcess("outerSubProcess").embeddedSubProcess().startEvent().userTask("userTask1").boundaryEvent("compensationBoundary").compensateEventDefinition().compensateEventDefinitionDone().moveToActivity("userTask1").subProcess("innerSubProcess").embeddedSubProcess().startEvent().userTask("userTask2").endEvent().subProcessDone().endEvent().subProcessDone().done();
CompensationModels.addUserTaskCompensationHandler(sourceModel, "compensationBoundary", "compensationHandler");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceModel);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL).endEventBuilder("subProcessEnd").compensateEventDefinition().waitForCompletion(true).compensateEventDefinitionDone().done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("innerSubProcess", "subProcess").mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when
testHelper.completeTask("userTask2");
// then compensation is not triggered from inside the inner sub process
// but only on process definition level
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").beginScope("subProcess").activity("compensationHandler").done());
}
Aggregations