use of io.zeebe.client.event.WorkflowInstanceEvent 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.client.event.WorkflowInstanceEvent 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.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRestartTest method shouldResolveFailedIncidentAfterRestart.
@Test
public void shouldResolveFailedIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
clientRule.workflows().updatePayload(activityInstance).payload("{\"x\":\"y\"}").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVE_FAILED")));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRestartTest method shouldResolveIncidentAfterRestart.
@Test
public void shouldResolveIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRestartTest method shouldDeployNewWorkflowVersionAfterRestart.
@Test
// FIXME: https://github.com/zeebe-io/zeebe/issues/567
@Category(io.zeebe.UnstableTest.class)
public void shouldDeployNewWorkflowVersionAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// when
restartBroker();
final DeploymentEvent deploymentResult = clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// then
assertThat(deploymentResult.getDeployedWorkflows().get(0).getVersion()).isEqualTo(2);
final WorkflowInstanceEvent workflowInstanceV1 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").version(1).execute();
final WorkflowInstanceEvent workflowInstanceV2 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").latestVersion().execute();
// then
assertThat(workflowInstanceV1.getVersion()).isEqualTo(1);
assertThat(workflowInstanceV2.getVersion()).isEqualTo(2);
}
Aggregations