Search in sources :

Example 26 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class WorkflowInstanceFunctionalTest method testWorkflowInstanceStatesWithServiceTask.

@Test
public void testWorkflowInstanceStatesWithServiceTask() {
    // given
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent("a").serviceTask("b", t -> t.taskType("foo")).endEvent("c").done();
    testClient.deploy(definition);
    testClient.createWorkflowInstance("process");
    // when
    testClient.completeTaskOfType("foo");
    // then
    final List<SubscribedEvent> workflowEvents = testClient.receiveEvents(workflowInstanceEvents()).limit(11).collect(Collectors.toList());
    assertThat(workflowEvents).extracting(e -> e.event().get(PROP_STATE)).containsExactly("CREATE_WORKFLOW_INSTANCE", "WORKFLOW_INSTANCE_CREATED", "START_EVENT_OCCURRED", "SEQUENCE_FLOW_TAKEN", "ACTIVITY_READY", "ACTIVITY_ACTIVATED", "ACTIVITY_COMPLETING", "ACTIVITY_COMPLETED", "SEQUENCE_FLOW_TAKEN", "END_EVENT_OCCURRED", "WORKFLOW_INSTANCE_COMPLETED");
}
Also used : java.util(java.util) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) MsgPackUtil.asMsgPack(io.zeebe.test.util.MsgPackUtil.asMsgPack) Collectors(java.util.stream.Collectors) File(java.io.File) TestTopicClient.taskEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.taskEvents) RuleChain(org.junit.rules.RuleChain) MsgPackUtil(io.zeebe.test.util.MsgPackUtil) ResourceType(io.zeebe.broker.workflow.data.ResourceType) io.zeebe.test.broker.protocol.clientapi(io.zeebe.test.broker.protocol.clientapi) EventType(io.zeebe.protocol.clientapi.EventType) WorkflowInstanceEvent(io.zeebe.broker.workflow.data.WorkflowInstanceEvent) Files(org.assertj.core.util.Files) org.junit(org.junit) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) TestTopicClient.workflowInstanceEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowInstanceEvents) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Example 27 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition 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)

Aggregations

WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)27 Bpmn (io.zeebe.model.bpmn.Bpmn)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 RuleChain (org.junit.rules.RuleChain)8 EmbeddedBrokerRule (io.zeebe.broker.test.EmbeddedBrokerRule)7 EventType (io.zeebe.protocol.clientapi.EventType)7 ResourceType (io.zeebe.broker.workflow.data.ResourceType)6 Protocol (io.zeebe.protocol.Protocol)6 ExecuteCommandResponse (io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)6 File (java.io.File)6 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)6 Files (org.assertj.core.util.Files)6 Test (org.junit.Test)6 org.junit (org.junit)5 WorkflowInstanceEvent (io.zeebe.broker.workflow.data.WorkflowInstanceEvent)4 TestTopicClient.taskEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.taskEvents)4 TestTopicClient.workflowInstanceEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowInstanceEvents)4 MsgPackUtil.asMsgPack (io.zeebe.test.util.MsgPackUtil.asMsgPack)4 WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)3 io.zeebe.test.broker.protocol.clientapi (io.zeebe.test.broker.protocol.clientapi)3