@Override public boolean canConvertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { return false; } return true; }
public String getTypeName() { if(value != null) { return value.getType().getName(); } else { return null; } }
public String getTypeName() { if(value != null) { return value.getType().getName(); } else { return null; } }
public Response getResponseForTypedVariable(TypedValue typedVariableValue, String id) { if (typedVariableValue instanceof BytesValue || ValueType.BYTES.equals(typedVariableValue.getType())) { return responseForByteVariable(typedVariableValue); } else if (ValueType.FILE.equals(typedVariableValue.getType())) { return responseForFileVariable((FileValue) typedVariableValue); } else { throw new InvalidRequestException(Response.Status.BAD_REQUEST, String.format("Value of variable with id %s is not a binary value.", id)); } }
public Response getResponseForTypedVariable(TypedValue typedVariableValue, String id) { if (typedVariableValue instanceof BytesValue || ValueType.BYTES.equals(typedVariableValue.getType())) { return responseForByteVariable(typedVariableValue); } else if (ValueType.FILE.equals(typedVariableValue.getType())) { return responseForFileVariable((FileValue) typedVariableValue); } else { throw new InvalidRequestException(Response.Status.BAD_REQUEST, String.format("Value of variable with id %s is not a binary value.", id)); } }
public void initialize(VariableSerializers serializers) { if (value.getType() != null && value.getType().isAbstract()) { valueCondition = new CompositeQueryVariableValueCondition(this); } else { valueCondition = new SingleQueryVariableValueCondition(this); } valueCondition.initializeValue(serializers); }
public void initialize(VariableSerializers serializers) { if (value.getType() != null && value.getType().isAbstract()) { valueCondition = new CompositeQueryVariableValueCondition(this); } else { valueCondition = new SingleQueryVariableValueCondition(this); } valueCondition.initializeValue(serializers); }
public boolean matches(Object argument) { if (argument == null || !TypedValue.class.isAssignableFrom(argument.getClass())) { return false; } TypedValue typedValue = (TypedValue) argument; if (type != null && !type.equals(typedValue.getType())) { return false; } return true; }
public TypedValue convertToFormValue(TypedValue modelValue) { if(modelValue.getValue() == null) { return Variables.stringValue(null, modelValue.isTransient()); } else if(modelValue.getType() == ValueType.DATE) { return Variables.stringValue(dateFormat.format(modelValue.getValue()), modelValue.isTransient()); } else { throw new ProcessEngineException("Expected value to be of type '"+ValueType.DATE+"' but got '"+modelValue.getType()+"'."); } }
public TypedValue convertToFormValue(TypedValue modelValue) { if(modelValue.getValue() == null) { return Variables.stringValue(null, modelValue.isTransient()); } else if(modelValue.getType() == ValueType.DATE) { return Variables.stringValue(dateFormat.format(modelValue.getValue()), modelValue.isTransient()); } else { throw new ProcessEngineException("Expected value to be of type '"+ValueType.DATE+"' but got '"+modelValue.getType()+"'."); } }
public static void assertUntypedNullValue(TypedValue nullValue) { assertNotNull(nullValue); assertNull(nullValue.getValue()); assertEquals(ValueType.NULL, nullValue.getType()); }
@Test public void testGetVariables() { when(taskServiceMock.getVariablesTyped(EXAMPLE_TASK_ID, true)).thenReturn(EXAMPLE_VARIABLES); Response response = given().pathParam("id", EXAMPLE_TASK_ID) .header("accept", MediaType.APPLICATION_JSON) .then().expect().statusCode(Status.OK.getStatusCode()) .body(EXAMPLE_VARIABLE_KEY, notNullValue()) .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue())) .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(EXAMPLE_VARIABLE_VALUE.getType()))) .when().get(SINGLE_TASK_VARIABLES_URL); Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size()); }
@Test public void testGetLocalVariables() { when(taskServiceMock.getVariablesLocalTyped(EXAMPLE_TASK_ID, true)).thenReturn(EXAMPLE_VARIABLES); Response response = given().pathParam("id", EXAMPLE_TASK_ID) .header("accept", MediaType.APPLICATION_JSON) .then().expect().statusCode(Status.OK.getStatusCode()) .body(EXAMPLE_VARIABLE_KEY, notNullValue()) .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue())) .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(EXAMPLE_VARIABLE_VALUE.getType()))) .when().get(SINGLE_TASK_VARIABLES_URL); Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size()); }
@Test public void shouldGetTypedVariable() { ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY); runtimeService.setVariable(instance.getId(), VARIABLE_NAME, typedValue); TypedValue typedVariableValue = runtimeService.getVariableTyped(instance.getId(), VARIABLE_NAME); assertEquals(typedValue.getType(), typedVariableValue.getType()); assertEquals(typedValue.getValue(), typedVariableValue.getValue()); }
@Test public void shouldGetTypedNullVariable() { ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY); runtimeService.setVariable(instance.getId(), VARIABLE_NAME, nullValue); assertEquals(null, runtimeService.getVariable(instance.getId(), VARIABLE_NAME)); TypedValue typedVariableValue = runtimeService.getVariableTyped(instance.getId(), VARIABLE_NAME); assertEquals(nullValue.getType(), typedVariableValue.getType()); assertEquals(null, typedVariableValue.getValue()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/form/FormServiceTest.startFormFieldsUnknownType.bpmn20.xml"}) @Test public void testGetStartFormVariablesEnumType() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); VariableMap startFormVariables = formService.getStartFormVariables(processDefinition.getId()); assertEquals("a", startFormVariables.get("enumField")); assertEquals(ValueType.STRING, startFormVariables.getValueTyped("enumField").getType()); }