Java Code Examples for org.camunda.bpm.engine.variable.VariableMap#putValue()
The following examples show how to use
org.camunda.bpm.engine.variable.VariableMap#putValue() .
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: CamundaModelApiOrderEventHandler.java From flowing-retail-old with Apache License 2.0 | 5 votes |
private VariableMap getNewVariables(JsonObject event) { VariableMap variables = Variables.createVariables(); if (event.get("pickId") != null) { variables.putValue("pickId", event.getString("pickId")); } if (event.get("shipmentId") != null) { variables.putValue("shipmentId", event.getString("shipmentId")); } return variables; }
Example 2
Source File: ExpressionLanguageTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@Test @DecisionResource(resource = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelDoesNotShadowInnerProperty() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestProperty"); Map<String, Object> mapVar = new HashMap<>(1); mapVar.put("b", "B_FROM_MAP"); inputs.putValue("a", mapVar); inputs.putValue("b", "B_FROM_CONTEXT"); DmnDecisionResult result = dmnEngine.evaluateDecision(decision, inputs.asVariableContext()); assertThat(result.getSingleEntry()).isEqualTo("B_FROM_MAP"); }
Example 3
Source File: ExpressionLanguageTest.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
@Test @DecisionResource(resource = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelResolvesListIndex() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestListIndex"); List<String> listVar = new ArrayList<>(1); listVar.add("0_FROM_LIST"); inputs.putValue("a", listVar); DmnDecisionResult result = dmnEngine.evaluateDecision(decision, inputs.asVariableContext()); assertThat(result.getSingleEntry()).isEqualTo("0_FROM_LIST"); }
Example 4
Source File: ExpressionLanguageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @DecisionResource(resource = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelDoesNotShadowInnerProperty() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestProperty"); Map<String, Object> mapVar = new HashMap<>(1); mapVar.put("b", "B_FROM_MAP"); inputs.putValue("a", mapVar); inputs.putValue("b", "B_FROM_CONTEXT"); DmnDecisionResult result = dmnEngine.evaluateDecision(decision, inputs.asVariableContext()); assertThat((String) result.getSingleEntry()).isEqualTo("B_FROM_MAP"); }
Example 5
Source File: ExpressionLanguageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @DecisionResource(resource = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelResolvesListIndex() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestListIndex"); List<String> listVar = new ArrayList<>(1); listVar.add("0_FROM_LIST"); inputs.putValue("a", listVar); DmnDecisionResult result = dmnEngine.evaluateDecision(decision, inputs.asVariableContext()); assertThat((String) result.getSingleEntry()).isEqualTo("0_FROM_LIST"); }
Example 6
Source File: CamundaBpmnOrderEventHandler.java From flowing-retail-old with Apache License 2.0 | 5 votes |
private VariableMap getNewVariables(JsonObject event) { VariableMap variables = Variables.createVariables(); if (event.get("pickId") != null) { variables.putValue("pickId", event.getString("pickId")); } if (event.get("shipmentId") != null) { variables.putValue("shipmentId", event.getString("shipmentId")); } return variables; }
Example 7
Source File: DmnExpressionLanguageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelResolvesListIndex() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestListIndex"); List<String> listVar = new ArrayList<>(1); listVar.add("0_FROM_LIST"); inputs.putValue("a", listVar); DmnDecisionTableResult result = decisionService.evaluateDecisionTableByKey("decision_1", inputs); assertThat((String)result.getSingleEntry()).isEqualTo("0_FROM_LIST"); }
Example 8
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseAsExpressionStartsWithDollar.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCallCaseAsExpressionStartsWithDollar() { // given // a deployed case definition VariableMap vars = new VariableMapImpl(); vars.putValue("oneTaskCase", ONE_TASK_CASE); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId(); CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId); assertEquals(caseTaskId, superCaseExecutionId); assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId()); // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 9
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseAsExpressionStartsWithHash.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCallCaseAsExpressionStartsWithHash() { // given // a deployed case definition VariableMap vars = new VariableMapImpl(); vars.putValue("oneTaskCase", ONE_TASK_CASE); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId(); CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId); assertEquals(caseTaskId, superCaseExecutionId); assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId()); // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 10
Source File: DmnExpressionLanguageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = JUEL_EXPRESSIONS_WITH_PROPERTIES_DMN) public void testJuelDoesNotShadowInnerProperty() { VariableMap inputs = Variables.createVariables(); inputs.putValue("testExpr", "TestProperty"); Map<String, Object> mapVar = new HashMap<>(1); mapVar.put("b", "B_FROM_MAP"); inputs.putValue("a", mapVar); inputs.putValue("b", "B_FROM_CONTEXT"); DmnDecisionTableResult result = decisionService.evaluateDecisionTableByKey("decision_1", inputs); assertThat((String)result.getSingleEntry()).isEqualTo("B_FROM_MAP"); }
Example 11
Source File: DelegateVarMapping.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void mapInputVariables(DelegateExecution execution, VariableMap variables) { variables.putValue("TestInputVar", "inValue"); }
Example 12
Source File: DelegatedVarMapping.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void mapInputVariables(DelegateExecution execution, VariableMap variables) { variables.putValue("TestInputVar", "inValue"); }
Example 13
Source File: RetryIntervalsConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void testlocalConfigurationWithNestedChangingExpression() throws ParseException { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask() .camundaClass("foo") .camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("${var}") .endEvent() .done(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date startDate = simpleDateFormat.parse("2017-01-01T09:55:00"); ClockUtil.setCurrentTime(startDate); testRule.deploy(bpmnModelInstance); VariableMap params = Variables.createVariables(); params.putValue("var", "${nestedVar1},PT15M,${nestedVar3}"); params.putValue("nestedVar", "PT13M"); params.putValue("nestedVar1", "PT5M"); params.putValue("nestedVar3", "PT25M"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", params); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 5); assertDueDateTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(2, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 15); assertDueDateTime(currentTime); ClockUtil.setCurrentTime(currentTime); runtimeService.setVariable(pi.getProcessInstanceId(), "var", "${nestedVar}"); jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 13); assertDueDateTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
Example 14
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * assertion on variables - change subprocess definition */ @Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testVariablesRoundtrip.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" }) public void testVariablesRoundtrip() { // given VariableMap vars = new VariableMapImpl(); vars.putValue("aVariable", "xyz"); vars.putValue("anotherVariable", 123); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId(); String subCaseInstanceId = queryOneTaskCaseInstance().getId(); caseService .withCaseExecution(subCaseInstanceId) .setVariable("aVariable", "abc") .setVariable("anotherVariable", 999) .execute(); String humanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId(); caseService .withCaseExecution(humanTaskId) .manualStart(); caseService .withCaseExecution(humanTaskId) .complete(); // when caseService .withCaseExecution(subCaseInstanceId) .close(); // then List<VariableInstance> variables = runtimeService .createVariableInstanceQuery() .caseInstanceIdIn(superCaseInstanceId) .list(); assertFalse(variables.isEmpty()); assertEquals(2, variables.size()); for (VariableInstance variable : variables) { String name = variable.getName(); if ("aVariable".equals(name)) { assertEquals("aVariable", name); assertEquals("abc", variable.getValue()); } else if ("anotherVariable".equals(name)) { assertEquals("anotherVariable", name); assertEquals(999, variable.getValue()); } else { fail("Found an unexpected variable: '"+name+"'"); } } // complete //////////////////////////////////////////////////////// close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 15
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputAll.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testInputAll() { // given VariableMap vars = new VariableMapImpl(); vars.putValue("aVariable", "abc"); vars.putValue("anotherVariable", 999); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); List<VariableInstance> variables = runtimeService .createVariableInstanceQuery() .caseInstanceIdIn(subCaseInstance.getId()) .list(); assertFalse(variables.isEmpty()); assertEquals(2, variables.size()); for (VariableInstance variable : variables) { String name = variable.getName(); if ("aVariable".equals(name)) { assertEquals("aVariable", name); assertEquals("abc", variable.getValue()); } else if ("anotherVariable".equals(name)) { assertEquals("anotherVariable", name); assertEquals(999, variable.getValue()); } else { fail("Found an unexpected variable: '"+name+"'"); } } // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 16
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * Default manual activation changed - add variables to case instantiation, remove manual activation */ @Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputSourceExpression.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testInputSourceExpression() { // given VariableMap vars = new VariableMapImpl(); vars.putValue("aVariable", "abc"); vars.putValue("anotherVariable", 999); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE,vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); List<VariableInstance> variables = runtimeService .createVariableInstanceQuery() .caseInstanceIdIn(subCaseInstance.getId()) .list(); assertFalse(variables.isEmpty()); assertEquals(2, variables.size()); for (VariableInstance variable : variables) { String name = variable.getName(); if ("aVariable".equals(name)) { assertEquals("aVariable", name); assertEquals("abc", variable.getValue()); } else if ("anotherVariable".equals(name)) { assertEquals("anotherVariable", name); assertEquals((long)1000, variable.getValue()); } else { fail("Found an unexpected variable: '"+name+"'"); } } // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 17
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * default manual activation behaviour changed - remove manual activation statement */ @Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputSourceDifferentTarget.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testInputSourceDifferentTarget() { // given VariableMap vars = new VariableMapImpl(); vars.putValue("aVariable", "abc"); vars.putValue("anotherVariable", 999); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); List<VariableInstance> variables = runtimeService .createVariableInstanceQuery() .caseInstanceIdIn(subCaseInstance.getId()) .list(); assertFalse(variables.isEmpty()); assertEquals(2, variables.size()); for (VariableInstance variable : variables) { String name = variable.getName(); if ("myVariable".equals(name)) { assertEquals("myVariable", name); assertEquals("abc", variable.getValue()); } else if ("myAnotherVariable".equals(name)) { assertEquals("myAnotherVariable", name); assertEquals(999, variable.getValue()); } else { fail("Found an unexpected variable: '"+name+"'"); } } // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); }
Example 18
Source File: CaseTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseByVersionAsExpressionStartsWithDollar.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testCallCaseByVersionAsExpressionStartsWithDollar() { // given String bpmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"; String secondDeploymentId = repositoryService.createDeployment() .addClasspathResource(bpmnResourceName) .deploy() .getId(); String thirdDeploymentId = repositoryService.createDeployment() .addClasspathResource(bpmnResourceName) .deploy() .getId(); assertEquals(4, repositoryService.createCaseDefinitionQuery().count()); VariableMap vars = new VariableMapImpl(); vars.putValue("myVersion", 2); String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE,vars).getId(); String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId(); String caseDefinitionIdInSecondDeployment = repositoryService .createCaseDefinitionQuery() .caseDefinitionKey(ONE_TASK_CASE) .deploymentId(secondDeploymentId) .singleResult() .getId(); // then CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance(); assertNotNull(subCaseInstance); String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId(); CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId); assertEquals(caseTaskId, superCaseExecutionId); assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId()); assertEquals(caseDefinitionIdInSecondDeployment, subCaseInstance.getCaseDefinitionId()); // complete //////////////////////////////////////////////////////// terminate(subCaseInstance.getId()); close(subCaseInstance.getId()); assertCaseEnded(subCaseInstance.getId()); terminate(caseTaskId); close(superCaseInstanceId); assertCaseEnded(superCaseInstanceId); repositoryService.deleteDeployment(secondDeploymentId, true); repositoryService.deleteDeployment(thirdDeploymentId, true); }
Example 19
Source File: SetVariableToChildMappingDelegate.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void mapInputVariables(DelegateExecution superExecution, VariableMap subVariables) { subVariables.putValue("orderId",superExecution.getVariable("orderId")); }
Example 20
Source File: SetVariableMappingDelegate.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void mapInputVariables(DelegateExecution superExecution, VariableMap subVariables) { subVariables.putValue("orderId",superExecution.getVariable("orderId")); }