use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessByIdAndVersion.
@Test
public void shouldCreateBpmnProcessByIdAndVersion() {
final WorkflowsClient workflowService = clientRule.workflows();
// when
final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("anId").version(1).execute();
// then instance is created of first workflow version
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
assertThat(workflowInstance.getVersion()).isEqualTo(1);
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 shouldModifyPayloadInTask.
@Test
public void shouldModifyPayloadInTask() {
// given
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", t -> t.taskType("foo").input("$.foo", "$.foo").output("$.foo", "$.foo")).endEvent("end").done(), "workflow.bpmn").execute();
workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("process").payload("{\"foo\":1}").execute();
// when
taskClient.newTaskSubscription(clientRule.getDefaultTopic()).taskType("foo").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler((c, t) -> {
final String modifiedPayload = t.getPayload().replaceAll("1", "2");
c.complete(t).payload(modifiedPayload).execute();
}).open();
// then
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED")));
final WorkflowInstanceEvent workflowEvent = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED"));
assertThat(workflowEvent.getPayload()).isEqualTo("{\"foo\":2}");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class ServiceTaskTest method shouldLockServiceTask.
@Test
public void shouldLockServiceTask() {
// given
final Map<String, String> taskHeaders = new HashMap<>();
taskHeaders.put("cust1", "a");
taskHeaders.put("cust2", "b");
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", t -> t.taskType("foo").taskHeader("cust1", "a").taskHeader("cust2", "b")).endEvent("end").done(), "workflow.bpmn").execute();
final WorkflowInstanceEvent workflowInstance = workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
// when
final RecordingTaskHandler recordingTaskHandler = new RecordingTaskHandler();
taskClient.newTaskSubscription(clientRule.getDefaultTopic()).taskType("foo").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler(recordingTaskHandler).open();
// then
waitUntil(() -> recordingTaskHandler.getHandledTasks().size() >= 1);
assertThat(recordingTaskHandler.getHandledTasks()).hasSize(1);
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(e -> "ACTIVITY_ACTIVATED".equals(e.getState()));
final TaskEvent taskLockedEvent = recordingTaskHandler.getHandledTasks().get(0);
assertThat(taskLockedEvent.getHeaders()).containsOnly(entry("bpmnProcessId", "process"), entry("workflowDefinitionVersion", 1), entry("workflowKey", workflowInstance.getWorkflowKey()), entry("workflowInstanceKey", workflowInstance.getWorkflowInstanceKey()), entry("activityId", "task"), entry("activityInstanceKey", activityInstance.getMetadata().getKey()));
assertThat(taskLockedEvent.getCustomHeaders()).containsOnly(entry("cust1", "a"), entry("cust2", "b"));
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class ServiceTaskTest method shouldCreateWorkflowInstanceWithServiceTask.
@Test
public void shouldCreateWorkflowInstanceWithServiceTask() {
// given
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", t -> t.taskType("foo")).endEvent("end").done(), "workflow.bpmn").execute();
// when
final WorkflowInstanceEvent workflowInstance = workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
// then
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 YamlWorkflowTest method shouldCreateWorkflowInstance.
@Test
public void shouldCreateWorkflowInstance() {
// given
workflowClient.deploy(clientRule.getDefaultTopic()).addResourceFromClasspath("workflows/simple-workflow.yaml").execute();
// when
final WorkflowInstanceEvent workflowInstance = workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("yaml-workflow").execute();
// then
assertThat(workflowInstance.getWorkflowInstanceKey()).isGreaterThan(0);
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CREATED")));
}
Aggregations