use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest in project zeebe by camunda.
the class CreateProcessInstanceTest method shouldCreateProcessInstanceWithStringVariables.
@Test
public void shouldCreateProcessInstanceWithStringVariables() {
// when
client.newCreateInstanceCommand().processDefinitionKey(123).variables("{\"foo\": \"bar\"}").send().join();
// then
final CreateProcessInstanceRequest request = gatewayService.getLastRequest();
assertThat(fromJsonAsMap(request.getVariables())).containsOnly(entry("foo", "bar"));
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest in project zeebe by camunda.
the class RequestMapper method toCreateProcessInstanceWithResultRequest.
public static BrokerCreateProcessInstanceWithResultRequest toCreateProcessInstanceWithResultRequest(final CreateProcessInstanceWithResultRequest grpcRequest) {
final BrokerCreateProcessInstanceWithResultRequest brokerRequest = new BrokerCreateProcessInstanceWithResultRequest();
final CreateProcessInstanceRequest request = grpcRequest.getRequest();
brokerRequest.setBpmnProcessId(request.getBpmnProcessId()).setKey(request.getProcessDefinitionKey()).setVersion(request.getVersion()).setVariables(ensureJsonSet(request.getVariables())).setFetchVariables(grpcRequest.getFetchVariablesList());
return brokerRequest;
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest in project zeebe by zeebe-io.
the class CreateProcessInstanceTest method shouldMapRequestAndResponse.
@Test
public void shouldMapRequestAndResponse() {
// given
final CreateProcessInstanceStub stub = new CreateProcessInstanceStub();
stub.registerWith(brokerClient);
final CreateProcessInstanceRequest request = CreateProcessInstanceRequest.newBuilder().setProcessDefinitionKey(stub.getProcessDefinitionKey()).build();
// when
final CreateProcessInstanceResponse response = client.createProcessInstance(request);
// then
assertThat(response.getBpmnProcessId()).isEqualTo(stub.getProcessId());
assertThat(response.getVersion()).isEqualTo(stub.getProcessVersion());
assertThat(response.getProcessDefinitionKey()).isEqualTo(stub.getProcessDefinitionKey());
assertThat(response.getProcessInstanceKey()).isEqualTo(stub.getProcessInstanceKey());
final BrokerCreateProcessInstanceRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getIntent()).isEqualTo(ProcessInstanceCreationIntent.CREATE);
assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.PROCESS_INSTANCE_CREATION);
final ProcessInstanceCreationRecord brokerRequestValue = brokerRequest.getRequestWriter();
assertThat(brokerRequestValue.getProcessDefinitionKey()).isEqualTo(stub.getProcessDefinitionKey());
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest in project zeebe by zeebe-io.
the class RequestMapper method toCreateProcessInstanceWithResultRequest.
public static BrokerCreateProcessInstanceWithResultRequest toCreateProcessInstanceWithResultRequest(final CreateProcessInstanceWithResultRequest grpcRequest) {
final BrokerCreateProcessInstanceWithResultRequest brokerRequest = new BrokerCreateProcessInstanceWithResultRequest();
final CreateProcessInstanceRequest request = grpcRequest.getRequest();
brokerRequest.setBpmnProcessId(request.getBpmnProcessId()).setKey(request.getProcessDefinitionKey()).setVersion(request.getVersion()).setVariables(ensureJsonSet(request.getVariables())).setFetchVariables(grpcRequest.getFetchVariablesList());
return brokerRequest;
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest in project zeebe by zeebe-io.
the class CreateProcessInstanceTest method shouldCreateProcessInstanceByProcessInstanceKey.
@Test
public void shouldCreateProcessInstanceByProcessInstanceKey() {
// given
gatewayService.onCreateProcessInstanceRequest(123, "testProcess", 12, 32);
// when
final ProcessInstanceEvent response = client.newCreateInstanceCommand().processDefinitionKey(123).send().join();
// then
assertThat(response.getProcessDefinitionKey()).isEqualTo(123);
assertThat(response.getBpmnProcessId()).isEqualTo("testProcess");
assertThat(response.getVersion()).isEqualTo(12);
assertThat(response.getProcessInstanceKey()).isEqualTo(32);
final CreateProcessInstanceRequest request = gatewayService.getLastRequest();
assertThat(request.getProcessDefinitionKey()).isEqualTo(123);
rule.verifyDefaultRequestTimeout();
}
Aggregations