Exemple #1
0
        public virtual void testSetSerializedVariableValue()
        {
            ProcessInstance  instance   = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            JsonSerializable bean       = new JsonSerializable("a String", 42, true);
            string           beanAsJson = bean.toExpectedJsonString();

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
            SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsJson).serializationDataFormat(JSON_FORMAT_NAME).objectTypeName(bean.GetType().FullName);

            runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);

            // java object can be retrieved
            JsonSerializable returnedBean = (JsonSerializable)runtimeService.getVariable(instance.Id, "simpleBean");

            assertEquals(bean, returnedBean);

            // validate typed value metadata
            ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean");

            assertEquals(bean, typedValue.Value);
            assertEquals(JSON_FORMAT_NAME, typedValue.SerializationDataFormat);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
            assertEquals(bean.GetType().FullName, typedValue.ObjectTypeName);
        }
Exemple #2
0
        public virtual void testRemoveVariable()
        {
            // given a serialized json variable
            ProcessInstance  instance   = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            JsonSerializable bean       = new JsonSerializable("a String", 42, true);
            string           beanAsJson = bean.toExpectedJsonString();

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method:
            SerializedObjectValueBuilder serializedValue = serializedObjectValue(beanAsJson).serializationDataFormat(JSON_FORMAT_NAME).objectTypeName(bean.GetType().FullName);

            runtimeService.setVariable(instance.Id, "simpleBean", serializedValue);

            // when
            runtimeService.removeVariable(instance.Id, "simpleBean");

            // then
            assertNull(runtimeService.getVariable(instance.Id, "simpleBean"));
            assertNull(runtimeService.getVariableTyped(instance.Id, "simpleBean"));
            assertNull(runtimeService.getVariableTyped(instance.Id, "simpleBean", false));
        }