use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method restartProcessInstanceWithoutInstructions.
@Test
public void restartProcessInstanceWithoutInstructions() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
try {
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).processInstanceIds(processInstance.getId()).executeAsync();
helper.completeBatch(batch);
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("instructions is empty"));
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldSkipIoMappings.
@Test
public void shouldSkipIoMappings() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).activityBuilder("userTask1").camundaInputParameter("foo", "bar").done());
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").skipIoMappings().processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list();
Execution task1Execution = runtimeService.createExecutionQuery().processInstanceId(restartedProcessInstances.get(0).getId()).activityId("userTask1").singleResult();
assertNotNull(task1Execution);
assertNull(runtimeService.getVariable(task1Execution.getId(), "foo"));
task1Execution = runtimeService.createExecutionQuery().processInstanceId(restartedProcessInstances.get(1).getId()).activityId("userTask1").singleResult();
assertNotNull(task1Execution);
assertNull(runtimeService.getVariable(task1Execution.getId(), "foo"));
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldRestartProcessInstance.
@Test
public void shouldRestartProcessInstance() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
Task task1 = taskService.createTaskQuery().processInstanceId(processInstance1.getId()).active().singleResult();
Task task2 = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).active().singleResult();
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().active().list();
ProcessInstance restartedProcessInstance = restartedProcessInstances.get(0);
Task restartedTask = engineRule.getTaskService().createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
Assert.assertEquals(task1.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
restartedProcessInstance = restartedProcessInstances.get(1);
restartedTask = engineRule.getTaskService().createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
Assert.assertEquals(task2.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchWithFailedExecutionJobDeletionWithCascade.
@Test
public void testBatchWithFailedExecutionJobDeletionWithCascade() {
// 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);
// create incidents
List<Job> executionJobs = helper.getExecutionJobs(batch);
for (Job executionJob : executionJobs) {
engineRule.getManagementService().setJobRetries(executionJob.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 shouldRestartProcessInstanceWithBusinessKey.
@Test
public void shouldRestartProcessInstanceWithBusinessKey() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process", "businessKey1", (String) null);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process", "businessKey2", (String) null);
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().list();
ProcessInstance restartedProcessInstance1 = restartedProcessInstances.get(0);
ProcessInstance restartedProcessInstance2 = restartedProcessInstances.get(1);
assertNotNull(restartedProcessInstance1.getBusinessKey());
assertNotNull(restartedProcessInstance2.getBusinessKey());
}
Aggregations