当前位置: 首页>>代码示例>>Java>>正文


Java VariableMap.getValueTyped方法代码示例

本文整理汇总了Java中org.camunda.bpm.engine.variable.VariableMap.getValueTyped方法的典型用法代码示例。如果您正苦于以下问题:Java VariableMap.getValueTyped方法的具体用法?Java VariableMap.getValueTyped怎么用?Java VariableMap.getValueTyped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.camunda.bpm.engine.variable.VariableMap的用法示例。


在下文中一共展示了VariableMap.getValueTyped方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreatePrimitiveVariableUntyped

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testCreatePrimitiveVariableUntyped() {
  VariableMap variables = createVariables().putValue(variableName, value);

  assertEquals(value, variables.get(variableName));
  assertEquals(value, variables.getValueTyped(variableName).getValue());

  // no type information present
  TypedValue typedValue = variables.getValueTyped(variableName);
  if (!(typedValue instanceof NullValueImpl)) {
    assertNull(typedValue.getType());
    assertEquals(variables.get(variableName), typedValue.getValue());
  } else {
    assertEquals(NULL, typedValue.getType());
  }
}
 
开发者ID:camunda,项目名称:camunda-commons,代码行数:17,代码来源:PrimitiveValueTest.java

示例2: testTransientVariables

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testTransientVariables() throws URISyntaxException {
  VariableMap variableMap = createVariables().putValueTyped("foo", doubleValue(10.0, true))
                   .putValueTyped("bar", integerValue(10, true))
                   .putValueTyped("aa", booleanValue(true, true))
                   .putValueTyped("bb", stringValue("bb", true))
                   .putValueTyped("test", byteArrayValue("test".getBytes(), true))
                   .putValueTyped("blob", fileValue(new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/variables/simpleFile.txt").toURI()), true))
                   .putValueTyped("val", dateValue(new Date(), true))
                   .putValueTyped("var", objectValue(new Integer(10), true).create())
                   .putValueTyped("short", shortValue((short)12, true))
                   .putValueTyped("long", longValue((long)10, true))
                   .putValueTyped("file", fileValue("org/camunda/bpm/engine/test/variables/simpleFile.txt").setTransient(true).create())
                   .putValueTyped("hi", untypedValue("stringUntyped", true))
                   .putValueTyped("null", untypedValue(null, true))
                   .putValueTyped("ser", serializedObjectValue("{\"name\" : \"foo\"}", true).create());

  for (Entry<String, Object> e : variableMap.entrySet()) {
    TypedValue value = (TypedValue) variableMap.getValueTyped(e.getKey());
    assertTrue(value.isTransient());
  }
}
 
开发者ID:camunda,项目名称:camunda-commons,代码行数:23,代码来源:VariableApiTest.java

示例3: handleSubmit

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
public void handleSubmit(VariableScope variableScope, VariableMap values, VariableMap allValues) {
  TypedValue submittedValue = (TypedValue) values.getValueTyped(id);
  values.remove(id);

  // perform validation
  for (FormFieldValidationConstraintHandler validationHandler : validationHandlers) {
    Object value = null;
    if(submittedValue != null) {
      value = submittedValue.getValue();
    }
    validationHandler.validate(value, allValues, this, variableScope);
  }

  // update variable(s)
  TypedValue modelValue = null;
  if (submittedValue != null) {
    if (type != null) {
      modelValue = type.convertToModelValue(submittedValue);
    }
    else {
      modelValue = submittedValue;
    }
  }
  else if (defaultValueExpression != null) {
    final TypedValue expressionValue = Variables.untypedValue(defaultValueExpression.getValue(variableScope));
    if (type != null) {
      // first, need to convert to model value since the default value may be a String Constant specified in the model xml.
      modelValue = type.convertToModelValue(Variables.untypedValue(expressionValue));
    }
    else if (expressionValue != null) {
      modelValue = Variables.stringValue(expressionValue.getValue().toString());
    }
  }

  if (modelValue != null) {
    if (id != null) {
      variableScope.setVariable(id, modelValue);
    }
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:41,代码来源:FormFieldHandler.java

示例4: testVariablesWithoutDeserialization

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
private void testVariablesWithoutDeserialization(String processDefinitionKey) throws Exception {
  //given serializable variable
  JavaSerializable javaSerializable = new JavaSerializable("foo");

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  new ObjectOutputStream(baos).writeObject(javaSerializable);
  String serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.getProcessEngine());

  //when execute process with serialized variable and wait state
  ProcessInstanceWithVariables procInstance = engineRule.getRuntimeService()
          .createProcessInstanceByKey(processDefinitionKey)
          .setVariable("serializedVar", serializedObjectValue(serializedObject)
            .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
            .objectTypeName(JavaSerializable.class.getName())
            .create())
          .executeWithVariablesInReturn(false, false);

  //then returned instance contains serialized variable
  VariableMap map = procInstance.getVariables();
  assertNotNull(map);

  ObjectValue serializedVar = (ObjectValue) map.getValueTyped("serializedVar");
  assertFalse(serializedVar.isDeserialized());
  assertObjectValueSerializedJava(serializedVar, javaSerializable);

  //access on value should fail because variable is not deserialized
  try {
    serializedVar.getValue();
    Assert.fail("Deserialization should fail!");
  } catch (IllegalStateException ise) {
    assertTrue(ise.getMessage().equals("Object is not deserialized."));
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:34,代码来源:ProcessInstantiationWithVariablesInReturnTest.java

示例5: matchesMatchers

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
protected boolean matchesMatchers(Object argument) {
  if (argument == null) {
    return false;
  }

  Map<String, Object> argumentMap = (Map<String, Object>) argument;

  boolean containSameKeys = matchers.keySet().containsAll(argumentMap.keySet()) &&
      argumentMap.keySet().containsAll(matchers.keySet());
  if (!containSameKeys) {
    return false;
  }

  for (String key : argumentMap.keySet()) {
    Matcher<?> matcher = matchers.get(key);
    Object value = null;
    if (argumentMap instanceof VariableMap) {
      VariableMap varMap = (VariableMap) argumentMap;
      value = varMap.getValueTyped(key);
    }
    else {
      value = argumentMap.get(key);
    }
    if (!matcher.matches(value)) {
      return false;
    }
  }


  return true;
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:32,代码来源:EqualsMap.java

示例6: testSubmitTaskFormWithFileValue

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Test
public void testSubmitTaskFormWithFileValue() {
  String variableKey = "aVariable";
  String filename = "test.txt";
  Map<String, Object> variables = VariablesBuilder.create().variable(variableKey, Base64.encodeBase64String("someBytes".getBytes()), "File")
      .getVariables();
  ((Map<String, Object>)variables.get(variableKey)).put("valueInfo", Collections.<String, Object>singletonMap("filename", filename));

  Map<String, Object> json = new HashMap<String, Object>();
  json.put("variables", variables);

  given().pathParam("id", EXAMPLE_TASK_ID)
    .header("accept", MediaType.APPLICATION_JSON)
    .contentType(POST_JSON_CONTENT_TYPE).body(json)
    .then().expect()
      .statusCode(Status.NO_CONTENT.getStatusCode())
    .when().post(SUBMIT_FORM_URL);

  ArgumentCaptor<VariableMap> captor = ArgumentCaptor.forClass(VariableMap.class);
  verify(formServiceMock).submitTaskForm(eq(EXAMPLE_TASK_ID), captor.capture());
  VariableMap map = captor.getValue();
  FileValue fileValue = (FileValue) map.getValueTyped(variableKey);
  assertThat(fileValue, is(notNullValue()));
  assertThat(fileValue.getFilename(), is(filename));
  assertThat(IoUtil.readInputStream(fileValue.getValue(), null), is("someBytes".getBytes()));
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:28,代码来源:TaskRestServiceInteractionTest.java

示例7: testProcessVariableMap

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testProcessVariableMap() {
  BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);

  VariableMap variables = (VariableMap) getBeanInstance("processVariableMap");
  assertNotNull(variables);

  ///////////////////////////////////////////////////////////////////
  // Put a variable via BusinessProcess and get it via VariableMap //
  ///////////////////////////////////////////////////////////////////
  String aValue = "aValue";
  businessProcess.setVariable(VARNAME_1, Variables.stringValue(aValue));

  // Legacy API
  assertEquals(aValue, variables.get(VARNAME_1));

  // Typed variable API
  TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);
  assertEquals(ValueType.STRING, aTypedValue.getType());
  assertEquals(aValue, aTypedValue.getValue());
  assertEquals(aValue, variables.getValue(VARNAME_1, String.class));

  // Type API with wrong type
  try {
    variables.getValue(VARNAME_1, Integer.class);
    fail("ClassCastException expected!");
  } catch(ClassCastException ex) {
    assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.getMessage());
  }

  ///////////////////////////////////////////////////////////////////
  // Put a variable via VariableMap and get it via BusinessProcess //
  ///////////////////////////////////////////////////////////////////
  String anotherValue = "anotherValue";
  variables.put(VARNAME_2, Variables.stringValue(anotherValue));

  // Legacy API
  assertEquals(anotherValue, businessProcess.getVariable(VARNAME_2));

  // Typed variable API
  TypedValue anotherTypedValue = businessProcess.getVariableTyped(VARNAME_2);
  assertEquals(ValueType.STRING, anotherTypedValue.getType());
  assertEquals(anotherValue, anotherTypedValue.getValue());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:45,代码来源:ProcessVariableMapTest.java

示例8: testProcessVariableMapLocal

import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testProcessVariableMapLocal() {
  BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
  businessProcess.startProcessByKey("businessProcessBeanTest");

  VariableMap variables = (VariableMap) getBeanInstance("processVariableMapLocal");
  assertNotNull(variables);

  ///////////////////////////////////////////////////////////////////
  // Put a variable via BusinessProcess and get it via VariableMap //
  ///////////////////////////////////////////////////////////////////
  String aValue = "aValue";
  businessProcess.setVariableLocal(VARNAME_1, Variables.stringValue(aValue));

  // Legacy API
  assertEquals(aValue, variables.get(VARNAME_1));

  // Typed variable API
  TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);
  assertEquals(ValueType.STRING, aTypedValue.getType());
  assertEquals(aValue, aTypedValue.getValue());
  assertEquals(aValue, variables.getValue(VARNAME_1, String.class));

  // Type API with wrong type
  try {
    variables.getValue(VARNAME_1, Integer.class);
    fail("ClassCastException expected!");
  } catch(ClassCastException ex) {
    assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.getMessage());
  }

  ///////////////////////////////////////////////////////////////////
  // Put a variable via VariableMap and get it via BusinessProcess //
  ///////////////////////////////////////////////////////////////////
  String anotherValue = "anotherValue";
  variables.put(VARNAME_2, Variables.stringValue(anotherValue));

  // Legacy API
  assertEquals(anotherValue, businessProcess.getVariableLocal(VARNAME_2));

  // Typed variable API
  TypedValue anotherTypedValue = businessProcess.getVariableLocalTyped(VARNAME_2);
  assertEquals(ValueType.STRING, anotherTypedValue.getType());
  assertEquals(anotherValue, anotherTypedValue.getValue());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:47,代码来源:ProcessVariableMapTest.java


注:本文中的org.camunda.bpm.engine.variable.VariableMap.getValueTyped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。