use of io.camunda.zeebe.client.api.response.ProcessInstanceResult in project zdb by Zelldon.
the class ZeebeTest method shouldRunProcessInstanceUntilEnd.
/**
* Just ot verify whether test container works with Zeebe Client.
*/
@Test
public void shouldRunProcessInstanceUntilEnd() {
// given
final ZeebeClient client = ZeebeClient.newClientBuilder().gatewayAddress(zeebeContainer.getExternalGatewayAddress()).usePlaintext().build();
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().endEvent().done();
// when
final DeploymentEvent deploymentEvent = client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
// then
final ProcessInstanceResult processInstanceResult = client.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().withResult().send().join();
assertThat(processInstanceResult.getProcessDefinitionKey()).isEqualTo(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey());
}
use of io.camunda.zeebe.client.api.response.ProcessInstanceResult in project zeebe-process-test by camunda.
the class EngineClientTest method shouldCompleteJob.
@Test
void shouldCompleteJob() {
// given
zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("process").startEvent().serviceTask("task", (task) -> task.zeebeJobType("test")).endEvent().done(), "process.bpmn").send().join();
zeebeClient.newWorker().jobType("test").handler((jobClient, job) -> jobClient.newCompleteCommand(job.getKey()).variables(Map.of("x", 1)).send().join()).open();
// when
final ProcessInstanceResult processInstanceResult = zeebeClient.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().withResult().send().join();
// then
assertThat(processInstanceResult.getVariablesAsMap()).containsEntry("x", 1);
}
use of io.camunda.zeebe.client.api.response.ProcessInstanceResult in project zeebe-process-test by camunda.
the class AbstractWorkerTest method testJobsCanBeProcessedAsynchronouslyByWorker.
@Test
void testJobsCanBeProcessedAsynchronouslyByWorker() throws InterruptedException, TimeoutException {
// given
getClient().newWorker().jobType(ProcessPackLoopingServiceTask.JOB_TYPE).handler((client, job) -> client.newCompleteCommand(job.getKey()).send()).open();
Utilities.deployProcess(getClient(), ProcessPackLoopingServiceTask.RESOURCE_NAME);
final Map<String, Object> variables = Collections.singletonMap(ProcessPackLoopingServiceTask.TOTAL_LOOPS, 3);
// when
final ProcessInstanceResult instanceEvent = Utilities.startProcessInstanceWithResult(getEngine(), getClient(), ProcessPackLoopingServiceTask.PROCESS_ID, variables);
// then
assertThat(instanceEvent).isStarted();
assertThat(instanceEvent).hasPassedElement(ProcessPackLoopingServiceTask.ELEMENT_ID, 3).isCompleted();
}
use of io.camunda.zeebe.client.api.response.ProcessInstanceResult in project zeebe-process-test by camunda.
the class BpmnAssertTest method testAssertThatProcessInstanceResultReturnsProcessInstanceAssert.
@Test
@DisplayName("Should return ProcessInstanceAssert for ProcessInstanceResult")
void testAssertThatProcessInstanceResultReturnsProcessInstanceAssert() {
// given
ProcessInstanceResult result = mock(ProcessInstanceResult.class);
// when
ProcessInstanceAssert assertions = BpmnAssert.assertThat(result);
// then
assertThat(assertions).isInstanceOf(ProcessInstanceAssert.class);
}
use of io.camunda.zeebe.client.api.response.ProcessInstanceResult 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;
}
Aggregations