Search in sources :

Example 1 with ProcessInstanceResult

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());
}
Also used : ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessInstanceResult

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);
}
Also used : PartitionBrokerRole(io.camunda.zeebe.client.api.response.PartitionBrokerRole) TimerIntent(io.camunda.zeebe.protocol.record.intent.TimerIntent) BeforeEach(org.junit.jupiter.api.BeforeEach) RecordType(io.camunda.zeebe.protocol.record.RecordType) ClientException(io.camunda.zeebe.client.api.command.ClientException) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JobRecordValue(io.camunda.zeebe.protocol.record.value.JobRecordValue) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) TimerRecordValue(io.camunda.zeebe.protocol.record.value.TimerRecordValue) ZeebeTestEngine(io.camunda.zeebe.process.test.api.ZeebeTestEngine) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Record(io.camunda.zeebe.protocol.record.Record) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) Duration(java.time.Duration) Map(java.util.Map) ActivatedJob(io.camunda.zeebe.client.api.response.ActivatedJob) Process(io.camunda.zeebe.client.api.response.Process) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) StreamSupport(java.util.stream.StreamSupport) PartitionBrokerHealth(io.camunda.zeebe.client.api.response.PartitionBrokerHealth) VersionUtil(io.camunda.zeebe.util.VersionUtil) Topology(io.camunda.zeebe.client.api.response.Topology) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) ZeebeFuture(io.camunda.zeebe.client.api.ZeebeFuture) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ProcessInstanceRecordValue(io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) SetVariablesResponse(io.camunda.zeebe.client.api.response.SetVariablesResponse) Optional(java.util.Optional) ActivateJobsResponse(io.camunda.zeebe.client.api.response.ActivateJobsResponse) Awaitility(org.awaitility.Awaitility) RecordStream(io.camunda.zeebe.process.test.filters.RecordStream) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessInstanceResult

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();
}
Also used : Test(org.junit.jupiter.api.Test) BpmnAssert.assertThat(io.camunda.zeebe.process.test.assertions.BpmnAssert.assertThat) Map(java.util.Map) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) TimeoutException(java.util.concurrent.TimeoutException) ZeebeTestEngine(io.camunda.zeebe.process.test.api.ZeebeTestEngine) Utilities(io.camunda.zeebe.process.test.qa.util.Utilities) Collections(java.util.Collections) ProcessPackLoopingServiceTask(io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessInstanceResult

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);
}
Also used : ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with ProcessInstanceResult

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;
}
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)

Aggregations

ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)40 Test (org.junit.Test)21 Test (org.junit.jupiter.api.Test)11 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)9 CreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest)9 Map (java.util.Map)7 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)6 ClientTest (io.camunda.zeebe.client.util.ClientTest)6 ZeebeFuture (io.camunda.zeebe.client.api.ZeebeFuture)5 ClientException (io.camunda.zeebe.client.api.command.ClientException)5 ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)5 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)5 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)5 JobIntent (io.camunda.zeebe.protocol.record.intent.JobIntent)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)5 ZeebeTestEngine (io.camunda.zeebe.process.test.api.ZeebeTestEngine)4 EmbeddedBrokerRule (io.camunda.zeebe.broker.test.EmbeddedBrokerRule)3 ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)3 GrpcClientRule (io.camunda.zeebe.it.util.GrpcClientRule)3