use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class ExclusiveGatewayTest method shouldEvaluateConditionOnFlow.
@Test
public void shouldEvaluateConditionOnFlow() {
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\":3}").execute();
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")));
final WorkflowInstanceEvent endEvent = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("END_EVENT_OCCURRED"));
assertThat(endEvent.getActivityId()).isEqualTo("a");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class ExclusiveGatewayTest method shouldExecuteWorkflowWithLoop.
@Test
public void shouldExecuteWorkflowWithLoop() {
// given
final WorkflowDefinition workflowDefinition = Bpmn.createExecutableWorkflow("workflow").startEvent().serviceTask("inc", t -> t.taskType("inc")).exclusiveGateway().sequenceFlow(s -> s.condition("$.count > 5")).endEvent().sequenceFlow("back", s -> s.defaultFlow()).joinWith("inc").done();
workflowClient.deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflowDefinition, "workflow.bpmn").execute();
// when
workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("workflow").payload("{\"count\":0}").execute();
taskClient.newTaskSubscription(clientRule.getDefaultTopic()).lockTime(Duration.ofSeconds(5)).lockOwner("test").taskType("inc").handler((c, task) -> {
final String payload = task.getPayload();
final int i = payload.indexOf(":");
final int count = Integer.valueOf(payload.substring(i + 1, i + 2));
c.complete(task).payload("{\"count\":" + (count + 1) + "}").execute();
}).open();
// then
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")));
final WorkflowInstanceEvent event = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED"));
assertThat(event.getPayload()).isEqualTo("{\"count\":6}");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class IncidentTopicSubscriptionTest method setUp.
@Before
public void setUp() {
this.client = clientRule.getClient();
final WorkflowDefinition workflow = Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", t -> t.taskType("test").input("$.foo", "$.foo")).endEvent("end").done();
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflow, "workflow.bpmn").execute();
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class WorkflowInstanceTopicSubscriptionTest method setUp.
@Before
public void setUp() {
this.client = clientRule.getClient();
final WorkflowDefinition workflow = Bpmn.createExecutableWorkflow("process").startEvent("a").endEvent("b").done();
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflow, "workflow.bpmn").execute();
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldDeployMultipleResources.
@SuppressWarnings("unchecked")
@Test
public void shouldDeployMultipleResources() {
// given
stubDeploymentRequest();
final WorkflowDefinition definition1 = Bpmn.createExecutableWorkflow("model1").startEvent().done();
final WorkflowDefinition definition2 = Bpmn.createExecutableWorkflow("model2").startEvent().done();
// when
clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addWorkflowModel(definition1, "model1.bpmn").addWorkflowModel(definition2, "model2.bpmn").execute();
// then
assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
assertThat(resources).hasSize(2);
assertThat(resources).extracting("resourceName").contains("model1.bpmn", "model2.bpmn");
assertThat(resources).extracting("resourceType").contains("BPMN_XML", "BPMN_XML");
assertThat(resources).extracting("resource").contains(Bpmn.convertToString(definition1).getBytes(UTF_8), Bpmn.convertToString(definition2).getBytes(UTF_8));
}
Aggregations