use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent 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");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateIncidentIfStandaloneTaskHasNoRetriesLeft.
@Test
public void shouldCreateIncidentIfStandaloneTaskHasNoRetriesLeft() {
// given
createStandaloneTask();
// when
failTaskWithNoRetriesLeft();
// then
final SubscribedEvent failedEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
assertThat(incidentEvent.key()).isGreaterThan(0);
assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.TASK_NO_RETRIES.name()).containsEntry("errorMessage", "No more retries left.").containsEntry("failureEventPosition", failedEvent.position()).containsEntry("bpmnProcessId", "").containsEntry("workflowInstanceKey", -1).containsEntry("activityId", "").containsEntry("activityInstanceKey", -1).containsEntry("taskKey", failedEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateIncidentForOutputMappingAndNoTaskCompletePayload.
@Test
public void shouldCreateIncidentForOutputMappingAndNoTaskCompletePayload() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("failingTask", t -> t.taskType("external").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 shouldResolveIncidentForOutputMappingAndNoTaskCompletePayload.
@Test
public void shouldResolveIncidentForOutputMappingAndNoTaskCompletePayload() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").output("$.testAttr", "$")).done());
final long workflowInstanceKey = testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD);
// when
testClient.completeTaskOfType("external");
// then incident is created
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETING"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
updatePayload(workflowInstanceKey, failureEvent, "{'testAttr':{'obj':'test'}}");
// then
final SubscribedEvent followUpEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETED"));
final byte[] result = (byte[]) followUpEvent.event().get(PROP_PAYLOAD);
assertThat(MSGPACK_MAPPER.readTree(result)).isEqualTo(JSON_MAPPER.readTree("{'obj':'test'}"));
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", "Task was completed without an payload - processing of output mapping failed!").containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "service").containsEntry("activityInstanceKey", followUpEvent.key()).containsEntry("taskKey", -1);
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldDeleteIncidentIfActivityTerminated.
@Test
public void shouldDeleteIncidentIfActivityTerminated() {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
final SubscribedEvent incidentCreatedEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
cancelWorkflowInstance(workflowInstanceKey);
// then
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETED"));
assertThat(incidentEvent.key()).isEqualTo(incidentCreatedEvent.key());
assertThat(incidentEvent.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", incidentEvent.event().get("activityInstanceKey"));
}
Aggregations