//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetTypedVariable() public virtual void shouldGetTypedVariable() { ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY); runtimeService.setVariable(instance.Id, VARIABLE_NAME, typedValue); TypedValue typedVariableValue = runtimeService.getVariableTyped(instance.Id, VARIABLE_NAME); assertEquals(typedValue.Type, typedVariableValue.Type); assertEquals(typedValue.Value, typedVariableValue.Value); }
public virtual void testSetSerializedVariableValues() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); EventSubscription messageEventSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); // when FailingJavaSerializable javaSerializable = new FailingJavaSerializable("foo"); MemoryStream baos = new MemoryStream(); (new ObjectOutputStream(baos)).writeObject(javaSerializable); string serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.ProcessEngine); // then it is not possible to deserialize the object try { (new ObjectInputStream(new MemoryStream(baos.toByteArray()))).readObject(); } catch (Exception e) { testRule.assertTextPresent("Exception while deserializing object.", e.Message); } // but it can be set as a variable when delivering a message: //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: runtimeService.messageEventReceived("newInvoiceMessage", messageEventSubscription.ExecutionId, Variables.createVariables().putValueTyped("var", Variables.serializedObjectValue(serializedObject).objectTypeName(typeof(FailingJavaSerializable).FullName).serializationDataFormat(Variables.SerializationDataFormats.JAVA).create())); // then ObjectValue variableTyped = runtimeService.getVariableTyped(processInstance.Id, "var", false); assertNotNull(variableTyped); assertFalse(variableTyped.Deserialized); assertEquals(serializedObject, variableTyped.ValueSerialized); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertEquals(typeof(FailingJavaSerializable).FullName, variableTyped.ObjectTypeName); assertEquals(Variables.SerializationDataFormats.JAVA.Name, variableTyped.SerializationDataFormat); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCanMigrateWithObjectVariableThatFailsOnDeserialization() public virtual void testCanMigrateWithObjectVariableThatFailsOnDeserialization() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "userTask").build(); ProcessInstance processInstance = rule.RuntimeService.startProcessInstanceById(sourceProcessDefinition.Id); ObjectValue objectValue = Variables.serializedObjectValue("does/not/deserialize").serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName("and.this.is.a.nonexisting.Class").create(); runtimeService.setVariable(processInstance.Id, "var", objectValue); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then ObjectValue migratedValue = runtimeService.getVariableTyped(processInstance.Id, "var", false); Assert.assertEquals(objectValue.ValueSerialized, migratedValue.ValueSerialized); Assert.assertEquals(objectValue.ObjectTypeName, migratedValue.ObjectTypeName); }