use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method restartProcessInstanceWithNullProcessInstanceId.
@Test
public void restartProcessInstanceWithNullProcessInstanceId() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
try {
runtimeService.restartProcessInstances(processDefinition.getId()).startAfterActivity("bar").processInstanceIds((String) null).execute();
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("Process instance ids cannot be null"));
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceWithInitialVariables.
@Test
public void shouldRestartProcessInstanceWithInitialVariables() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent("startEvent").userTask("userTask1").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, SetVariableExecutionListenerImpl.class.getName()).userTask("userTask2").endEvent().done();
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
// initial variable
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("var", "bar"));
// variable update
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).active().singleResult();
taskService.complete(task.getId());
// delete process instance
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").initialSetOfVariables().processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().active().singleResult();
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().processInstanceIdIn(restartedProcessInstance.getId()).singleResult();
assertEquals(variableInstance.getExecutionId(), restartedProcessInstance.getId());
assertEquals("var", variableInstance.getName());
assertEquals("bar", variableInstance.getValue());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldSkipIoMappings.
@Test
public void shouldSkipIoMappings() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).activityBuilder("userTask1").camundaInputParameter("foo", "bar").done());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").skipIoMappings().processInstanceIds(processInstance.getId()).execute();
// then
Execution task1Execution = runtimeService.createExecutionQuery().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 RestartProcessInstanceSyncTest method shouldNotSetInitialVariablesIfThereIsNoUniqueStartActivity.
@Test
public void shouldNotSetInitialVariablesIfThereIsNoUniqueStartActivity() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.createProcessInstanceById(processDefinition.getId()).startBeforeActivity("userTask1").startBeforeActivity("userTask2").setVariable("foo", "bar").execute();
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").initialSetOfVariables().processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).singleResult();
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().processInstanceIdIn(restartedProcessInstance.getId()).list();
Assert.assertEquals(0, variables.size());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldNotSetInitialVersionOfLocalVariables.
@Test
public void shouldNotSetInitialVersionOfLocalVariables() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("var", "bar"));
Execution subProcess = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("userTask").singleResult();
runtimeService.setVariableLocal(subProcess.getId(), "local", "foo");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).initialSetOfVariables().execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult();
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().processInstanceIdIn(restartedProcessInstance.getId()).list();
assertEquals(1, variables.size());
assertEquals("var", variables.get(0).getName());
assertEquals("bar", variables.get(0).getValue());
}
Aggregations