Search in sources :

Example 1 with CreateProcessInstanceWithResultRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest in project zeebe by camunda.

the class CreateProcessInstanceWithResultCommandImpl method send.

@Override
public ZeebeFuture<ProcessInstanceResult> send() {
    final CreateProcessInstanceWithResultRequest request = builder.setRequest(createProcessInstanceRequestBuilder).setRequestTimeout(requestTimeout.toMillis()).build();
    final RetriableClientFutureImpl<ProcessInstanceResult, GatewayOuterClass.CreateProcessInstanceWithResultResponse> future = new RetriableClientFutureImpl<>(response -> new CreateProcessInstanceWithResultResponseImpl(jsonMapper, response), retryPredicate, streamObserver -> send(request, streamObserver));
    send(request, future);
    return future;
}
Also used : CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) CreateProcessInstanceWithResultResponseImpl(io.camunda.zeebe.client.impl.response.CreateProcessInstanceWithResultResponseImpl) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) RetriableClientFutureImpl(io.camunda.zeebe.client.impl.RetriableClientFutureImpl)

Example 2 with CreateProcessInstanceWithResultRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest in project zeebe by camunda.

the class CreateProcessInstanceWithResultTest method shouldBeAbleToSpecifyFetchVariables.

@Test
public void shouldBeAbleToSpecifyFetchVariables() {
    // given
    final String variables = "{\"key\": \"val\"}";
    gatewayService.onCreateProcessInstanceWithResultRequest(123, "testProcess", 12, 32, variables);
    // when
    final ProcessInstanceResult response = client.newCreateInstanceCommand().processDefinitionKey(123).withResult().fetchVariables("x").requestTimeout(Duration.ofSeconds(123)).send().join();
    // then
    final CreateProcessInstanceWithResultRequest request = gatewayService.getLastRequest();
    assertThat(request.getRequest().getProcessDefinitionKey()).isEqualTo(123);
    assertThat(request.getRequestTimeout()).isEqualTo(Duration.ofSeconds(123).toMillis());
    assertThat(request.getFetchVariablesList()).containsExactly("x");
}
Also used : CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 3 with CreateProcessInstanceWithResultRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest in project zeebe by zeebe-io.

the class CreateProcessInstanceWithResultTest method shouldBeAbleToSpecifyFetchVariables.

@Test
public void shouldBeAbleToSpecifyFetchVariables() {
    // given
    final String variables = "{\"key\": \"val\"}";
    gatewayService.onCreateProcessInstanceWithResultRequest(123, "testProcess", 12, 32, variables);
    // when
    final ProcessInstanceResult response = client.newCreateInstanceCommand().processDefinitionKey(123).withResult().fetchVariables("x").requestTimeout(Duration.ofSeconds(123)).send().join();
    // then
    final CreateProcessInstanceWithResultRequest request = gatewayService.getLastRequest();
    assertThat(request.getRequest().getProcessDefinitionKey()).isEqualTo(123);
    assertThat(request.getRequestTimeout()).isEqualTo(Duration.ofSeconds(123).toMillis());
    assertThat(request.getFetchVariablesList()).containsExactly("x");
}
Also used : CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 4 with CreateProcessInstanceWithResultRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest in project zeebe by zeebe-io.

the class CreateProcessInstanceWithResultTest method shouldCreateProcessInstanceWithStringVariables.

@Test
public void shouldCreateProcessInstanceWithStringVariables() {
    // when
    client.newCreateInstanceCommand().processDefinitionKey(123).variables("{\"foo\": \"bar\"}").withResult().send().join();
    // then
    final CreateProcessInstanceWithResultRequest request = gatewayService.getLastRequest();
    assertThat(fromJsonAsMap(request.getRequest().getVariables())).containsOnly(entry("foo", "bar"));
}
Also used : CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 5 with CreateProcessInstanceWithResultRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest in project zeebe by zeebe-io.

the class CreateProcessInstanceWithResultTest method shouldCreateProcessInstanceByProcessInstanceKey.

@Test
public void shouldCreateProcessInstanceByProcessInstanceKey() {
    // given
    final String variables = "{\"key\": \"val\"}";
    gatewayService.onCreateProcessInstanceWithResultRequest(123, "testProcess", 12, 32, variables);
    // when
    final ProcessInstanceResult response = client.newCreateInstanceCommand().processDefinitionKey(123).withResult().requestTimeout(Duration.ofSeconds(123)).send().join();
    // then
    assertThat(response.getProcessDefinitionKey()).isEqualTo(123);
    assertThat(response.getBpmnProcessId()).isEqualTo("testProcess");
    assertThat(response.getVersion()).isEqualTo(12);
    assertThat(response.getProcessInstanceKey()).isEqualTo(32);
    assertThat(response.getVariablesAsMap()).containsExactly(entry("key", "val"));
    assertThat(response.getVariables()).isEqualTo(variables);
    final VariablesPojo result = response.getVariablesAsType(VariablesPojo.class);
    assertThat(result.getKey()).isEqualTo("val");
    final CreateProcessInstanceWithResultRequest request = gatewayService.getLastRequest();
    assertThat(request.getRequest().getProcessDefinitionKey()).isEqualTo(123);
    assertThat(request.getRequestTimeout()).isEqualTo(Duration.ofSeconds(123).toMillis());
    assertThat(request.getFetchVariablesList()).isEmpty();
}
Also used : CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

CreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest)21 Test (org.junit.Test)18 ClientTest (io.camunda.zeebe.client.util.ClientTest)12 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)9 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)6 BrokerCreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceWithResultRequest)6 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 CreateProcessInstanceWithResultResponseImpl (io.camunda.zeebe.client.impl.response.CreateProcessInstanceWithResultResponseImpl)3 CreateProcessInstanceWithResultResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultResponse)3 ProcessInstanceCreationRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)3