Search in sources :

Example 1 with ProcessInstanceEvent

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

the class EngineClientTest method shouldUpdateVariablesOnProcessInstance.

@Test
void shouldUpdateVariablesOnProcessInstance() {
    // given
    zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().serviceTask("task", task -> task.zeebeJobType("jobType")).endEvent().done(), "simpleProcess.bpmn").send().join();
    final ProcessInstanceEvent processInstance = zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
    // when
    final SetVariablesResponse variablesResponse = zeebeClient.newSetVariablesCommand(processInstance.getProcessInstanceKey()).variables(Map.of("test123", 234)).local(true).send().join();
    // then
    assertThat(variablesResponse).isNotNull();
    assertThat(variablesResponse.getKey()).isPositive();
}
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) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) SetVariablesResponse(io.camunda.zeebe.client.api.response.SetVariablesResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessInstanceEvent

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

the class EngineClientTest method shouldCreateProcessInstance.

@Test
void shouldCreateProcessInstance() {
    // given
    final DeploymentEvent deployment = zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().endEvent().done(), "simpleProcess.bpmn").send().join();
    // when
    final ProcessInstanceEvent processInstance = zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
    // then
    assertThat(processInstance.getProcessInstanceKey()).isPositive();
    assertThat(processInstance.getBpmnProcessId()).isEqualTo("simpleProcess");
    assertThat(processInstance.getProcessDefinitionKey()).isEqualTo(deployment.getProcesses().get(0).getProcessDefinitionKey());
    assertThat(processInstance.getVersion()).isEqualTo(1);
}
Also used : ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessInstanceEvent

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

the class AbstractProcessInstanceInspectionsTest method testStartedByProcessInstanceWithProcessId_wrongId.

@Test
void testStartedByProcessInstanceWithProcessId_wrongId() throws InterruptedException, TimeoutException {
    // given
    Utilities.deployProcesses(getClient(), ProcessPackCallActivity.RESOURCE_NAME, ProcessPackCallActivity.CALLED_RESOURCE_NAME);
    final ProcessInstanceEvent instanceEvent = Utilities.startProcessInstance(getEngine(), getClient(), ProcessPackCallActivity.PROCESS_ID);
    // when
    final Optional<InspectedProcessInstance> firstProcessInstance = InspectionUtility.findProcessInstances().withParentProcessInstanceKey(instanceEvent.getProcessInstanceKey()).withBpmnProcessId("wrongId").findFirstProcessInstance();
    // then
    Assertions.assertThat(firstProcessInstance).isEmpty();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessInstanceEvent

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

the class AbstractProcessInstanceInspectionsTest method testStartedByProcessInstanceWithProcessId.

@Test
void testStartedByProcessInstanceWithProcessId() throws InterruptedException, TimeoutException {
    // given
    Utilities.deployProcesses(getClient(), ProcessPackCallActivity.RESOURCE_NAME, ProcessPackCallActivity.CALLED_RESOURCE_NAME);
    final ProcessInstanceEvent instanceEvent = Utilities.startProcessInstance(getEngine(), getClient(), ProcessPackCallActivity.PROCESS_ID);
    // when
    final Optional<InspectedProcessInstance> firstProcessInstance = InspectionUtility.findProcessInstances().withParentProcessInstanceKey(instanceEvent.getProcessInstanceKey()).withBpmnProcessId(ProcessPackCallActivity.CALLED_PROCESS_ID).findFirstProcessInstance();
    // then
    Assertions.assertThat(firstProcessInstance).isNotEmpty();
    BpmnAssert.assertThat(firstProcessInstance.get()).isCompleted();
    BpmnAssert.assertThat(instanceEvent).hasPassedElement(ProcessPackCallActivity.CALL_ACTIVITY_ID).isCompleted();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessInstanceEvent

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

the class Utilities method startProcessInstance.

public static ProcessInstanceEvent startProcessInstance(final ZeebeTestEngine engine, final ZeebeClient client, final String processId, final Map<String, Object> variables) throws InterruptedException, TimeoutException {
    final ProcessInstanceEvent instanceEvent = client.newCreateInstanceCommand().bpmnProcessId(processId).latestVersion().variables(variables).send().join();
    waitForIdleState(engine, Duration.ofSeconds(1));
    return instanceEvent;
}
Also used : ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent)

Aggregations

ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)78 Test (org.junit.Test)33 Test (org.junit.jupiter.api.Test)29 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)19 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)17 ZeebeTestEngine (io.camunda.zeebe.process.test.api.ZeebeTestEngine)10 Map (java.util.Map)10 ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)9 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)9 ZeebeFuture (io.camunda.zeebe.client.api.ZeebeFuture)8 ClientException (io.camunda.zeebe.client.api.command.ClientException)8 BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)8 PartitionBrokerHealth (io.camunda.zeebe.client.api.response.PartitionBrokerHealth)8 PartitionBrokerRole (io.camunda.zeebe.client.api.response.PartitionBrokerRole)8 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)8 Process (io.camunda.zeebe.client.api.response.Process)8 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)8 SetVariablesResponse (io.camunda.zeebe.client.api.response.SetVariablesResponse)8 Topology (io.camunda.zeebe.client.api.response.Topology)8 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)8