Search in sources :

Example 6 with ObjectValue

use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.

the class CaseInstanceRestServiceInteractionTest 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(caseServiceMock.getVariableTyped(eq(MockProvider.EXAMPLE_CASE_INSTANCE_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
    // when
    given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_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_CASE_INSTANCE_VARIABLE_URL);
    // then
    verify(caseServiceMock).getVariableTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, variableKey, true);
}
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 7 with ObjectValue

use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testGetLocalObjectVariablesSerialized.

@Test
public void testGetLocalObjectVariablesSerialized() {
    // given
    String variableKey = "aVariableId";
    ObjectValue variableValue = Variables.serializedObjectValue("a serialized value").serializationDataFormat("application/json").objectTypeName(ArrayList.class.getName()).create();
    when(caseServiceMock.getVariablesLocalTyped(eq(MockProvider.EXAMPLE_CASE_EXECUTION_ID), anyBoolean())).thenReturn(Variables.createVariables().putValueTyped(variableKey, variableValue));
    // when
    given().pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_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(CASE_EXECUTION_LOCAL_VARIABLES_URL);
    // then
    verify(caseServiceMock).getVariablesLocalTyped(MockProvider.EXAMPLE_CASE_EXECUTION_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 8 with ObjectValue

use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testGetSingleLocalObjectVariable.

@Test
public void testGetSingleLocalObjectVariable() {
    // 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(caseServiceMock.getVariableLocalTyped(eq(MockProvider.EXAMPLE_CASE_EXECUTION_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
    // when
    given().pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_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_CASE_EXECUTION_LOCAL_VARIABLE_URL);
    // then
    verify(caseServiceMock).getVariableLocalTyped(MockProvider.EXAMPLE_CASE_EXECUTION_ID, variableKey, true);
}
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 9 with ObjectValue

use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testGetSingleLocalObjectVariable.

@Test
public void testGetSingleLocalObjectVariable() {
    // 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(runtimeServiceMock.getVariableTyped(eq(EXAMPLE_PROCESS_INSTANCE_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
    // when
    given().pathParam("id", EXAMPLE_PROCESS_INSTANCE_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_PROCESS_INSTANCE_VARIABLE_URL);
    // then
    verify(runtimeServiceMock).getVariableTyped(EXAMPLE_PROCESS_INSTANCE_ID, variableKey, true);
}
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) Test(org.junit.Test)

Example 10 with ObjectValue

use of org.camunda.bpm.engine.variable.value.ObjectValue in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest 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(runtimeServiceMock.getVariablesTyped(eq(EXAMPLE_PROCESS_INSTANCE_ID), anyBoolean())).thenReturn(Variables.createVariables().putValueTyped(variableKey, variableValue));
    // when
    given().pathParam("id", EXAMPLE_PROCESS_INSTANCE_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(PROCESS_INSTANCE_VARIABLES_URL);
    // then
    verify(runtimeServiceMock).getVariablesTyped(EXAMPLE_PROCESS_INSTANCE_ID, true);
}
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) Test(org.junit.Test)

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