use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class ExclusiveGatewayTest method shouldTakeDefaultFlow.
@Test
public void shouldTakeDefaultFlow() {
final WorkflowDefinition workflowDefinition = Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway().sequenceFlow(s -> s.condition("$.foo < 5")).endEvent("a").sequenceFlow(s -> s.defaultFlow()).endEvent("b").done();
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflowDefinition, "workflow.bpmn").execute();
// when
workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("workflow").payload("{\"foo\":7}").execute();
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")));
final WorkflowInstanceEvent endEvent = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("END_EVENT_OCCURRED"));
assertThat(endEvent.getActivityId()).isEqualTo("b");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class UpdatePayloadTest method shouldUpdatePayloadWhenActivityIsActivated.
@Test
public void shouldUpdatePayloadWhenActivityIsActivated() {
// given
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_ACTIVATED")));
final WorkflowInstanceEvent activtyInstance = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_ACTIVATED"));
// when
clientRule.workflows().updatePayload(activtyInstance).payload(PAYLOAD).execute();
// then
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("PAYLOAD_UPDATED")));
clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopic()).taskType("task-1").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler((c, t) -> c.complete(t).payload("{\"result\": \"ok\"}").execute()).open();
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")));
final WorkflowInstanceEvent wfEvent = eventRecorder.getWorkflowInstanceEvents(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")).get(0);
assertThat(wfEvent.getPayload()).isEqualTo("{\"foo\":\"bar\",\"result\":\"ok\"}");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessByKey.
@Test
public void shouldCreateBpmnProcessByKey() {
final WorkflowsClient workflowService = clientRule.workflows();
waitUntil(() -> eventRecorder.hasWorkflowEvent(wfEvent("CREATED")));
final long workflowKey = eventRecorder.getSingleWorkflowEvent(wfEvent("CREATED")).getMetadata().getKey();
// when
final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).workflowKey(workflowKey).execute();
// then
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
assertThat(workflowInstance.getVersion()).isEqualTo(1);
assertThat(workflowInstance.getWorkflowKey()).isEqualTo(workflowKey);
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CREATED")));
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessById.
@Test
public void shouldCreateBpmnProcessById() {
final WorkflowsClient workflowService = clientRule.workflows();
// when
final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("anId").execute();
// then instance of latest of workflow version is created
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
assertThat(workflowInstance.getVersion()).isEqualTo(2);
assertThat(workflowInstance.getWorkflowInstanceKey()).isGreaterThan(0);
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CREATED")));
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class ServiceTaskTest method shouldMapPayloadFromTask.
@Test
public void shouldMapPayloadFromTask() {
// given
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", t -> t.taskType("foo").output("$.foo", "$.bar")).endEvent("end").done(), "workflow.bpmn").execute();
workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
// when
taskClient.newTaskSubscription(clientRule.getDefaultTopic()).taskType("foo").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler((c, t) -> c.complete(t).payload("{\"foo\":2}").execute()).open();
// then
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED")));
final WorkflowInstanceEvent workflowEvent = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED"));
assertThat(workflowEvent.getPayload()).isEqualTo("{\"bar\":2}");
}
Aggregations