use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceQueryTest method verifySerializedValue.
@SuppressWarnings("unchecked")
protected void verifySerializedValue(Map<String, Object> serializedValue) {
ObjectValue exampleValue = MockProvider.EXAMPLE_HISTORIC_DECISION_SERIALIZED_VALUE;
assertThat(serializedValue, hasEntry("type", (Object) VariableValueDto.toRestApiTypeName(exampleValue.getType().getName())));
assertThat(serializedValue, hasEntry("value", exampleValue.getValue()));
Map<String, String> valueInfo = (Map<String, String>) serializedValue.get("valueInfo");
assertThat(valueInfo, hasEntry("serializationDataFormat", exampleValue.getSerializationDataFormat()));
assertThat(valueInfo, hasEntry("objectTypeName", exampleValue.getObjectTypeName()));
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceInteractionTest method testGetSingleVariableUpdateSerialized.
@Test
public void testGetSingleVariableUpdateSerialized() {
ObjectValue serializedValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("aDataFormat").objectTypeName("aTypeName").create();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate().typedValue(serializedValue);
HistoricVariableUpdate variableInstanceMock = builder.build();
when(historicDetailQueryMock.detailId(variableInstanceMock.getId())).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableBinaryFetching()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock);
when(historicDetailQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", builder.getId()).queryParam("deserializeValue", false).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 serialized 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, times(1)).disableCustomObjectDeserialization();
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class TaskVariableRestResourceInteractionTest method testGetObjectVariablesSerialized.
@Test
public void testGetObjectVariablesSerialized() {
// given
String variableKey = "aVariableId";
ObjectValue variableValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("application/json").objectTypeName(ArrayList.class.getName()).create();
when(taskServiceMock.getVariablesTyped(eq(EXAMPLE_TASK_ID), anyBoolean())).thenReturn(Variables.createVariables().putValueTyped(variableKey, variableValue));
// when
given().pathParam("id", EXAMPLE_TASK_ID).queryParam("deserializeValues", false).then().expect().statusCode(Status.OK.getStatusCode()).body(variableKey + ".value", equalTo("a serialized value")).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, false);
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class HistoricDetailRestServiceQueryTest method testSerializableVariableInstanceRetrieval.
@Test
public void testSerializableVariableInstanceRetrieval() {
ObjectValue serializedValue = Variables.serializedObjectValue("a serialized value").create();
MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate().typedValue(serializedValue);
List<HistoricDetail> details = new ArrayList<HistoricDetail>();
details.add(builder.build());
mockedQuery = setUpMockedDetailsQuery(details);
given().then().expect().statusCode(Status.OK.getStatusCode()).and().body("[0].value", equalTo("a serialized value")).body("[0].variableType", equalTo(VariableTypeHelper.toExpectedValueTypeName(serializedValue.getType()))).body("[0].errorMessage", nullValue()).when().get(HISTORIC_DETAIL_RESOURCE_URL);
// should not resolve custom objects but existing API requires it
// verify(mockedQuery).disableCustomObjectDeserialization();
verify(mockedQuery, never()).disableCustomObjectDeserialization();
}
use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.
the class MockHistoricVariableInstanceBuilder method build.
public HistoricVariableInstance build() {
HistoricVariableInstance mockVariable = mock(HistoricVariableInstance.class);
when(mockVariable.getId()).thenReturn(id);
when(mockVariable.getName()).thenReturn(name);
when(mockVariable.getVariableName()).thenReturn(name);
when(mockVariable.getTypeName()).thenReturn(value.getType().getName());
when(mockVariable.getVariableTypeName()).thenReturn(value.getType().getName());
if (ObjectValue.class.isAssignableFrom(value.getClass())) {
ObjectValue objectValue = (ObjectValue) value;
if (objectValue.isDeserialized()) {
when(mockVariable.getValue()).thenReturn(value.getValue());
} else {
when(mockVariable.getValue()).thenReturn(null);
}
} else {
when(mockVariable.getValue()).thenReturn(value.getValue());
}
when(mockVariable.getTypedValue()).thenReturn(value);
when(mockVariable.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId);
when(mockVariable.getExecutionId()).thenReturn(executionId);
when(mockVariable.getErrorMessage()).thenReturn(errorMessage);
when(mockVariable.getActivtyInstanceId()).thenReturn(activityInstanceId);
when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId);
when(mockVariable.getCaseDefinitionKey()).thenReturn(caseDefinitionKey);
when(mockVariable.getCaseDefinitionId()).thenReturn(caseDefinitionId);
when(mockVariable.getCaseInstanceId()).thenReturn(caseInstanceId);
when(mockVariable.getCaseExecutionId()).thenReturn(caseExecutionId);
when(mockVariable.getTaskId()).thenReturn(taskId);
when(mockVariable.getTenantId()).thenReturn(tenantId);
return mockVariable;
}
Aggregations