use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceQueryTest method createIncompleteMockExecutions.
private List<Execution> createIncompleteMockExecutions() {
List<Execution> mocks = new ArrayList<Execution>();
Execution mockExecution = mock(Execution.class);
when(mockExecution.getId()).thenReturn(MockProvider.EXAMPLE_EXECUTION_ID);
mocks.add(mockExecution);
return mocks;
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class MockProvider method createMockExecution.
public static Execution createMockExecution(String tenantId) {
Execution mock = mock(Execution.class);
when(mock.getId()).thenReturn(EXAMPLE_EXECUTION_ID);
when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
when(mock.isEnded()).thenReturn(EXAMPLE_EXECUTION_IS_ENDED);
when(mock.getTenantId()).thenReturn(tenantId);
return mock;
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionResourceImpl method getExecution.
@Override
public ExecutionDto getExecution() {
RuntimeService runtimeService = engine.getRuntimeService();
Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
if (execution == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Execution with id " + executionId + " does not exist");
}
return ExecutionDto.fromExecution(execution);
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryVariablesUpdatedToNullValue.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryVariablesUpdatedToNullValue() {
// Start process instance with different types of variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("longVar", 928374L);
variables.put("shortVar", (short) 123);
variables.put("integerVar", 1234);
variables.put("stringVar", "coca-cola");
variables.put("dateVar", new Date());
variables.put("booleanVar", true);
variables.put("nullVar", null);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().variableValueEquals("longVar", null).variableValueEquals("shortVar", null).variableValueEquals("integerVar", null).variableValueEquals("stringVar", null).variableValueEquals("booleanVar", null).variableValueEquals("dateVar", null);
ProcessInstanceQuery notQuery = runtimeService.createProcessInstanceQuery().variableValueNotEquals("longVar", null).variableValueNotEquals("shortVar", null).variableValueNotEquals("integerVar", null).variableValueNotEquals("stringVar", null).variableValueNotEquals("booleanVar", null).variableValueNotEquals("dateVar", null);
assertNull(query.singleResult());
assertNotNull(notQuery.singleResult());
// Set all existing variables values to null
runtimeService.setVariable(processInstance.getId(), "longVar", null);
runtimeService.setVariable(processInstance.getId(), "shortVar", null);
runtimeService.setVariable(processInstance.getId(), "integerVar", null);
runtimeService.setVariable(processInstance.getId(), "stringVar", null);
runtimeService.setVariable(processInstance.getId(), "dateVar", null);
runtimeService.setVariable(processInstance.getId(), "nullVar", null);
runtimeService.setVariable(processInstance.getId(), "booleanVar", null);
Execution queryResult = query.singleResult();
assertNotNull(queryResult);
assertEquals(processInstance.getId(), queryResult.getId());
assertNull(notQuery.singleResult());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testFindActiveActivityIdProcessWithErrorEventAndSubProcess.
/**
* Testcase to reproduce ACT-950 (https://jira.codehaus.org/browse/ACT-950)
*/
@Deployment
@Test
public void testFindActiveActivityIdProcessWithErrorEventAndSubProcess() {
ProcessInstance processInstance = engineRule.getProcessEngine().getRuntimeService().startProcessInstanceByKey("errorEventSubprocess");
List<String> activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(3, activeActivities.size());
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task parallelUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("ParallelUserTask") && !task.getName().equals("MainUserTask")) {
fail("Expected: <ParallelUserTask> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("ParallelUserTask")) {
parallelUserTask = task;
}
}
assertNotNull(parallelUserTask);
taskService.complete(parallelUserTask.getId());
Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("subprocess1WaitBeforeError").singleResult();
runtimeService.signal(execution.getId());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(2, activeActivities.size());
tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task beforeErrorUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("BeforeError") && !task.getName().equals("MainUserTask")) {
fail("Expected: <BeforeError> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("BeforeError")) {
beforeErrorUserTask = task;
}
}
assertNotNull(beforeErrorUserTask);
taskService.complete(beforeErrorUserTask.getId());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(2, activeActivities.size());
tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task afterErrorUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("AfterError") && !task.getName().equals("MainUserTask")) {
fail("Expected: <AfterError> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("AfterError")) {
afterErrorUserTask = task;
}
}
assertNotNull(afterErrorUserTask);
taskService.complete(afterErrorUserTask.getId());
tasks = taskService.createTaskQuery().list();
assertEquals(1, tasks.size());
assertEquals("MainUserTask", tasks.get(0).getName());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(1, activeActivities.size());
assertEquals("MainUserTask", activeActivities.get(0));
taskService.complete(tasks.get(0).getId());
testRule.assertProcessEnded(processInstance.getId());
}
Aggregations