public virtual void decisionRefWithCompositeExpression() { VariableMap variables = Variables.createVariables().putValue("version", 1); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcessCompositeExpression", variables); assertEquals("okay", getDecisionResult(processInstance)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testAutoCompleteStageWithoutEntryCriteria() public virtual void testAutoCompleteStageWithoutEntryCriteria() { // given VariableMap variables = Variables.createVariables().putValue("manualActivation", false); string caseInstanceId = createCaseInstanceByKey("case", variables).Id; // then (1) CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1"); assertEquals(1, query.count()); assertEquals(1, query.active().count()); string activeTaskId = query.singleResult().Id; // when (2) // completing active task complete(activeTaskId); // then (2) // the stage should be completed CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1"); assertNull(stage); CaseInstance caseInstance = (CaseInstance)queryCaseExecutionById(caseInstanceId); assertTrue(caseInstance.Completed); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStatisticForRootDecisionWithNullInstanceConstraintEvaluation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testStatisticForRootDecisionWithNullInstanceConstraintEvaluation() { //when decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate(); DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult(); //when HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.Id).decisionInstanceId(null); //then try { query.count(); } catch (NullValueException) { //expected } try { query.list(); } catch (NullValueException) { //expected } }
public virtual void testRepeatTaskWithoutEntryCriteriaWhenTerminating() { // given string caseInstanceId = createCaseInstanceByKey(CASE_ID, Variables.createVariables().putValue("repeating", true)).Id; CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1"); assertEquals(1, query.count()); CaseExecution activeCaseExecution = query.active().singleResult(); assertNotNull(activeCaseExecution); // when (1) terminate(activeCaseExecution.Id); // then (1) query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1"); assertEquals(1, query.count()); activeCaseExecution = query.active().singleResult(); assertNotNull(activeCaseExecution); // when (2) caseService.setVariable(caseInstanceId, "repeating", false); terminate(activeCaseExecution.Id); // then (2) query = caseService.createCaseExecutionQuery(); assertEquals(1, query.count()); assertEquals(caseInstanceId, query.singleResult().Id); }
public virtual void testCatchErrorThrownBySignalOfDelegateExpression() { VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate()); string pi = runtimeService.startProcessInstanceByKey("testProcess", variables).Id; assertTrue((bool?)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.Id); assertTrue((bool?)runtimeService.getVariable(pi, "executed")); assertTrue((bool?)runtimeService.getVariable(pi, "signaled")); Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult(); assertNotNull(userTask); assertEquals("userTaskError", userTask.TaskDefinitionKey); taskService.complete(userTask.Id); }
public virtual void testConcurrentFetchAndDelete() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String processInstanceId = deployAndStartProcess(PROCESS_WITH_USERTASK, org.camunda.bpm.engine.variable.Variables.createVariables().putValue(VARIABLE_NAME, org.camunda.bpm.engine.variable.Variables.byteArrayValue(VARIABLE_VALUE.getBytes()))).getId(); string processInstanceId = deployAndStartProcess(PROCESS_WITH_USERTASK, Variables.createVariables().putValue(VARIABLE_NAME, Variables.byteArrayValue(VARIABLE_VALUE.GetBytes()))).Id; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String[] historicByteArrayId = new String[1]; string[] historicByteArrayId = new string[1]; commandExecutor.execute(new CommandAnonymousInnerClass(this, processInstanceId, historicByteArrayId)); ThreadControl asyncThread = executeControllableCommand(new AsyncThread(this, processInstanceId, historicByteArrayId[0])); asyncThread.waitForSync(); commandExecutor.execute(new CommandAnonymousInnerClass2(this, historicByteArrayId)); commandExecutor.execute(new CommandAnonymousInnerClass3(this, historicByteArrayId)); // when asyncThread.makeContinue(); asyncThread.waitUntilDone(); // then assertThat(runtimeService.createVariableInstanceQuery().singleResult().Name, @is(VARIABLE_NAME)); assertThat(StringHelper.NewString((sbyte[])runtimeService.createVariableInstanceQuery().singleResult().Value), @is(ANOTHER_VARIABLE_VALUE)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSerializeFileVariable() public virtual void testSerializeFileVariable() { BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy(); VariableMap variables = Variables.createVariables(); string filename = "test.txt"; string type = "text/plain"; FileValue fileValue = Variables.fileValue(filename).file("ABC".GetBytes()).encoding("UTF-8").mimeType(type).create(); variables.put("file", fileValue); runtimeService.startProcessInstanceByKey("process", variables); Task task = taskService.createTaskQuery().singleResult(); VariableInstance result = runtimeService.createVariableInstanceQuery().processInstanceIdIn(task.ProcessInstanceId).singleResult(); FileValue value = (FileValue)result.TypedValue; assertThat(value.Filename, @is(filename)); assertThat(value.MimeType, @is(type)); assertThat(value.Encoding, @is("UTF-8")); assertThat(value.EncodingAsCharset, @is(Charset.forName("UTF-8"))); using (Scanner scanner = new Scanner(value.Value)) { assertThat(scanner.nextLine(), @is("ABC")); } // clean up repositoryService.deleteDeployment(deployment.Id, true); }
public virtual void testPojo() { VariableMap variables = Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37)); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables); assertEquals("okay", getDecisionResult(processInstance)); }
public virtual void testPojo() { // given VariableMap variables = Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37)); CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, variables); assertEquals("okay", getDecisionResult(caseInstance)); }
protected internal virtual CaseInstance startTestCase(string input) { CaseInstance caseInstance = createCaseInstanceByKey("case", Variables.createVariables().putValue("input", input)); results = DecisionResultTestListener.DecisionResult; assertNotNull(results); return(caseInstance); }
public virtual void testCallDecisionAsExpressionStartsWithHash() { // given CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, Variables.createVariables().putValue("testDecision", "testDecision")); // then assertNull(queryCaseExecutionByActivityId(DECISION_TASK)); assertEquals("okay", getDecisionResult(caseInstance)); }
public virtual void testManualActivationRuleWithoutCondition() { createCaseInstanceByKey("case", Variables.createVariables().putValue("manual", false)); CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1"); assertNotNull(taskExecution); assertTrue(taskExecution.Enabled); }
public virtual void testCallDecisionWithRequiredDecisions() { // given CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, Variables.createVariables().putValue("testDecision", "dish-decision").putValue("temperature", 32).putValue("dayType", "Weekend")); // then assertNull(queryCaseExecutionByActivityId(DECISION_TASK)); assertEquals("Light salad", getDecisionResult(caseInstance)); }
public virtual void testExecutionWithScriptTargetScope() { VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 })); ProcessInstance processInstance = engineRule.RuntimeService.startProcessInstanceByKey("Process_MultiInstanceCallAcitivity", variables); // it runs without any problems assertThat(processInstance.Ended, @is(true)); assertThat(((ProcessInstanceWithVariablesImpl)processInstance).Variables.containsKey("targetOrderId"), @is(false)); }
public virtual void testExecutionWithoutProperTargetScope() { VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 })); //fails due to inappropriate variable scope target thrown.expect(typeof(ScriptEvaluationException)); ProcessDefinition processDefinition = engineRule.RepositoryService.createProcessDefinitionQuery().processDefinitionKey("Process_MultiInstanceCallAcitivity").singleResult(); thrown.expectMessage(startsWith("Unable to evaluate script while executing activity 'CallActivity_1' in the process definition with id '" + processDefinition.Id + "': org.camunda.bpm.engine.ProcessEngineException: ENGINE-20011 Scope with specified activity Id NOT_EXISTING and execution")); engineRule.RuntimeService.startProcessInstanceByKey("Process_MultiInstanceCallAcitivity", variables); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void setUp() { decisionService = engineRule.DecisionService; repositoryService = engineRule.RepositoryService; historyService = engineRule.HistoryService; identityService = engineRule.IdentityService; testRule.deploy(DISH_DRG_DMN); decisionService.evaluateDecisionByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate(); }
public virtual void testWithDelegateVariableMapping() { BpmnModelInstance instance = Bpmn.createExecutableProcess("process1").startEvent().subProcess("SubProcess_1").embeddedSubProcess().startEvent().callActivity().calledElement("Process_StuffDoer").camundaVariableMappingClass("org.camunda.bpm.engine.test.api.variables.scope.SetVariableMappingDelegate").serviceTask().camundaClass("org.camunda.bpm.engine.test.api.variables.scope.AssertVariableScopeDelegate").endEvent().subProcessDone().endEvent().done(); instance = modify(instance).activityBuilder("SubProcess_1").multiInstance().parallel().camundaCollection("orderIds").camundaElementVariable("orderId").done(); ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(instance); VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 })); engineRule.RuntimeService.startProcessInstanceById(processDefinition.Id, variables); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testLimitedRepetitions() public virtual void testLimitedRepetitions() { // given VariableMap variables = Variables.createVariables().putValue("repetition", 0); createCaseInstanceByKey("case", variables); CaseExecutionQuery availableQuery = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").available(); // fire three times entry criteria of repeatable task // -> three enabled tasks // -> one available task fireEntryCriteria(availableQuery.singleResult().Id); fireEntryCriteria(availableQuery.singleResult().Id); fireEntryCriteria(availableQuery.singleResult().Id); // get any enabled task CaseExecutionQuery activeQuery = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").active(); string activeTaskId = activeQuery.listPage(0, 1).get(0).Id; // when (1) complete(activeTaskId); // then (1) CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2"); assertEquals(2, query.count()); assertEquals(1, query.active().count()); assertEquals(1, query.available().count()); // when (2) activeTaskId = activeQuery.listPage(0, 1).get(0).Id; complete(activeTaskId); // then (2) query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2"); assertEquals(3, query.count()); assertEquals(2, query.active().count()); assertEquals(1, query.available().count()); // when (3) activeTaskId = activeQuery.listPage(0, 1).get(0).Id; complete(activeTaskId); // then (3) query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2"); assertEquals(3, query.count()); assertEquals(3, query.active().count()); assertEquals(0, query.available().count()); }
public virtual void testCallDecisionByVersionAsExpressionStartsWithHash() { // given string deploymentId = repositoryService.createDeployment().addClasspathResource(DECISION_NOT_OKAY_DMN).deploy().Id; CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, Variables.createVariables().putValue("myVersion", 2)); // then assertNull(queryCaseExecutionByActivityId(DECISION_TASK)); assertEquals("not okay", getDecisionResult(caseInstance)); repositoryService.deleteDeployment(deploymentId, true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStatisticForRootDecisionWithFakeInstanceConstraintEvaluation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testStatisticForRootDecisionWithFakeInstanceConstraintEvaluation() { //when decisionService.evaluateDecisionTableByKey(DISH_DECISION).variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND)).evaluate(); DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult(); HistoricDecisionInstanceStatisticsQuery query = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.Id).decisionInstanceId(NON_EXISTING); //then assertThat(query.count(), @is(0L)); assertThat(query.list().size(), @is(0)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNewKeyInSyncServiceTask() public virtual void testNewKeyInSyncServiceTask() { // given testRule.deploy(SYNC_SERVICE_TASK_PROCESS); // when string newBusinessKeyValue = "newBusinessKey"; runtimeService.startProcessInstanceByKey(PROCESS_KEY, Variables.createVariables().putValue(BUSINESS_KEY_VARIABLE, newBusinessKeyValue)); // then checkBusinessKeyChanged(newBusinessKeyValue); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void decisionRefVersionTagBindingExpression() public virtual void decisionRefVersionTagBindingExpression() { // given testRule.deploy(DECISION_VERSION_TAG_OKAY_DMN); testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().businessRuleTask().camundaDecisionRef("decision").camundaDecisionRefBinding("versionTag").camundaDecisionRefVersionTag("${versionTagExpr}").camundaMapDecisionResult("singleEntry").camundaResultVariable("result").endEvent().camundaAsyncBefore().done()); // when VariableMap variables = Variables.createVariables().putValue("versionTagExpr", "0.0.2").putValue("status", "gold"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", variables); // then assertEquals("A", getDecisionResult(processInstance)); }
public virtual void testWithDelegateVariableMappingAndChildScope() { BpmnModelInstance instance = Bpmn.createExecutableProcess("process1").startEvent().parallelGateway().subProcess("SubProcess_1").embeddedSubProcess().startEvent().callActivity().calledElement("Process_StuffDoer").camundaVariableMappingClass("org.camunda.bpm.engine.test.api.variables.scope.SetVariableToChildMappingDelegate").serviceTask().camundaClass("org.camunda.bpm.engine.test.api.variables.scope.AssertVariableScopeDelegate").endEvent().subProcessDone().moveToLastGateway().subProcess("SubProcess_2").embeddedSubProcess().startEvent().userTask("ut").endEvent().subProcessDone().endEvent().done(); instance = modify(instance).activityBuilder("SubProcess_1").multiInstance().parallel().camundaCollection("orderIds").camundaElementVariable("orderId").done(); ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(instance); thrown.expect(typeof(ProcessEngineException)); thrown.expectMessage(startsWith("org.camunda.bpm.engine.ProcessEngineException: ENGINE-20011 Scope with specified activity Id SubProcess_2 and execution")); VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 })); engineRule.RuntimeService.startProcessInstanceById(processDefinition.Id, variables); }
public virtual void testCallDecisionWithLiteralExpression() { // given CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, Variables.createVariables().putValue("testDecision", "decisionLiteralExpression").putValue("a", 2).putValue("b", 3)); string decisionTaskId = queryCaseExecutionByActivityId(DECISION_TASK).Id; // when caseService.withCaseExecution(decisionTaskId).manualStart(); // then assertNull(queryCaseExecutionByActivityId(DECISION_TASK)); assertEquals(5, getDecisionResult(caseInstance)); }
public virtual void testProcessVariableTypeAnnotation() { BusinessProcess businessProcess = getBeanInstance(typeof(BusinessProcess)); VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda"); businessProcess.startProcessByKey("keyOfTheProcess", variables); TypedValue value = getBeanInstance(typeof(DeclarativeProcessController)).InjectedValue; assertNotNull(value); assertTrue(value is StringValue); assertEquals(ValueType.STRING, value.Type); assertEquals("camunda", value.Value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStatisticForChildDecisionEvaluation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testStatisticForChildDecisionEvaluation() { //when decisionService.evaluateDecisionTableByKey("season").variables(Variables.createVariables().putValue(TEMPERATURE, 21)).evaluate(); DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult(); HistoricDecisionInstanceStatisticsQuery statisticsQuery = historyService.createHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.Id); //then assertThat(statisticsQuery.count(), @is(1L)); assertThat(statisticsQuery.list().size(), @is(1)); assertThat(statisticsQuery.list().get(0).Evaluations, @is(1)); assertThat(statisticsQuery.list().get(0).DecisionDefinitionKey, @is(notNullValue())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNewKeyInStartExecListener() public virtual void testNewKeyInStartExecListener() { // given string listener = [email protected]_Fields.EVENTNAME_START; BpmnModelInstance process = createModelExecutionListener(listener); testRule.deploy(process); // when string newBusinessKeyValue = "newBusinessKey"; runtimeService.startProcessInstanceByKey(PROCESS_KEY, Variables.createVariables().putValue(BUSINESS_KEY_VARIABLE, newBusinessKeyValue)); // then checkBusinessKeyChanged(newBusinessKeyValue); }
public virtual void testRepetitionRuleWithoutEntryCriteria() { // given createCaseInstanceByKey("case", Variables.createVariables().putValue("repetition", true)); string firstHumanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").Id; // when complete(firstHumanTaskId); // then CaseExecutionQuery query = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1"); assertEquals(1, query.count()); assertEquals(1, query.active().count()); }
public virtual void testSentryIfPartCondition() { // given createCaseInstanceByKey("case", Variables.createVariables().putValue("value", 99)); string humanTask1 = queryCaseExecutionByActivityId("PI_HumanTask_1").Id; string humanTask2 = queryCaseExecutionByActivityId("PI_HumanTask_2").Id; assertTrue(queryCaseExecutionById(humanTask2).Available); // when caseService.withCaseExecution(humanTask1).setVariable("value", 999).manualStart(); // then assertTrue(queryCaseExecutionById(humanTask2).Enabled); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateKeyNullValueInStartTaskListener() public virtual void testUpdateKeyNullValueInStartTaskListener() { // given string listener = [email protected]_Fields.EVENTNAME_CREATE; BpmnModelInstance process = createModelTaskListener(listener); testRule.deploy(process); // when string newBusinessKeyValue = null; runtimeService.startProcessInstanceByKey(PROCESS_KEY, "aBusinessKey", Variables.createVariables().putValue(BUSINESS_KEY_VARIABLE, newBusinessKeyValue)); // then checkBusinessKeyChanged(newBusinessKeyValue); }