Search in sources :

Example 1 with ProcessInstanceAssert

use of io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert in project micronaut-zeebe-client by camunda-community-hub.

the class ProcessTest method workerShouldProcessWork.

@Test
void workerShouldProcessWork() {
    // Deploy process model
    DeploymentEvent deploymentEvent = client.newDeployCommand().addResourceFromClasspath("bpmn/say_hello.bpmn").send().join();
    BpmnAssert.assertThat(deploymentEvent);
    // Start process instance
    ProcessInstanceEvent event = client.newCreateInstanceCommand().bpmnProcessId("Process_SayHello").latestVersion().send().join();
    engine.waitForIdleState();
    // Verify that process has started
    ProcessInstanceAssert processInstanceAssertions = BpmnAssert.assertThat(event);
    processInstanceAssertions.hasPassedElement("start");
    processInstanceAssertions.isWaitingAtElement("say_hello");
    // Fetch job: say-hello
    ActivateJobsResponse response = client.newActivateJobsCommand().jobType("say-hello").maxJobsToActivate(1).send().join();
    // Complete job: say-hello
    ActivatedJob activatedJob = response.getJobs().get(0);
    client.newCompleteCommand(activatedJob.getKey()).send().join();
    engine.waitForIdleState();
    // Fetch job: say-goodbye
    response = client.newActivateJobsCommand().jobType("say-goodbye").maxJobsToActivate(1).send().join();
    // Complete job: say-goodbye
    activatedJob = response.getJobs().get(0);
    client.newCompleteCommand(activatedJob.getKey()).send().join();
    engine.waitForIdleState();
    // Verify completed
    engine.waitForIdleState();
    processInstanceAssertions.isCompleted();
}
Also used : ActivatedJob(io.camunda.zeebe.client.api.response.ActivatedJob) ProcessInstanceAssert(io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert) ActivateJobsResponse(io.camunda.zeebe.client.api.response.ActivateJobsResponse) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test) ZeebeProcessTest(io.camunda.zeebe.process.test.extensions.ZeebeProcessTest)

Aggregations

ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)1 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)1 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)1 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)1 ProcessInstanceAssert (io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert)1 ZeebeProcessTest (io.camunda.zeebe.process.test.extensions.ZeebeProcessTest)1 Test (org.junit.jupiter.api.Test)1