Search in sources :

Example 1 with Foo

use of org.camunda.bpm.integrationtest.functional.spin.dataformat.Foo in project camunda-bpm-platform by camunda.

the class PaDataFormatProviderTest method customFormatCanBeUsedForVariableSerialization.

/**
 * Tests that
 * 1) a serialized value can be set OUT OF process application context
 *   even if the data format is not available (using the fallback serializer)
 * 2) and that this value can be deserialized IN process application context
 *   by using the PA-local serializer
 */
@Test
public void customFormatCanBeUsedForVariableSerialization() {
    final ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", Variables.createVariables().putValue("serializedObject", serializedObjectValue("foo").serializationDataFormat(FooDataFormat.NAME).objectTypeName(Foo.class.getName())));
    ObjectValue objectValue = null;
    try {
        ProcessApplicationContext.setCurrentProcessApplication(ReferenceStoringProcessApplication.INSTANCE);
        objectValue = runtimeService.getVariableTyped(pi.getId(), "serializedObject", true);
    } finally {
        ProcessApplicationContext.clear();
    }
    Object value = objectValue.getValue();
    Assert.assertNotNull(value);
    Assert.assertTrue(value instanceof Foo);
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) Variables.serializedObjectValue(org.camunda.bpm.engine.variable.Variables.serializedObjectValue) Foo(org.camunda.bpm.integrationtest.functional.spin.dataformat.Foo) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 Variables.serializedObjectValue (org.camunda.bpm.engine.variable.Variables.serializedObjectValue)1 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)1 Foo (org.camunda.bpm.integrationtest.functional.spin.dataformat.Foo)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1 Test (org.junit.Test)1