use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class ConnectProcessEnginePluginTest method testIntermediateMessageThrowEventWithConnector.
@Deployment
public void testIntermediateMessageThrowEventWithConnector() {
String outputParamValue = "someMessageThrowOutputValue";
String inputVariableValue = "someMessageThrowInputVariableValue";
TestConnector.responseParameters.put("someOutputParameter", outputParamValue);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("someInputVariable", inputVariableValue);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process_sending_with_connector", vars);
// validate input parameter
assertNotNull(TestConnector.requestParameters.get("reqParam1"));
assertEquals(inputVariableValue, TestConnector.requestParameters.get("reqParam1"));
// validate connector output
VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("out1").singleResult();
assertNotNull(variable);
assertEquals(outputParamValue, variable.getValue());
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class ConnectProcessEnginePluginTest method testConnectorInvoked.
@Deployment
public void testConnectorInvoked() {
String outputParamValue = "someOutputValue";
String inputVariableValue = "someInputVariableValue";
TestConnector.responseParameters.put("someOutputParameter", outputParamValue);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("someInputVariable", inputVariableValue);
runtimeService.startProcessInstanceByKey("testProcess", vars);
// validate input parameter
assertNotNull(TestConnector.requestParameters.get("reqParam1"));
assertEquals(inputVariableValue, TestConnector.requestParameters.get("reqParam1"));
// validate connector output
VariableInstance variable = runtimeService.createVariableInstanceQuery().variableName("out1").singleResult();
assertNotNull(variable);
assertEquals(outputParamValue, variable.getValue());
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class ConnectProcessEnginePluginTest method testConnectorWithScriptInputOutputMapping.
@Deployment
public void testConnectorWithScriptInputOutputMapping() {
int x = 3;
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("x", x);
runtimeService.startProcessInstanceByKey("testProcess", variables);
// validate input parameter
Object in = TestConnector.requestParameters.get("in");
assertNotNull(in);
assertEquals(2 * x, in);
// validate output parameter
VariableInstance out = runtimeService.createVariableInstanceQuery().variableName("out").singleResult();
assertNotNull(out);
assertEquals(3 * x, out.getValue());
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class VariableInstanceRestServiceInteractionTest method testBinaryDataForBinaryVariable.
@Test
public void testBinaryDataForBinaryVariable() {
final byte[] byteContent = "some bytes".getBytes();
VariableInstance variableInstanceMock = MockProvider.mockVariableInstance().typedValue(Variables.byteArrayValue(byteContent)).build();
when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock);
Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).contentType(ContentType.BINARY.toString()).when().get(VARIABLE_INSTANCE_BINARY_DATA_URL);
byte[] responseBytes = response.getBody().asByteArray();
Assert.assertEquals(new String(byteContent), new String(responseBytes));
verify(variableInstanceQueryMock, never()).disableBinaryFetching();
verify(variableInstanceQueryMock).disableCustomObjectDeserialization();
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class VariableInstanceRestServiceInteractionTest method testGetSingleVariableInstanceForBinaryVariable.
@Test
public void testGetSingleVariableInstanceForBinaryVariable() {
MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance();
VariableInstance 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();
}
Aggregations