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