Search in sources :

Example 1 with VariableInstance

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());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with VariableInstance

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());
}
Also used : HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 3 with VariableInstance

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());
}
Also used : HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with VariableInstance

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();
}
Also used : Response(com.jayway.restassured.response.Response) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 5 with VariableInstance

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();
}
Also used : MockVariableInstanceBuilder(org.camunda.bpm.engine.rest.helper.MockVariableInstanceBuilder) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Aggregations

VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)374 Deployment (org.camunda.bpm.engine.test.Deployment)265 Test (org.junit.Test)167 HashMap (java.util.HashMap)136 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)122 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)93 Task (org.camunda.bpm.engine.task.Task)67 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)39 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)33 Execution (org.camunda.bpm.engine.runtime.Execution)33 VariableMap (org.camunda.bpm.engine.variable.VariableMap)30 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)27 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)26 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)23 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)17 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)13 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)11 List (java.util.List)10