Search in sources :

Example 1 with Process

use of io.camunda.zeebe.client.api.response.Process 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 2 with Process

use of io.camunda.zeebe.client.api.response.Process in project zeebe by camunda.

the class CreateDeploymentTest method shouldDeployProcessModel.

@Test
public void shouldDeployProcessModel() {
    // given
    final String processId = helper.getBpmnProcessId();
    final String resourceName = processId + ".bpmn";
    final BpmnModelInstance process = Bpmn.createExecutableProcess(processId).startEvent().serviceTask("task", t -> t.zeebeJobType("test")).endEvent().done();
    // when
    final DeploymentEvent result = CLIENT_RULE.getClient().newDeployCommand().addProcessModel(process, resourceName).send().join();
    // then
    assertThat(result.getKey()).isGreaterThan(0);
    assertThat(result.getProcesses()).hasSize(1);
    final Process deployedProcess = result.getProcesses().get(0);
    assertThat(deployedProcess.getBpmnProcessId()).isEqualTo(processId);
    assertThat(deployedProcess.getVersion()).isEqualTo(1);
    assertThat(deployedProcess.getProcessDefinitionKey()).isGreaterThan(0);
    assertThat(deployedProcess.getResourceName()).isEqualTo(resourceName);
}
Also used : Process(io.camunda.zeebe.client.api.response.Process) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.Test)

Example 3 with Process

use of io.camunda.zeebe.client.api.response.Process in project zeebe by camunda.

the class DeployProcessTest method shouldDeployMultipleProcesses.

@Test
public void shouldDeployMultipleProcesses() {
    // given
    final long key = 345L;
    final String filename1 = BPMN_1_FILENAME.substring(1);
    final String filename2 = BPMN_2_FILENAME.substring(1);
    final Process expected1 = new ProcessImpl(1, BPMN_1_PROCESS_ID, 1, filename1);
    final Process expected2 = new ProcessImpl(2, BPMN_2_PROCESS_ID, 1, filename2);
    gatewayService.onDeployProcessRequest(key, deployedProcess(BPMN_1_PROCESS_ID, 1, 1, filename1), deployedProcess(BPMN_2_PROCESS_ID, 1, 2, filename2));
    // when
    final DeploymentEvent response = client.newDeployCommand().addResourceFromClasspath(filename1).addResourceFromClasspath(filename2).send().join();
    // then
    assertThat(response.getKey()).isEqualTo(key);
    final List<Process> processes = response.getProcesses();
    assertThat(processes).containsOnly(expected1, expected2);
    final DeployProcessRequest request = gatewayService.getLastRequest();
    assertThat(request.getProcessesList()).hasSize(2);
    ProcessRequestObject process = request.getProcesses(0);
    assertThat(process.getName()).isEqualTo(filename1);
    assertThat(process.getDefinition().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
    process = request.getProcesses(1);
    assertThat(process.getName()).isEqualTo(filename2);
    assertThat(process.getDefinition().toByteArray()).isEqualTo(getBytes(BPMN_2_FILENAME));
}
Also used : ProcessImpl(io.camunda.zeebe.client.impl.response.ProcessImpl) RecordingGatewayService.deployedProcess(io.camunda.zeebe.client.util.RecordingGatewayService.deployedProcess) Process(io.camunda.zeebe.client.api.response.Process) DeployProcessRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessRequest) ProcessRequestObject(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ProcessRequestObject) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 4 with Process

use of io.camunda.zeebe.client.api.response.Process in project zeebe-process-test by camunda-cloud.

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 5 with Process

use of io.camunda.zeebe.client.api.response.Process in project zeebe-process-test by camunda-cloud.

the class EngineClientTest method shouldDeployProcess.

@Test
void shouldDeployProcess() {
    // given
    // when
    final DeploymentEvent deployment = zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().endEvent().done(), "simpleProcess.bpmn").send().join();
    // then
    assertThat(deployment.getKey()).isPositive();
    assertThat(deployment.getProcesses()).isNotEmpty();
    final Process process = deployment.getProcesses().get(0);
    assertThat(process.getVersion()).isEqualTo(1);
    assertThat(process.getResourceName()).isEqualTo("simpleProcess.bpmn");
    assertThat(process.getBpmnProcessId()).isEqualTo("simpleProcess");
    assertThat(process.getProcessDefinitionKey()).isPositive();
}
Also used : Process(io.camunda.zeebe.client.api.response.Process) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Aggregations

DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)11 Process (io.camunda.zeebe.client.api.response.Process)11 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)2 ZeebeFuture (io.camunda.zeebe.client.api.ZeebeFuture)2 ClientException (io.camunda.zeebe.client.api.command.ClientException)2 ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)2 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)2 BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)2 PartitionBrokerHealth (io.camunda.zeebe.client.api.response.PartitionBrokerHealth)2 PartitionBrokerRole (io.camunda.zeebe.client.api.response.PartitionBrokerRole)2 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)2 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)2 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)2 SetVariablesResponse (io.camunda.zeebe.client.api.response.SetVariablesResponse)2 Topology (io.camunda.zeebe.client.api.response.Topology)2 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)2 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)2 ZeebeTestEngine (io.camunda.zeebe.process.test.api.ZeebeTestEngine)2