Examples of ObjectValue


Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    catch(ProcessEngineException e) {
      // happy path
    }

    // However, I can access the serialized value
    ObjectValue objectValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean", false);
    assertFalse(objectValue.isDeserialized());
    assertNotNull(objectValue.getObjectTypeName());
    assertNotNull(objectValue.getValueSerialized());
    // but not the deserialized properties
    try {
      objectValue.getValue();
      fail("exception expected");
    }
    catch(IllegalStateException e) {
      assertTextPresent("Object is not deserialized", e.getMessage());
    }

    try {
      objectValue.getValue(XmlSerializable.class);
      fail("exception expected");
    }
    catch(IllegalStateException e) {
      assertTextPresent("Object is not deserialized", e.getMessage());
    }

    try {
      objectValue.getObjectType();
      fail("exception expected");
    }
    catch(IllegalStateException e) {
      assertTextPresent("Object is not deserialized", e.getMessage());
    }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

    XmlSerializable bean = new XmlSerializable("a String", 42, true);
    runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(bean).serializationDataFormat(XML_FORMAT_NAME).create());

    ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean", false);

    SpinXmlElement serializedValue = Spin.XML(typedValue.getValueSerialized());
    assertEquals(bean.getStringProperty(), serializedValue.childElement("stringProperty").textContent());
    assertEquals(bean.getBooleanProperty(), Boolean.parseBoolean(serializedValue.childElement("booleanProperty").textContent()));
    assertEquals(bean.getIntProperty(), Integer.parseInt(serializedValue.childElement("intProperty").textContent()));
  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    // java object can be retrieved
    XmlSerializable returnedBean = (XmlSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
    assertEquals(bean, returnedBean);

    // validate typed value metadata
    ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
    assertEquals(bean, typedValue.getValue());
    assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
    assertEquals(bean.getClass().getCanonicalName(), typedValue.getObjectTypeName());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    // null can be retrieved
    XmlSerializable returnedBean = (XmlSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
    assertNull(returnedBean);

    // validate typed value metadata
    ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
    assertNull(typedValue.getValue());
    assertNull(typedValue.getValueSerialized());
    assertEquals(XML_FORMAT_NAME, typedValue.getSerializationDataFormat());
    assertEquals(XmlSerializable.class.getCanonicalName(), typedValue.getObjectTypeName());

  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

  @Test
  public void spinCanBeUsedForVariableSerialization() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", Variables.createVariables()
        .putValue("serializedObject", serializedObjectValue("{\"foo\": \"bar\"}").serializationDataFormat("application/json").objectTypeName(HashMap.class.getName())));

    ObjectValue objectValue = runtimeService.getVariableTyped(pi.getId(), "serializedObject", true);

    HashMap<String, String> expected = new HashMap<String, String>();
    expected.put("foo", "bar");

    Assert.assertEquals(expected, objectValue.getValue());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

  public Map<String, Object> getValueInfo(TypedValue typedValue) {
    if(!(typedValue instanceof ObjectValue)) {
      throw new IllegalArgumentException("Value not of type Object.");
    }
    ObjectValue objectValue = (ObjectValue) typedValue;

    Map<String, Object> valueInfo = new HashMap<String, Object>();

    String serializationDataFormat = objectValue.getSerializationDataFormat();
    if(serializationDataFormat != null) {
      valueInfo.put(VALUE_INFO_SERIALIZATION_DATA_FORMAT, serializationDataFormat);
    }

    String objectTypeName = objectValue.getObjectTypeName();
    if(objectTypeName != null) {
      valueInfo.put(VALUE_INFO_OBJECT_TYPE_NAME, objectTypeName);
    }

    return valueInfo;
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    assertEquals(serializableValue, value);

    Object valueLocal = taskService.getVariableLocal(taskId, "objectVariableLocal");
    assertEquals(serializableValueLocal, valueLocal);

    ObjectValue typedValue = taskService.getVariableTyped(taskId, "objectVariable");
    assertEquals(serializableValue, typedValue.getValue());

    ObjectValue serializedValue = taskService.getVariableTyped(taskId, "objectVariable", false);
    assertFalse(serializedValue.isDeserialized());

    ObjectValue typedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal");
    assertEquals(serializableValueLocal, typedValueLocal.getValue());

    ObjectValue serializedValueLocal = taskService.getVariableLocalTyped(taskId, "objectVariableLocal", false);
    assertFalse(serializedValueLocal.isDeserialized());

    try {
      StringValue val = taskService.getVariableTyped(taskId, "objectVariable");
      fail("expected exception");
    }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    for (HistoricDetail update : results) {
      HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) update;
      assertNull(variableUpdate.getErrorMessage());

      ObjectValue typedValue = (ObjectValue) variableUpdate.getTypedValue();
      assertNotNull(typedValue);
      assertFalse(typedValue.isDeserialized());
      // cannot access the deserialized value
      try {
        typedValue.getValue();
      }
      catch(IllegalStateException e) {
        assertTextPresent("Object is not deserialized", e.getMessage());
      }
      assertNotNull(typedValue.getValueSerialized());
    }

    taskService.deleteTask(newTask.getId(), true);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    assertEquals(2, results.size());

    for (VariableInstance variableInstance : results) {
      assertNull(variableInstance.getErrorMessage());

      ObjectValue typedValue = (ObjectValue) variableInstance.getTypedValue();
      assertNotNull(typedValue);
      assertFalse(typedValue.isDeserialized());
      // cannot access the deserialized value
      try {
        typedValue.getValue();
      }
      catch(IllegalStateException e) {
        assertTextPresent("Object is not deserialized", e.getMessage());
      }
      assertNotNull(typedValue.getValueSerialized());
    }

    // delete task
    taskService.deleteTask(task.getId(), true);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.variable.value.ObjectValue

    // validate untyped value
    JavaSerializable value = (JavaSerializable) runtimeService.getVariable(instance.getId(), "simpleBean");
    assertEquals(javaSerializable, value);

    // validate typed value
    ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBean");
    assertObjectValueDeserialized(typedValue, javaSerializable);
    assertObjectValueSerializedJava(typedValue, javaSerializable);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.