use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testGetObjectVariables.
@Test
public void testGetObjectVariables() {
// given
String variableKey = "aVariableId";
List<String> payload = Arrays.asList("a", "b");
ObjectValue variableValue = MockObjectValue.fromObjectValue(Variables.objectValue(payload).serializationDataFormat("application/json").create()).objectTypeName(ArrayList.class.getName()).serializedValue(// this should differ from the serialized json
"a serialized value");
when(taskServiceMock.getVariablesTyped(eq(EXAMPLE_TASK_ID), anyBoolean())).thenReturn(Variables.createVariables().putValueTyped(variableKey, variableValue));
// when
given().pathParam("id", EXAMPLE_TASK_ID).then().expect().statusCode(Status.OK.getStatusCode()).body(variableKey + ".value", equalTo(payload)).body(variableKey + ".type", equalTo("Object")).body(variableKey + ".valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json")).body(variableKey + ".valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ArrayList.class.getName())).when().get(SINGLE_TASK_VARIABLES_URL);
// then
verify(taskServiceMock).getVariablesTyped(EXAMPLE_TASK_ID, true);
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testGetSingleObjectVariable.
@Test
public void testGetSingleObjectVariable() {
// given
String variableKey = "aVariableId";
List<String> payload = Arrays.asList("a", "b");
ObjectValue variableValue = MockObjectValue.fromObjectValue(Variables.objectValue(payload).serializationDataFormat("application/json").create()).objectTypeName(ArrayList.class.getName()).serializedValue(// this should differ from the serialized json
"a serialized value");
when(taskServiceMock.getVariableTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
// when
given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey).then().expect().statusCode(Status.OK.getStatusCode()).body("value", equalTo(payload)).body("type", equalTo("Object")).body("valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json")).body("valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ArrayList.class.getName())).when().get(SINGLE_TASK_SINGLE_VARIABLE_URL);
// then
verify(taskServiceMock).getVariableTyped(EXAMPLE_TASK_ID, variableKey, true);
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testGetSingleVariableUpdateDeserialized.
@Test
public void testGetSingleVariableUpdateDeserialized() {
ObjectValue serializedValue = MockObjectValue.fromObjectValue(Variables.objectValue("a value").serializationDataFormat("aDataFormat").create()).objectTypeName("aTypeName");
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate().typedValue(serializedValue);
HistoricVariableUpdate variableInstanceMock = builder.build();
when(historicDetailQueryMock.detailId(variableInstanceMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableBinaryFetching()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", builder.getId()).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("variableName", equalTo(builder.getName())).body("variableInstanceId", equalTo(builder.getVariableInstanceId())).body("variableType", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.getTypedValue().getType()))).body("value", equalTo("a value")).body("valueInfo.serializationDataFormat", equalTo("aDataFormat")).body("valueInfo.objectTypeName", equalTo("aTypeName")).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("revision", equalTo(builder.getRevision())).body("time", equalTo(builder.getTime())).body("taskId", equalTo(builder.getTaskId())).body("executionId", equalTo(builder.getExecutionId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("tenantId", equalTo(builder.getTenantId())).when().get(HISTORIC_DETAIL_URL);
verify(historicDetailQueryMock, times(1)).disableBinaryFetching();
verify(historicDetailQueryMock, never()).disableCustomObjectDeserialization();
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class MockProvider method createMockSerializedVariables.
public static VariableMap createMockSerializedVariables() {
VariableMap variables = Variables.createVariables();
ObjectValue serializedVar = Variables.serializedObjectValue(EXAMPLE_VARIABLE_INSTANCE_SERIALIZED_VALUE).serializationDataFormat(FORMAT_APPLICATION_JSON).objectTypeName(ArrayList.class.getName()).create();
ObjectValue deserializedVar = new ObjectValueImpl(EXAMPLE_VARIABLE_INSTANCE_DESERIALIZED_VALUE, EXAMPLE_VARIABLE_INSTANCE_SERIALIZED_VALUE, FORMAT_APPLICATION_JSON, Object.class.getName(), true);
variables.putValueTyped(EXAMPLE_VARIABLE_INSTANCE_NAME, serializedVar);
variables.putValueTyped(EXAMPLE_DESERIALIZED_VARIABLE_INSTANCE_NAME, deserializedVar);
return variables;
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class MockHistoricVariableUpdateBuilder method build.
public HistoricVariableUpdate build() {
HistoricVariableUpdate mockVariable = mock(HistoricVariableUpdate.class);
when(mockVariable.getId()).thenReturn(id);
when(mockVariable.getVariableName()).thenReturn(name);
when(mockVariable.getVariableInstanceId()).thenReturn(variableInstanceId);
when(mockVariable.getVariableTypeName()).thenReturn(typedValue.getType().getName());
if (ObjectValue.class.isAssignableFrom(typedValue.getClass())) {
ObjectValue objectValue = (ObjectValue) typedValue;
if (objectValue.isDeserialized()) {
when(mockVariable.getValue()).thenReturn(typedValue.getValue());
} else {
when(mockVariable.getValue()).thenReturn(null);
}
} else {
when(mockVariable.getValue()).thenReturn(typedValue.getValue());
}
when(mockVariable.getTypedValue()).thenReturn(typedValue);
when(mockVariable.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId);
when(mockVariable.getErrorMessage()).thenReturn(errorMessage);
when(mockVariable.getRevision()).thenReturn(revision);
when(mockVariable.getTime()).thenReturn(DateTimeUtil.parseDate(time));
when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId);
when(mockVariable.getTaskId()).thenReturn(taskId);
when(mockVariable.getExecutionId()).thenReturn(executionId);
when(mockVariable.getTypeName()).thenReturn(typedValue.getType().getName());
when(mockVariable.getCaseDefinitionKey()).thenReturn(caseDefinitionKey);
when(mockVariable.getCaseDefinitionId()).thenReturn(caseDefinitionId);
when(mockVariable.getCaseInstanceId()).thenReturn(caseInstanceId);
when(mockVariable.getCaseExecutionId()).thenReturn(caseExecutionId);
when(mockVariable.getTenantId()).thenReturn(tenantId);
when(mockVariable.getUserOperationId()).thenReturn(userOperationId);
return mockVariable;
}
Aggregations