use of org.camunda.bpm.engine.repository.ProcessDefinition 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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldSkipTenantIdProviderOnRestart.
@Test
public void shouldSkipTenantIdProviderOnRestart() {
// given
engineRule.getProcessEngineConfiguration().setTenantIdProvider(new TestTenantIdProvider());
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
assertEquals(processInstance.getTenantId(), TestTenantIdProvider.TENANT_ID);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// set tenant id provider to fail to verify it is not called during instantiation
engineRule.getProcessEngineConfiguration().setTenantIdProvider(new FailingTenantIdProvider());
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity(ProcessModels.USER_TASK_ID).processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processDefinition.getId()).singleResult();
assertNotNull(restartedInstance);
assertEquals(restartedInstance.getTenantId(), TestTenantIdProvider.TENANT_ID);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceWithTenant.
@Test
public void shouldRestartProcessInstanceWithTenant() {
// given
ProcessDefinition processDefinition = testRule.deployForTenantAndGetDefinition("tenantId", ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult();
assertNotNull(restartedProcessInstance.getTenantId());
assertEquals(processInstance.getTenantId(), restartedProcessInstance.getTenantId());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldNotRestartActiveProcessInstance.
@Test
public void shouldNotRestartActiveProcessInstance() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
// then
thrown.expect(ProcessEngineException.class);
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").initialSetOfVariables().processInstanceIds(processInstance.getId()).execute();
}
use of org.camunda.bpm.engine.repository.ProcessDefinition 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());
}
Aggregations