use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class WorkflowTaskIOMappingTest method shouldNotDeployIfInputMappingMapsRootAndOtherObject.
@Test
public void shouldNotDeployIfInputMappingMapsRootAndOtherObject() throws Throwable {
// given
final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").input(NODE_STRING_PATH, NODE_ROOT_PATH).input(NODE_JSON_OBJECT_PATH, NODE_JSON_OBJECT_PATH)).endEvent().done();
// when
final ExecuteCommandResponse response = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
// then
assertThat(response.getEvent().get(PROP_STATE)).isEqualTo("REJECTED");
assertThat(response.getEvent().get(PROP_ERRO_MSG).toString()).contains("Target mapping: root mapping is not allowed because it would override other mapping.");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class IncidentTest method shouldFailToResolveIncident.
@Test
public void shouldFailToResolveIncident() throws Exception {
// given
final WorkflowDefinition modelInstance = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("failingTask", t -> t.taskType("external").input("$.foo", "$.foo").input("$.bar", "$.bar")).done();
testClient.deploy(modelInstance);
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_READY"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
assertThat(incidentEvent.event()).containsEntry("errorMessage", "No data found for query $.foo.");
// when
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// then
final SubscribedEvent resolveFailedEvent = testClient.receiveSingleEvent(incidentEvents("RESOLVE_FAILED"));
assertThat(resolveFailedEvent.key()).isEqualTo(incidentEvent.key());
assertThat(resolveFailedEvent.event()).containsEntry("errorType", ErrorType.IO_MAPPING_ERROR.name()).containsEntry("errorMessage", "No data found for query $.bar.").containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateMultipleWorkflowInstancesForDifferentVersions.
@Test
public void shouldCreateMultipleWorkflowInstancesForDifferentVersions() {
// given
final WorkflowDefinition workflow = Bpmn.createExecutableWorkflow("process").startEvent("start").serviceTask("task", task -> task.taskType("test").taskRetries(3).taskHeader("foo", "bar")).endEvent("end").done();
testClient.deploy(workflow);
final long workflowInstance1 = testClient.createWorkflowInstance("process");
testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
// when
testClient.deploy(workflow);
final long workflowInstance2 = testClient.createWorkflowInstance("process");
// then
final List<SubscribedEvent> workflowInstanceEvents = testClient.receiveEvents(workflowInstanceEvents("ACTIVITY_ACTIVATED")).limit(2).collect(Collectors.toList());
assertThat(workflowInstanceEvents.get(0).event()).containsEntry("workflowInstanceKey", workflowInstance1).containsEntry("version", 1);
assertThat(workflowInstanceEvents.get(1).event()).containsEntry("workflowInstanceKey", workflowInstance2).containsEntry("version", 2);
final long createdTasks = testClient.receiveEvents(taskEvents("CREATED")).limit(2).count();
assertThat(createdTasks).isEqualTo(2);
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class WorkflowInstanceFunctionalTest method shouldConsumeTokenIfActivityHasNoOutgoingSequenceflow.
@Test
public void shouldConsumeTokenIfActivityHasNoOutgoingSequenceflow() {
// given
final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("foo", t -> t.taskType("bar")).done();
testClient.deploy(definition);
// when
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
testClient.completeTaskOfType("bar");
// then
final SubscribedEvent event = testClient.receiveSingleEvent(workflowInstanceEvents("WORKFLOW_INSTANCE_COMPLETED"));
assertThat(event.key()).isEqualTo(workflowInstanceKey);
assertThat(event.event()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "process").containsEntry(PROP_WORKFLOW_VERSION, 1).containsEntry(PROP_WORKFLOW_INSTANCE_KEY, workflowInstanceKey).containsEntry(PROP_WORKFLOW_ACTIVITY_ID, "");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class WorkflowInstanceFunctionalTest method testWorkflowInstanceStatesWithExclusiveGateway.
@Test
public void testWorkflowInstanceStatesWithExclusiveGateway() {
// given
final WorkflowDefinition workflowDefinition = Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway("xor").sequenceFlow("s1", s -> s.condition("$.foo < 5")).endEvent("a").sequenceFlow("s2", s -> s.defaultFlow()).endEvent("b").done();
testClient.deploy(workflowDefinition);
// when
testClient.createWorkflowInstance("workflow", MsgPackUtil.asMsgPack("foo", 4));
// then
final List<SubscribedEvent> workflowEvents = testClient.receiveEvents(workflowInstanceEvents()).limit(8).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", "GATEWAY_ACTIVATED", "SEQUENCE_FLOW_TAKEN", "END_EVENT_OCCURRED", "WORKFLOW_INSTANCE_COMPLETED");
}
Aggregations