use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForOutputMappingFailure.
@Test
public void shouldResolveIncidentForOutputMappingFailure() throws Exception {
// given
testClient.deploy(WORKFLOW_OUTPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
testClient.completeTaskOfType("test", MSGPACK_PAYLOAD);
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETING"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// then
final SubscribedEvent followUpEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETED"));
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);
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldProcessIncidentsAfterMultipleTerminations.
@Test
public void shouldProcessIncidentsAfterMultipleTerminations() {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
// create and cancel instance with incident
long workflowInstanceKey = testClient.createWorkflowInstance("process");
cancelWorkflowInstance(workflowInstanceKey);
// create and cancel instance without incident
workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD);
cancelWorkflowInstance(workflowInstanceKey);
// create another instance which creates an incident
workflowInstanceKey = testClient.createWorkflowInstance("process");
final SubscribedEvent incidentCreatedEvent = testClient.receiveSingleEvent(incidentEvents("CREATED", workflowInstanceKey));
// when
cancelWorkflowInstance(workflowInstanceKey);
// then
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETED", workflowInstanceKey));
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"));
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveMultipleIncidents.
@Test
public void shouldResolveMultipleIncidents() throws Exception {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
// create and resolve an first incident
long workflowInstanceKey = testClient.createWorkflowInstance("process");
SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_READY", workflowInstanceKey));
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// create a second incident
workflowInstanceKey = testClient.createWorkflowInstance("process");
failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_READY", workflowInstanceKey));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED", workflowInstanceKey));
// when
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// then
final SubscribedEvent incidentResolvedEvent = testClient.receiveSingleEvent(incidentEvents("RESOLVED", workflowInstanceKey));
assertThat(incidentResolvedEvent.key()).isEqualTo(incidentEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldDeleteIncidentIfTaskIsCanceled.
@Test
public void shouldDeleteIncidentIfTaskIsCanceled() {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD);
failTaskWithNoRetriesLeft();
final SubscribedEvent incidentCreatedEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
cancelWorkflowInstance(workflowInstanceKey);
// then
final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETE"));
assertThat(incidentEvent.key()).isEqualTo(incidentCreatedEvent.key());
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", incidentEvent.event().get("activityInstanceKey")).containsEntry("taskKey", taskEvent.key());
incidentEvent = testClient.receiveSingleEvent(incidentEvents("DELETED"));
assertThat(incidentEvent.key()).isEqualTo(incidentCreatedEvent.key());
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", incidentEvent.event().get("activityInstanceKey")).containsEntry("taskKey", taskEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForExclusiveGatewayWithoutMatchingCondition.
@Test
public void shouldResolveIncidentForExclusiveGatewayWithoutMatchingCondition() 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", 12));
// then incident is created
testClient.receiveSingleEvent(incidentEvents("CREATED"));
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("GATEWAY_ACTIVATED"));
// when
updatePayload(workflowInstanceKey, failureEvent.key(), asMsgPack("foo", 7).byteArray());
// then
testClient.receiveSingleEvent(incidentEvents("RESOLVED"));
testClient.receiveSingleEvent(workflowInstanceEvents("WORKFLOW_INSTANCE_COMPLETED"));
}
Aggregations