use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class TestOrderingUtil method executionByProcessDefinitionKey.
public static NullTolerantComparator<Execution> executionByProcessDefinitionKey(ProcessEngine processEngine) {
final RuntimeService runtimeService = processEngine.getRuntimeService();
final RepositoryService repositoryService = processEngine.getRepositoryService();
return propertyComparator(new PropertyAccessor<Execution, String>() {
@Override
public String getProperty(Execution obj) {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(obj.getProcessInstanceId()).singleResult();
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
return processDefinition.getKey();
}
});
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesTest method testIoMappingInvocation.
@Deployment(resources = IO_PROCESS)
public void testIoMappingInvocation() {
// when
runtimeService.createProcessInstanceByKey("ioProcess").startBeforeActivity("innerTask").execute();
// then no io mappings have been executed
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().orderByVariableName().asc().list();
assertEquals(2, variables.size());
Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
VariableInstance innerTaskVariable = variables.get(0);
assertEquals("innerTaskVariable", innerTaskVariable.getName());
assertEquals("innerTaskValue", innerTaskVariable.getValue());
assertEquals(innerTaskExecution.getId(), innerTaskVariable.getExecutionId());
VariableInstance subProcessVariable = variables.get(1);
assertEquals("subProcessVariable", subProcessVariable.getName());
assertEquals("subProcessValue", subProcessVariable.getValue());
assertEquals(((ExecutionEntity) innerTaskExecution).getParentId(), subProcessVariable.getExecutionId());
}
use of org.camunda.bpm.engine.runtime.Execution 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.runtime.Execution 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.runtime.Execution 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