Package org.camunda.bpm.engine.variable

Examples of org.camunda.bpm.engine.variable.VariableMap


          .putValue("broken", Variables.serializedObjectValue("broken")
              .serializationDataFormat(JavaObjectSerializer.SERIALIZATION_DATA_FORMAT)
              .objectTypeName("unexisting").create()));

    // this works
    VariableMap variablesTyped = taskService.getVariablesLocalTyped(taskId, false);
    assertNotNull(variablesTyped.getValueTyped("broken"));
    variablesTyped = taskService.getVariablesLocalTyped(taskId, Arrays.asList("broken"), false);
    assertNotNull(variablesTyped.getValueTyped("broken"));

    // this does not
    try {
      taskService.getVariablesLocalTyped(taskId);
    } catch(ProcessEngineException e) {
View Full Code Here


  private static final String SERIALIZATION_DATA_FORMAT_NAME = "data-format-name";

  @Test
  public void testCreatePrimitiveVariablesUntyped() {

    VariableMap variables = createVariables()
      .putValue(STRING_VAR_NAME, STRING_VAR_VALUE)
      .putValue(INTEGER_VAR_NAME, INTEGER_VAR_VALUE)
      .putValue(BOOLEAN_VAR_NAME, BOOLEAN_VAR_VALUE)
      .putValue(NULL_VAR_NAME, null)
      .putValue(SHORT_VAR_NAME, SHORT_VAR_VALUE)
      .putValue(DOUBLE_VAR_NAME, DOUBLE_VAR_VALUE)
      .putValue(DATE_VAR_NAME, DATE_VAR_VALUE)
      .putValue(BYTES_VAR_NAME, BYTES_VAR_VALUE);

    assertEquals(STRING_VAR_VALUE, variables.get(STRING_VAR_NAME));
    assertEquals(INTEGER_VAR_VALUE, variables.get(INTEGER_VAR_NAME));
    assertEquals(BOOLEAN_VAR_VALUE, variables.get(BOOLEAN_VAR_NAME));
    assertEquals(null, variables.get(NULL_VAR_NAME));
    assertEquals(SHORT_VAR_VALUE, variables.get(SHORT_VAR_NAME));
    assertEquals(DOUBLE_VAR_VALUE, variables.get(DOUBLE_VAR_NAME));
    assertEquals(DATE_VAR_VALUE, variables.get(DATE_VAR_NAME));
    assertEquals(BYTES_VAR_VALUE, variables.get(BYTES_VAR_NAME));

    assertEquals(STRING_VAR_VALUE, variables.getValueTyped(STRING_VAR_NAME).getValue());
    assertEquals(INTEGER_VAR_VALUE, variables.getValueTyped(INTEGER_VAR_NAME).getValue());
    assertEquals(BOOLEAN_VAR_VALUE, variables.getValueTyped(BOOLEAN_VAR_NAME).getValue());
    assertEquals(null, variables.getValueTyped(NULL_VAR_NAME).getValue());
    assertEquals(SHORT_VAR_VALUE, variables.getValueTyped(SHORT_VAR_NAME).getValue());
    assertEquals(DOUBLE_VAR_VALUE, variables.getValueTyped(DOUBLE_VAR_NAME).getValue());
    assertEquals(DATE_VAR_VALUE, variables.getValueTyped(DATE_VAR_NAME).getValue());
    assertEquals(BYTES_VAR_VALUE, variables.getValueTyped(BYTES_VAR_NAME).getValue());

    // type for untyped null is untyped null
    TypedValue untypedNullVariable = variables.getValueTyped(NULL_VAR_NAME);
    assertNotNull(untypedNullVariable);
    assertEquals(NULL, untypedNullVariable.getType());
    variables.remove(NULL_VAR_NAME);

    // no type information present
    for (String varName : variables.keySet()) {
      TypedValue typedValue = variables.getValueTyped(varName);
      assertNull(typedValue.getType());
      assertEquals(variables.get(varName), typedValue.getValue());
    }

  }
View Full Code Here

  }

  @Test
  public void testCreatePrimitiveVariablesTyped() {

    VariableMap variables = createVariables()
        .putValue(STRING_VAR_NAME, stringValue(STRING_VAR_VALUE))
        .putValue(INTEGER_VAR_NAME, integerValue(INTEGER_VAR_VALUE))
        .putValue(BOOLEAN_VAR_NAME, booleanValue(BOOLEAN_VAR_VALUE))
        .putValue(NULL_VAR_NAME, untypedNullValue())
        .putValue(SHORT_VAR_NAME, shortValue(SHORT_VAR_VALUE))
        .putValue(DOUBLE_VAR_NAME, doubleValue(DOUBLE_VAR_VALUE))
        .putValue(DATE_VAR_NAME, dateValue(DATE_VAR_VALUE))
        .putValue(BYTES_VAR_NAME, byteArrayValue(BYTES_VAR_VALUE));

    // get returns values

    assertEquals(STRING_VAR_VALUE, variables.get(STRING_VAR_NAME));
    assertEquals(INTEGER_VAR_VALUE, variables.get(INTEGER_VAR_NAME));
    assertEquals(BOOLEAN_VAR_VALUE, variables.get(BOOLEAN_VAR_NAME));
    assertEquals(null, variables.get(NULL_VAR_NAME));
    assertEquals(SHORT_VAR_VALUE, variables.get(SHORT_VAR_NAME));
    assertEquals(DOUBLE_VAR_VALUE, variables.get(DOUBLE_VAR_NAME));
    assertEquals(DATE_VAR_VALUE, variables.get(DATE_VAR_NAME));
    assertEquals(BYTES_VAR_VALUE, variables.get(BYTES_VAR_NAME));

    // types are not lost

    assertEquals(STRING, variables.getValueTyped(STRING_VAR_NAME).getType());
    assertEquals(INTEGER, variables.getValueTyped(INTEGER_VAR_NAME).getType());
    assertEquals(BOOLEAN, variables.getValueTyped(BOOLEAN_VAR_NAME).getType());
    assertEquals(NULL, variables.getValueTyped(NULL_VAR_NAME).getType());
    assertEquals(SHORT, variables.getValueTyped(SHORT_VAR_NAME).getType());
    assertEquals(DOUBLE, variables.getValueTyped(DOUBLE_VAR_NAME).getType());
    assertEquals(DATE, variables.getValueTyped(DATE_VAR_NAME).getType());
    assertEquals(BYTES, variables.getValueTyped(BYTES_VAR_NAME).getType());

    // get wrappers

    String stringValue = variables.<StringValue>getValueTyped(STRING_VAR_NAME).getValue();
    assertEquals(STRING_VAR_VALUE, stringValue);
    Integer integerValue = variables.<IntegerValue>getValueTyped(INTEGER_VAR_NAME).getValue();
    assertEquals(INTEGER_VAR_VALUE, integerValue);
    Boolean booleanValue = variables.<BooleanValue>getValueTyped(BOOLEAN_VAR_NAME).getValue();
    assertEquals(BOOLEAN_VAR_VALUE, booleanValue);
    Short shortValue = variables.<ShortValue>getValueTyped(SHORT_VAR_NAME).getValue();
    assertEquals(SHORT_VAR_VALUE, shortValue);
    Double doubleValue = variables.<DoubleValue>getValueTyped(DOUBLE_VAR_NAME).getValue();
    assertEquals(DOUBLE_VAR_VALUE, doubleValue);
    Date dateValue = variables.<DateValue>getValueTyped(DATE_VAR_NAME).getValue();
    assertEquals(DATE_VAR_VALUE, dateValue);
    byte[] bytesValue = variables.<BytesValue>getValueTyped(BYTES_VAR_NAME).getValue();
    assertEquals(BYTES_VAR_VALUE, bytesValue);

  }
View Full Code Here

  }

  @Test
  public void testCreatePrimitiveVariablesNull() {

    VariableMap variables = createVariables()
      .putValue(STRING_VAR_NAME, stringValue(null))
      .putValue(INTEGER_VAR_NAME, integerValue(null))
      .putValue(BOOLEAN_VAR_NAME, booleanValue(null))
      .putValue(NULL_VAR_NAME, untypedNullValue())
      .putValue(SHORT_VAR_NAME, shortValue(null))
      .putValue(DOUBLE_VAR_NAME, doubleValue(null))
      .putValue(DATE_VAR_NAME, dateValue(null))
      .putValue(BYTES_VAR_NAME, byteArrayValue(null));

    // get returns values

    assertEquals(null, variables.get(STRING_VAR_NAME));
    assertEquals(null, variables.get(INTEGER_VAR_NAME));
    assertEquals(null, variables.get(BOOLEAN_VAR_NAME));
    assertEquals(null, variables.get(NULL_VAR_NAME));
    assertEquals(null, variables.get(SHORT_VAR_NAME));
    assertEquals(null, variables.get(DOUBLE_VAR_NAME));
    assertEquals(null, variables.get(DATE_VAR_NAME));
    assertEquals(null, variables.get(BYTES_VAR_NAME));

    // types are not lost

    assertEquals(STRING, variables.getValueTyped(STRING_VAR_NAME).getType());
    assertEquals(INTEGER, variables.getValueTyped(INTEGER_VAR_NAME).getType());
    assertEquals(BOOLEAN, variables.getValueTyped(BOOLEAN_VAR_NAME).getType());
    assertEquals(NULL, variables.getValueTyped(NULL_VAR_NAME).getType());
    assertEquals(SHORT, variables.getValueTyped(SHORT_VAR_NAME).getType());
    assertEquals(DOUBLE, variables.getValueTyped(DOUBLE_VAR_NAME).getType());
    assertEquals(DATE, variables.getValueTyped(DATE_VAR_NAME).getType());
    assertEquals(BYTES, variables.getValueTyped(BYTES_VAR_NAME).getType());

    // get wrappers

    String stringValue = variables.<StringValue>getValueTyped(STRING_VAR_NAME).getValue();
    assertEquals(null, stringValue);
    Integer integerValue = variables.<IntegerValue>getValueTyped(INTEGER_VAR_NAME).getValue();
    assertEquals(null, integerValue);
    Boolean booleanValue = variables.<BooleanValue>getValueTyped(BOOLEAN_VAR_NAME).getValue();
    assertEquals(null, booleanValue);
    Short shortValue = variables.<ShortValue>getValueTyped(SHORT_VAR_NAME).getValue();
    assertEquals(null, shortValue);
    Double doubleValue = variables.<DoubleValue>getValueTyped(DOUBLE_VAR_NAME).getValue();
    assertEquals(null, doubleValue);
    Date dateValue = variables.<DateValue>getValueTyped(DATE_VAR_NAME).getValue();
    assertEquals(null, dateValue);
    byte[] bytesValue = variables.<BytesValue>getValueTyped(BYTES_VAR_NAME).getValue();
    assertEquals(null, bytesValue);

  }
View Full Code Here

  }

  @Test
  public void testCreateObjectVariables() {

    VariableMap variables = createVariables()
      .putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE));

    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.get(DESERIALIZED_OBJECT_VAR_NAME));
    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.getValue(DESERIALIZED_OBJECT_VAR_NAME, ExampleObject.class));

    Object untypedValue = variables.getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getValue();
    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, untypedValue);

    ExampleObject typedValue = variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getValue(ExampleObject.class);
    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, typedValue);

    // object type name is not yet available
    assertNull(variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getObjectTypeName());
    // class is available
    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE.getClass(), variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getObjectType());


    variables = createVariables()
        .putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE).serializationDataFormat(SERIALIZATION_DATA_FORMAT_NAME));

    assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.get(DESERIALIZED_OBJECT_VAR_NAME));


  }
View Full Code Here

  @Test
  public void testVariableMapCompatibility() {

    // test compatibility with Map<String, Object>
    VariableMap map1 = createVariables()
        .putValue("foo", 10)
        .putValue("bar", 20);

    // assert the map is assignable to Map<String,Object>
    @SuppressWarnings("unused")
    Map<String, Object> assignable = map1;

    VariableMap map2 = createVariables()
        .putValueTyped("foo", integerValue(10))
        .putValueTyped("bar", integerValue(20));

    Map<String, Object> map3 = new HashMap<String, Object>();
    map3.put("foo", 10);
    map3.put("bar", 20);

    // equals()
    assertEquals(map1, map2);
    assertEquals(map2, map3);
    assertEquals(map1, Variables.fromMap(map1));
    assertEquals(map1, Variables.fromMap(map3));

    // hashCode()
    assertEquals(map1.hashCode(), map2.hashCode());
    assertEquals(map2.hashCode(), map3.hashCode());

    // values()
    Collection<Object> values1 = map1.values();
    Collection<Object> values2 = map2.values();
    Collection<Object> values3 = map3.values();
    assertTrue(values1.containsAll(values2));
    assertTrue(values2.containsAll(values1));
    assertTrue(values2.containsAll(values3));
    assertTrue(values3.containsAll(values2));

    // entry set
    assertEquals(map1.entrySet(), map2.entrySet());
    assertEquals(map2.entrySet(), map3.entrySet());
  }
View Full Code Here

      formFields.add(formFieldHandler.createFormField(execution));
    }
  }

  public void submitFormVariables(VariableMap properties, VariableScope variableScope) {
    VariableMap propertiesCopy = new VariableMapImpl(properties);

    // support legacy form properties
    for (FormPropertyHandler formPropertyHandler: formPropertyHandlers) {
      // submitFormProperty will remove all the keys which it takes care of
      formPropertyHandler.submitFormProperty(variableScope, propertiesCopy);
    }

    // support form data:
    for (FormFieldHandler formFieldHandler : formFieldHandlers) {
      formFieldHandler.handleSubmit(variableScope, propertiesCopy, properties);
    }

    // any variables passed in which are not handled by form-fields or form
    // properties are added to the process as variables
    for (String propertyId: propertiesCopy.keySet()) {
      variableScope.setVariable(propertyId, propertiesCopy.getValueTyped(propertyId));
    }

    fireFormPropertyHistoryEvents(properties, variableScope);
  }
View Full Code Here

    assertEquals(VAR_VALUE_STRING, variables.get(VAR_NAME));
  }

  @Test
  public void testGetVariablesTyped() {
    VariableMap variables = variableScope.getVariablesTyped();
    assertNotNull(variables);
    assertEquals(VAR_VALUE_STRING, variables.get(VAR_NAME));
    assertEquals(variables, variableScope.getVariablesTyped(true));
  }
View Full Code Here

        .createCaseExecutionQuery()
        .activityId("PI_HumanTask_1")
        .singleResult()
        .getId();

    VariableMap variables = createVariables()
        .putValueTyped("aVariableName", stringValue("abc"))
        .putValueTyped("anotherVariableName", integerValue(null));

    // when
    caseService
View Full Code Here

        .createCaseExecutionQuery()
        .activityId("PI_HumanTask_1")
        .singleResult()
        .getId();

    VariableMap variables = createVariables()
        .putValueTyped("aVariableName", stringValue("abc"))
        .putValueTyped("anotherVariableName", integerValue(null));

    // when
    caseService
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.variable.VariableMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.