use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValueNoTypeName.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNoTypeName() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
XmlSerializable bean = new XmlSerializable("a String", 42, true);
String beanAsXml = bean.toExpectedXmlString();
SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsXml).serializationDataFormat(XML_FORMAT_NAME);
try {
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
fail("Exception expected.");
} catch (Exception e) {
assertTextPresent("no 'objectTypeName' provided for non-null value", e.getMessage());
}
}
use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValue() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
XmlSerializable bean = new XmlSerializable("a String", 42, true);
String beanAsXml = bean.toExpectedXmlString();
SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsXml).serializationDataFormat(XML_FORMAT_NAME).objectTypeName(bean.getClass().getCanonicalName());
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
// 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());
}
use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValueNullNoTypeName.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNullNoTypeName() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME);
// no objectTypeName specified
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
// 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());
assertNull(typedValue.getObjectTypeName());
}
use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValueNull.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNull() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
SerializedObjectValueBuilder serializedValue = serializedObjectValue().serializationDataFormat(XML_FORMAT_NAME).objectTypeName(XmlSerializable.class.getCanonicalName());
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
// 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());
}
use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.
the class XmlSerializationTest method testSetSerializedVariableValueMismatchingTypeName.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueMismatchingTypeName() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
XmlSerializable bean = new XmlSerializable("a String", 42, true);
String beanAsXml = bean.toExpectedXmlString();
SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsXml).serializationDataFormat(XML_FORMAT_NAME).objectTypeName(// < not a valid type name
"Insensible type name.");
runtimeService.setVariable(instance.getId(), "simpleBean", serializedValue);
try {
runtimeService.getVariable(instance.getId(), "simpleBean");
fail("Exception expected.");
} catch (ProcessEngineException e) {
// happy path
}
}
Aggregations