JSONAssert.assertEquals(bean.toExpectedJsonString(), new String(typedValue.getValueSerialized()), true);
}
@Deployment(resources = ONE_TASK_PROCESS)
public void testListSerializationAsJson() throws JSONException {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<JsonSerializable> beans = new ArrayList<JsonSerializable>();
for (int i = 0; i < 20; i++) {
beans.add(new JsonSerializable("a String" + i, 42 + i, true));
}
runtimeService.setVariable(instance.getId(), "simpleBeans", objectValue(beans).serializationDataFormat(JSON_FORMAT_NAME).create());
// validate untyped value
Object value = runtimeService.getVariable(instance.getId(), "simpleBeans");
assertEquals(beans, value);
// validate typed value
ObjectValue typedValue = runtimeService.getVariableTyped(instance.getId(), "simpleBeans");
assertEquals(ValueType.OBJECT, typedValue.getType());
assertEquals(beans, typedValue.getValue());
assertTrue(typedValue.isDeserialized());
assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
assertNotNull(typedValue.getObjectTypeName());