Search in sources :

Example 1 with CreateProcessInstanceRequest

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"));
}
Also used : CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 2 with CreateProcessInstanceRequest

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;
}
Also used : BrokerCreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceWithResultRequest) CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)

Example 3 with CreateProcessInstanceRequest

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());
}
Also used : CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest) CreateProcessInstanceResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 4 with CreateProcessInstanceRequest

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;
}
Also used : BrokerCreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceWithResultRequest) CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)

Example 5 with CreateProcessInstanceRequest

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();
}
Also used : CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

CreateProcessInstanceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest)30 Test (org.junit.Test)24 ClientTest (io.camunda.zeebe.client.util.ClientTest)21 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)6 BrokerCreateProcessInstanceRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)6 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 CreateProcessInstanceResponseImpl (io.camunda.zeebe.client.impl.response.CreateProcessInstanceResponseImpl)3 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerCreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceWithResultRequest)3 CreateProcessInstanceResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceResponse)3 ProcessInstanceCreationRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3