use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchWithFailedSeedJobDeletionWithCascade.
@Test
public void testBatchWithFailedSeedJobDeletionWithCascade() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_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()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
// create incident
Job seedJob = helper.getSeedJob(batch);
engineRule.getManagementService().setJobRetries(seedJob.getId(), 0);
engineRule.getManagementService().deleteBatch(batch.getId(), true);
// then the no historic incidents exists
long historicIncidents = engineRule.getHistoryService().createHistoricIncidentQuery().count();
assertEquals(0, historicIncidents);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchDeletionWithoutCascade.
@Test
public void testBatchDeletionWithoutCascade() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_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()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.executeSeedJob(batch);
engineRule.getManagementService().deleteBatch(batch.getId(), false);
// then the batch was deleted
assertEquals(0, engineRule.getManagementService().createBatchQuery().count());
// and the seed and execution job definition were deleted
assertEquals(0, engineRule.getManagementService().createJobDefinitionQuery().count());
// and the seed job and execution jobs were deleted
assertEquals(0, engineRule.getManagementService().createJobQuery().count());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldNotSetInitialVariablesIfThereIsNoUniqueStartActivity.
@Test
public void shouldNotSetInitialVariablesIfThereIsNoUniqueStartActivity() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.createProcessInstanceById(processDefinition.getId()).startBeforeActivity("userTask2").startBeforeActivity("userTask1").execute();
ProcessInstance processInstance2 = runtimeService.createProcessInstanceById(processDefinition.getId()).startBeforeActivity("userTask1").startBeforeActivity("userTask2").setVariable("foo", "bar").execute();
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").initialSetOfVariables().processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list();
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().processInstanceIdIn(restartedProcessInstances.get(0).getId(), restartedProcessInstances.get(1).getId()).list();
Assert.assertEquals(0, variables.size());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition 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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldSkipCustomListeners.
@Test
public void shouldSkipCustomListeners() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).activityBuilder("userTask1").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, IncrementCounterListener.class.getName()).done());
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
IncrementCounterListener.counter = 0;
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).skipCustomListeners().executeAsync();
helper.completeBatch(batch);
// then
assertEquals(0, IncrementCounterListener.counter);
}
Aggregations