use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldDeleteStandaloneIncidentIfTaskRetriesIncreased.
@Test
public void shouldDeleteStandaloneIncidentIfTaskRetriesIncreased() {
// given
createStandaloneTask();
failTaskWithNoRetriesLeft();
// when
updateTaskRetries();
// then
final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
final SubscribedEvent 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", "").containsEntry("workflowInstanceKey", -1).containsEntry("activityId", "").containsEntry("activityInstanceKey", -1).containsEntry("taskKey", taskEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateIncidentIfTaskHasNoRetriesLeft.
@Test
public void shouldCreateIncidentIfTaskHasNoRetriesLeft() {
// given
testClient.deploy(WORKFLOW_INPUT_MAPPING);
final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD);
// when
failTaskWithNoRetriesLeft();
// then
final SubscribedEvent activityEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
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", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask").containsEntry("activityInstanceKey", activityEvent.key()).containsEntry("taskKey", failedEvent.key());
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method updateTaskRetries.
private void updateTaskRetries() {
final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
final ExecuteCommandResponse response = apiRule.createCmdRequest().key(taskEvent.key()).eventTypeTask().command().put("state", "UPDATE_RETRIES").put("retries", 1).put("type", "test").put("lockOwner", taskEvent.event().get("lockOwner")).put("headers", taskEvent.event().get("headers")).done().sendAndAwait();
assertThat(response.getEvent()).containsEntry("state", "RETRIES_UPDATED");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForInvalidResultOnOutputMapping.
@Test
public void shouldResolveIncidentForInvalidResultOnOutputMapping() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").input("$.jsonObject", "$").output("$.testAttr", "$")).done());
final long workflowInstanceKey = testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD);
// when
testClient.completeTaskOfType("external", MSGPACK_MAPPER.writeValueAsBytes(JSON_MAPPER.readTree("{'testAttr':'test'}")));
testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
// 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", "Processing failed, since mapping will result in a non map object (json object).").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 shouldResolveIncidentForInAndOutputMappingAndNoTaskCompletePayload.
@Test
public void shouldResolveIncidentForInAndOutputMappingAndNoTaskCompletePayload() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").input("$.jsonObject", "$").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);
}
Aggregations