use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent 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");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldDeleteIncidentIfTaskRetriesIncreased.
@Test
public void shouldDeleteIncidentIfTaskRetriesIncreased() {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD);
failTaskWithNoRetriesLeft();
// when
updateTaskRetries();
// then
final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
final SubscribedEvent activityEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETE"));
assertThat(incidentEvent.key()).isGreaterThan(0);
assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.TASK_NO_RETRIES.name()).containsEntry("errorMessage", "No more retries left.").containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask").containsEntry("activityInstanceKey", activityEvent.key()).containsEntry("taskKey", taskEvent.key());
incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETED"));
assertThat(incidentEvent.key()).isGreaterThan(0);
assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.TASK_NO_RETRIES.name()).containsEntry("errorMessage", "No more retries left.").containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask").containsEntry("activityInstanceKey", activityEvent.key()).containsEntry("taskKey", taskEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForFailedConditionAfterUploadingWrongPayload.
@Test
public void shouldResolveIncidentForFailedConditionAfterUploadingWrongPayload() throws Throwable {
// 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
final long workflowInstanceKey = testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar"));
// then incident is created
testClient.receiveSingleEvent(incidentEvents("CREATED"));
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("GATEWAY_ACTIVATED"));
// when not correct payload is used
updatePayload(workflowInstanceKey, failureEvent.key(), asMsgPack("foo", 10).byteArray());
// then
testClient.receiveSingleEvent(incidentEvents("RESOLVE"));
testClient.receiveSingleEvent(workflowInstanceEvents("GATEWAY_ACTIVATED"));
testClient.receiveSingleEvent(incidentEvents("RESOLVE_FAILED"));
// when correct payload is used
updatePayload(workflowInstanceKey, failureEvent.key(), asMsgPack("foo", 7).byteArray());
// then
testClient.receiveSingleEvent(incidentEvents("RESOLVE"));
testClient.receiveSingleEvent(workflowInstanceEvents("GATEWAY_ACTIVATED"));
testClient.receiveSingleEvent(workflowInstanceEvents("SEQUENCE_FLOW_TAKEN"));
testClient.receiveSingleEvent(incidentEvents("RESOLVED"));
testClient.receiveSingleEvent(workflowInstanceEvents("END_EVENT_OCCURRED"));
testClient.receiveSingleEvent(workflowInstanceEvents("WORKFLOW_INSTANCE_COMPLETED"));
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateIncidentForInAndOutputMappingAndNoTaskCompletePayload.
@Test
public void shouldCreateIncidentForInAndOutputMappingAndNoTaskCompletePayload() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("failingTask", t -> t.taskType("external").input("$.jsonObject", "$").output("$.testAttr", "$")).done());
testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD);
// when
testClient.completeTaskOfType("external");
// then incident is created
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATE"));
assertThat(incidentEvent.key()).isGreaterThan(0);
assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.IO_MAPPING_ERROR.name()).containsEntry("errorMessage", "Task was completed without an payload - processing of output mapping failed!");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForInputMappingFailure.
@Test
public void shouldResolveIncidentForInputMappingFailure() throws Exception {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_READY"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// then
final SubscribedEvent followUpEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
assertThat(followUpEvent.event()).containsEntry("payload", PAYLOAD);
final SubscribedEvent incidentResolvedEvent = testClient.receiveSingleEvent(incidentEvents("RESOLVED"));
assertThat(incidentResolvedEvent.key()).isEqualTo(incidentEvent.key());
assertThat(incidentResolvedEvent.event()).containsEntry("errorType", ErrorType.IO_MAPPING_ERROR.name()).containsEntry("errorMessage", "No data found for query $.foo.").containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask").containsEntry("activityInstanceKey", followUpEvent.key()).containsEntry("taskKey", -1);
}
Aggregations