protected List<Execution> collectExecutionsFor(String... activityIds) { List<Execution> executions = new ArrayList<Execution>(); for (String activityId : activityIds) { executions.addAll(runtimeService.createExecutionQuery().activityId(activityId).list()); } return executions; } }
public void testQueryByInvalidActivityId() { ExecutionQuery query = runtimeService.createExecutionQuery().activityId("invalid"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); }
@Deployment public void testExecutionExternalTask() { runtimeService.startProcessInstanceByKey("oneExternalTaskProcess"); ExecutionEntity execution = (ExecutionEntity) runtimeService .createExecutionQuery() .activityId("externalTask") .singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.EXTERNAL_TASKS_BIT), execution.getCachedEntityStateRaw()); }
@Deployment public void testInputExternalClasspathScriptValueAsVariable() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("scriptPath", "classpath://org/camunda/bpm/engine/test/bpmn/iomapping/oneplusone.groovy"); runtimeService.startProcessInstanceByKey("testProcess", variables); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment public void testInputExternalClasspathScriptValueAsBean() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("onePlusOneBean", new OnePlusOneBean()); runtimeService.startProcessInstanceByKey("testProcess", variables); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment public void testAsyncStartEvent() { runtimeService.startProcessInstanceByKey("asyncStartEvent"); Task task = taskService.createTaskQuery().singleResult(); Assert.assertNull("The user task should not have been reached yet", task); Assert.assertEquals(1, runtimeService.createExecutionQuery().activityId("startEvent").count()); executeAvailableJobs(); task = taskService.createTaskQuery().singleResult(); Assert.assertEquals(0, runtimeService.createExecutionQuery().activityId("startEvent").count()); Assert.assertNotNull("The user task should have been reached", task); }
@Deployment public void testInputExternalScriptValueAsBean() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("onePlusOneBean", new OnePlusOneBean()); runtimeService.startProcessInstanceByKey("testProcess", variables); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Test public void testSendTaskWithBoundaryEvent() throws Exception { // given testHelper.deploy(PROCESS_WITH_SEND_TASK_AND_BOUNDARY_EVENT); runtimeService.startProcessInstanceByKey("process"); Execution activity = runtimeService.createExecutionQuery().activityId("sendTask").singleResult(); runtimeService.signal(activity.getId()); // then checkRecordedEvents("sendTask", "boundary", "endEventBoundary"); }
@Deployment public void testQueryByVariableInParallelBranch() throws Exception { runtimeService.startProcessInstanceByKey("parallelGateway"); // when there are two process variables of the same name but different types Execution task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult(); runtimeService.setVariableLocal(task1Execution.getId(), "var", 12345L); Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult(); runtimeService.setVariableLocal(task2Execution.getId(), "var", 12345); // then the task query should be able to filter by both variables and return both tasks assertEquals(2, taskService.createTaskQuery().processVariableValueEquals("var", 12345).count()); assertEquals(2, taskService.createTaskQuery().processVariableValueEquals("var", 12345L).count()); }
@Deployment public void testJavaServiceDelegation() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("javaServiceDelegation", CollectionUtil.singletonMap("input", "Activiti BPM Engine")); Execution execution = runtimeService.createExecutionQuery() .processInstanceId(pi.getId()) .activityId("waitState") .singleResult(); assertEquals("ACTIVITI BPM ENGINE", runtimeService.getVariable(execution.getId(), "input")); }
@Deployment public void testAsyncEndEvent() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("asyncEndEvent"); long count = runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).active().count(); Assert.assertEquals(1, runtimeService.createExecutionQuery().activityId("endEvent").count()); Assert.assertEquals(1, count); executeAvailableJobs(); count = runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).count(); Assert.assertEquals(0, runtimeService.createExecutionQuery().activityId("endEvent").active().count()); Assert.assertEquals(0, count); }
@Deployment public void testExecutionJobsParallel() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(0, processInstance.getCachedEntityStateRaw()); ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("userTask").singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.JOBS_STATE_BIT), execution.getCachedEntityStateRaw()); }
@Deployment public void testWaitStateBehavior() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask"); Execution execution = runtimeService.createExecutionQuery() .processInstanceId(pi.getId()) .activityId("waitState") .singleResult(); assertNotNull(execution); runtimeService.signal(execution.getId()); assertProcessEnded(pi.getId()); } }
@Deployment public void testParallelReceiveTasks() { ProcessInstance procInst = runtimeService.startProcessInstanceByKey("miParallelReceiveTasks"); String procId = procInst.getId(); assertEquals(3, runtimeService.createEventSubscriptionQuery().count()); List<Execution> receiveTaskExecutions = runtimeService .createExecutionQuery().activityId("miTasks").list(); for (Execution execution : receiveTaskExecutions) { runtimeService.messageEventReceived("message", execution.getId()); } assertProcessEnded(procId); }
@Deployment public void testExecutionTasksScope() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(0, processInstance.getCachedEntityStateRaw()); ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("userTask").singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.TASKS_STATE_BIT), execution.getCachedEntityStateRaw()); }
@Deployment public void testInputExternalClasspathScriptValue() { runtimeService.startProcessInstanceByKey("testProcess"); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment public void testInputElValue() { runtimeService.startProcessInstanceByKey("testProcess"); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2l, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment public void testInputExternalScriptValue() { runtimeService.startProcessInstanceByKey("testProcess"); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/iomapping/InputOutputTest.testInputExternalDeploymentScriptValue.bpmn", "org/camunda/bpm/engine/test/bpmn/iomapping/oneplusone.groovy" }) public void testInputExternalDeploymentScriptValue() { runtimeService.startProcessInstanceByKey("testProcess"); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); assertEquals(2, variable.getValue()); assertEquals(execution.getId(), variable.getExecutionId()); }
@Deployment public void testCatchErrorOnSubprocessThrownByInterruptingEventSubprocess() { runtimeService.startProcessInstanceByKey("testProcess"); EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); runtimeService.messageEventReceived("message", messageSubscription.getExecutionId()); // should successfully have reached the task following the boundary event Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult(); assertNotNull(taskExecution); Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult(); assertNotNull(task); }