public virtual void testCallActivityByExpression() { // Start process (main) ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testCallActivityByExpression"); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskBeforeSubProcess = taskQuery.singleResult(); assertEquals("Task before subprocess", taskBeforeSubProcess.Name); // Completing the task continues the process which leads to calling the subprocess. The sub process we want to // call is passed in as a variable into this task taskService.complete(taskBeforeSubProcess.Id); Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.Name); // Completing the task in the subprocess, finishes the subprocess taskService.complete(taskInSubProcess.Id); Task taskAfterSubProcess = taskQuery.singleResult(); assertEquals("Task after subprocess", taskAfterSubProcess.Name); // Completing this task end the process instance taskService.complete(taskAfterSubProcess.Id); assertProcessEnded(processInstance.Id); }
protected internal virtual void testDelegation() { TaskQuery taskQuery = taskService.createTaskQuery(); //when Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.Name); //then check value from input variable object inputVar = runtimeService.getVariable(taskInSubProcess.ProcessInstanceId, "TestInputVar"); assertEquals("inValue", inputVar); //when completing the task in the subprocess, finishes the subprocess taskService.complete(taskInSubProcess.Id); Task taskAfterSubProcess = taskQuery.singleResult(); assertEquals("Task after subprocess", taskAfterSubProcess.Name); //then check value from output variable ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); object outputVar = runtimeService.getVariable(processInstance.Id, "TestOutputVar"); assertEquals("outValue", outputVar); //complete task after sub process taskService.complete(taskAfterSubProcess.Id); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNonInterruptingSetVariableInOutMappingOfCallActivity() public virtual void testNonInterruptingSetVariableInOutMappingOfCallActivity() { engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, DELEGATED_PROCESS).deploy()); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().callActivity(TASK_WITH_CONDITION_ID).calledElement(DELEGATED_PROCESS_KEY).camundaOut(VARIABLE_NAME, VARIABLE_NAME).userTask().name(TASK_AFTER_OUTPUT_MAPPING).endEvent().subProcessDone().endEvent().done(); modelInstance = addEventSubProcess(modelInstance, SUB_PROCESS_ID, TASK_AFTER_COND_START_EVENT_IN_SUB_PROCESS, false); modelInstance = addBoundaryEvent(modelInstance, TASK_WITH_CONDITION_ID, TASK_AFTER_COND_BOUN_EVENT_IN_SUB_PROCESS, false); deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, SUB_PROCESS_ID, false); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); Task task = taskQuery.singleResult(); assertNotNull(task); assertEquals(TASK_BEFORE_CONDITION, task.Name); //when task before service task is completed taskService.complete(task.Id); //then out mapping of call activity sets a variable //-> all non interrupting conditional events are triggered tasksAfterVariableIsSet = taskQuery.list(); assertEquals(5, tasksAfterVariableIsSet.Count); //three subscriptions: event sub process in sub process and on process instance level and boundary event of sub process assertEquals(3, conditionEventSubscriptionQuery.count()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNonInterruptingSetVariableOnOutputMappingInSubProcessWithBoundary() public virtual void testNonInterruptingSetVariableOnOutputMappingInSubProcessWithBoundary() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_WITH_CONDITION_ID).camundaOutputParameter(VARIABLE_NAME, "1").name(TASK_WITH_CONDITION).userTask().name(TASK_AFTER_OUTPUT_MAPPING).endEvent().subProcessDone().endEvent().done(); modelInstance = addEventSubProcess(modelInstance, SUB_PROCESS_ID, TASK_AFTER_COND_START_EVENT_IN_SUB_PROCESS, false); deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, SUB_PROCESS_ID, false); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); //when task before is completed taskService.complete(taskQuery.singleResult().Id); //then all conditional events are triggered tasksAfterVariableIsSet = taskQuery.list(); assertEquals(4, tasksAfterVariableIsSet.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSetVariableOnEndExecutionListenerInSubProcessWithBoundary() public virtual void testSetVariableOnEndExecutionListenerInSubProcessWithBoundary() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_WITH_CONDITION_ID).camundaExecutionListenerExpression([email protected]_Fields.EVENTNAME_END, EXPR_SET_VARIABLE).name(TASK_WITH_CONDITION).endEvent().subProcessDone().endEvent().done(); modelInstance = addEventSubProcess(modelInstance, SUB_PROCESS_ID, TASK_AFTER_COND_START_EVENT_IN_SUB_PROCESS, true); deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, SUB_PROCESS_ID, true); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); Task task = taskQuery.singleResult(); //when task before is completed taskService.complete(task.Id); //then conditional boundary should not triggered but conditional start event tasksAfterVariableIsSet = taskQuery.list(); assertEquals(TASK_AFTER_CONDITIONAL_START_EVENT, tasksAfterVariableIsSet[0].Name); }
// io mapping //////////////////////////////////////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSetVariableOnInputMapping() public virtual void testSetVariableOnInputMapping() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).camundaInputParameter(VARIABLE_NAME, "1").name(TASK_WITH_CONDITION).endEvent().done(); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).camundaInputParameter(VARIABLE_NAME, "1").name(TASK_WITH_CONDITION).endEvent().done(); deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, true); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); Task task = taskQuery.singleResult(); //when task before is completed taskService.complete(task.Id); //then conditional boundary event should triggered with the default evaluation behavior tasksAfterVariableIsSet = taskQuery.list(); assertEquals(TASK_AFTER_CONDITIONAL_BOUNDARY_EVENT, tasksAfterVariableIsSet[0].Name); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNonInterruptingSetVariableOnOutputMappingInSubProcess() public virtual void testNonInterruptingSetVariableOnOutputMappingInSubProcess() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_WITH_CONDITION_ID).camundaOutputParameter(VARIABLE_NAME, "1").name(TASK_WITH_CONDITION).userTask().name(TASK_AFTER_OUTPUT_MAPPING).endEvent().subProcessDone().endEvent().done(); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_WITH_CONDITION_ID).camundaOutputParameter(VARIABLE_NAME, "1").name(TASK_WITH_CONDITION).userTask().name(TASK_AFTER_OUTPUT_MAPPING).endEvent().subProcessDone().endEvent().done(); deployMixedProcess(modelInstance, SUB_PROCESS_ID, false); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); //when task before is completed taskService.complete(taskQuery.singleResult().Id); //then conditional boundary should not triggered but conditional start event tasksAfterVariableIsSet = taskQuery.list(); assertEquals(2, tasksAfterVariableIsSet.Count); assertTaskNames(tasksAfterVariableIsSet, TASK_AFTER_CONDITIONAL_START_EVENT, TASK_AFTER_OUTPUT_MAPPING); }
// sub process testing with event sub process and conditional start event and boundary event on user task // execution listener in sub process ////////////////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSetVariableOnStartExecutionListenerInSubProcess() public virtual void testSetVariableOnStartExecutionListenerInSubProcess() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).camundaExecutionListenerExpression(org.camunda.bpm.engine.delegate.ExecutionListener_Fields.EVENTNAME_START, EXPR_SET_VARIABLE).name(TASK_WITH_CONDITION).endEvent().subProcessDone().endEvent().done(); BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().subProcess(SUB_PROCESS_ID).embeddedSubProcess().startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).userTask(TASK_WITH_CONDITION_ID).camundaExecutionListenerExpression([email protected]_Fields.EVENTNAME_START, EXPR_SET_VARIABLE).name(TASK_WITH_CONDITION).endEvent().subProcessDone().endEvent().done(); deployMixedProcess(modelInstance, SUB_PROCESS_ID, true); // given ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.Id); Task task = taskQuery.singleResult(); //when task before is completed taskService.complete(task.Id); //then conditional boundary should not triggered but conditional start event tasksAfterVariableIsSet = taskQuery.list(); assertEquals(TASK_AFTER_CONDITIONAL_START_EVENT, tasksAfterVariableIsSet[0].Name); }