use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceQueryTest method testSerializableVariableInstanceRetrieval.
@Test
public void testSerializableVariableInstanceRetrieval() {
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance().typedValue(MockObjectValue.fromObjectValue(Variables.objectValue("a serialized value").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create()).objectTypeName(String.class.getName()));
List<HistoricVariableInstance> mockInstances = new ArrayList<HistoricVariableInstance>();
mockInstances.add(builder.build());
mockedQuery = setUpMockHistoricVariableInstanceQuery(mockInstances);
given().then().expect().statusCode(Status.OK.getStatusCode()).and().body("[0].type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT))).body("[0].value", equalTo("a serialized value")).body("[0].valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(String.class.getName())).body("[0].valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo(Variables.SerializationDataFormats.JAVA.getName())).when().get(HISTORIC_VARIABLE_INSTANCE_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.rest.helper.MockHistoricVariableInstanceBuilder in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceQueryTest method testSpinVariableInstanceRetrieval.
@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);
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceForBinaryVariable.
@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance();
HistoricVariableInstance variableInstanceMock = builder.typedValue(Variables.byteArrayValue(null)).build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).and().body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.BYTES))).body("value", nullValue()).when().get(VARIABLE_INSTANCE_URL);
verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstance.
@Test
public void testGetSingleVariableInstance() {
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance();
HistoricVariableInstance variableInstanceMock = builder.build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", builder.getId()).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("name", equalTo(builder.getName())).body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.getTypedValue().getType()))).body("value", equalTo(builder.getValue())).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("executionId", equalTo(builder.getExecutionId())).body("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("taskId", equalTo(builder.getTaskId())).body("tenantId", equalTo(builder.getTenantId())).when().get(VARIABLE_INSTANCE_URL);
verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
}
use of org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceSerialized.
@Test
public void testGetSingleVariableInstanceSerialized() {
ObjectValue serializedValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("aDataFormat").objectTypeName("aTypeName").create();
MockHistoricVariableInstanceBuilder builder = MockProvider.mockHistoricVariableInstance().typedValue(serializedValue);
HistoricVariableInstance variableInstanceMock = builder.build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).queryParam("deserializeValue", false).then().expect().statusCode(Status.OK.getStatusCode()).and().body("id", equalTo(builder.getId())).body("name", equalTo(builder.getName())).body("type", equalTo(VariableTypeHelper.toExpectedValueTypeName(builder.getTypedValue().getType()))).body("value", equalTo("a serialized value")).body("valueInfo.serializationDataFormat", equalTo("aDataFormat")).body("valueInfo.objectTypeName", equalTo("aTypeName")).body("processInstanceId", equalTo(builder.getProcessInstanceId())).body("processDefinitionKey", equalTo(builder.getProcessDefinitionKey())).body("processDefinitionId", equalTo(builder.getProcessDefinitionId())).body("executionId", equalTo(builder.getExecutionId())).body("errorMessage", equalTo(builder.getErrorMessage())).body("activityInstanceId", equalTo(builder.getActivityInstanceId())).body("caseDefinitionKey", equalTo(builder.getCaseDefinitionKey())).body("caseDefinitionId", equalTo(builder.getCaseDefinitionId())).body("caseInstanceId", equalTo(builder.getCaseInstanceId())).body("caseExecutionId", equalTo(builder.getCaseExecutionId())).body("taskId", equalTo(builder.getTaskId())).body("tenantId", equalTo(builder.getTenantId())).when().get(VARIABLE_INSTANCE_URL);
verify(variableInstanceQueryMock, times(1)).disableBinaryFetching();
verify(variableInstanceQueryMock, times(1)).disableCustomObjectDeserialization();
}
Aggregations