예제 #1
0
 protected internal override bool canWriteValue(TypedValue value)
 {
     if (value == null || value.Type == null)
     {
         // untyped value
         return(false);
     }
     return(value.Type.Name.Equals(Name));
 }
예제 #2
0
        public virtual void execute(DelegateExecution execution)
        {
            execution.setVariable("jsonVariable", Variables.untypedValue(jsonValue("{}"), true));

            // when
            TypedValue typedValue = execution.getVariableTyped("jsonVariable");

            // then
            assertThat(typedValue.Transient, @is(true));
        }
예제 #3
0
 protected internal override bool canWriteValue(TypedValue value)
 {
     if (isDeserializedObjectValue(value) || value is UntypedValueImpl)
     {
         return(value.Value == null || mappings.isJPAEntity(value.Value));
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
        public virtual void testProcessVariableMapLocal()
        {
            BusinessProcess businessProcess = getBeanInstance(typeof(BusinessProcess));

            businessProcess.startProcessByKey("businessProcessBeanTest");

            VariableMap variables = (VariableMap)getBeanInstance("processVariableMapLocal");

            assertNotNull(variables);

            ///////////////////////////////////////////////////////////////////
            // Put a variable via BusinessProcess and get it via VariableMap //
            ///////////////////////////////////////////////////////////////////
            string aValue = "aValue";

            businessProcess.setVariableLocal(VARNAME_1, Variables.stringValue(aValue));

            // Legacy API
            assertEquals(aValue, variables.get(VARNAME_1));

            // Typed variable API
            TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);

            assertEquals(ValueType.STRING, aTypedValue.Type);
            assertEquals(aValue, aTypedValue.Value);
            assertEquals(aValue, variables.getValue(VARNAME_1, typeof(string)));

            // Type API with wrong type
            try
            {
                variables.getValue(VARNAME_1, typeof(Integer));
                fail("ClassCastException expected!");
            }
            catch (System.InvalidCastException ex)
            {
                assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.Message);
            }

            ///////////////////////////////////////////////////////////////////
            // Put a variable via VariableMap and get it via BusinessProcess //
            ///////////////////////////////////////////////////////////////////
            string anotherValue = "anotherValue";

            variables.put(VARNAME_2, Variables.stringValue(anotherValue));

            // Legacy API
            assertEquals(anotherValue, businessProcess.getVariableLocal(VARNAME_2));

            // Typed variable API
            TypedValue anotherTypedValue = businessProcess.getVariableLocalTyped(VARNAME_2);

            assertEquals(ValueType.STRING, anotherTypedValue.Type);
            assertEquals(anotherValue, anotherTypedValue.Value);
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.camunda.bpm.engine.impl.variable.serializer.TypedValueSerializer<?> getSerializer(org.camunda.bpm.engine.variable.value.TypedValue value)
        public virtual TypedValueSerializer <object> getSerializer(TypedValue value)
        {
            if (value is ObjectValue)
            {
                ObjectValue objectValue = (ObjectValue)value;
                if (objectValue.SerializationDataFormat != null && !objectValue.Deserialized)
                {
                    return(new FallbackSpinObjectValueSerializer(objectValue.SerializationDataFormat));
                }
            }
            return(null);
        }
예제 #6
0
        public virtual void testProcessVariableTypeAnnotation()
        {
            BusinessProcess businessProcess = getBeanInstance(typeof(BusinessProcess));

            VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda");

            businessProcess.startProcessByKey("keyOfTheProcess", variables);

            TypedValue value = getBeanInstance(typeof(DeclarativeProcessController)).InjectedValue;

            assertNotNull(value);
            assertTrue(value is StringValue);
            assertEquals(ValueType.STRING, value.Type);
            assertEquals("camunda", value.Value);
        }
예제 #7
0
        /* General test asserting that the business process bean is functional */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Deployment public void test() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void test()
        {
            BusinessProcess businessProcess = getBeanInstance(typeof(BusinessProcess));

            // start the process
            businessProcess.startProcessByKey("businessProcessBeanTest").Id;

            // ensure that the process is started:
            assertNotNull(processEngine.RuntimeService.createProcessInstanceQuery().singleResult());

            // ensure that there is a single task waiting
            Task task = processEngine.TaskService.createTaskQuery().singleResult();

            assertNotNull(task);

            string value = "value";

            businessProcess.setVariable("key", Variables.stringValue(value));
            assertEquals(value, businessProcess.getVariable("key"));

            // Typed variable API
            TypedValue typedValue = businessProcess.getVariableTyped("key");

            assertEquals(ValueType.STRING, typedValue.Type);
            assertEquals(value, typedValue.Value);

            // Local variables
            string localValue = "localValue";

            businessProcess.setVariableLocal("localKey", Variables.stringValue(localValue));
            assertEquals(localValue, businessProcess.getVariableLocal("localKey"));

            // Local typed variable API
            TypedValue typedLocalValue = businessProcess.getVariableLocalTyped("localKey");

            assertEquals(ValueType.STRING, typedLocalValue.Type);
            assertEquals(localValue, typedLocalValue.Value);

            // complete the task
            assertEquals(task.Id, businessProcess.startTask(task.Id).Id);
            businessProcess.completeTask();

            // assert the task is completed
            assertNull(processEngine.TaskService.createTaskQuery().singleResult());

            // assert that the process is ended:
            assertNull(processEngine.RuntimeService.createProcessInstanceQuery().singleResult());
        }
예제 #8
0
        public virtual bool matches(object argument)
        {
            if (argument == null || !argument.GetType().IsAssignableFrom(typeof(TypedValue)))
            {
                return(false);
            }

            TypedValue typedValue = (TypedValue)argument;

            if (type_Renamed != null && !type_Renamed.Equals(typedValue.Type))
            {
                return(false);
            }

            return(true);
        }
예제 #9
0
 public override TypedValue convertValue(TypedValue propertyValue)
 {
     if (propertyValue is StringValue)
     {
         return(propertyValue);
     }
     else
     {
         object value = propertyValue.Value;
         if (value == null)
         {
             return(Variables.stringValue(null, propertyValue.Transient));
         }
         else
         {
             return(Variables.stringValue(value.ToString(), propertyValue.Transient));
         }
     }
 }
예제 #10
0
 public virtual object mapDecisionResult(DmnDecisionResult decisionResult)
 {
     try
     {
         TypedValue typedValue = decisionResult.SingleEntryTyped;
         if (typedValue != null)
         {
             return(typedValue);
         }
         else
         {
             return(Variables.untypedNullValue());
         }
     }
     catch (DmnEngineException e)
     {
         throw LOG.decisionResultMappingException(decisionResult, this, e);
     }
 }
예제 #11
0
        public virtual void testStartProcessByKey()
        {
            assertNull(runtimeService.createProcessInstanceQuery().singleResult());

            getBeanInstance(typeof(DeclarativeProcessController)).startProcessByKey();
            BusinessProcess businessProcess = getBeanInstance(typeof(BusinessProcess));

            assertNotNull(runtimeService.createProcessInstanceQuery().singleResult());

            assertEquals("camunda", businessProcess.getVariable("name"));

            TypedValue nameTypedValue = businessProcess.getVariableTyped("name");

            assertNotNull(nameTypedValue);
            assertTrue(nameTypedValue is StringValue);
            assertEquals(ValueType.STRING, nameTypedValue.Type);
            assertEquals("camunda", nameTypedValue.Value);

            assertEquals("untypedName", businessProcess.getVariable("untypedName"));

            TypedValue untypedNameTypedValue = businessProcess.getVariableTyped("untypedName");

            assertNotNull(untypedNameTypedValue);
            assertTrue(untypedNameTypedValue is StringValue);
            assertEquals(ValueType.STRING, untypedNameTypedValue.Type);
            assertEquals("untypedName", untypedNameTypedValue.Value);


            assertEquals("typedName", businessProcess.getVariable("typedName"));

            TypedValue typedNameTypedValue = businessProcess.getVariableTyped("typedName");

            assertNotNull(typedNameTypedValue);
            assertTrue(typedNameTypedValue is StringValue);
            assertEquals(ValueType.STRING, typedNameTypedValue.Type);
            assertEquals("typedName", typedNameTypedValue.Value);

            businessProcess.startTask(taskService.createTaskQuery().singleResult().Id);
            businessProcess.completeTask();
        }
예제 #12
0
 public virtual MockVariableInstanceBuilder typedValue(TypedValue value)
 {
     this.typedValue_Renamed = value;
     return(this);
 }
예제 #13
0
 protected internal override bool canWriteValue(TypedValue value)
 {
     return(value.Value == null);
 }
예제 #14
0
 public virtual MockHistoricVariableUpdateBuilder typedValue(TypedValue value)
 {
     this.typedValue_Renamed = value;
     return(this);
 }
예제 #15
0
//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)
        {
            TypedValue typedValue = execution.getVariableTyped("varName", false);

            Assert.assertNotNull(typedValue);
        }
예제 #16
0
 public virtual VariableInstanceEntity build(string name, TypedValue value, bool isTransient)
 {
     return(VariableInstanceEntity.create(name, value, isTransient));
 }
예제 #17
0
 public virtual SimpleVariableInstance build(string name, TypedValue value, bool isTransient)
 {
     return(new SimpleVariableInstance(name, value));
 }
예제 #18
0
 public override TypedValue convertToModelValue(TypedValue propertyValue)
 {
     return(convertValue(propertyValue));
 }
예제 #19
0
 protected internal virtual bool isDeserializedObjectValue(TypedValue value)
 {
     return(value is ObjectValue && ((ObjectValue)value).Deserialized);
 }
예제 #20
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.camunda.bpm.engine.impl.variable.serializer.TypedValueSerializer<?> getSerializer(org.camunda.bpm.engine.variable.value.TypedValue value)
            public virtual TypedValueSerializer <object> getSerializer(TypedValue value)
            {
                return(new ExampleSerializer());
            }
예제 #21
0
 protected internal abstract TypedValue convertValue(TypedValue propertyValue);
예제 #22
0
 public SimpleVariableInstance(string name, TypedValue value)
 {
     this.name  = name;
     this.value = value;
 }