Search in sources :

Example 11 with ObjectValue

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()));
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) Matchers.containsString(org.hamcrest.Matchers.containsString) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with ObjectValue

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();
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) MockObjectValue(org.camunda.bpm.engine.rest.helper.MockObjectValue) MockHistoricVariableUpdateBuilder(org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 13 with ObjectValue

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);
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) MockObjectValue(org.camunda.bpm.engine.rest.helper.MockObjectValue) EqualsObjectValue(org.camunda.bpm.engine.rest.helper.variable.EqualsObjectValue) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 14 with ObjectValue

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();
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ArrayList(java.util.ArrayList) MockHistoricVariableUpdateBuilder(org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 15 with ObjectValue

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;
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance)

Aggregations

ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)99 Test (org.junit.Test)58 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)53 Deployment (org.camunda.bpm.engine.test.Deployment)46 Variables.serializedObjectValue (org.camunda.bpm.engine.variable.Variables.serializedObjectValue)36 MockObjectValue (org.camunda.bpm.engine.rest.helper.MockObjectValue)29 EqualsObjectValue (org.camunda.bpm.engine.rest.helper.variable.EqualsObjectValue)23 Matchers.containsString (org.hamcrest.Matchers.containsString)20 Matchers.anyString (org.mockito.Matchers.anyString)19 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 ObjectOutputStream (java.io.ObjectOutputStream)9 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)8 Task (org.camunda.bpm.engine.task.Task)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ObjectInputStream (java.io.ObjectInputStream)6 HashMap (java.util.HashMap)6 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)6 FailingJavaSerializable (org.camunda.bpm.engine.test.api.variables.FailingJavaSerializable)6 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 SerializedObjectValueBuilder (org.camunda.bpm.engine.variable.value.builder.SerializedObjectValueBuilder)6