//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateObjectVariables() public virtual void testCreateObjectVariables() { VariableMap variables = createVariables().putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE)); assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables[DESERIALIZED_OBJECT_VAR_NAME]); assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.getValue(DESERIALIZED_OBJECT_VAR_NAME, typeof(ExampleObject))); object untypedValue = variables.getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).Value; assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, untypedValue); ExampleObject typedValue = variables.getValueTyped <ObjectValue>(DESERIALIZED_OBJECT_VAR_NAME).getValue(typeof(ExampleObject)); assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, typedValue); // object type name is not yet available assertNull(variables.getValueTyped <ObjectValue>(DESERIALIZED_OBJECT_VAR_NAME).ObjectTypeName); // class is available assertEquals(DESERIALIZED_OBJECT_VAR_VALUE.GetType(), variables.getValueTyped <ObjectValue>(DESERIALIZED_OBJECT_VAR_NAME).ObjectType); variables = createVariables().putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE).serializationDataFormat(SERIALIZATION_DATA_FORMAT_NAME)); assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables[DESERIALIZED_OBJECT_VAR_NAME]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreatePrimitiveVariableNull() public virtual void testCreatePrimitiveVariableNull() { VariableMap variables = createVariables().putValue(variableName, nullValue); // get return value assertEquals(null, variables[variableName]); // type is not lost assertEquals(valueType, variables.getValueTyped(variableName).Type); // get wrapper object stringValue = variables.getValueTyped(variableName).Value; assertEquals(null, stringValue); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void testVariablesWithoutDeserialization(String processDefinitionKey) throws Exception private void testVariablesWithoutDeserialization(string processDefinitionKey) { //given serializable variable JavaSerializable javaSerializable = new JavaSerializable("foo"); MemoryStream baos = new MemoryStream(); (new ObjectOutputStream(baos)).writeObject(javaSerializable); string serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.ProcessEngine); //when execute process with serialized variable and wait state //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: ProcessInstanceWithVariables procInstance = engineRule.RuntimeService.createProcessInstanceByKey(processDefinitionKey).setVariable("serializedVar", serializedObjectValue(serializedObject).serializationDataFormat(Variables.SerializationDataFormats.JAVA).objectTypeName(typeof(JavaSerializable).FullName).create()).executeWithVariablesInReturn(false, false); //then returned instance contains serialized variable VariableMap map = procInstance.Variables; assertNotNull(map); ObjectValue serializedVar = (ObjectValue)map.getValueTyped("serializedVar"); assertFalse(serializedVar.Deserialized); assertObjectValueSerializedJava(serializedVar, javaSerializable); //access on value should fail because variable is not deserialized try { serializedVar.Value; Assert.fail("Deserialization should fail!"); } catch (System.InvalidOperationException ise) { assertTrue(ise.Message.Equals("Object is not deserialized.")); } }
private void checkVariables(VariableMap map, int expectedSize) { IList <HistoricVariableInstance> variables = engineRule.HistoryService.createHistoricVariableInstanceQuery().orderByVariableName().asc().list(); assertEquals(expectedSize, variables.Count); assertEquals(variables.Count, map.size()); foreach (HistoricVariableInstance instance in variables) { assertTrue(map.containsKey(instance.Name)); object instanceValue = instance.TypedValue.Value; object mapValue = map.getValueTyped(instance.Name).Value; if (instanceValue == null) { assertNull(mapValue); } else if (instanceValue is sbyte[]) { assertTrue(Arrays.Equals((sbyte[])instanceValue, (sbyte[])mapValue)); } else { assertEquals(instanceValue, mapValue); } } }
protected internal virtual bool matchesMatchers(object argument) { if (argument == null) { return(false); } VariableMap argumentMap = (VariableMap)argument; //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: bool containSameKeys = matchers.Keys.containsAll(argumentMap.Keys) && argumentMap.Keys.containsAll(matchers.Keys); if (!containSameKeys) { return(false); } foreach (string key in argumentMap.Keys) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.hamcrest.Matcher<?> matcher = matchers.get(key); Matcher <object> matcher = matchers[key]; if (!matcher.matches(argumentMap.getValueTyped(key))) { return(false); } } return(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testTransientVariables() throws java.net.URISyntaxException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testTransientVariables() { VariableMap variableMap = createVariables().putValueTyped("foo", doubleValue(10.0, true)).putValueTyped("bar", integerValue(10, true)).putValueTyped("aa", booleanValue(true, true)).putValueTyped("bb", stringValue("bb", true)).putValueTyped("test", byteArrayValue("test".GetBytes(), true)).putValueTyped("blob", fileValue(new File(this.GetType().ClassLoader.getResource("org/camunda/bpm/engine/test/variables/simpleFile.txt").toURI()), true)).putValueTyped("val", dateValue(DateTime.Now, true)).putValueTyped("var", objectValue(new int?(10), true).create()).putValueTyped("short", shortValue((short)12, true)).putValueTyped("long", longValue((long)10, true)).putValueTyped("file", fileValue("org/camunda/bpm/engine/test/variables/simpleFile.txt").setTransient(true).create()).putValueTyped("hi", untypedValue("stringUntyped", true)).putValueTyped("null", untypedValue(null, true)).putValueTyped("ser", serializedObjectValue("{\"name\" : \"foo\"}", true).create()); foreach (KeyValuePair <string, object> e in variableMap.SetOfKeyValuePairs()) { TypedValue value = (TypedValue)variableMap.getValueTyped(e.Key); assertTrue(value.Transient); } }
// submit ///////////////////////////////////////////// public virtual void handleSubmit(VariableScope variableScope, VariableMap values, VariableMap allValues) { TypedValue submittedValue = (TypedValue)values.getValueTyped(id); values.remove(id); // perform validation foreach (FormFieldValidationConstraintHandler validationHandler in validationHandlers) { object value = null; if (submittedValue != null) { value = submittedValue.Value; } validationHandler.validate(value, allValues, this, variableScope); } // update variable(s) TypedValue modelValue = null; if (submittedValue != null) { if (type != null) { modelValue = type.convertToModelValue(submittedValue); } else { modelValue = submittedValue; } } else if (defaultValueExpression != null) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.variable.value.TypedValue expressionValue = org.camunda.bpm.engine.variable.Variables.untypedValue(defaultValueExpression.getValue(variableScope)); TypedValue expressionValue = Variables.untypedValue(defaultValueExpression.getValue(variableScope)); if (type != null) { // first, need to convert to model value since the default value may be a String Constant specified in the model xml. modelValue = type.convertToModelValue(Variables.untypedValue(expressionValue)); } else if (expressionValue != null) { modelValue = Variables.stringValue(expressionValue.Value.ToString()); } } if (modelValue != null) { if (!string.ReferenceEquals(id, null)) { variableScope.setVariable(id, modelValue); } } }
protected internal virtual void fireFormPropertyHistoryEvents(VariableMap properties, VariableScope variableScope) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration(); ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration; HistoryLevel historyLevel = processEngineConfiguration.HistoryLevel; if (historyLevel.isHistoryEventProduced(HistoryEventTypes.FORM_PROPERTY_UPDATE, variableScope)) { // fire history events //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity executionEntity; ExecutionEntity executionEntity; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String taskId; string taskId; if (variableScope is ExecutionEntity) { executionEntity = (ExecutionEntity)variableScope; taskId = null; } else if (variableScope is TaskEntity) { TaskEntity task = (TaskEntity)variableScope; executionEntity = task.getExecution(); taskId = task.Id; } else { executionEntity = null; taskId = null; } if (executionEntity != null) { foreach (String variableName in properties.Keys) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.variable.value.TypedValue value = properties.getValueTyped(variableName); TypedValue value = properties.getValueTyped(variableName); // NOTE: SerializableValues are never stored as form properties if (!(value is SerializableValue) && value.Value != null && value.Value is String) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String stringValue = (String) value.getValue(); string stringValue = (String)value.Value; HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, executionEntity, taskId, stringValue)); } } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreatePrimitiveVariableUntyped() public virtual void testCreatePrimitiveVariableUntyped() { VariableMap variables = createVariables().putValue(variableName, value); assertEquals(value, variables[variableName]); assertEquals(value, variables.getValueTyped(variableName).Value); // no type information present TypedValue typedValue = variables.getValueTyped(variableName); if (!(typedValue is NullValueImpl)) { assertNull(typedValue.Type); assertEquals(variables[variableName], typedValue.Value); } else { assertEquals(NULL, typedValue.Type); } }
public static IDictionary <string, VariableValueDto> fromMap(VariableMap variables, bool preferSerializedValue) { IDictionary <string, VariableValueDto> result = new Dictionary <string, VariableValueDto>(); foreach (string variableName in variables.Keys) { VariableValueDto valueDto = VariableValueDto.fromTypedValue(variables.getValueTyped(variableName), preferSerializedValue); result[variableName] = valueDto; } return(result); }