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;
}
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");
}
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");
}
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"));
}
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();
}
Aggregations