use of io.camunda.zeebe.client.api.response.SetVariablesResponse in project zeebe-process-test by camunda.
the class EngineClientTest method shouldUpdateVariablesOnProcessInstance.
@Test
void shouldUpdateVariablesOnProcessInstance() {
// given
zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().serviceTask("task", task -> task.zeebeJobType("jobType")).endEvent().done(), "simpleProcess.bpmn").send().join();
final ProcessInstanceEvent processInstance = zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
// when
final SetVariablesResponse variablesResponse = zeebeClient.newSetVariablesCommand(processInstance.getProcessInstanceKey()).variables(Map.of("test123", 234)).local(true).send().join();
// then
assertThat(variablesResponse).isNotNull();
assertThat(variablesResponse.getKey()).isPositive();
}
use of io.camunda.zeebe.client.api.response.SetVariablesResponse in project zeebe by camunda.
the class SetVariablesTest method shouldSetVariables.
@Test
public void shouldSetVariables() {
// given
final long processInstanceKey = CLIENT_RULE.createProcessInstance(processDefinitionKey);
// when
final SetVariablesResponse response = CLIENT_RULE.getClient().newSetVariablesCommand(processInstanceKey).variables(Map.of("foo", "bar")).send().join();
// then
ZeebeAssertHelper.assertVariableDocumentUpdated((variableDocument) -> assertThat(variableDocument.getVariables()).containsOnly(entry("foo", "bar")));
final Record<VariableDocumentRecordValue> record = RecordingExporter.variableDocumentRecords(VariableDocumentIntent.UPDATED).getFirst();
assertThat(response.getKey()).isEqualTo(record.getKey());
}
use of io.camunda.zeebe.client.api.response.SetVariablesResponse in project zeebe by camunda.
the class SetVariablesTest method shouldCommandWithVariablesAsString.
@Test
public void shouldCommandWithVariablesAsString() {
// given
gatewayService.onSetVariablesRequest(345);
final String variables = "{\"key\": \"val\"}";
// when
final SetVariablesResponse response = client.newSetVariablesCommand(123).variables(variables).send().join();
// then
assertThat(response).isNotNull();
assertThat(response.getKey()).isEqualTo(345);
final SetVariablesRequest request = gatewayService.getLastRequest();
assertThat(request.getElementInstanceKey()).isEqualTo(123);
assertThat(fromJsonAsMap(request.getVariables())).containsOnly(entry("key", "val"));
rule.verifyDefaultRequestTimeout();
}
use of io.camunda.zeebe.client.api.response.SetVariablesResponse in project zeebe by zeebe-io.
the class SetVariablesTest method shouldCommandWithVariablesAsString.
@Test
public void shouldCommandWithVariablesAsString() {
// given
gatewayService.onSetVariablesRequest(345);
final String variables = "{\"key\": \"val\"}";
// when
final SetVariablesResponse response = client.newSetVariablesCommand(123).variables(variables).send().join();
// then
assertThat(response).isNotNull();
assertThat(response.getKey()).isEqualTo(345);
final SetVariablesRequest request = gatewayService.getLastRequest();
assertThat(request.getElementInstanceKey()).isEqualTo(123);
assertThat(fromJsonAsMap(request.getVariables())).containsOnly(entry("key", "val"));
rule.verifyDefaultRequestTimeout();
}
use of io.camunda.zeebe.client.api.response.SetVariablesResponse in project zeebe by camunda-cloud.
the class SetVariablesCommandImpl method send.
@Override
public ZeebeFuture<SetVariablesResponse> send() {
final SetVariablesRequest request = builder.build();
final RetriableClientFutureImpl<SetVariablesResponse, GatewayOuterClass.SetVariablesResponse> future = new RetriableClientFutureImpl<>(SetVariablesResponseImpl::new, retryPredicate, streamObserver -> send(request, streamObserver));
send(request, future);
return future;
}
Aggregations