public virtual void testSerializationAsJava() { ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); JavaSerializable bean = new JavaSerializable("a String", 42, true); // request object to be serialized as Java runtimeService.setVariable(instance.Id, "simpleBean", objectValue(bean).serializationDataFormat(Variables.SerializationDataFormats.JAVA).create()); // validate untyped value object value = runtimeService.getVariable(instance.Id, "simpleBean"); assertEquals(bean, value); // validate typed value ObjectValue typedValue = runtimeService.getVariableTyped(instance.Id, "simpleBean"); assertEquals(ValueType.OBJECT, typedValue.Type); assertTrue(typedValue.Deserialized); assertEquals(bean, typedValue.Value); assertEquals(bean, typedValue.getValue(typeof(JavaSerializable))); assertEquals(typeof(JavaSerializable), typedValue.ObjectType); assertEquals(Variables.SerializationDataFormats.JAVA.Name, typedValue.SerializationDataFormat); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertEquals(typeof(JavaSerializable).FullName, typedValue.ObjectTypeName); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception public virtual void execute(DelegateExecution execution) { // validate integer variable int?expectedIntValue = 1234; assertEquals(expectedIntValue, execution.getVariable("anIntegerVariable")); assertEquals(expectedIntValue, execution.getVariableTyped("anIntegerVariable").Value); assertEquals(ValueType.INTEGER, execution.getVariableTyped("anIntegerVariable").Type); assertNull(execution.getVariableLocal("anIntegerVariable")); assertNull(execution.getVariableLocalTyped("anIntegerVariable")); // set an additional local variable execution.setVariableLocal("aStringVariable", "aStringValue"); string expectedStringValue = "aStringValue"; assertEquals(expectedStringValue, execution.getVariable("aStringVariable")); assertEquals(expectedStringValue, execution.getVariableTyped("aStringVariable").Value); assertEquals(ValueType.STRING, execution.getVariableTyped("aStringVariable").Type); assertEquals(expectedStringValue, execution.getVariableLocal("aStringVariable")); assertEquals(expectedStringValue, execution.getVariableLocalTyped("aStringVariable").Value); assertEquals(ValueType.STRING, execution.getVariableLocalTyped("aStringVariable").Type); SimpleSerializableBean objectValue = (SimpleSerializableBean)execution.getVariable("anObjectValue"); assertNotNull(objectValue); assertEquals(10, objectValue.IntProperty); ObjectValue variableTyped = execution.getVariableTyped("anObjectValue"); assertEquals(10, variableTyped.getValue(typeof(SimpleSerializableBean)).IntProperty); assertEquals(Variables.SerializationDataFormats.JAVA.Name, variableTyped.SerializationDataFormat); objectValue = (SimpleSerializableBean)execution.getVariable("anUntypedObjectValue"); assertNotNull(objectValue); assertEquals(30, objectValue.IntProperty); variableTyped = execution.getVariableTyped("anUntypedObjectValue"); assertEquals(30, variableTyped.getValue(typeof(SimpleSerializableBean)).IntProperty); assertEquals(Context.ProcessEngineConfiguration.DefaultSerializationFormat, variableTyped.SerializationDataFormat); }