use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method failTaskWithNoRetriesLeft.
private void failTaskWithNoRetriesLeft() {
apiRule.openTaskSubscription("test").await();
final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("LOCKED"));
final ExecuteCommandResponse response = apiRule.createCmdRequest().key(taskEvent.key()).eventTypeTask().command().put("state", "FAIL").put("retries", 0).put("type", "failingTask").put("lockOwner", taskEvent.event().get("lockOwner")).put("headers", taskEvent.event().get("headers")).done().sendAndAwait();
assertThat(response.getEvent()).containsEntry("state", "FAILED");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForFailedCondition.
@Test
public void shouldResolveIncidentForFailedCondition() 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 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 shouldCreateIncidentForInvalidResultOnInputMapping.
@Test
public void shouldCreateIncidentForInvalidResultOnInputMapping() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("failingTask", t -> t.taskType("external").input("$.string", "$")).done());
// when
testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD);
// 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", "Processing failed, since mapping will result in a non map object (json object).");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent 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");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class CompleteTaskTest method shouldRejectCompletionIfTaskIsCompleted.
@Test
public void shouldRejectCompletionIfTaskIsCompleted() {
// given
createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
completeTask(subscribedEvent.key(), subscribedEvent.event());
// when
final ExecuteCommandResponse response = completeTask(subscribedEvent.key(), subscribedEvent.event());
// then
assertThat(response.getEvent()).containsEntry("state", "COMPLETE_REJECTED");
}
Aggregations