Search in sources :

Example 26 with WorkflowInstanceEvent

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");
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Example 27 with WorkflowInstanceEvent

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\"}");
}
Also used : TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.zeebe.model.bpmn.Bpmn) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) TopicEventRecorder(io.zeebe.broker.it.util.TopicEventRecorder) RuleChain(org.junit.rules.RuleChain) ClientRule(io.zeebe.broker.it.ClientRule) TopicEventRecorder.wfInstanceEvent(io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent) Duration(java.time.Duration) EmbeddedBrokerRule(io.zeebe.broker.it.EmbeddedBrokerRule) org.junit(org.junit) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) ExpectedException(org.junit.rules.ExpectedException) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 28 with WorkflowInstanceEvent

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")));
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 29 with WorkflowInstanceEvent

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")));
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 30 with WorkflowInstanceEvent

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}");
}
Also used : TasksClient(io.zeebe.client.TasksClient) TaskEvent(io.zeebe.client.event.TaskEvent) RecordingTaskHandler(io.zeebe.broker.it.util.RecordingTaskHandler) TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) WorkflowsClient(io.zeebe.client.WorkflowsClient) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) Bpmn(io.zeebe.model.bpmn.Bpmn) TopicEventRecorder.taskEvent(io.zeebe.broker.it.util.TopicEventRecorder.taskEvent) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Assertions.entry(org.assertj.core.api.Assertions.entry) TopicEventRecorder(io.zeebe.broker.it.util.TopicEventRecorder) RuleChain(org.junit.rules.RuleChain) ClientRule(io.zeebe.broker.it.ClientRule) TopicEventRecorder.wfInstanceEvent(io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent) Duration(java.time.Duration) Map(java.util.Map) EmbeddedBrokerRule(io.zeebe.broker.it.EmbeddedBrokerRule) org.junit(org.junit) ExpectedException(org.junit.rules.ExpectedException) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Aggregations

WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)31 Test (org.junit.Test)14 ClientRule (io.zeebe.broker.it.ClientRule)7 EmbeddedBrokerRule (io.zeebe.broker.it.EmbeddedBrokerRule)7 TopicEventRecorder (io.zeebe.broker.it.util.TopicEventRecorder)7 Bpmn (io.zeebe.model.bpmn.Bpmn)7 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)7 TestUtil.waitUntil (io.zeebe.test.util.TestUtil.waitUntil)7 Duration (java.time.Duration)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 RuleChain (org.junit.rules.RuleChain)7 RecordingTaskHandler (io.zeebe.broker.it.util.RecordingTaskHandler)6 WorkflowsClient (io.zeebe.client.WorkflowsClient)6 TaskEvent (io.zeebe.client.event.TaskEvent)6 ExpectedException (org.junit.rules.ExpectedException)6 TopicEventRecorder.wfInstanceEvent (io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent)5 org.junit (org.junit)5 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)4 DeploymentEvent (io.zeebe.client.event.DeploymentEvent)4 TasksClient (io.zeebe.client.TasksClient)3