use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldWriteWorkflowEvent.
@Test
public void shouldWriteWorkflowEvent() {
// when
final long deploymentKey = apiRule.topic().deploy(ClientApiRule.DEFAULT_TOPIC_NAME, WORKFLOW);
// then
final SubscribedEvent workflowEvent = apiRule.topic().receiveSingleEvent(workflowEvents("CREATED"));
assertThat(workflowEvent.key()).isGreaterThanOrEqualTo(0L).isNotEqualTo(deploymentKey);
assertThat(workflowEvent.event()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "process").containsEntry(PROP_WORKFLOW_VERSION, 1).containsEntry("deploymentKey", deploymentKey).containsEntry("bpmnXml", bpmnXml(WORKFLOW));
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateIncidentForOutputMappingFailure.
@Test
public void shouldCreateIncidentForOutputMappingFailure() {
// given
testClient.deploy(WORKFLOW_OUTPUT_MAPPING);
// when
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
testClient.completeTaskOfType("test", MSGPACK_PAYLOAD);
// then
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETING"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
assertThat(incidentEvent.key()).isGreaterThan(0);
assertThat(incidentEvent.event()).containsEntry("errorType", ErrorType.IO_MAPPING_ERROR.name()).containsEntry("errorMessage", "No data found for query $.foo.").containsEntry("failureEventPosition", failureEvent.position()).containsEntry("bpmnProcessId", "process").containsEntry("workflowInstanceKey", workflowInstanceKey).containsEntry("activityId", "failingTask").containsEntry("activityInstanceKey", failureEvent.key()).containsEntry("taskKey", -1);
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentAfterPreviousResolvingFailed.
@Test
public void shouldResolveIncidentAfterPreviousResolvingFailed() 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"));
updatePayload(workflowInstanceKey, failureEvent.key(), MsgPackHelper.EMTPY_OBJECT);
testClient.receiveSingleEvent(incidentEvents("RESOLVE_FAILED"));
// when
updatePayload(workflowInstanceKey, failureEvent.key(), PAYLOAD);
// then
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");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldResolveIncidentForInvalidResultOnInputMapping.
@Test
public void shouldResolveIncidentForInvalidResultOnInputMapping() throws Throwable {
// given
testClient.deploy(Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").input("$.string", "$")).done());
// when
final long workflowInstanceKey = testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD);
// then incident is created
final SubscribedEvent failureEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_READY"));
final SubscribedEvent incidentEvent = testClient.receiveSingleEvent(incidentEvents("CREATED"));
// when
updatePayload(workflowInstanceKey, failureEvent, "{'string':{'obj':'test'}}");
// then
final SubscribedEvent followUpEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
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 shouldCreateIncidentForInvalidResultOnOutputMapping.
@Test
public void shouldCreateIncidentForInvalidResultOnOutputMapping() 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", MSGPACK_MAPPER.writeValueAsBytes(JSON_MAPPER.readTree("{'testAttr':'test'}")));
testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
// 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).");
}
Aggregations