org.camunda.bpm.engine.variable.type.ValueType Java Examples
The following examples show how to use
org.camunda.bpm.engine.variable.type.ValueType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public LongValue convertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { throw unsupportedConversion(typedValue.getType()); } LongValueImpl longvalue = null; NumberValue numberValue = (NumberValue) typedValue; if (numberValue.getValue() != null) { longvalue = (LongValueImpl) Variables.longValue(numberValue.getValue().longValue()); } else { longvalue = (LongValueImpl) Variables.longValue(null); } longvalue.setTransient(numberValue.isTransient()); return longvalue; }
Example #2
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public boolean canConvertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { return false; } if (typedValue.getValue() != null) { NumberValue numberValue = (NumberValue) typedValue; double doubleValue = numberValue.getValue().doubleValue(); // returns false if the value changes due to conversion (e.g. by overflows // or by loss in precision) if (numberValue.getValue().shortValue() != doubleValue) { return false; } } return true; }
Example #3
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public IntegerValue convertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { throw unsupportedConversion(typedValue.getType()); } IntegerValueImpl integerValue = null; NumberValue numberValue = (NumberValue) typedValue; if (numberValue.getValue() != null) { integerValue = (IntegerValueImpl) Variables.integerValue(numberValue.getValue().intValue()); } else { integerValue = (IntegerValueImpl) Variables.integerValue(null); } integerValue.setTransient(numberValue.isTransient()); return integerValue; }
Example #4
Source File: ExecutionRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testPutSingleLocalVariableFromSerializedWithNoValue() { String variableKey = "aVariableKey"; Map<String, Object> requestJson = VariablesBuilder .getObjectValueMap(null, ValueType.OBJECT.getName(), null, null); given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).pathParam("varId", variableKey) .contentType(ContentType.JSON).body(requestJson) .then().expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().put(SINGLE_EXECUTION_LOCAL_VARIABLE_URL); verify(runtimeServiceMock).setVariableLocal(eq(MockProvider.EXAMPLE_EXECUTION_ID), eq(variableKey), argThat(EqualsObjectValue .objectValueMatcher() .serializationFormat(null) .objectTypeName(null) .serializedValue(null))); }
Example #5
Source File: TaskVariableRestResourceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testPutSingleVariableFromSerialized() throws Exception { String serializedValue = "{\"prop\" : \"value\"}"; Map<String, Object> requestJson = VariablesBuilder .getObjectValueMap(serializedValue, ValueType.OBJECT.getName(), "aDataFormat", "aRootType"); String variableKey = "aVariableKey"; given() .pathParam("id", MockProvider.EXAMPLE_TASK_ID).pathParam("varId", variableKey) .contentType(ContentType.JSON) .body(requestJson) .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL); verify(taskServiceMock).setVariable( eq(MockProvider.EXAMPLE_TASK_ID), eq(variableKey), argThat(EqualsObjectValue.objectValueMatcher() .serializedValue(serializedValue) .serializationFormat("aDataFormat") .objectTypeName("aRootType"))); }
Example #6
Source File: CaseInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testJavaObjectVariableSerialization() { when(caseServiceMock.getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true)).thenReturn(EXAMPLE_OBJECT_VARIABLES); Response response = given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID) .then().expect().statusCode(Status.OK.getStatusCode()) .body(EXAMPLE_VARIABLE_KEY, notNullValue()) .body(EXAMPLE_VARIABLE_KEY + ".value.property1", equalTo("aPropertyValue")) .body(EXAMPLE_VARIABLE_KEY + ".value.property2", equalTo(true)) .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT))) .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ExampleVariableObject.class.getName())) .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json")) .when().get(CASE_INSTANCE_VARIABLES_URL); Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size()); verify(caseServiceMock).getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true); }
Example #7
Source File: HistoricVariableJsonSerializationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = ONE_TASK_PROCESS) public void testSelectHistoricVariableInstances() throws JSONException { if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) { ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); JsonSerializable bean = new JsonSerializable("a String", 42, false); runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(bean).serializationDataFormat(JSON_FORMAT_NAME).create()); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().singleResult(); assertNotNull(historicVariable.getValue()); assertNull(historicVariable.getErrorMessage()); assertEquals(ValueType.OBJECT.getName(), historicVariable.getTypeName()); assertEquals(ValueType.OBJECT.getName(), historicVariable.getVariableTypeName()); JsonSerializable historyValue = (JsonSerializable) historicVariable.getValue(); assertEquals(bean.getStringProperty(), historyValue.getStringProperty()); assertEquals(bean.getIntProperty(), historyValue.getIntProperty()); assertEquals(bean.getBooleanProperty(), historyValue.getBooleanProperty()); } }
Example #8
Source File: TaskVariableRestResourceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testPutSingleVariableFromSerializedWithNoValue() { String variableKey = "aVariableKey"; Map<String, Object> requestJson = VariablesBuilder .getObjectValueMap(null, ValueType.OBJECT.getName(), null, null); given().pathParam("id", MockProvider.EXAMPLE_TASK_ID).pathParam("varId", variableKey) .contentType(ContentType.JSON).body(requestJson) .then().expect().statusCode(Status.NO_CONTENT.getStatusCode()) .when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL); verify(taskServiceMock).setVariable( eq(MockProvider.EXAMPLE_TASK_ID), eq(variableKey), argThat(EqualsObjectValue.objectValueMatcher())); }
Example #9
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public boolean canConvertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { return false; } if (typedValue.getValue() != null) { NumberValue numberValue = (NumberValue) typedValue; double doubleValue = numberValue.getValue().doubleValue(); // returns false if the value changes due to conversion (e.g. by overflows // or by loss in precision) if (numberValue.getValue().intValue() != doubleValue) { return false; } } return true; }
Example #10
Source File: HistoricVariableInstanceRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testSpinVariableInstanceRetrieval() { MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance() .typedValue(Variables .serializedObjectValue("aSpinSerializedValue") .serializationDataFormat("aDataFormat") .objectTypeName("aRootType") .create()); List<HistoricVariableInstance> mockInstances = new ArrayList<HistoricVariableInstance>(); mockInstances.add(builder.build()); mockedQuery = setUpMockHistoricVariableInstanceQuery(mockInstances); given() .then().expect().statusCode(Status.OK.getStatusCode()) .and() .body("size()", is(1)) .body("[0].type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT))) .body("[0].value", equalTo("aSpinSerializedValue")) .body("[0].valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo("aRootType")) .body("[0].valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("aDataFormat")) .when().get(HISTORIC_VARIABLE_INSTANCE_RESOURCE_URL); }
Example #11
Source File: ProcessEngineConfigurationImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void initJpa() { if (jpaPersistenceUnitName != null) { jpaEntityManagerFactory = JpaHelper.createEntityManagerFactory(jpaPersistenceUnitName); } if (jpaEntityManagerFactory != null) { sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(jpaEntityManagerFactory, jpaHandleTransaction, jpaCloseEntityManager)); JPAVariableSerializer jpaType = (JPAVariableSerializer) variableSerializers.getSerializerByName(JPAVariableSerializer.NAME); // Add JPA-type if (jpaType == null) { // We try adding the variable right after byte serializer, if available int serializableIndex = variableSerializers.getSerializerIndexByName(ValueType.BYTES.getName()); if (serializableIndex > -1) { variableSerializers.addSerializer(new JPAVariableSerializer(), serializableIndex); } else { variableSerializers.addSerializer(new JPAVariableSerializer()); } } } }
Example #12
Source File: SingleQueryVariableValueCondition.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected TypedValueSerializer determineSerializer(VariableSerializers serializers, TypedValue value) { TypedValueSerializer serializer = serializers.findSerializerForValue(value); if(serializer.getType() == ValueType.BYTES){ throw new ProcessEngineException("Variables of type ByteArray cannot be used to query"); } else if(serializer.getType() == ValueType.FILE){ throw new ProcessEngineException("Variables of type File cannot be used to query"); } else if(serializer instanceof JPAVariableSerializer) { if(wrappedQueryValue.getOperator() != QueryOperator.EQUALS) { throw new ProcessEngineException("JPA entity variables can only be used in 'variableValueEquals'"); } } else { if(!serializer.getType().isPrimitiveValueType()) { throw new ProcessEngineException("Object values cannot be used to query"); } } return serializer; }
Example #13
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml") public void testQueryResultOrderingByStringVariableWithMixedCase() { // given three tasks with String and Integer process instance variables ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "a")); ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "B")); ProcessInstance instance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "c")); // when I make a task query with variable ordering by String values List<Task> tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.STRING) .asc() .list(); // then the tasks are ordered correctly assertEquals(3, tasks.size()); // first the numeric valued task (since it is treated like null-valued) assertEquals(instance1.getId(), tasks.get(0).getProcessInstanceId()); // then the others in alphabetical order assertEquals(instance2.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance3.getId(), tasks.get(2).getProcessInstanceId()); }
Example #14
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn") public void testQueryResultOrderingByCaseInstanceVariables() { // given three tasks with String case instance variables CaseInstance instance1 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "cValue")); CaseInstance instance2 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "aValue")); CaseInstance instance3 = caseService.createCaseInstanceByKey("oneTaskCase", Collections.<String, Object>singletonMap("var", "bValue")); // when I make a task query with ascending variable ordering by tasks variables List<Task> tasks = taskService.createTaskQuery() .caseDefinitionKey("oneTaskCase") .orderByCaseInstanceVariable("var", ValueType.STRING) .asc() .list(); // then the tasks are ordered correctly by their local variables assertEquals(3, tasks.size()); assertEquals(instance2.getId(), tasks.get(0).getCaseInstanceId()); assertEquals(instance3.getId(), tasks.get(1).getCaseInstanceId()); assertEquals(instance1.getId(), tasks.get(2).getCaseInstanceId()); }
Example #15
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public ShortValue convertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { throw unsupportedConversion(typedValue.getType()); } ShortValueImpl shortValue = null; NumberValue numberValue = (NumberValue) typedValue; if (numberValue.getValue() != null) { shortValue = (ShortValueImpl) Variables.shortValue(numberValue.getValue().shortValue()); } else { shortValue = (ShortValueImpl) Variables.shortValue(null); } shortValue.setTransient(numberValue.isTransient()); return shortValue; }
Example #16
Source File: AssertVariableInstancesDelegate.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void execute(DelegateExecution execution) throws Exception { // validate integer variable Integer expectedIntValue = 1234; assertEquals(expectedIntValue, execution.getVariable("anIntegerVariable")); assertEquals(expectedIntValue, execution.getVariableTyped("anIntegerVariable").getValue()); assertEquals(ValueType.INTEGER, execution.getVariableTyped("anIntegerVariable").getType()); assertNull(execution.getVariableLocal("anIntegerVariable")); assertNull(execution.getVariableLocalTyped("anIntegerVariable")); // set an additional local variable execution.setVariableLocal("aStringVariable", "aStringValue"); String expectedStringValue = "aStringValue"; assertEquals(expectedStringValue, execution.getVariable("aStringVariable")); assertEquals(expectedStringValue, execution.getVariableTyped("aStringVariable").getValue()); assertEquals(ValueType.STRING, execution.getVariableTyped("aStringVariable").getType()); assertEquals(expectedStringValue, execution.getVariableLocal("aStringVariable")); assertEquals(expectedStringValue, execution.getVariableLocalTyped("aStringVariable").getValue()); assertEquals(ValueType.STRING, execution.getVariableLocalTyped("aStringVariable").getType()); SimpleSerializableBean objectValue = (SimpleSerializableBean) execution.getVariable("anObjectValue"); assertNotNull(objectValue); assertEquals(10, objectValue.getIntProperty()); ObjectValue variableTyped = execution.getVariableTyped("anObjectValue"); assertEquals(10, variableTyped.getValue(SimpleSerializableBean.class).getIntProperty()); assertEquals(Variables.SerializationDataFormats.JAVA.getName(), variableTyped.getSerializationDataFormat()); objectValue = (SimpleSerializableBean) execution.getVariable("anUntypedObjectValue"); assertNotNull(objectValue); assertEquals(30, objectValue.getIntProperty()); variableTyped = execution.getVariableTyped("anUntypedObjectValue"); assertEquals(30, variableTyped.getValue(SimpleSerializableBean.class).getIntProperty()); assertEquals(Context.getProcessEngineConfiguration().getDefaultSerializationFormat(), variableTyped.getSerializationDataFormat()); }
Example #17
Source File: ProcessInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testJavaObjectVariableSerialization() { Response response = given().pathParam("id", MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID) .then().expect().statusCode(Status.OK.getStatusCode()) .body(EXAMPLE_VARIABLE_KEY, notNullValue()) .body(EXAMPLE_VARIABLE_KEY + ".value.property1", equalTo("aPropertyValue")) .body(EXAMPLE_VARIABLE_KEY + ".value.property2", equalTo(true)) .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT))) .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ExampleVariableObject.class.getName())) .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json")) .when().get(PROCESS_INSTANCE_VARIABLES_URL); Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size()); }
Example #18
Source File: VariableTypeHelper.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * The REST API is expected to return the variable's value type name in capitalized form. */ public static String toExpectedValueTypeName(ValueType type) { String typeName = type.getName(); String expectedName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1); return expectedName; }
Example #19
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml") public void testQueryResultOrderingByVariablesWithSecondaryOrderingByProcessInstanceId() { // given three tasks with String process instance variables ProcessInstance bInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "b")); ProcessInstance bInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "b")); ProcessInstance cInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "c")); ProcessInstance cInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "c")); ProcessInstance aInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "a")); ProcessInstance aInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", "a")); // when I make a task query with variable ordering by String values List<Task> tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.STRING) .asc() .orderByProcessInstanceId() .asc() .list(); // then the tasks are ordered correctly assertEquals(6, tasks.size()); // var = a verifyTasksSortedByProcessInstanceId(Arrays.asList(aInstance1, aInstance2), tasks.subList(0, 2)); // var = b verifyTasksSortedByProcessInstanceId(Arrays.asList(bInstance1, bInstance2), tasks.subList(2, 4)); // var = c verifyTasksSortedByProcessInstanceId(Arrays.asList(cInstance1, cInstance2), tasks.subList(4, 6)); }
Example #20
Source File: TaskQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public TaskQuery orderByCaseInstanceVariable(String variableName, ValueType valueType) { if (isOrQueryActive) { throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseInstanceVariable() within 'or' query"); } ensureNotNull("variableName", variableName); ensureNotNull("valueType", valueType); orderBy(VariableOrderProperty.forCaseInstanceVariable(variableName, valueType)); return this; }
Example #21
Source File: TaskRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testHandleBpmnErrorWithVariables() { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("errorCode", "anErrorCode"); Map<String, Object> variables = VariablesBuilder .create() .variable("var1", "val1") .variable("var2", "val2", "String") .variable("var3", ValueType.OBJECT.getName(), "val3", "aFormat", "aRootType") .getVariables(); parameters.put("variables", variables); given() .contentType(POST_JSON_CONTENT_TYPE) .body(parameters) .pathParam("id", "aTaskId") .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(HANDLE_BPMN_ERROR_URL); verify(taskServiceMock).handleBpmnError( eq("aTaskId"), eq("anErrorCode"), isNull(String.class), argThat(EqualsVariableMap.matches() .matcher("var1", EqualsUntypedValue.matcher().value("val1")) .matcher("var2", EqualsPrimitiveValue.stringValue("val2")) .matcher("var3", EqualsObjectValue.objectValueMatcher() .type(ValueType.OBJECT) .serializedValue("val3") .serializationFormat("aFormat") .objectTypeName("aRootType")))); verifyNoMoreInteractions(taskServiceMock); }
Example #22
Source File: DelegateCaseVariableInstanceFakeTest.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Test public void variable_delete() { fake.delete("foo", stringValue("bar")); assertThat(fake.getName()).isEqualTo("foo"); assertThat(fake.getTypedValue().getValue()).isEqualTo("bar"); assertThat(fake.getTypeName()).isEqualTo("string"); assertThat(fake.getTypedValue().getType()).isEqualTo(ValueType.STRING); assertThat(fake.getEventName()).isEqualTo(CaseVariableListener.DELETE); }
Example #23
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml") public void testQueryResultOrderingByVariablesWithNullValues() { // given three tasks with String process instance variables ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "bValue")); ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "cValue")); ProcessInstance instance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "aValue")); ProcessInstance instance4 = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // when I make a task query with variable ordering by String values List<Task> tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.STRING) .asc() .list(); Task firstTask = tasks.get(0); // the null-valued task should be either first or last if (firstTask.getProcessInstanceId().equals(instance4.getId())) { // then the others in ascending order assertEquals(instance3.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance1.getId(), tasks.get(2).getProcessInstanceId()); assertEquals(instance2.getId(), tasks.get(3).getProcessInstanceId()); } else { assertEquals(instance3.getId(), tasks.get(0).getProcessInstanceId()); assertEquals(instance1.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance2.getId(), tasks.get(2).getProcessInstanceId()); assertEquals(instance4.getId(), tasks.get(3).getProcessInstanceId()); } }
Example #24
Source File: SpinValueImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public SpinValueImpl( Spin<?> value, String serializedValue, String dataFormatName, boolean isDeserialized, ValueType type, boolean isTransient) { super(value, type); this.serializedValue = serializedValue; this.dataFormatName = dataFormatName; this.isDeserialized = isDeserialized; this.isTransient = isTransient; }
Example #25
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml") public void testQueryResultOrderingByVariablesWithMixedTypes() { // given three tasks with String and Integer process instance variables ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", 42)); ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "cValue")); ProcessInstance instance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "aValue")); // when I make a task query with variable ordering by String values List<Task> tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.STRING) .asc() .list(); Task firstTask = tasks.get(0); // the numeric-valued task should be either first or last if (firstTask.getProcessInstanceId().equals(instance1.getId())) { // then the others in ascending order assertEquals(instance3.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance2.getId(), tasks.get(2).getProcessInstanceId()); } else { assertEquals(instance3.getId(), tasks.get(0).getProcessInstanceId()); assertEquals(instance2.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance1.getId(), tasks.get(2).getProcessInstanceId()); } }
Example #26
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public DoubleValue convertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { throw unsupportedConversion(typedValue.getType()); } DoubleValueImpl doubleValue = null; NumberValue numberValue = (NumberValue) typedValue; if (numberValue.getValue() != null) { doubleValue = (DoubleValueImpl) Variables.doubleValue(numberValue.getValue().doubleValue()); } else { doubleValue = (DoubleValueImpl) Variables.doubleValue(null); } doubleValue.setTransient(numberValue.isTransient()); return doubleValue; }
Example #27
Source File: FilterRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testGetFilterWithVariableTypeSorting() { TaskQuery query = new TaskQueryImpl() .orderByExecutionVariable("foo", ValueType.STRING).asc() .orderByProcessVariable("foo", ValueType.STRING).asc() .orderByTaskVariable("foo", ValueType.STRING).asc() .orderByCaseExecutionVariable("foo", ValueType.STRING).asc() .orderByCaseInstanceVariable("foo", ValueType.STRING).asc(); Filter filter = new FilterEntity("Task").setName("test").setQuery(query); when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter); Response response = given() .pathParam("id", EXAMPLE_FILTER_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(SINGLE_FILTER_URL); // validate sorting content String content = response.asString(); List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting"); assertThat(sortings).hasSize(5); assertSorting(sortings.get(0), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING); assertSorting(sortings.get(1), SORT_BY_PROCESS_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING); assertSorting(sortings.get(2), SORT_BY_TASK_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING); assertSorting(sortings.get(3), SORT_BY_CASE_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING); assertSorting(sortings.get(4), SORT_BY_CASE_INSTANCE_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING); }
Example #28
Source File: TaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml") public void testQueryOrderByProcessVariableInteger() { ProcessInstance instance500 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 500)); ProcessInstance instance1000 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 1000)); ProcessInstance instance250 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 250)); // asc List<Task> tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.INTEGER) .asc() .list(); assertEquals(3, tasks.size()); assertEquals(instance250.getId(), tasks.get(0).getProcessInstanceId()); assertEquals(instance500.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance1000.getId(), tasks.get(2).getProcessInstanceId()); // desc tasks = taskService.createTaskQuery() .processDefinitionKey("oneTaskProcess") .orderByProcessVariable("var", ValueType.INTEGER) .desc() .list(); assertEquals(3, tasks.size()); assertEquals(instance1000.getId(), tasks.get(0).getProcessInstanceId()); assertEquals(instance500.getId(), tasks.get(1).getProcessInstanceId()); assertEquals(instance250.getId(), tasks.get(2).getProcessInstanceId()); }
Example #29
Source File: VariableOrderProperty.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static VariableOrderProperty forCaseInstanceVariable(String variableName, ValueType valueType) { VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); orderingProperty.relationConditions.add( new QueryEntityRelationCondition(VariableInstanceQueryProperty.CASE_EXECUTION_ID, TaskQueryProperty.CASE_INSTANCE_ID)); return orderingProperty; }
Example #30
Source File: TypedValueAssert.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static void assertObjectValueDeserialized(ObjectValue typedValue, Object value) { Class<? extends Object> expectedObjectType = value.getClass(); assertTrue(typedValue.isDeserialized()); assertEquals(ValueType.OBJECT, typedValue.getType()); assertEquals(value, typedValue.getValue()); assertEquals(value, typedValue.getValue(expectedObjectType)); assertEquals(expectedObjectType, typedValue.getObjectType()); assertEquals(expectedObjectType.getName(), typedValue.getObjectTypeName()); }