org.camunda.bpm.engine.runtime.Execution Java Examples
The following examples show how to use
org.camunda.bpm.engine.runtime.Execution.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoundaryConditionalEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testParallelVariableCondition.bpmn20.xml"}) public void testParallelSetVariableOnTaskCondition() { //given process with parallel user tasks and boundary conditional event ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId()); List<Task> tasks = taskQuery.list(); assertEquals(2, tasks.size()); Task task = tasks.get(0); //when variable is set on execution taskService.setVariable(task.getId(), VARIABLE_NAME, 1); //then both boundary event are triggered and process instance ends List<Execution> executions = runtimeService.createExecutionQuery() .processInstanceId(procInst.getId()) .list(); assertEquals(0, executions.size()); tasksAfterVariableIsSet = taskQuery.list(); assertEquals(0, tasksAfterVariableIsSet.size()); }
Example #2
Source File: ExecutionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testClashingValues() throws Exception { Map<String, Object> vars = new HashMap<String, Object>(); vars.put("var", 1234L); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars); Map<String, Object> vars2 = new HashMap<String, Object>(); vars2.put("var", 1234); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars2); List<Execution> executions = runtimeService.createExecutionQuery() .processDefinitionKey("oneTaskProcess") .variableValueEquals("var", 1234L) .list(); assertEquals(1, executions.size()); assertEquals(processInstance.getId(), executions.get(0).getProcessInstanceId()); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); runtimeService.deleteProcessInstance(processInstance2.getId(), "test"); }
Example #3
Source File: ExecutionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml"}) public void testExecutionQueryForSuspendedExecutions() { List<Execution> suspendedExecutions = runtimeService.createExecutionQuery().suspended().list(); assertEquals(suspendedExecutions.size(), 0); for (String instanceId : concurrentProcessInstanceIds) { runtimeService.suspendProcessInstanceById(instanceId); } suspendedExecutions = runtimeService.createExecutionQuery().suspended().list(); assertEquals(12, suspendedExecutions.size()); List<Execution> activeExecutions = runtimeService.createExecutionQuery().active().list(); assertEquals(1, activeExecutions.size()); for (Execution activeExecution : activeExecutions) { assertEquals(activeExecution.getProcessInstanceId(), sequentialProcessInstanceIds.get(0)); } }
Example #4
Source File: CatchErrorFromProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @OperateOnDeployment("clientDeployment") public void testThrowErrorInDelegateExpressionSignalParallelMultiInstance() { String pi = runtimeService.startProcessInstanceByKey("testProcessParallelMI").getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwError()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskError", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #5
Source File: MultiInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment( resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml" }) public void testCatchErrorThrownBySignalOfParallelDelegateExpression() { VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate()); String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwError()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskError", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #6
Source File: IntermediateConditionalEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment public void testFalseCondition() { //given process with intermediate conditional event ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery(); Task task = taskQuery.processInstanceId(procInst.getId()).singleResult(); assertNotNull(task); assertEquals(TASK_BEFORE_CONDITION, task.getName()); //when task before condition is completed taskService.complete(task.getId()); //then next wait state is on conditional event, since condition is false //and a condition event subscription is create Execution execution = runtimeService.createExecutionQuery() .processInstanceId(procInst.getId()) .activityId(CONDITIONAL_EVENT) .singleResult(); assertNotNull(execution); assertEquals(1, conditionEventSubscriptionQuery.list().size()); }
Example #7
Source File: ErrorEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/ErrorEventSubProcessTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml" }) public void testCatchExceptionThrownBySignalOfDelegateExpression() { VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate()); String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult(); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwException()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskException", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #8
Source File: CatchErrorFromProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @OperateOnDeployment("clientDeployment") public void testThrowErrorInSignal() { String pi = runtimeService.startProcessInstanceByKey("testProcess").getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult(); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwError()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskError", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #9
Source File: SingleProcessInstanceModificationAsyncTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = IO_MAPPING_PROCESS) public void testSkipIoMappings() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ioMappingProcess"); // when I start task2 Batch modificationBatch = runtimeService .createProcessInstanceModification(processInstance.getId()) .startBeforeActivity("task2") .executeAsync(false, true); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); // then the input mapping should not have executed Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult(); assertNotNull(task2Execution); assertNull(runtimeService.getVariable(task2Execution.getId(), "inputMappingExecuted")); // when I cancel task2 Batch modificationBatch2 = runtimeService.createProcessInstanceModification(processInstance.getId()).cancelAllForActivity("task2").executeAsync(false, true); assertNotNull(modificationBatch2); executeSeedAndBatchJobs(modificationBatch2); // then the output mapping should not have executed assertNull(runtimeService.getVariable(processInstance.getId(), "outputMappingExecuted")); }
Example #10
Source File: MultiTenancySignalReceiveCmdTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void failToSendSignalToIntermediateCatchEventWithExecutionIdAndNoAuthenticatedTenants() { testRule.deployForTenant(TENANT_ONE, SIGNAL_CATCH_PROCESS); engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").processDefinitionTenantId(TENANT_ONE).execute(); Execution execution = engineRule.getRuntimeService().createExecutionQuery() .processDefinitionKey("signalCatch") .signalEventSubscriptionName("signal") .singleResult(); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot update the process instance"); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getRuntimeService().createSignalEvent("signal").executionId(execution.getId()).send(); }
Example #11
Source File: BoundaryErrorEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment( resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml" }) public void testCatchExceptionThrownBySignalMethodOfDelegateExpression() { VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate()); String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult(); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwException()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskException", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #12
Source File: CompleteProcessWithCallActivityTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @ScenarioUnderTest("init.complete.one.1") public void testCompleteProcessWithCallActivityAndOneCompletedTask() { //given process within sub process ProcessInstance processInstance = rule.processInstance(); Execution subProcess = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).singleResult(); TaskQuery taskQuery = rule.getTaskService().createTaskQuery(); Task taskInSubProcess = taskQuery.processInstanceId(subProcess.getId()).taskName("Task in subprocess").singleResult(); assertNotNull(taskInSubProcess); // Completing the task in the subprocess, finishes the subprocess rule.getTaskService().complete(taskInSubProcess.getId()); Task taskAfterSubProcess = taskQuery.processInstanceId(processInstance.getId()).taskName("Task after subprocess").singleResult(); assertNotNull(taskAfterSubProcess); // Completing this task end the process instance rule.getTaskService().complete(taskAfterSubProcess.getId()); rule.assertScenarioEnded(); }
Example #13
Source File: RestartProcessInstanceSyncTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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")); }
Example #14
Source File: CatchErrorFromProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @OperateOnDeployment("clientDeployment") public void testThrowExceptionInDelegateExpressionSignalParallelMultiInstance() { String pi = runtimeService.startProcessInstanceByKey("testProcessParallelMI").getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwException()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskException", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #15
Source File: MultiTenancyExecutionPropagationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testPropagateTenantIdToEmbeddedSubprocess() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .subProcess() .embeddedSubProcess() .startEvent() .userTask() .endEvent() .subProcessDone() .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); List<Execution> executions = runtimeService.createExecutionQuery().list(); assertThat(executions.size(), is(2)); assertThat(executions.get(0).getTenantId(), is(TENANT_ID)); // inherit the tenant id from parent execution (e.g. process instance) assertThat(executions.get(1).getTenantId(), is(TENANT_ID)); }
Example #16
Source File: CatchErrorFromProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @OperateOnDeployment("clientDeployment") public void testThrowErrorInDelegateExpressionSignal() { String pi = runtimeService.startProcessInstanceByKey("testProcess").getId(); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertNull(runtimeService.getVariable(pi, "signaled")); Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult(); assertNotNull(serviceTask); runtimeService.setVariables(pi, throwError()); runtimeService.signal(serviceTask.getId()); assertTrue((Boolean) runtimeService.getVariable(pi, "executed")); assertTrue((Boolean) runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskError", userTask.getTaskDefinitionKey()); taskService.complete(userTask.getId()); }
Example #17
Source File: MultiTenancyExecutionPropagationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testPropagateTenantIdToConcurrentExecution() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .parallelGateway("fork") .userTask() .parallelGateway("join") .endEvent() .moveToNode("fork") .userTask() .connectTo("join") .done()); startProcessInstance(PROCESS_DEFINITION_KEY); List<Execution> executions = runtimeService.createExecutionQuery().list(); assertThat(executions.size(), is(3)); assertThat(executions.get(0).getTenantId(), is(TENANT_ID)); // inherit the tenant id from process instance assertThat(executions.get(1).getTenantId(), is(TENANT_ID)); assertThat(executions.get(2).getTenantId(), is(TENANT_ID)); }
Example #18
Source File: SelfCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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"); }
Example #19
Source File: ExecutionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testQueryAllVariableTypes() throws Exception { Map<String, Object> vars = new HashMap<String, Object>(); vars.put("nullVar", null); vars.put("stringVar", "string"); vars.put("longVar", 10L); vars.put("doubleVar", 1.2); vars.put("integerVar", 1234); vars.put("booleanVar", true); vars.put("shortVar", (short) 123); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars); ExecutionQuery query = runtimeService.createExecutionQuery() .variableValueEquals("nullVar", null) .variableValueEquals("stringVar", "string") .variableValueEquals("longVar", 10L) .variableValueEquals("doubleVar", 1.2) .variableValueEquals("integerVar", 1234) .variableValueEquals("booleanVar", true) .variableValueEquals("shortVar", (short) 123); List<Execution> executions = query.list(); Assert.assertNotNull(executions); Assert.assertEquals(1, executions.size()); Assert.assertEquals(processInstance.getId(), executions.get(0).getId()); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); }
Example #20
Source File: MessageCorrelationByLocalVariablesTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testReceiveTaskMessageCorrelation() { //given BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1") .startEvent() .subProcess("SubProcess_1").embeddedSubProcess() .startEvent() .receiveTask("MessageReceiver_1").message(TEST_MESSAGE_NAME) .camundaInputParameter("localVar", "${loopVar}") .camundaInputParameter("constVar", "someValue") //to test array of parameters .userTask("UserTask_1") .endEvent() .subProcessDone() .multiInstance().camundaCollection("${vars}").camundaElementVariable("loopVar").multiInstanceDone() .endEvent().done(); testHelper.deploy(model); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("vars", Arrays.asList(1, 2, 3)); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", variables); //when correlated by local variables String messageName = TEST_MESSAGE_NAME; Map<String, Object> correlationKeys = new HashMap<String, Object>(); int correlationKey = 1; correlationKeys.put("localVar", correlationKey); correlationKeys.put("constVar", "someValue"); MessageCorrelationResult messageCorrelationResult = engineRule.getRuntimeService().createMessageCorrelation(messageName) .localVariablesEqual(correlationKeys).setVariables(Variables.createVariables().putValue("newVar", "newValue")).correlateWithResult(); //then one message is correlated, two other continue waiting checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "MessageReceiver_1"); //uncorrelated executions List<Execution> uncorrelatedExecutions = engineRule.getRuntimeService().createExecutionQuery().activityId("MessageReceiver_1").list(); assertEquals(2, uncorrelatedExecutions.size()); }
Example #21
Source File: AsyncTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void FAILING_testFailingAsyncServiceTimer() { // start process runtimeService.startProcessInstanceByKey("asyncService"); // now there are two jobs the message and a timer: assertEquals(2, managementService.createJobQuery().count()); // let 'max-retires' on the message be reached executeAvailableJobs(); // the service failed: the execution is still sitting in the service task: Execution execution = runtimeService.createExecutionQuery().singleResult(); assertNotNull(execution); assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0)); // there are two jobs, the message and the timer (the message will not be retried anymore, max retires is reached.) assertEquals(2, managementService.createJobQuery().count()); // now the timer triggers: ClockUtil.setCurrentTime(new Date(System.currentTimeMillis()+10000)); executeAvailableJobs(); // and we are done: assertNull(runtimeService.createExecutionQuery().singleResult()); // and there are no more jobs left: assertEquals(0, managementService.createJobQuery().count()); }
Example #22
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }
Example #23
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void testInputScriptValue() { 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()); }
Example #24
Source File: ExecutionRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private ExecutionQuery setUpMockExecutionQuery(List<Execution> mockedExecutions) { ExecutionQuery sampleExecutionQuery = mock(ExecutionQuery.class); when(sampleExecutionQuery.list()).thenReturn(mockedExecutions); when(sampleExecutionQuery.count()).thenReturn((long) mockedExecutions.size()); when(processEngine.getRuntimeService().createExecutionQuery()).thenReturn(sampleExecutionQuery); return sampleExecutionQuery; }
Example #25
Source File: CreateProcessInstanceWithVariableScenario.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@DescribesScenario("initProcessInstance") public static ScenarioSetup initProcessInstance() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { // given ProcessInstance processInstance = engine.getRuntimeService().startProcessInstanceByKey("Process", "process"); // when Execution execution = engine.getRuntimeService().createExecutionQuery().processInstanceId(processInstance.getId()).singleResult(); engine.getRuntimeService().setVariable(execution.getId(), "foo", "bar"); } }; }
Example #26
Source File: MigrationCompensationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testCanMigrateWithCompensationEventScopeExecutionChangeIdsAssertExecutionTree() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL) .changeElementId("subProcess", "newSubProcess") .changeElementId("userTask1", "newUserTask1") .changeElementId("compensationBoundary", "newCompensationBoundary") .changeElementId("compensationHandler", "newCompensationHandler")); MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask2", "userTask2") .mapActivities("subProcess", "newSubProcess") .mapActivities("compensationBoundary", "newCompensationBoundary") .build(); ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId()); testHelper.completeTask("userTask1"); Execution eventScopeExecution = rule.getRuntimeService() .createExecutionQuery() .activityId("subProcess") .singleResult(); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then testHelper.assertExecutionTreeAfterMigration() .hasProcessDefinitionId(targetProcessDefinition.getId()) .matches( describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()) .child("newSubProcess").scope().eventScope().id(eventScopeExecution.getId()) .done()); }
Example #27
Source File: MockProvider.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static MessageCorrelationResultWithVariables createMessageCorrelationResultWithVariables(MessageCorrelationResultType type) { MessageCorrelationResultWithVariables result = mock(MessageCorrelationResultWithVariables.class); when(result.getResultType()).thenReturn(type); if (result.getResultType().equals(MessageCorrelationResultType.Execution)) { Execution ex = createMockExecution(); when(result.getExecution()).thenReturn(ex); } else { ProcessInstance instance = createMockInstance(); when(result.getProcessInstance()).thenReturn(instance); } when(result.getVariables()).thenReturn(createMockSerializedVariables()); return result; }
Example #28
Source File: MultiInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void testSequentialScriptTasks() { Map<String, Object> vars = new HashMap<String, Object>(); vars.put("sum", 0); vars.put("nrOfLoops", 5); runtimeService.startProcessInstanceByKey("miSequentialScriptTask", vars); Execution waitStateExecution = runtimeService.createExecutionQuery().singleResult(); int sum = (Integer) runtimeService.getVariable(waitStateExecution.getId(), "sum"); assertEquals(10, sum); }
Example #29
Source File: MigrationHistoricVariablesTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT) public void testMigrateEventScopeVariable() { //given ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()) .mapActivities("userTask2", "userTask2") .mapActivities("subProcess", "subProcess") .mapActivities("compensationBoundary", "compensationBoundary") .build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId()); Execution subProcessExecution = runtimeService.createExecutionQuery().activityId("userTask1").singleResult(); runtimeService.setVariableLocal(subProcessExecution.getId(), "foo", "bar"); testHelper.completeTask("userTask1"); Execution eventScopeExecution = runtimeService.createExecutionQuery().activityId("subProcess").singleResult(); HistoricVariableInstance eventScopeVariable = historyService .createHistoricVariableInstanceQuery() .executionIdIn(eventScopeExecution.getId()) .singleResult(); //when runtimeService.newMigration(migrationPlan) .processInstanceIds(processInstance.getId()) .execute(); // then HistoricVariableInstance historicVariableInstance = historyService .createHistoricVariableInstanceQuery() .variableId(eventScopeVariable.getId()) .singleResult(); Assert.assertEquals(targetDefinition.getId(), historicVariableInstance.getProcessDefinitionId()); }
Example #30
Source File: JavaServiceTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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")); }