Search in sources :

Example 21 with WorkflowDefinition

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

Example 22 with WorkflowDefinition

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) MsgPackUtil.encodeMsgPack(io.zeebe.broker.test.MsgPackUtil.encodeMsgPack) MSGPACK_PAYLOAD(io.zeebe.broker.test.MsgPackUtil.MSGPACK_PAYLOAD) TestTopicClient(io.zeebe.test.broker.protocol.clientapi.TestTopicClient) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MsgPackHelper(io.zeebe.msgpack.spec.MsgPackHelper) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) MsgPackUtil.asMsgPack(io.zeebe.test.util.MsgPackUtil.asMsgPack) TestTopicClient.taskEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.taskEvents) ErrorType(io.zeebe.broker.incident.data.ErrorType) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) Before(org.junit.Before) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) IOException(java.io.IOException) Test(org.junit.Test) RuleChain(org.junit.rules.RuleChain) TestTopicClient.incidentEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.incidentEvents) JSON_MAPPER(io.zeebe.broker.test.MsgPackUtil.JSON_MAPPER) Rule(org.junit.Rule) MSGPACK_MAPPER(io.zeebe.broker.test.MsgPackUtil.MSGPACK_MAPPER) EventType(io.zeebe.protocol.clientapi.EventType) BufferUtil.wrapString(io.zeebe.util.buffer.BufferUtil.wrapString) MutableDirectBuffer(org.agrona.MutableDirectBuffer) TestTopicClient.workflowInstanceEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowInstanceEvents) WorkflowInstanceState(io.zeebe.broker.workflow.data.WorkflowInstanceState) ClientApiRule(io.zeebe.test.broker.protocol.clientapi.ClientApiRule) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 23 with WorkflowDefinition

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

Example 24 with WorkflowDefinition

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, "");
}
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 25 with WorkflowDefinition

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");
}
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)

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