Search in sources :

Example 11 with SerializedObjectValueBuilder

use of org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder in project camunda-bpm-platform by camunda.

the class JsonSerializationTest method testSetSerializedVariableValueNoTypeName.

@Deployment(resources = ONE_TASK_PROCESS)
public void testSetSerializedVariableValueNoTypeName() throws JSONException {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    JsonSerializable bean = new JsonSerializable("a String", 42, true);
    String beanAsJson = bean.toExpectedJsonString();
    SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsJson).serializationDataFormat(JSON_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());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SerializedObjectValueBuilder(org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) JSONException(org.json.JSONException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 SerializedObjectValueBuilder (org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder)11 Variables.serializedObjectValue (org.camunda.bpm.engine.variable.Variables.serializedObjectValue)6 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 JSONException (org.json.JSONException)2