Java Code Examples for org.camunda.bpm.engine.runtime.VariableInstance#getValue()
The following examples show how to use
org.camunda.bpm.engine.runtime.VariableInstance#getValue() .
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: SampleCamundaRestApplicationIT.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void multipartFileUploadCamundaRestIsWorking() throws Exception { final String variableName = "testvariable"; ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TestProcess"); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); map.add("data", new ClassPathResource("/bpmn/test.bpmn")); map.add("valueType", "File"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentDispositionFormData("data", "test.bpmn"); HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers); ResponseEntity<String> exchange = testRestTemplate.exchange("/engine-rest/engine/{enginename}/process-instance/{id}/variables/{variableName}/data", HttpMethod.POST, requestEntity, String.class, camundaBpmProperties.getProcessEngineName(), processInstance.getId(), variableName); assertEquals(HttpStatus.NO_CONTENT, exchange.getStatusCode()); VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstance.getId()).variableName(variableName) .singleResult(); ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) variableInstance.getValue(); assertTrue(byteArrayInputStream.available() > 0); }
Example 2
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testOutputMapElKey() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("varExpr1", "a"); variables.put("varExpr2", "b"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals("potato", value.get("a")); assertEquals("tomato", value.get("b")); }
Example 3
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment @SuppressWarnings("unchecked") public void testOutputListNestedValues() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("exprKey", "vegie"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals("constantStringValue", value.get(0)); assertEquals("elValue", value.get(1)); assertEquals("scriptValue", value.get(2)); List<Object> nestedList = (List<Object>) value.get(3); List<Object> nestedNestedList = (List<Object>) nestedList.get(0); assertEquals("a", nestedNestedList.get(0)); assertEquals("b", nestedNestedList.get(1)); assertEquals("c", nestedNestedList.get(2)); assertEquals("d", nestedList.get(1)); TreeMap<String, Object> nestedMap = (TreeMap<String, Object>) value.get(4); assertEquals("bar", nestedMap.get("foo")); assertEquals("world", nestedMap.get("hello")); assertEquals("potato", nestedMap.get("vegie")); }
Example 4
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testInputNested() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("exprKey", "b"); runtimeService.startProcessInstanceByKey("testProcess", variables); Execution execution = runtimeService.createExecutionQuery().activityId("wait").singleResult(); VariableInstance var1 = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); TreeMap<String, Object> value = (TreeMap) var1.getValue(); List<Object> nestedList = (List<Object>) value.get("a"); assertEquals("stringInListNestedInMap", nestedList.get(0)); assertEquals("b", nestedList.get(1)); assertEquals("stringValueWithExprKey", value.get("b")); VariableInstance var2 = runtimeService.createVariableInstanceQuery().variableName("var2").singleResult(); assertNotNull(var2); assertEquals("stringConstantValue", var2.getValue()); assertEquals(execution.getId(), var2.getExecutionId()); }
Example 5
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment @SuppressWarnings("unchecked") public void testInputNestedListValues() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("exprKey", "vegie"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals("constantStringValue", value.get(0)); assertEquals("elValue", value.get(1)); assertEquals("scriptValue", value.get(2)); List<Object> nestedList = (List<Object>) value.get(3); List<Object> nestedNestedList = (List<Object>) nestedList.get(0); assertEquals("a", nestedNestedList.get(0)); assertEquals("b", nestedNestedList.get(1)); assertEquals("c", nestedNestedList.get(2)); assertEquals("d", nestedList.get(1)); TreeMap<String, Object> nestedMap = (TreeMap<String, Object>) value.get(4); assertEquals("bar", nestedMap.get("foo")); assertEquals("world", nestedMap.get("hello")); assertEquals("potato", nestedMap.get("vegie")); }
Example 6
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testOutputNested() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("exprKey", "b"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance var1 = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); TreeMap<String, Object> value = (TreeMap) var1.getValue(); List<Object> nestedList = (List<Object>) value.get("a"); assertEquals("stringInListNestedInMap", nestedList.get(0)); assertEquals("b", nestedList.get(1)); assertEquals(pi.getId(), var1.getExecutionId()); assertEquals("stringValueWithExprKey", value.get("b")); VariableInstance var2 = runtimeService.createVariableInstanceQuery().variableName("var2").singleResult(); assertNotNull(var2); assertEquals("stringConstantValue", var2.getValue()); assertEquals(pi.getId(), var2.getExecutionId()); }
Example 7
Source File: SampleCamundaRestApplicationIT.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 6 votes |
@Test public void multipartFileUploadCamundaRestIsWorking() throws Exception { final String variableName = "testvariable"; ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TestProcess"); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); map.add("data", new ClassPathResource("/bpmn/test.bpmn")); map.add("valueType", "File"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentDispositionFormData("data", "test.bpmn"); HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers); ResponseEntity<String> exchange = testRestTemplate.exchange("/rest/engine/{enginename}/process-instance/{id}/variables/{variableName}/data", HttpMethod.POST, requestEntity, String.class, camundaBpmProperties.getProcessEngineName(), processInstance.getId(), variableName); assertEquals(HttpStatus.NO_CONTENT, exchange.getStatusCode()); VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstance.getId()).variableName(variableName) .singleResult(); ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) variableInstance.getValue(); assertTrue(byteArrayInputStream.available() > 0); }
Example 8
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testInputMapElMixedKey() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("varExpr1", "a"); variables.put("varExpr2", "b"); variables.put("varExprMapValue", "avocado"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals("potato", value.get("a")); assertEquals("tomato", value.get("b")); }
Example 9
Source File: DecisionContextSwitchTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") @OperateOnDeployment("clientDeployment") public void shouldSwitchContextWhenCallingFromBpmn() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance decisionResult = runtimeService.createVariableInstanceQuery() .processInstanceIdIn(pi.getId()) .variableName("result").singleResult(); List<Map<String, Object>> result = (List<Map<String, Object>>) decisionResult.getValue(); assertEquals("ok", result.get(0).get("result")); }
Example 10
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testOutputMapElMixedKey() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("varExpr1", "a"); variables.put("varExpr2", "b"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals("potato", value.get("a")); assertEquals("tomato", value.get("b")); }
Example 11
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testOutputMapElValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals(2l, value.get("a")); assertEquals(3l, value.get("b")); assertEquals(4l, value.get("c")); }
Example 12
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings("unchecked") public void testOutputListMixedValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals("constantStringValue", value.get(0)); assertEquals("elValue", value.get(1)); assertEquals("scriptValue", value.get(2)); }
Example 13
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings("unchecked") public void testOutputListElValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals(2l, value.get(0)); assertEquals(3l, value.get(1)); assertEquals(4l, value.get(2)); }
Example 14
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testInputMapElKey() { Map<String, Object> variables = new HashMap<String, Object>(); variables.put("varExpr1", "a"); variables.put("varExpr2", "b"); runtimeService.startProcessInstanceByKey("testProcess", variables); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals("potato", value.get("a")); assertEquals("tomato", value.get("b")); }
Example 15
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings({ "unchecked", "rawtypes" }) public void testInputMapElValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); TreeMap<String, Object> value = (TreeMap) variable.getValue(); assertEquals(2l, value.get("a")); assertEquals(3l, value.get("b")); assertEquals(4l, value.get("c")); }
Example 16
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings("unchecked") public void testInputListMixedValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals("constantStringValue", value.get(0)); assertEquals("elValue", value.get(1)); assertEquals("scriptValue", value.get(2)); }
Example 17
Source File: InputOutputTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment @SuppressWarnings("unchecked") public void testInputListElValues() { runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult(); assertNotNull(variable); List<Object> value = (List<Object>) variable.getValue(); assertEquals(2l, value.get(0)); assertEquals(3l, value.get(1)); assertEquals(4l, value.get(2)); }
Example 18
Source File: VariableInstanceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private void checkVariables(List<VariableInstance> variableInstances) { assertFalse(variableInstances.isEmpty()); for (VariableInstance instance : variableInstances) { if (instance.getName().equals("nrOfInstances")) { assertEquals("nrOfInstances", instance.getName()); assertEquals("integer", instance.getTypeName()); } else if (instance.getName().equals("nrOfCompletedInstances")) { assertEquals("nrOfCompletedInstances", instance.getName()); assertEquals("integer", instance.getTypeName()); } else if (instance.getName().equals("nrOfActiveInstances")) { assertEquals("nrOfActiveInstances", instance.getName()); assertEquals("integer", instance.getTypeName()); } else if (instance.getName().equals("loopCounter")) { assertEquals("loopCounter", instance.getName()); assertEquals("integer", instance.getTypeName()); } else if (instance.getName().equals("nullVar")) { assertEquals("nullVar", instance.getName()); assertEquals("null", instance.getTypeName()); } else if (instance.getName().equals("integerVar")) { assertEquals("integerVar", instance.getName()); assertEquals("integer", instance.getTypeName()); } else if (instance.getName().equals("dateVar")) { assertEquals("dateVar", instance.getName()); assertEquals("date", instance.getTypeName()); } else if (instance.getName().equals("stringVar")) { assertEquals("stringVar", instance.getName()); assertEquals("string", instance.getTypeName()); } else if (instance.getName().equals("shortVar")) { assertEquals("shortVar", instance.getName()); assertEquals("short", instance.getTypeName()); } else if (instance.getName().equals("longVar")) { assertEquals("longVar", instance.getName()); assertEquals("long", instance.getTypeName()); } else if (instance.getName().equals("byteVar")) { assertEquals("bytes", instance.getTypeName()); } else if (instance.getName().equals("serializableVar")) { assertEquals("serializableVar", instance.getName()); try { instance.getValue(); } catch(NullPointerException e) { // the serialized value has not been initially loaded } } else { fail("An unexpected variable '" + instance.getName() + "' was found with value " + instance.getValue()); } } }
Example 19
Source File: DecisionContextSwitchTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test @SuppressWarnings("unchecked") @OperateOnDeployment("clientDeployment") public void shouldSwitchContextWhenCallingFromBpmnAfterRedeployment() { // given List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery() .list(); // find dmn deployment org.camunda.bpm.engine.repository.Deployment dmnDeployment = null; for (org.camunda.bpm.engine.repository.Deployment deployment : deployments) { List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId()); if(resourceNames.contains(DMN_RESOURCE_NAME)) { dmnDeployment = deployment; } } if(dmnDeployment == null) { Assert.fail("Expected to find DMN deployment"); } org.camunda.bpm.engine.repository.Deployment deployment2 = repositoryService .createDeployment() .nameFromDeployment(dmnDeployment.getId()) .addDeploymentResources(dmnDeployment.getId()) .deploy(); try { // when then ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); VariableInstance decisionResult = runtimeService.createVariableInstanceQuery() .processInstanceIdIn(pi.getId()) .variableName("result") .singleResult(); List<Map<String, Object>> result = (List<Map<String, Object>>) decisionResult.getValue(); assertEquals("ok", result.get(0).get("result")); } finally { repositoryService.deleteDeployment(deployment2.getId(), true); } }