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