Search in sources :

Example 1 with ErrorType

use of io.zeebe.broker.incident.data.ErrorType in project zeebe by zeebe-io.

the class IncidentTest method shouldCreateIncidentIfConditionFailsToEvaluate.

@Test
public void shouldCreateIncidentIfConditionFailsToEvaluate() {
    // given
    testClient.deploy(Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway("xor").sequenceFlow("s1", s -> s.condition("$.foo < 5")).endEvent().sequenceFlow("s2", s -> s.condition("$.foo >= 5 && $.foo < 10")).endEvent().done());
    // when
    testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar"));
    // then incident is created
    final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATE"));
    assertThat(incidentEvent.key()).isGreaterThan(0);
    assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.CONDITION_ERROR.name()).containsEntry("errorMessage", "Cannot compare values of different types: STRING and INTEGER").containsEntry("activityId", "xor");
}
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) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 2 with ErrorType

use of io.zeebe.broker.incident.data.ErrorType in project zeebe by zeebe-io.

the class IncidentTest method shouldCreateIncidentIfExclusiveGatewayHasNoMatchingCondition.

@Test
public void shouldCreateIncidentIfExclusiveGatewayHasNoMatchingCondition() {
    // given
    testClient.deploy(Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway("xor").sequenceFlow("s1", s -> s.condition("$.foo < 5")).endEvent().sequenceFlow("s2", s -> s.condition("$.foo >= 5 && $.foo < 10")).endEvent().done());
    // when
    testClient.createWorkflowInstance("workflow", asMsgPack("foo", 12));
    // then incident is created
    final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATE"));
    assertThat(incidentEvent.key()).isGreaterThan(0);
    assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.CONDITION_ERROR.name()).containsEntry("errorMessage", "All conditions evaluated to false and no default flow is set.").containsEntry("activityId", "xor");
}
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) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 3 with ErrorType

use of io.zeebe.broker.incident.data.ErrorType 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)

Aggregations

ErrorType (io.zeebe.broker.incident.data.ErrorType)3 EmbeddedBrokerRule (io.zeebe.broker.test.EmbeddedBrokerRule)3 JSON_MAPPER (io.zeebe.broker.test.MsgPackUtil.JSON_MAPPER)3 MSGPACK_MAPPER (io.zeebe.broker.test.MsgPackUtil.MSGPACK_MAPPER)3 MSGPACK_PAYLOAD (io.zeebe.broker.test.MsgPackUtil.MSGPACK_PAYLOAD)3 MsgPackUtil.encodeMsgPack (io.zeebe.broker.test.MsgPackUtil.encodeMsgPack)3 WorkflowInstanceState (io.zeebe.broker.workflow.data.WorkflowInstanceState)3 Bpmn (io.zeebe.model.bpmn.Bpmn)3 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)3 MsgPackHelper (io.zeebe.msgpack.spec.MsgPackHelper)3 EventType (io.zeebe.protocol.clientapi.EventType)3 ClientApiRule (io.zeebe.test.broker.protocol.clientapi.ClientApiRule)3 ExecuteCommandResponse (io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)3 SubscribedEvent (io.zeebe.test.broker.protocol.clientapi.SubscribedEvent)3 TestTopicClient (io.zeebe.test.broker.protocol.clientapi.TestTopicClient)3 TestTopicClient.incidentEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.incidentEvents)3 TestTopicClient.taskEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.taskEvents)3 TestTopicClient.workflowInstanceEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowInstanceEvents)3 MsgPackUtil.asMsgPack (io.zeebe.test.util.MsgPackUtil.asMsgPack)3 BufferUtil.wrapString (io.zeebe.util.buffer.BufferUtil.wrapString)3