use of org.camunda.bpm.engine.runtime.VariableInstance 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.runtime.VariableInstance 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.runtime.VariableInstance 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.runtime.VariableInstance 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());
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationRemoveSubProcessTest method testNoOutputMappingExecuted.
@Test
public void testNoOutputMappingExecuted() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).activityBuilder("subProcess").camundaOutputParameter("foo", "${bar}").done());
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
rule.getRuntimeService().setVariable(processInstance.getId(), "bar", "value1");
// => sets "foo" to "value1"
testHelper.completeTask("userTask1");
rule.getRuntimeService().setVariable(processInstance.getId(), "bar", "value2");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then "foo" has not been set to "value2"
// "foo" and "bar"
Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().size());
VariableInstance variableInstance = testHelper.snapshotAfterMigration.getSingleVariable("foo");
Assert.assertEquals("value1", variableInstance.getValue());
}
Aggregations